• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Discussion HRESULT: 0x80070057 / vertex_create_buffer_from_buffer / DLL buffer generation

DukeSoft

Member
Just FYI - Since runtime 2.2.4 I've had issues where I got this message pop up:

upload_2019-11-5_16-7-4.png
Code:
Win32 function failed: HRESULT: 0x80070057

Call: GR_D3D_Device->CreateBuffer at line 294 in file \VertexBuilderM.cpp
and my vertex buffers were empty.

My projects generates buffers through a DLL - GM creates the buffer and sends the address to the DLL, DLL fills it, GM makes a vertex buffer out of it.

I've been searching quite a while where this issue came from, but I found it now (and yes, a bug report has been submitted).

Just posting this here that in case someone else is doing the same and getting this message, they will find it and know its (most likely) a bug in GM. Reverting to a runtime from before 2.2.4 (2.2.3.344 is the latest working one for me) fixes it.

Here's the code I'm using that might contain some nice search engine keywords;
Code:
global.vbuf_format_size = 0;

dll = external_define("Bug DLL.dll", "vertex_buffer", dll_cdecl, ty_real, 1, ty_string);

vertex_format_begin();
vertex_format_add_position_3d(); global.vbuf_format_size += 3 * 4;
vertex_format_add_normal(); global.vbuf_format_size += 3 * 4;
vertex_format_add_texcoord(); global.vbuf_format_size += 2 * 4;
vertex_format_add_color(); global.vbuf_format_size += 4; // 4x byte
global.buff_format = vertex_format_end();

var vbufsize = 3 * global.vbuf_format_size; //1 triangle
vbuf_dll = buffer_create(vbufsize, buffer_grow, 1);
external_call(dll, buffer_get_address(vbuf_dll));
terrainmesh = vertex_create_buffer_from_buffer(vbuf_dll, global.buff_format);
buffer_delete(vbuf_dll);
vertex_freeze(terrainmesh);
 

rmanthorp

YoYo Games Staff
Admin
YYG Staff
Heyo, because you are using external code to fill the buffer he needs to tell the runtime how large the vertex buffer is, a bug was fixed that was causing the whole buffer to be copied all the time when it should only have been the amount used, you need to use: https://docs2.yoyogames.com/source/_build/3_scripting/4_gml_reference/drawing/primitives/primitive building/vertex_create_buffer_from_buffer_ext.html

Just tell the runtime how many verts should be in the buffer the _ext function is also more flexible in how the buffer is created.
 

DukeSoft

Member
Ahaaaa so its an anti-bug ? :+) I've checked the changelogs but I missed anything that was related to these functions. Thanks though!

In that case it kind of made sense - I thought I've seen this error message before with empty buffers. I think a GM Error can be thrown there to supply the user with a clear error message - but we'll sort that in the ticket.

I've replaced the functions with the _ext version and it does work on the newer ones! Thanks again :)
 
Top