1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Discussion HRESULT: 0x80070057 / vertex_create_buffer_from_buffer / DLL buffer generation

Discussion in 'GameMaker Studio 2 Community Tech Support' started by DukeSoft, Nov 5, 2019.

  1. DukeSoft

    DukeSoft Member

    Joined:
    Jun 20, 2016
    Posts:
    783
    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);
    
     
  2. rmanthorp

    rmanthorp YoYo Games Staff Admin YYG Staff

    Joined:
    Apr 15, 2016
    Posts:
    304
    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/...ing/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 likes this.
  3. DukeSoft

    DukeSoft Member

    Joined:
    Jun 20, 2016
    Posts:
    783
    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 :)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice