diff --git a/bindings/cs/bgfx.cs b/bindings/cs/bgfx.cs index 093a6982c..60ef987ee 100644 --- a/bindings/cs/bgfx.cs +++ b/bindings/cs/bgfx.cs @@ -1999,7 +1999,7 @@ public static partial class bgfx public uint startVertex; public ushort stride; public VertexBufferHandle handle; - public VertexLayoutHandle decl; + public VertexLayoutHandle layoutHandle; } public unsafe struct InstanceDataBuffer @@ -2219,12 +2219,12 @@ public static partial class bgfx /// Value to be packed into vertex stream. /// `true` if input value is already normalized. /// Attribute to pack. - /// Vertex stream layout. + /// Vertex stream layout. /// Destination vertex stream where data will be packed. /// Vertex index that will be modified. /// [DllImport(DllName, EntryPoint="bgfx_vertex_pack", CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe void vertex_pack(float _input, bool _inputNormalized, Attrib _attr, VertexLayout* _decl, void* _data, uint _index); + public static extern unsafe void vertex_pack(float _input, bool _inputNormalized, Attrib _attr, VertexLayout* _layout, void* _data, uint _index); /// /// Unpack vertex attribute from vertex stream format. @@ -2232,38 +2232,38 @@ public static partial class bgfx /// /// Result of unpacking. /// Attribute to unpack. - /// Vertex stream layout. + /// Vertex stream layout. /// Source vertex stream from where data will be unpacked. /// Vertex index that will be unpacked. /// [DllImport(DllName, EntryPoint="bgfx_vertex_unpack", CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe void vertex_unpack(float _output, Attrib _attr, VertexLayout* _decl, void* _data, uint _index); + public static extern unsafe void vertex_unpack(float _output, Attrib _attr, VertexLayout* _layout, void* _data, uint _index); /// /// Converts vertex stream data from one vertex stream format to another. /// /// - /// Destination vertex stream layout. + /// Destination vertex stream layout. /// Destination vertex stream. - /// Source vertex stream layout. + /// Source vertex stream layout. /// Source vertex stream data. /// Number of vertices to convert from source to destination. /// [DllImport(DllName, EntryPoint="bgfx_vertex_convert", CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe void vertex_convert(VertexLayout* _dstDecl, void* _dstData, VertexLayout* _srcDecl, void* _srcData, uint _num); + public static extern unsafe void vertex_convert(VertexLayout* _dstLayout, void* _dstData, VertexLayout* _srcLayout, void* _srcData, uint _num); /// /// Weld vertices. /// /// /// Welded vertices remapping table. The size of buffer must be the same as number of vertices. - /// Vertex stream layout. + /// Vertex stream layout. /// Vertex stream. /// Number of vertices in vertex stream. /// Error tolerance for vertex position comparison. /// [DllImport(DllName, EntryPoint="bgfx_weld_vertices", CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe ushort weld_vertices(ushort* _output, VertexLayout* _decl, void* _data, ushort _num, float _epsilon); + public static extern unsafe ushort weld_vertices(ushort* _output, VertexLayout* _layout, void* _data, ushort _num, float _epsilon); /// /// Convert index buffer for use with different primitive topologies. @@ -2532,30 +2532,30 @@ public static partial class bgfx /// Create vertex layout. /// /// - /// Vertex layout. + /// Vertex layout. /// [DllImport(DllName, EntryPoint="bgfx_create_vertex_layout", CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe VertexLayoutHandle create_vertex_layout(VertexLayout* _decl); + public static extern unsafe VertexLayoutHandle create_vertex_layout(VertexLayout* _layout); /// /// Destroy vertex layout. /// /// - /// Vertex layout handle. + /// Vertex layout handle. /// - [DllImport(DllName, EntryPoint="bgfx_destroy_vertex_decl", CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe void destroy_vertex_decl(VertexLayoutHandle _handle); + [DllImport(DllName, EntryPoint="bgfx_destroy_vertex_layout", CallingConvention = CallingConvention.Cdecl)] + public static extern unsafe void destroy_vertex_layout(VertexLayoutHandle _layoutHandle); /// /// Create static vertex buffer. /// /// /// Vertex buffer data. - /// Vertex layout. + /// Vertex layout. /// Buffer creation flags. - `BGFX_BUFFER_NONE` - No flags. - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers. - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on index buffers. /// [DllImport(DllName, EntryPoint="bgfx_create_vertex_buffer", CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe VertexBufferHandle create_vertex_buffer(Memory* _mem, VertexLayout* _decl, ushort _flags); + public static extern unsafe VertexBufferHandle create_vertex_buffer(Memory* _mem, VertexLayout* _layout, ushort _flags); /// /// Set static vertex buffer debug name. @@ -2622,22 +2622,22 @@ public static partial class bgfx /// /// /// Number of vertices. - /// Vertex layout. + /// Vertex layout. /// Buffer creation flags. - `BGFX_BUFFER_NONE` - No flags. - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers. - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on index buffers. /// [DllImport(DllName, EntryPoint="bgfx_create_dynamic_vertex_buffer", CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe DynamicVertexBufferHandle create_dynamic_vertex_buffer(uint _num, VertexLayout* _decl, ushort _flags); + public static extern unsafe DynamicVertexBufferHandle create_dynamic_vertex_buffer(uint _num, VertexLayout* _layout, ushort _flags); /// /// Create dynamic vertex buffer and initialize it. /// /// /// Vertex buffer data. - /// Vertex layout. + /// Vertex layout. /// Buffer creation flags. - `BGFX_BUFFER_NONE` - No flags. - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers. - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on index buffers. /// [DllImport(DllName, EntryPoint="bgfx_create_dynamic_vertex_buffer_mem", CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe DynamicVertexBufferHandle create_dynamic_vertex_buffer_mem(Memory* _mem, VertexLayout* _decl, ushort _flags); + public static extern unsafe DynamicVertexBufferHandle create_dynamic_vertex_buffer_mem(Memory* _mem, VertexLayout* _layout, ushort _flags); /// /// Update dynamic vertex buffer. @@ -2673,10 +2673,10 @@ public static partial class bgfx /// /// /// Number of required vertices. - /// Vertex layout. + /// Vertex layout. /// [DllImport(DllName, EntryPoint="bgfx_get_avail_transient_vertex_buffer", CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe uint get_avail_transient_vertex_buffer(uint _num, VertexLayout* _decl); + public static extern unsafe uint get_avail_transient_vertex_buffer(uint _num, VertexLayout* _layout); /// /// Returns number of requested or maximum available instance buffer slots. @@ -2706,10 +2706,10 @@ public static partial class bgfx /// /// TransientVertexBuffer structure is filled and is valid for the duration of frame, and it can be reused for multiple draw calls. /// Number of vertices to allocate. - /// Vertex layout. + /// Vertex layout. /// [DllImport(DllName, EntryPoint="bgfx_alloc_transient_vertex_buffer", CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe void alloc_transient_vertex_buffer(TransientVertexBuffer* _tvb, uint _num, VertexLayout* _decl); + public static extern unsafe void alloc_transient_vertex_buffer(TransientVertexBuffer* _tvb, uint _num, VertexLayout* _layout); /// /// Check for required space and allocate transient vertex and index @@ -2720,14 +2720,14 @@ public static partial class bgfx /// /// /// TransientVertexBuffer structure is filled and is valid for the duration of frame, and it can be reused for multiple draw calls. - /// Vertex layout. + /// Vertex layout. /// Number of vertices to allocate. /// TransientIndexBuffer structure is filled and is valid for the duration of frame, and it can be reused for multiple draw calls. /// Number of indices to allocate. /// [DllImport(DllName, EntryPoint="bgfx_alloc_transient_buffers", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.I1)] - public static extern unsafe bool alloc_transient_buffers(TransientVertexBuffer* _tvb, VertexLayout* _decl, uint _numVertices, TransientIndexBuffer* _tib, uint _numIndices); + public static extern unsafe bool alloc_transient_buffers(TransientVertexBuffer* _tvb, VertexLayout* _layout, uint _numVertices, TransientIndexBuffer* _tib, uint _numIndices); /// /// Allocate instance data buffer. @@ -3536,10 +3536,10 @@ public static partial class bgfx /// Vertex buffer. /// First vertex to render. /// Number of vertices to render. - /// VertexLayout handle for aliasing vertex buffer. + /// VertexLayout handle for aliasing vertex buffer. /// [DllImport(DllName, EntryPoint="bgfx_encoder_set_vertex_buffer", CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe void encoder_set_vertex_buffer(Encoder* _this, byte _stream, VertexBufferHandle _handle, uint _startVertex, uint _numVertices, VertexLayoutHandle _declHandle); + public static extern unsafe void encoder_set_vertex_buffer(Encoder* _this, byte _stream, VertexBufferHandle _handle, uint _startVertex, uint _numVertices, VertexLayoutHandle _layoutHandle); /// /// Set vertex buffer for draw primitive. @@ -3549,10 +3549,10 @@ public static partial class bgfx /// Dynamic vertex buffer. /// First vertex to render. /// Number of vertices to render. - /// VertexLayout handle for aliasing vertex buffer. + /// VertexLayout handle for aliasing vertex buffer. /// [DllImport(DllName, EntryPoint="bgfx_encoder_set_dynamic_vertex_buffer", CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe void encoder_set_dynamic_vertex_buffer(Encoder* _this, byte _stream, DynamicVertexBufferHandle _handle, uint _startVertex, uint _numVertices, VertexLayoutHandle _declHandle); + public static extern unsafe void encoder_set_dynamic_vertex_buffer(Encoder* _this, byte _stream, DynamicVertexBufferHandle _handle, uint _startVertex, uint _numVertices, VertexLayoutHandle _layoutHandle); /// /// Set vertex buffer for draw primitive. @@ -3562,10 +3562,10 @@ public static partial class bgfx /// Transient vertex buffer. /// First vertex to render. /// Number of vertices to render. - /// VertexLayout handle for aliasing vertex buffer. + /// VertexLayout handle for aliasing vertex buffer. /// [DllImport(DllName, EntryPoint="bgfx_encoder_set_transient_vertex_buffer", CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe void encoder_set_transient_vertex_buffer(Encoder* _this, byte _stream, TransientVertexBuffer* _tvb, uint _startVertex, uint _numVertices, VertexLayoutHandle _declHandle); + public static extern unsafe void encoder_set_transient_vertex_buffer(Encoder* _this, byte _stream, TransientVertexBuffer* _tvb, uint _startVertex, uint _numVertices, VertexLayoutHandle _layoutHandle); /// /// Set number of vertices for auto generated vertices use in conjuction diff --git a/examples/01-cubes/cubes.cpp b/examples/01-cubes/cubes.cpp index 33e87e130..d9c028f5d 100644 --- a/examples/01-cubes/cubes.cpp +++ b/examples/01-cubes/cubes.cpp @@ -19,17 +19,17 @@ struct PosColorVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true) .end(); }; - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosColorVertex::ms_decl; +bgfx::VertexLayout PosColorVertex::ms_layout; static PosColorVertex s_cubeVertices[] = { @@ -170,7 +170,7 @@ public: m_vbh = bgfx::createVertexBuffer( // Static data can be passed with bgfx::makeRef bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) ) - , PosColorVertex::ms_decl + , PosColorVertex::ms_layout ); // Create static index buffer for triangle list rendering. diff --git a/examples/02-metaballs/metaballs.cpp b/examples/02-metaballs/metaballs.cpp index b5a9b032b..8438bfd48 100644 --- a/examples/02-metaballs/metaballs.cpp +++ b/examples/02-metaballs/metaballs.cpp @@ -32,7 +32,7 @@ struct PosNormalColorVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Normal, 3, bgfx::AttribType::Float) @@ -40,10 +40,10 @@ struct PosNormalColorVertex .end(); }; - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosNormalColorVertex::ms_decl; +bgfx::VertexLayout PosNormalColorVertex::ms_layout; struct Grid { @@ -605,7 +605,7 @@ public: // Allocate 32K vertices in transient vertex buffer. uint32_t maxVertices = (32<<10); bgfx::TransientVertexBuffer tvb; - bgfx::allocTransientVertexBuffer(&tvb, maxVertices, PosNormalColorVertex::ms_decl); + bgfx::allocTransientVertexBuffer(&tvb, maxVertices, PosNormalColorVertex::ms_layout); const uint32_t numSpheres = 16; float sphere[numSpheres][4]; @@ -723,7 +723,7 @@ public: &grid[xoffset ], }; - uint32_t num = triangulate( (uint8_t*)vertex, PosNormalColorVertex::ms_decl.getStride(), rgb, pos, val, 0.5f); + uint32_t num = triangulate( (uint8_t*)vertex, PosNormalColorVertex::ms_layout.getStride(), rgb, pos, val, 0.5f); vertex += num; numVertices += num; } diff --git a/examples/03-raymarch/raymarch.cpp b/examples/03-raymarch/raymarch.cpp index 57e8642c0..cbd39a1c4 100644 --- a/examples/03-raymarch/raymarch.cpp +++ b/examples/03-raymarch/raymarch.cpp @@ -21,7 +21,7 @@ struct PosColorTexCoord0Vertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true) @@ -29,17 +29,17 @@ struct PosColorTexCoord0Vertex .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosColorTexCoord0Vertex::ms_decl; +bgfx::VertexLayout PosColorTexCoord0Vertex::ms_layout; void renderScreenSpaceQuad(uint8_t _view, bgfx::ProgramHandle _program, float _x, float _y, float _width, float _height) { bgfx::TransientVertexBuffer tvb; bgfx::TransientIndexBuffer tib; - if (bgfx::allocTransientBuffers(&tvb, PosColorTexCoord0Vertex::ms_decl, 4, &tib, 6) ) + if (bgfx::allocTransientBuffers(&tvb, PosColorTexCoord0Vertex::ms_layout, 4, &tib, 6) ) { PosColorTexCoord0Vertex* vertex = (PosColorTexCoord0Vertex*)tvb.data; diff --git a/examples/05-instancing/instancing.cpp b/examples/05-instancing/instancing.cpp index d97380002..9cc23cb8e 100644 --- a/examples/05-instancing/instancing.cpp +++ b/examples/05-instancing/instancing.cpp @@ -19,17 +19,17 @@ struct PosColorVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true) .end(); }; - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosColorVertex::ms_decl; +bgfx::VertexLayout PosColorVertex::ms_layout; static PosColorVertex s_cubeVertices[8] = { @@ -101,7 +101,7 @@ public: // Create static vertex buffer. m_vbh = bgfx::createVertexBuffer( bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) ) - , PosColorVertex::ms_decl + , PosColorVertex::ms_layout ); // Create static index buffer. diff --git a/examples/06-bump/bump.cpp b/examples/06-bump/bump.cpp index 1b4500aef..fd0095b63 100644 --- a/examples/06-bump/bump.cpp +++ b/examples/06-bump/bump.cpp @@ -22,7 +22,7 @@ struct PosNormalTangentTexcoordVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Normal, 4, bgfx::AttribType::Uint8, true, true) @@ -31,10 +31,10 @@ struct PosNormalTangentTexcoordVertex .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosNormalTangentTexcoordVertex::ms_decl; +bgfx::VertexLayout PosNormalTangentTexcoordVertex::ms_layout; static PosNormalTangentTexcoordVertex s_cubeVertices[24] = { @@ -127,7 +127,7 @@ public: calcTangents(s_cubeVertices , BX_COUNTOF(s_cubeVertices) - , PosNormalTangentTexcoordVertex::ms_decl + , PosNormalTangentTexcoordVertex::ms_layout , s_cubeIndices , BX_COUNTOF(s_cubeIndices) ); @@ -135,7 +135,7 @@ public: // Create static vertex buffer. m_vbh = bgfx::createVertexBuffer( bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) ) - , PosNormalTangentTexcoordVertex::ms_decl + , PosNormalTangentTexcoordVertex::ms_layout ); // Create static index buffer. diff --git a/examples/07-callback/callback.cpp b/examples/07-callback/callback.cpp index 63b7b65fd..f5bd05082 100644 --- a/examples/07-callback/callback.cpp +++ b/examples/07-callback/callback.cpp @@ -29,17 +29,17 @@ struct PosColorVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true) .end(); }; - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosColorVertex::ms_decl; +bgfx::VertexLayout PosColorVertex::ms_layout; static PosColorVertex s_cubeVertices[8] = { @@ -352,7 +352,7 @@ public: // Create static vertex buffer. m_vbh = bgfx::createVertexBuffer( bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) ) - , PosColorVertex::ms_decl + , PosColorVertex::ms_layout ); // Create static index buffer. diff --git a/examples/08-update/update.cpp b/examples/08-update/update.cpp index 057e4fd3c..a0cb982a9 100644 --- a/examples/08-update/update.cpp +++ b/examples/08-update/update.cpp @@ -26,17 +26,17 @@ struct PosTexcoordVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::TexCoord0, 3, bgfx::AttribType::Float) .end(); }; - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosTexcoordVertex::ms_decl; +bgfx::VertexLayout PosTexcoordVertex::ms_layout; static PosTexcoordVertex s_cubeVertices[] = { @@ -239,7 +239,7 @@ public: } // Create static vertex buffer. - m_vbh = bgfx::createVertexBuffer(bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) ), PosTexcoordVertex::ms_decl); + m_vbh = bgfx::createVertexBuffer(bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) ), PosTexcoordVertex::ms_layout); // Create static index buffer. m_ibh = bgfx::createIndexBuffer(bgfx::makeRef(s_cubeIndices, sizeof(s_cubeIndices) ) ); diff --git a/examples/09-hdr/hdr.cpp b/examples/09-hdr/hdr.cpp index 55281bd0e..9be020e01 100644 --- a/examples/09-hdr/hdr.cpp +++ b/examples/09-hdr/hdr.cpp @@ -24,7 +24,7 @@ struct PosColorTexCoord0Vertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true) @@ -32,17 +32,17 @@ struct PosColorTexCoord0Vertex .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosColorTexCoord0Vertex::ms_decl; +bgfx::VertexLayout PosColorTexCoord0Vertex::ms_layout; void screenSpaceQuad(float _textureWidth, float _textureHeight, bool _originBottomLeft = false, float _width = 1.0f, float _height = 1.0f) { - if (3 == bgfx::getAvailTransientVertexBuffer(3, PosColorTexCoord0Vertex::ms_decl) ) + if (3 == bgfx::getAvailTransientVertexBuffer(3, PosColorTexCoord0Vertex::ms_layout) ) { bgfx::TransientVertexBuffer vb; - bgfx::allocTransientVertexBuffer(&vb, 3, PosColorTexCoord0Vertex::ms_decl); + bgfx::allocTransientVertexBuffer(&vb, 3, PosColorTexCoord0Vertex::ms_layout); PosColorTexCoord0Vertex* vertex = (PosColorTexCoord0Vertex*)vb.data; const float zz = 0.0f; diff --git a/examples/13-stencil/stencil.cpp b/examples/13-stencil/stencil.cpp index 7c5fc34e2..bfdb6e2f6 100644 --- a/examples/13-stencil/stencil.cpp +++ b/examples/13-stencil/stencil.cpp @@ -15,7 +15,7 @@ namespace bgfx { - int32_t read(bx::ReaderI* _reader, bgfx::VertexLayout& _decl, bx::Error* _err = NULL); + int32_t read(bx::ReaderI* _reader, bgfx::VertexLayout& _layout, bx::Error* _err = NULL); } namespace @@ -43,7 +43,7 @@ struct PosNormalTexcoordVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Normal, 4, bgfx::AttribType::Uint8, true, true) @@ -51,10 +51,10 @@ struct PosNormalTexcoordVertex .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosNormalTexcoordVertex::ms_decl; +bgfx::VertexLayout PosNormalTexcoordVertex::ms_layout; static const float s_texcoord = 5.0f; static PosNormalTexcoordVertex s_hplaneVertices[] = @@ -622,15 +622,15 @@ struct Group struct Mesh { - void load(const void* _vertices, uint32_t _numVertices, const bgfx::VertexLayout _decl, const uint16_t* _indices, uint32_t _numIndices) + void load(const void* _vertices, uint32_t _numVertices, const bgfx::VertexLayout _layout, const uint16_t* _indices, uint32_t _numIndices) { Group group; const bgfx::Memory* mem; uint32_t size; - size = _numVertices*_decl.getStride(); + size = _numVertices*_layout.getStride(); mem = bgfx::makeRef(_vertices, size); - group.m_vbh = bgfx::createVertexBuffer(mem, _decl); + group.m_vbh = bgfx::createVertexBuffer(mem, _layout); size = _numIndices*2; mem = bgfx::makeRef(_indices, size); @@ -661,15 +661,15 @@ struct Mesh bx::read(reader, group.m_aabb); bx::read(reader, group.m_obb); - bgfx::read(reader, m_decl); - uint16_t stride = m_decl.getStride(); + bgfx::read(reader, m_layout); + uint16_t stride = m_layout.getStride(); uint16_t numVertices; bx::read(reader, numVertices); const bgfx::Memory* mem = bgfx::alloc(numVertices*stride); bx::read(reader, mem->data, mem->size); - group.m_vbh = bgfx::createVertexBuffer(mem, m_decl); + group.m_vbh = bgfx::createVertexBuffer(mem, m_layout); } break; @@ -780,7 +780,7 @@ struct Mesh } } - bgfx::VertexLayout m_decl; + bgfx::VertexLayout m_layout; typedef std::vector GroupArray; GroupArray m_groups; }; @@ -832,9 +832,9 @@ public: m_bunnyMesh.load("meshes/bunny.bin"); m_columnMesh.load("meshes/column.bin"); - m_cubeMesh.load(s_cubeVertices, BX_COUNTOF(s_cubeVertices), PosNormalTexcoordVertex::ms_decl, s_cubeIndices, BX_COUNTOF(s_cubeIndices) ); - m_hplaneMesh.load(s_hplaneVertices, BX_COUNTOF(s_hplaneVertices), PosNormalTexcoordVertex::ms_decl, s_planeIndices, BX_COUNTOF(s_planeIndices) ); - m_vplaneMesh.load(s_vplaneVertices, BX_COUNTOF(s_vplaneVertices), PosNormalTexcoordVertex::ms_decl, s_planeIndices, BX_COUNTOF(s_planeIndices) ); + m_cubeMesh.load(s_cubeVertices, BX_COUNTOF(s_cubeVertices), PosNormalTexcoordVertex::ms_layout, s_cubeIndices, BX_COUNTOF(s_cubeIndices) ); + m_hplaneMesh.load(s_hplaneVertices, BX_COUNTOF(s_hplaneVertices), PosNormalTexcoordVertex::ms_layout, s_planeIndices, BX_COUNTOF(s_planeIndices) ); + m_vplaneMesh.load(s_vplaneVertices, BX_COUNTOF(s_vplaneVertices), PosNormalTexcoordVertex::ms_layout, s_planeIndices, BX_COUNTOF(s_planeIndices) ); m_figureTex = loadTexture("textures/figure-rgba.dds"); m_flareTex = loadTexture("textures/flare.dds"); diff --git a/examples/14-shadowvolumes/shadowvolumes.cpp b/examples/14-shadowvolumes/shadowvolumes.cpp index 3102d6c0f..a7c16d0ed 100644 --- a/examples/14-shadowvolumes/shadowvolumes.cpp +++ b/examples/14-shadowvolumes/shadowvolumes.cpp @@ -26,7 +26,7 @@ namespace stl = tinystl; namespace bgfx { - int32_t read(bx::ReaderI* _reader, bgfx::VertexLayout& _decl, bx::Error* _err = NULL); + int32_t read(bx::ReaderI* _reader, bgfx::VertexLayout& _layout, bx::Error* _err = NULL); } namespace @@ -52,7 +52,7 @@ struct PosNormalTexcoordVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Normal, 4, bgfx::AttribType::Uint8, true, true) @@ -60,10 +60,10 @@ struct PosNormalTexcoordVertex .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosNormalTexcoordVertex::ms_decl; +bgfx::VertexLayout PosNormalTexcoordVertex::ms_layout; static const float s_texcoord = 50.0f; static PosNormalTexcoordVertex s_hplaneVertices[] = @@ -697,7 +697,7 @@ inline float sqLength(const float _a[3], const float _b[3]) return xx*xx + yy*yy + zz*zz; } -uint16_t weldVertices(WeldedVertex* _output, const bgfx::VertexLayout& _decl, const void* _data, uint16_t _num, float _epsilon) +uint16_t weldVertices(WeldedVertex* _output, const bgfx::VertexLayout& _layout, const void* _data, uint16_t _num, float _epsilon) { const uint32_t hashSize = bx::uint32_nextpow2(_num); const uint32_t hashMask = hashSize-1; @@ -714,14 +714,14 @@ uint16_t weldVertices(WeldedVertex* _output, const bgfx::VertexLayout& _decl, co for (uint16_t ii = 0; ii < _num; ++ii) { float pos[4]; - vertexUnpack(pos, bgfx::Attrib::Position, _decl, _data, ii); + vertexUnpack(pos, bgfx::Attrib::Position, _layout, _data, ii); uint32_t hashValue = bx::hash(pos, 3*sizeof(float) ) & hashMask; uint16_t offset = hashTable[hashValue]; for (; UINT16_MAX != offset; offset = next[offset]) { float test[4]; - vertexUnpack(test, bgfx::Attrib::Position, _decl, _data, _output[offset].m_v); + vertexUnpack(test, bgfx::Attrib::Position, _layout, _data, _output[offset].m_v); if (sqLength(test, pos) < epsilonSq) { @@ -782,9 +782,9 @@ struct Group Plane m_plane[2]; }; - void fillStructures(const bgfx::VertexLayout& _decl) + void fillStructures(const bgfx::VertexLayout& _layout) { - uint16_t stride = _decl.getStride(); + uint16_t stride = _layout.getStride(); m_faces.clear(); m_halfEdges.destroy(); @@ -802,7 +802,7 @@ struct Group //Get unique indices. WeldedVertex* uniqueVertices = (WeldedVertex*)malloc(m_numVertices*sizeof(WeldedVertex) ); - ::weldVertices(uniqueVertices, _decl, m_vertices, m_numVertices, 0.0001f); + ::weldVertices(uniqueVertices, _layout, m_vertices, m_numVertices, 0.0001f); uint16_t* uniqueIndices = (uint16_t*)malloc(m_numIndices*sizeof(uint16_t) ); for (uint32_t ii = 0; ii < m_numIndices; ++ii) { @@ -933,7 +933,7 @@ typedef std::vector GroupArray; struct Mesh { - void load(const void* _vertices, uint16_t _numVertices, const bgfx::VertexLayout _decl, const uint16_t* _indices, uint32_t _numIndices) + void load(const void* _vertices, uint16_t _numVertices, const bgfx::VertexLayout _layout, const uint16_t* _indices, uint32_t _numIndices) { Group group; const bgfx::Memory* mem; @@ -941,13 +941,13 @@ struct Mesh //vertices group.m_numVertices = _numVertices; - size = _numVertices*_decl.getStride(); + size = _numVertices*_layout.getStride(); group.m_vertices = (uint8_t*)malloc(size); bx::memCopy(group.m_vertices, _vertices, size); mem = bgfx::makeRef(group.m_vertices, size); - group.m_vbh = bgfx::createVertexBuffer(mem, _decl); + group.m_vbh = bgfx::createVertexBuffer(mem, _layout); //indices group.m_numIndices = _numIndices; @@ -965,8 +965,8 @@ struct Mesh void load(const char* _filePath) { ::Mesh* mesh = ::meshLoad(_filePath, true); - m_decl = mesh->m_decl; - uint16_t stride = m_decl.getStride(); + m_layout = mesh->m_layout; + uint16_t stride = m_layout.getStride(); for (::GroupArray::iterator it = mesh->m_groups.begin(), itEnd = mesh->m_groups.end(); it != itEnd; ++it) { @@ -977,7 +977,7 @@ struct Mesh bx::memCopy(group.m_vertices, it->m_vertices, vertexSize); const bgfx::Memory* mem = bgfx::makeRef(group.m_vertices, vertexSize); - group.m_vbh = bgfx::createVertexBuffer(mem, m_decl); + group.m_vbh = bgfx::createVertexBuffer(mem, m_layout); group.m_numIndices = it->m_numIndices; const uint32_t indexSize = 2 * group.m_numIndices; @@ -998,7 +998,7 @@ struct Mesh for (GroupArray::iterator it = m_groups.begin(), itEnd = m_groups.end(); it != itEnd; ++it) { - it->fillStructures(m_decl); + it->fillStructures(m_layout); } } @@ -1011,7 +1011,7 @@ struct Mesh m_groups.clear(); } - bgfx::VertexLayout m_decl; + bgfx::VertexLayout m_layout; GroupArray m_groups; }; @@ -1023,9 +1023,9 @@ struct Model m_texture.idx = bgfx::kInvalidHandle; } - void load(const void* _vertices, uint16_t _numVertices, const bgfx::VertexLayout _decl, const uint16_t* _indices, uint32_t _numIndices) + void load(const void* _vertices, uint16_t _numVertices, const bgfx::VertexLayout _layout, const uint16_t* _indices, uint32_t _numIndices) { - m_mesh.load(_vertices, _numVertices, _decl, _indices, _numIndices); + m_mesh.load(_vertices, _numVertices, _layout, _indices, _numIndices); } void load(const char* _meshFilePath) @@ -1543,8 +1543,8 @@ void shadowVolumeCreate( } } - bgfx::VertexLayout decl; - decl.begin() + bgfx::VertexLayout layout; + layout.begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float) .end(); @@ -1563,7 +1563,7 @@ void shadowVolumeCreate( uint32_t isize = sideI * sizeof(uint16_t); mem = bgfx::makeRef(verticesSide, vsize); - _shadowVolume.m_vbSides = bgfx::createVertexBuffer(mem, decl); + _shadowVolume.m_vbSides = bgfx::createVertexBuffer(mem, layout); mem = bgfx::makeRef(indicesSide, isize); _shadowVolume.m_ibSides = bgfx::createIndexBuffer(mem); @@ -1859,7 +1859,7 @@ public: m_hplaneFieldModel.load(s_hplaneVertices , BX_COUNTOF(s_hplaneVertices) - , PosNormalTexcoordVertex::ms_decl + , PosNormalTexcoordVertex::ms_layout , s_planeIndices , BX_COUNTOF(s_planeIndices) ); @@ -1868,7 +1868,7 @@ public: m_hplaneFigureModel.load(s_hplaneVertices , BX_COUNTOF(s_hplaneVertices) - , PosNormalTexcoordVertex::ms_decl + , PosNormalTexcoordVertex::ms_layout , s_planeIndices , BX_COUNTOF(s_planeIndices) ); @@ -1877,7 +1877,7 @@ public: m_vplaneModel.load(s_vplaneVertices , BX_COUNTOF(s_vplaneVertices) - , PosNormalTexcoordVertex::ms_decl + , PosNormalTexcoordVertex::ms_layout , s_planeIndices , BX_COUNTOF(s_planeIndices) ); @@ -2600,7 +2600,7 @@ public: ); GroupArray& groups = model->m_mesh.m_groups; - const uint16_t stride = model->m_mesh.m_decl.getStride(); + const uint16_t stride = model->m_mesh.m_layout.getStride(); for (GroupArray::iterator it = groups.begin(), itEnd = groups.end(); it != itEnd; ++it) { Group& group = *it; diff --git a/examples/15-shadowmaps-simple/shadowmaps_simple.cpp b/examples/15-shadowmaps-simple/shadowmaps_simple.cpp index 091759055..b1493ff4d 100644 --- a/examples/15-shadowmaps-simple/shadowmaps_simple.cpp +++ b/examples/15-shadowmaps-simple/shadowmaps_simple.cpp @@ -32,17 +32,17 @@ struct PosNormalVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Normal, 4, bgfx::AttribType::Uint8, true, true) .end(); }; - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosNormalVertex::ms_decl; +bgfx::VertexLayout PosNormalVertex::ms_layout; static PosNormalVertex s_hplaneVertices[] = { @@ -118,7 +118,7 @@ public: m_vbh = bgfx::createVertexBuffer( bgfx::makeRef(s_hplaneVertices, sizeof(s_hplaneVertices) ) - , PosNormalVertex::ms_decl + , PosNormalVertex::ms_layout ); m_ibh = bgfx::createIndexBuffer( diff --git a/examples/16-shadowmaps/shadowmaps.cpp b/examples/16-shadowmaps/shadowmaps.cpp index f2d158574..f3048bd5d 100644 --- a/examples/16-shadowmaps/shadowmaps.cpp +++ b/examples/16-shadowmaps/shadowmaps.cpp @@ -20,7 +20,7 @@ namespace bgfx { - int32_t read(bx::ReaderI* _reader, bgfx::VertexLayout& _decl, bx::Error* _err = NULL); + int32_t read(bx::ReaderI* _reader, bgfx::VertexLayout& _layout, bx::Error* _err = NULL); } namespace @@ -812,15 +812,15 @@ struct Group struct Mesh { - void load(const void* _vertices, uint32_t _numVertices, const bgfx::VertexLayout _decl, const uint16_t* _indices, uint32_t _numIndices) + void load(const void* _vertices, uint32_t _numVertices, const bgfx::VertexLayout _layout, const uint16_t* _indices, uint32_t _numIndices) { Group group; const bgfx::Memory* mem; uint32_t size; - size = _numVertices*_decl.getStride(); + size = _numVertices*_layout.getStride(); mem = bgfx::makeRef(_vertices, size); - group.m_vbh = bgfx::createVertexBuffer(mem, _decl); + group.m_vbh = bgfx::createVertexBuffer(mem, _layout); size = _numIndices*2; mem = bgfx::makeRef(_indices, size); @@ -851,15 +851,15 @@ struct Mesh bx::read(reader, group.m_aabb); bx::read(reader, group.m_obb); - bgfx::read(reader, m_decl); - uint16_t stride = m_decl.getStride(); + bgfx::read(reader, m_layout); + uint16_t stride = m_layout.getStride(); uint16_t numVertices; bx::read(reader, numVertices); const bgfx::Memory* mem = bgfx::alloc(numVertices*stride); bx::read(reader, mem->data, mem->size); - group.m_vbh = bgfx::createVertexBuffer(mem, m_decl); + group.m_vbh = bgfx::createVertexBuffer(mem, m_layout); } break; @@ -977,7 +977,7 @@ struct Mesh } } - bgfx::VertexLayout m_decl; + bgfx::VertexLayout m_layout; typedef std::vector GroupArray; GroupArray m_groups; }; @@ -993,7 +993,7 @@ struct PosColorTexCoord0Vertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true) @@ -1001,17 +1001,17 @@ struct PosColorTexCoord0Vertex .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosColorTexCoord0Vertex::ms_decl; +bgfx::VertexLayout PosColorTexCoord0Vertex::ms_layout; void screenSpaceQuad(float _textureWidth, float _textureHeight, bool _originBottomLeft = true, float _width = 1.0f, float _height = 1.0f) { - if (3 == bgfx::getAvailTransientVertexBuffer(3, PosColorTexCoord0Vertex::ms_decl) ) + if (3 == bgfx::getAvailTransientVertexBuffer(3, PosColorTexCoord0Vertex::ms_layout) ) { bgfx::TransientVertexBuffer vb; - bgfx::allocTransientVertexBuffer(&vb, 3, PosColorTexCoord0Vertex::ms_decl); + bgfx::allocTransientVertexBuffer(&vb, 3, PosColorTexCoord0Vertex::ms_layout); PosColorTexCoord0Vertex* vertex = (PosColorTexCoord0Vertex*)vb.data; const float zz = 0.0f; @@ -1344,16 +1344,16 @@ public: s_programs.init(); // Vertex declarations. - bgfx::VertexLayout PosNormalTexcoordDecl; - PosNormalTexcoordDecl.begin() + bgfx::VertexLayout PosNormalTexcoordLayout; + PosNormalTexcoordLayout.begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Normal, 4, bgfx::AttribType::Uint8, true, true) .add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float) .end(); - m_posDecl.begin(); - m_posDecl.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float); - m_posDecl.end(); + m_posLayout.begin(); + m_posLayout.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float); + m_posLayout.end(); PosColorTexCoord0Vertex::init(); @@ -1367,8 +1367,8 @@ public: m_treeMesh.load("meshes/tree.bin"); m_cubeMesh.load("meshes/cube.bin"); m_hollowcubeMesh.load("meshes/hollowcube.bin"); - m_hplaneMesh.load(s_hplaneVertices, BX_COUNTOF(s_hplaneVertices), PosNormalTexcoordDecl, s_planeIndices, BX_COUNTOF(s_planeIndices) ); - m_vplaneMesh.load(s_vplaneVertices, BX_COUNTOF(s_vplaneVertices), PosNormalTexcoordDecl, s_planeIndices, BX_COUNTOF(s_planeIndices) ); + m_hplaneMesh.load(s_hplaneVertices, BX_COUNTOF(s_hplaneVertices), PosNormalTexcoordLayout, s_planeIndices, BX_COUNTOF(s_planeIndices) ); + m_vplaneMesh.load(s_vplaneVertices, BX_COUNTOF(s_vplaneVertices), PosNormalTexcoordLayout, s_planeIndices, BX_COUNTOF(s_planeIndices) ); // Materials. m_defaultMaterial = @@ -2801,7 +2801,7 @@ public: // Craft stencil mask for point light shadow map packing. if(LightType::PointLight == m_settings.m_lightType && m_settings.m_stencilPack) { - if (6 == bgfx::getAvailTransientVertexBuffer(6, m_posDecl) ) + if (6 == bgfx::getAvailTransientVertexBuffer(6, m_posLayout) ) { struct Pos { @@ -2809,7 +2809,7 @@ public: }; bgfx::TransientVertexBuffer vb; - bgfx::allocTransientVertexBuffer(&vb, 6, m_posDecl); + bgfx::allocTransientVertexBuffer(&vb, 6, m_posLayout); Pos* vertex = (Pos*)vb.data; const float min = 0.0f; @@ -3219,7 +3219,7 @@ public: ViewState m_viewState; ClearValues m_clearValues; - bgfx::VertexLayout m_posDecl; + bgfx::VertexLayout m_posLayout; bgfx::TextureHandle m_texFigure; bgfx::TextureHandle m_texFlare; diff --git a/examples/17-drawstress/drawstress.cpp b/examples/17-drawstress/drawstress.cpp index 0a4f3356d..08b0bc5d4 100644 --- a/examples/17-drawstress/drawstress.cpp +++ b/examples/17-drawstress/drawstress.cpp @@ -37,17 +37,17 @@ struct PosColorVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true) .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosColorVertex::ms_decl; +bgfx::VertexLayout PosColorVertex::ms_layout; static PosColorVertex s_cubeVertices[8] = { @@ -163,7 +163,7 @@ public: // Create static vertex buffer. m_vbh = bgfx::createVertexBuffer( bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) ) - , PosColorVertex::ms_decl + , PosColorVertex::ms_layout ); // Create static index buffer. diff --git a/examples/18-ibl/ibl.cpp b/examples/18-ibl/ibl.cpp index f34f5acfe..4bc253d64 100644 --- a/examples/18-ibl/ibl.cpp +++ b/examples/18-ibl/ibl.cpp @@ -77,7 +77,7 @@ struct PosColorTexCoord0Vertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true) @@ -85,17 +85,17 @@ struct PosColorTexCoord0Vertex .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosColorTexCoord0Vertex::ms_decl; +bgfx::VertexLayout PosColorTexCoord0Vertex::ms_layout; void screenSpaceQuad(float _textureWidth, float _textureHeight, bool _originBottomLeft = false, float _width = 1.0f, float _height = 1.0f) { - if (3 == bgfx::getAvailTransientVertexBuffer(3, PosColorTexCoord0Vertex::ms_decl) ) + if (3 == bgfx::getAvailTransientVertexBuffer(3, PosColorTexCoord0Vertex::ms_layout) ) { bgfx::TransientVertexBuffer vb; - bgfx::allocTransientVertexBuffer(&vb, 3, PosColorTexCoord0Vertex::ms_decl); + bgfx::allocTransientVertexBuffer(&vb, 3, PosColorTexCoord0Vertex::ms_layout); PosColorTexCoord0Vertex* vertex = (PosColorTexCoord0Vertex*)vb.data; const float zz = 0.0f; diff --git a/examples/19-oit/oit.cpp b/examples/19-oit/oit.cpp index 6169e7a94..6055ed99f 100644 --- a/examples/19-oit/oit.cpp +++ b/examples/19-oit/oit.cpp @@ -19,17 +19,17 @@ struct PosColorVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true) .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosColorVertex::ms_decl; +bgfx::VertexLayout PosColorVertex::ms_layout; struct PosColorTexCoord0Vertex { @@ -42,7 +42,7 @@ struct PosColorTexCoord0Vertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true) @@ -50,10 +50,10 @@ struct PosColorTexCoord0Vertex .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosColorTexCoord0Vertex::ms_decl; +bgfx::VertexLayout PosColorTexCoord0Vertex::ms_layout; static PosColorVertex s_cubeVertices[8] = { @@ -93,10 +93,10 @@ inline void mtxProj(float* _result, float _fovy, float _aspect, float _near, flo void screenSpaceQuad(float _textureWidth, float _textureHeight, bool _originBottomLeft = false, float _width = 1.0f, float _height = 1.0f) { - if (3 == bgfx::getAvailTransientVertexBuffer(3, PosColorTexCoord0Vertex::ms_decl) ) + if (3 == bgfx::getAvailTransientVertexBuffer(3, PosColorTexCoord0Vertex::ms_layout) ) { bgfx::TransientVertexBuffer vb; - bgfx::allocTransientVertexBuffer(&vb, 3, PosColorTexCoord0Vertex::ms_decl); + bgfx::allocTransientVertexBuffer(&vb, 3, PosColorTexCoord0Vertex::ms_layout); PosColorTexCoord0Vertex* vertex = (PosColorTexCoord0Vertex*)vb.data; const float zz = 0.0f; @@ -203,7 +203,7 @@ public: // Create static vertex buffer. m_vbh = bgfx::createVertexBuffer( bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) ) - , PosColorVertex::ms_decl + , PosColorVertex::ms_layout ); // Create static index buffer. diff --git a/examples/21-deferred/deferred.cpp b/examples/21-deferred/deferred.cpp index 7478429e9..ce4c55d86 100644 --- a/examples/21-deferred/deferred.cpp +++ b/examples/21-deferred/deferred.cpp @@ -32,7 +32,7 @@ struct PosNormalTangentTexcoordVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Normal, 4, bgfx::AttribType::Uint8, true, true) @@ -41,10 +41,10 @@ struct PosNormalTangentTexcoordVertex .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosNormalTangentTexcoordVertex::ms_decl; +bgfx::VertexLayout PosNormalTangentTexcoordVertex::ms_layout; struct PosTexCoord0Vertex { @@ -56,17 +56,17 @@ struct PosTexCoord0Vertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float) .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosTexCoord0Vertex::ms_decl; +bgfx::VertexLayout PosTexCoord0Vertex::ms_layout; struct DebugVertex { @@ -77,17 +77,17 @@ struct DebugVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true) .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout DebugVertex::ms_decl; +bgfx::VertexLayout DebugVertex::ms_layout; static PosNormalTangentTexcoordVertex s_cubeVertices[24] = { @@ -137,10 +137,10 @@ static const uint16_t s_cubeIndices[36] = void screenSpaceQuad(float _textureWidth, float _textureHeight, float _texelHalf, bool _originBottomLeft, float _width = 1.0f, float _height = 1.0f) { - if (3 == bgfx::getAvailTransientVertexBuffer(3, PosTexCoord0Vertex::ms_decl) ) + if (3 == bgfx::getAvailTransientVertexBuffer(3, PosTexCoord0Vertex::ms_layout) ) { bgfx::TransientVertexBuffer vb; - bgfx::allocTransientVertexBuffer(&vb, 3, PosTexCoord0Vertex::ms_decl); + bgfx::allocTransientVertexBuffer(&vb, 3, PosTexCoord0Vertex::ms_layout); PosTexCoord0Vertex* vertex = (PosTexCoord0Vertex*)vb.data; const float minx = -_width; @@ -247,7 +247,7 @@ public: calcTangents(s_cubeVertices , BX_COUNTOF(s_cubeVertices) - , PosNormalTangentTexcoordVertex::ms_decl + , PosNormalTangentTexcoordVertex::ms_layout , s_cubeIndices , BX_COUNTOF(s_cubeIndices) ); @@ -255,7 +255,7 @@ public: // Create static vertex buffer. m_vbh = bgfx::createVertexBuffer( bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) ) - , PosNormalTangentTexcoordVertex::ms_decl + , PosNormalTangentTexcoordVertex::ms_layout ); // Create static index buffer. @@ -699,7 +699,7 @@ public: { bgfx::TransientVertexBuffer tvb; bgfx::TransientIndexBuffer tib; - if (bgfx::allocTransientBuffers(&tvb, DebugVertex::ms_decl, 4, &tib, 8) ) + if (bgfx::allocTransientBuffers(&tvb, DebugVertex::ms_layout, 4, &tib, 8) ) { uint32_t abgr = 0x8000ff00; diff --git a/examples/22-windows/windows.cpp b/examples/22-windows/windows.cpp index 97bd991a0..3d8dbd785 100644 --- a/examples/22-windows/windows.cpp +++ b/examples/22-windows/windows.cpp @@ -26,17 +26,17 @@ struct PosColorVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true) .end(); }; - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosColorVertex::ms_decl; +bgfx::VertexLayout PosColorVertex::ms_layout; static PosColorVertex s_cubeVertices[8] = { @@ -126,7 +126,7 @@ public: m_vbh = bgfx::createVertexBuffer( // Static data can be passed with bgfx::makeRef bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) ) - , PosColorVertex::ms_decl + , PosColorVertex::ms_layout ); // Create static index buffer. diff --git a/examples/23-vectordisplay/main.cpp b/examples/23-vectordisplay/main.cpp index f55389b0d..fbcefdc42 100644 --- a/examples/23-vectordisplay/main.cpp +++ b/examples/23-vectordisplay/main.cpp @@ -22,17 +22,17 @@ struct PosColorVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true) .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosColorVertex::ms_decl; +bgfx::VertexLayout PosColorVertex::ms_layout; class ExampleVectorDisplay : public entry::AppI { diff --git a/examples/23-vectordisplay/vectordisplay.cpp b/examples/23-vectordisplay/vectordisplay.cpp index debdb14e6..7bface50c 100644 --- a/examples/23-vectordisplay/vectordisplay.cpp +++ b/examples/23-vectordisplay/vectordisplay.cpp @@ -35,7 +35,7 @@ const int HALF_TEXTURE_SIZE = TEXTURE_SIZE / 2; void PosColorUvVertex::init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float) @@ -43,7 +43,7 @@ void PosColorUvVertex::init() .end(); } -bgfx::VertexLayout PosColorUvVertex::ms_decl; +bgfx::VertexLayout PosColorUvVertex::ms_layout; inline float normalizef(float _a) { @@ -737,7 +737,7 @@ bool VectorDisplay::setDecaySteps(int _steps) for (int i = 0; i < m_numberDecaySteps; ++i) { - m_vertexBuffers.push_back(bgfx::createDynamicVertexBuffer(MAX_NUMBER_VERTICES, PosColorUvVertex::ms_decl) ); + m_vertexBuffers.push_back(bgfx::createDynamicVertexBuffer(MAX_NUMBER_VERTICES, PosColorUvVertex::ms_layout) ); m_vertexBuffersSize.push_back(0); } @@ -769,10 +769,10 @@ void VectorDisplay::getSize(float* _outWidth, float* _outHeight) void VectorDisplay::screenSpaceQuad(float _textureWidth, float _textureHeight, float _width, float _height) { - if (3 == getAvailTransientVertexBuffer(3, PosColorUvVertex::ms_decl) ) + if (3 == getAvailTransientVertexBuffer(3, PosColorUvVertex::ms_layout) ) { bgfx::TransientVertexBuffer vb; - bgfx::allocTransientVertexBuffer(&vb, 3, PosColorUvVertex::ms_decl); + bgfx::allocTransientVertexBuffer(&vb, 3, PosColorUvVertex::ms_layout); PosColorUvVertex* vertex = (PosColorUvVertex*)vb.data; const float zz = 0.0f; diff --git a/examples/23-vectordisplay/vectordisplay.h b/examples/23-vectordisplay/vectordisplay.h index 8f04aedf2..3b208b019 100644 --- a/examples/23-vectordisplay/vectordisplay.h +++ b/examples/23-vectordisplay/vectordisplay.h @@ -22,7 +22,7 @@ struct PosColorUvVertex uint32_t m_abgr; static void init(); - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; class VectorDisplay diff --git a/examples/24-nbody/nbody.cpp b/examples/24-nbody/nbody.cpp index e977c299d..21e04fc53 100644 --- a/examples/24-nbody/nbody.cpp +++ b/examples/24-nbody/nbody.cpp @@ -154,8 +154,8 @@ public: if (m_computeSupported) { - bgfx::VertexLayout quadVertexDecl; - quadVertexDecl.begin() + bgfx::VertexLayout quadVertexLayout; + quadVertexLayout.begin() .add(bgfx::Attrib::Position, 2, bgfx::AttribType::Float) .end(); @@ -163,7 +163,7 @@ public: m_vbh = bgfx::createVertexBuffer( // Static data can be passed with bgfx::makeRef bgfx::makeRef(s_quadVertices, sizeof(s_quadVertices) ) - , quadVertexDecl + , quadVertexLayout ); // Create static index buffer. @@ -176,15 +176,15 @@ public: m_particleProgram = loadProgram("vs_particle", "fs_particle"); // Setup compute buffers - bgfx::VertexLayout computeVertexDecl; - computeVertexDecl.begin() + bgfx::VertexLayout computeVertexLayout; + computeVertexLayout.begin() .add(bgfx::Attrib::TexCoord0, 4, bgfx::AttribType::Float) .end(); - m_currPositionBuffer0 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ_WRITE); - m_currPositionBuffer1 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ_WRITE); - m_prevPositionBuffer0 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ_WRITE); - m_prevPositionBuffer1 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ_WRITE); + m_currPositionBuffer0 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexLayout, BGFX_BUFFER_COMPUTE_READ_WRITE); + m_currPositionBuffer1 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexLayout, BGFX_BUFFER_COMPUTE_READ_WRITE); + m_prevPositionBuffer0 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexLayout, BGFX_BUFFER_COMPUTE_READ_WRITE); + m_prevPositionBuffer1 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexLayout, BGFX_BUFFER_COMPUTE_READ_WRITE); u_params = bgfx::createUniform("u_params", bgfx::UniformType::Vec4, 3); diff --git a/examples/26-occlusion/occlusion.cpp b/examples/26-occlusion/occlusion.cpp index af249048e..4a09aed85 100644 --- a/examples/26-occlusion/occlusion.cpp +++ b/examples/26-occlusion/occlusion.cpp @@ -22,17 +22,17 @@ struct PosColorVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true) .end(); }; - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosColorVertex::ms_decl; +bgfx::VertexLayout PosColorVertex::ms_layout; static PosColorVertex s_cubeVertices[8] = { @@ -112,7 +112,7 @@ public: m_vbh = bgfx::createVertexBuffer( // Static data can be passed with bgfx::makeRef bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) ) - , PosColorVertex::ms_decl + , PosColorVertex::ms_layout ); // Create static index buffer. diff --git a/examples/27-terrain/terrain.cpp b/examples/27-terrain/terrain.cpp index f23460089..d7d5bf529 100644 --- a/examples/27-terrain/terrain.cpp +++ b/examples/27-terrain/terrain.cpp @@ -27,17 +27,17 @@ struct PosTexCoord0Vertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float) .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosTexCoord0Vertex::ms_decl; +bgfx::VertexLayout PosTexCoord0Vertex::ms_layout; struct TerrainData { @@ -241,7 +241,7 @@ public: } mem = bgfx::makeRef(&m_terrain.m_vertices[0], sizeof(PosTexCoord0Vertex) * m_terrain.m_vertexCount); - m_vbh = bgfx::createVertexBuffer(mem, PosTexCoord0Vertex::ms_decl); + m_vbh = bgfx::createVertexBuffer(mem, PosTexCoord0Vertex::ms_layout); if (bgfx::isValid(m_ibh) ) { bgfx::destroy(m_ibh); @@ -256,7 +256,7 @@ public: if (!bgfx::isValid(m_dvbh) ) { - m_dvbh = bgfx::createDynamicVertexBuffer(m_terrain.m_vertexCount, PosTexCoord0Vertex::ms_decl); + m_dvbh = bgfx::createDynamicVertexBuffer(m_terrain.m_vertexCount, PosTexCoord0Vertex::ms_layout); } mem = bgfx::makeRef(&m_terrain.m_vertices[0], sizeof(PosTexCoord0Vertex) * m_terrain.m_vertexCount); @@ -277,7 +277,7 @@ public: updateTerrainMesh(); mem = bgfx::makeRef(&m_terrain.m_vertices[0], sizeof(PosTexCoord0Vertex) * m_terrain.m_vertexCount); - m_vbh = bgfx::createVertexBuffer(mem, PosTexCoord0Vertex::ms_decl); + m_vbh = bgfx::createVertexBuffer(mem, PosTexCoord0Vertex::ms_layout); mem = bgfx::makeRef(&m_terrain.m_indices[0], sizeof(uint16_t) * m_terrain.m_indexCount); m_ibh = bgfx::createIndexBuffer(mem); diff --git a/examples/31-rsm/reflectiveshadowmap.cpp b/examples/31-rsm/reflectiveshadowmap.cpp index 5b2eb36a7..ac200e759 100644 --- a/examples/31-rsm/reflectiveshadowmap.cpp +++ b/examples/31-rsm/reflectiveshadowmap.cpp @@ -105,7 +105,7 @@ static const float s_meshScale[] = 0.05f }; -// Vertex decl for our screen space quad (used in deferred rendering) +// Vertex layout for our screen space quad (used in deferred rendering) struct PosTexCoord0Vertex { float m_x; @@ -116,24 +116,24 @@ struct PosTexCoord0Vertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float) .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosTexCoord0Vertex::ms_decl; +bgfx::VertexLayout PosTexCoord0Vertex::ms_layout; // Utility function to draw a screen space quad for deferred rendering void screenSpaceQuad(float _textureWidth, float _textureHeight, float _texelHalf, bool _originBottomLeft, float _width = 1.0f, float _height = 1.0f) { - if (3 == bgfx::getAvailTransientVertexBuffer(3, PosTexCoord0Vertex::ms_decl) ) + if (3 == bgfx::getAvailTransientVertexBuffer(3, PosTexCoord0Vertex::ms_layout) ) { bgfx::TransientVertexBuffer vb; - bgfx::allocTransientVertexBuffer(&vb, 3, PosTexCoord0Vertex::ms_decl); + bgfx::allocTransientVertexBuffer(&vb, 3, PosTexCoord0Vertex::ms_layout); PosTexCoord0Vertex* vertex = (PosTexCoord0Vertex*)vb.data; const float minx = -_width; @@ -359,7 +359,7 @@ public: m_shadowBuffer = bgfx::createFrameBuffer(BX_COUNTOF(m_shadowBufferTex), m_shadowBufferTex, true); - // Vertex decl + // Vertex layout PosTexCoord0Vertex::init(); // Init camera diff --git a/examples/33-pom/pom.cpp b/examples/33-pom/pom.cpp index be0ced4be..e8533094b 100644 --- a/examples/33-pom/pom.cpp +++ b/examples/33-pom/pom.cpp @@ -23,7 +23,7 @@ struct PosTangentBitangentTexcoordVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Tangent, 4, bgfx::AttribType::Uint8, true, true) @@ -32,10 +32,10 @@ struct PosTangentBitangentTexcoordVertex .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosTangentBitangentTexcoordVertex::ms_decl; +bgfx::VertexLayout PosTangentBitangentTexcoordVertex::ms_layout; uint32_t packUint32(uint8_t _x, uint8_t _y, uint8_t _z, uint8_t _w) { @@ -149,7 +149,7 @@ public: // Create static vertex buffer. m_vbh = bgfx::createVertexBuffer(bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) ), - PosTangentBitangentTexcoordVertex::ms_decl); + PosTangentBitangentTexcoordVertex::ms_layout); // Create static index buffer. m_ibh = bgfx::createIndexBuffer(bgfx::makeRef(s_cubeIndices, sizeof(s_cubeIndices) ) ); diff --git a/examples/34-mvs/mvs.cpp b/examples/34-mvs/mvs.cpp index 7d5c85422..1b2d9d810 100644 --- a/examples/34-mvs/mvs.cpp +++ b/examples/34-mvs/mvs.cpp @@ -18,16 +18,16 @@ struct PosVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .end(); }; - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosVertex::ms_decl; +bgfx::VertexLayout PosVertex::ms_layout; struct ColorVertex { @@ -35,16 +35,16 @@ struct ColorVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true) .end(); }; - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout ColorVertex::ms_decl; +bgfx::VertexLayout ColorVertex::ms_layout; static PosVertex s_cubePosVertices[] = { @@ -148,13 +148,13 @@ public: m_vbh[0] = bgfx::createVertexBuffer( // Static data can be passed with bgfx::makeRef bgfx::makeRef(s_cubePosVertices, sizeof(s_cubePosVertices) ) - , PosVertex::ms_decl + , PosVertex::ms_layout ); m_vbh[1] = bgfx::createVertexBuffer( // Static data can be passed with bgfx::makeRef bgfx::makeRef(s_cubeColorVertices, sizeof(s_cubeColorVertices) ) - , ColorVertex::ms_decl + , ColorVertex::ms_layout ); // Create static index buffer. diff --git a/examples/35-dynamic/dynamic.cpp b/examples/35-dynamic/dynamic.cpp index da9c581de..6359510cf 100644 --- a/examples/35-dynamic/dynamic.cpp +++ b/examples/35-dynamic/dynamic.cpp @@ -24,17 +24,17 @@ struct PosColorVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true) .end(); }; - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosColorVertex::ms_decl; +bgfx::VertexLayout PosColorVertex::ms_layout; static PosColorVertex s_cubeVertices[] = { @@ -129,7 +129,7 @@ public: m_vbh[yy*kDimWidth+xx] = bgfx::createDynamicVertexBuffer( // Static data can be passed with bgfx::makeRef bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) ) - , PosColorVertex::ms_decl + , PosColorVertex::ms_layout ); } } diff --git a/examples/36-sky/sky.cpp b/examples/36-sky/sky.cpp index 4f3d9c8ea..0c66873d3 100644 --- a/examples/36-sky/sky.cpp +++ b/examples/36-sky/sky.cpp @@ -304,16 +304,16 @@ namespace static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 2, bgfx::AttribType::Float) .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; - bgfx::VertexLayout ScreenPosVertex::ms_decl; + bgfx::VertexLayout ScreenPosVertex::ms_layout; // Renders a screen-space grid of triangles. // Because of performance reasons, and because sky color is smooth, sky color is computed in vertex shader. @@ -365,7 +365,7 @@ namespace } } - m_vbh = bgfx::createVertexBuffer(bgfx::copy(vertices, sizeof(ScreenPosVertex) * verticalCount * horizontalCount), ScreenPosVertex::ms_decl); + m_vbh = bgfx::createVertexBuffer(bgfx::copy(vertices, sizeof(ScreenPosVertex) * verticalCount * horizontalCount), ScreenPosVertex::ms_layout); m_ibh = bgfx::createIndexBuffer(bgfx::copy(indices, sizeof(uint16_t) * k)); BX_FREE(allocator, indices); diff --git a/examples/37-gpudrivenrendering/gpudrivenrendering.cpp b/examples/37-gpudrivenrendering/gpudrivenrendering.cpp index 58d8fd6a8..b15896c64 100644 --- a/examples/37-gpudrivenrendering/gpudrivenrendering.cpp +++ b/examples/37-gpudrivenrendering/gpudrivenrendering.cpp @@ -193,16 +193,16 @@ struct PosVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .end(); }; - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosVertex::ms_decl; +bgfx::VertexLayout PosVertex::ms_layout; static PosVertex s_cubeVertices[8] = { @@ -287,12 +287,12 @@ void createCubeMesh(Prop& prop) prop.m_vertices = new PosVertex[prop.m_noofVertices]; prop.m_indices = new uint16_t[prop.m_noofIndices]; - bx::memCopy(prop.m_vertices, s_cubeVertices, prop.m_noofVertices * PosVertex::ms_decl.getStride()); + bx::memCopy(prop.m_vertices, s_cubeVertices, prop.m_noofVertices * PosVertex::ms_layout.getStride()); bx::memCopy(prop.m_indices, s_cubeIndices, prop.m_noofIndices * sizeof(uint16_t)); prop.m_vertexbufferHandle = bgfx::createVertexBuffer( - bgfx::makeRef(prop.m_vertices, prop.m_noofVertices * PosVertex::ms_decl.getStride()), - PosVertex::ms_decl); + bgfx::makeRef(prop.m_vertices, prop.m_noofVertices * PosVertex::ms_layout.getStride()), + PosVertex::ms_layout); prop.m_indexbufferHandle = bgfx::createIndexBuffer(bgfx::makeRef(prop.m_indices, prop.m_noofIndices * sizeof(uint16_t))); } @@ -528,8 +528,8 @@ public: //bounding box for each instance, will be fed to the compute shader to calculate occlusion { - bgfx::VertexLayout computeVertexDecl; - computeVertexDecl.begin() + bgfx::VertexLayout computeVertexLayout; + computeVertexLayout.begin() .add(bgfx::Attrib::TexCoord0, 4, bgfx::AttribType::Float) .end(); @@ -557,13 +557,13 @@ public: const bgfx::Memory* mem = bgfx::makeRef(boundingBoxes, sizeof(float) * sizeOfBuffer); - m_instanceBoundingBoxes = bgfx::createDynamicVertexBuffer(mem, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ); + m_instanceBoundingBoxes = bgfx::createDynamicVertexBuffer(mem, computeVertexLayout, BGFX_BUFFER_COMPUTE_READ); } //pre and post occlusion culling instance data buffers { - bgfx::VertexLayout instanceBufferVertexDecl; - instanceBufferVertexDecl.begin() + bgfx::VertexLayout instanceBufferVertexLayout; + instanceBufferVertexLayout.begin() .add(bgfx::Attrib::TexCoord0, 4, bgfx::AttribType::Float) .add(bgfx::Attrib::TexCoord1, 4, bgfx::AttribType::Float) .add(bgfx::Attrib::TexCoord2, 4, bgfx::AttribType::Float) @@ -593,10 +593,10 @@ public: const bgfx::Memory* mem = bgfx::makeRef(instanceData, sizeof(float) * sizeOfBuffer); //pre occlusion buffer - m_instanceBuffer = bgfx::createVertexBuffer(mem, instanceBufferVertexDecl, BGFX_BUFFER_COMPUTE_READ); + m_instanceBuffer = bgfx::createVertexBuffer(mem, instanceBufferVertexLayout, BGFX_BUFFER_COMPUTE_READ); //post occlusion buffer - m_culledInstanceBuffer = bgfx::createDynamicVertexBuffer(4 * m_totalInstancesCount, instanceBufferVertexDecl, BGFX_BUFFER_COMPUTE_WRITE); + m_culledInstanceBuffer = bgfx::createDynamicVertexBuffer(4 * m_totalInstancesCount, instanceBufferVertexLayout, BGFX_BUFFER_COMPUTE_WRITE); } //we use one "drawcall" per prop to render all its instances @@ -677,8 +677,8 @@ public: // Create master vertex buffer m_allPropsVertexbufferHandle = bgfx::createVertexBuffer( - bgfx::makeRef(m_allPropVerticesDataCPU, totalNoofVertices * PosVertex::ms_decl.getStride()) - , PosVertex::ms_decl + bgfx::makeRef(m_allPropVerticesDataCPU, totalNoofVertices * PosVertex::ms_layout.getStride()) + , PosVertex::ms_layout ); // Create master index buffer. diff --git a/examples/38-bloom/bloom.cpp b/examples/38-bloom/bloom.cpp index 53562fe64..3709959e8 100644 --- a/examples/38-bloom/bloom.cpp +++ b/examples/38-bloom/bloom.cpp @@ -43,16 +43,16 @@ struct PosVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosVertex::ms_decl; +bgfx::VertexLayout PosVertex::ms_layout; struct PosTexCoord0Vertex { @@ -64,17 +64,17 @@ struct PosTexCoord0Vertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float) .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosTexCoord0Vertex::ms_decl; +bgfx::VertexLayout PosTexCoord0Vertex::ms_layout; constexpr float cs = 0.29f; @@ -126,10 +126,10 @@ static const uint16_t s_cubeIndices[36] = void screenSpaceQuad(float _textureWidth, float _textureHeight, float _texelHalf, bool _originBottomLeft, float _width = 1.0f, float _height = 1.0f) { - if (3 == bgfx::getAvailTransientVertexBuffer(3, PosTexCoord0Vertex::ms_decl) ) + if (3 == bgfx::getAvailTransientVertexBuffer(3, PosTexCoord0Vertex::ms_layout) ) { bgfx::TransientVertexBuffer vb; - bgfx::allocTransientVertexBuffer(&vb, 3, PosTexCoord0Vertex::ms_decl); + bgfx::allocTransientVertexBuffer(&vb, 3, PosTexCoord0Vertex::ms_layout); PosTexCoord0Vertex* vertex = (PosTexCoord0Vertex*)vb.data; const float minx = -_width; @@ -238,7 +238,7 @@ public: // Create static vertex buffer. m_vbh = bgfx::createVertexBuffer( bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) ) - , PosVertex::ms_decl + , PosVertex::ms_layout ); m_ibh = bgfx::createIndexBuffer(bgfx::makeRef(s_cubeIndices, sizeof(s_cubeIndices) ) ); diff --git a/examples/39-assao/assao.cpp b/examples/39-assao/assao.cpp index 16b4d8b4e..f4e41a8d9 100644 --- a/examples/39-assao/assao.cpp +++ b/examples/39-assao/assao.cpp @@ -60,7 +60,7 @@ namespace 0.25f }; - // Vertex decl for our screen space quad (used in deferred rendering) + // Vertex layout for our screen space quad (used in deferred rendering) struct PosTexCoord0Vertex { float m_x; @@ -71,25 +71,25 @@ namespace static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float) .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; - bgfx::VertexLayout PosTexCoord0Vertex::ms_decl; + bgfx::VertexLayout PosTexCoord0Vertex::ms_layout; // Utility function to draw a screen space quad for deferred rendering void screenSpaceQuad(float _textureWidth, float _textureHeight, float _texelHalf, bool _originBottomLeft, float _width = 1.0f, float _height = 1.0f) { - if (3 == bgfx::getAvailTransientVertexBuffer(3, PosTexCoord0Vertex::ms_decl)) + if (3 == bgfx::getAvailTransientVertexBuffer(3, PosTexCoord0Vertex::ms_layout)) { bgfx::TransientVertexBuffer vb; - bgfx::allocTransientVertexBuffer(&vb, 3, PosTexCoord0Vertex::ms_decl); + bgfx::allocTransientVertexBuffer(&vb, 3, PosTexCoord0Vertex::ms_layout); PosTexCoord0Vertex* vertex = (PosTexCoord0Vertex*)vb.data; const float minx = -_width; @@ -365,7 +365,7 @@ namespace m_loadCounter = bgfx::createDynamicIndexBuffer(1, BGFX_BUFFER_COMPUTE_READ_WRITE | BGFX_BUFFER_INDEX32); - // Vertex decl + // Vertex layout PosTexCoord0Vertex::init(); // Init camera diff --git a/examples/40-svt/svt.cpp b/examples/40-svt/svt.cpp index 9bf33c64c..c10562921 100644 --- a/examples/40-svt/svt.cpp +++ b/examples/40-svt/svt.cpp @@ -33,17 +33,17 @@ struct PosTexcoordVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float) .end(); }; - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosTexcoordVertex::ms_decl; +bgfx::VertexLayout PosTexcoordVertex::ms_layout; static const float s_planeScale = 50.0f; @@ -107,7 +107,7 @@ public: // Create static vertex buffer. m_vbh = bgfx::createVertexBuffer( bgfx::makeRef(s_vplaneVertices, sizeof(s_vplaneVertices)) - , PosTexcoordVertex::ms_decl + , PosTexcoordVertex::ms_layout ); m_ibh = bgfx::createIndexBuffer( diff --git a/examples/41-tess/tess.cpp b/examples/41-tess/tess.cpp index 214dd2adf..6c33bdfcb 100644 --- a/examples/41-tess/tess.cpp +++ b/examples/41-tess/tess.cpp @@ -758,11 +758,11 @@ namespace const uint32_t indices[] = { 0, 1, 3, 2, 3, 1 }; - m_geometryDecl.begin().add(bgfx::Attrib::Position, 4, bgfx::AttribType::Float).end(); + m_geometryLayout.begin().add(bgfx::Attrib::Position, 4, bgfx::AttribType::Float).end(); m_geometryVertices = bgfx::createVertexBuffer( bgfx::copy(vertices, sizeof(vertices) ) - , m_geometryDecl + , m_geometryLayout , BGFX_BUFFER_COMPUTE_READ ); m_geometryIndices = bgfx::createIndexBuffer( @@ -842,14 +842,14 @@ namespace break; } - m_instancedGeometryDecl + m_instancedGeometryLayout .begin() .add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float) .end(); m_instancedGeometryVertices = bgfx::createVertexBuffer( bgfx::makeRef(vertices, sizeof(float) * 2 * m_instancedMeshVertexCount) - , m_instancedGeometryDecl + , m_instancedGeometryLayout ); m_instancedGeometryIndices = bgfx::createIndexBuffer( @@ -872,11 +872,11 @@ namespace bgfx::IndexBufferHandle m_geometryIndices; bgfx::VertexBufferHandle m_geometryVertices; - bgfx::VertexLayout m_geometryDecl; + bgfx::VertexLayout m_geometryLayout; bgfx::IndexBufferHandle m_instancedGeometryIndices; bgfx::VertexBufferHandle m_instancedGeometryVertices; - bgfx::VertexLayout m_instancedGeometryDecl; + bgfx::VertexLayout m_instancedGeometryLayout; bgfx::IndirectBufferHandle m_dispatchIndirect; diff --git a/examples/common/bgfx_utils.cpp b/examples/common/bgfx_utils.cpp index 9b9a72d3a..ed8b44314 100644 --- a/examples/common/bgfx_utils.cpp +++ b/examples/common/bgfx_utils.cpp @@ -258,7 +258,7 @@ bimg::ImageContainer* imageLoad(const char* _filePath, bgfx::TextureFormat::Enum return bimg::imageParse(entry::getAllocator(), data, size, bimg::TextureFormat::Enum(_dstFormat) ); } -void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexLayout _decl, const uint16_t* _indices, uint32_t _numIndices) +void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexLayout _layout, const uint16_t* _indices, uint32_t _numIndices) { struct PosTexcoord { @@ -286,14 +286,14 @@ void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexLayout _de uint32_t i1 = indices[1]; uint32_t i2 = indices[2]; - bgfx::vertexUnpack(&v0.m_x, bgfx::Attrib::Position, _decl, _vertices, i0); - bgfx::vertexUnpack(&v0.m_u, bgfx::Attrib::TexCoord0, _decl, _vertices, i0); + bgfx::vertexUnpack(&v0.m_x, bgfx::Attrib::Position, _layout, _vertices, i0); + bgfx::vertexUnpack(&v0.m_u, bgfx::Attrib::TexCoord0, _layout, _vertices, i0); - bgfx::vertexUnpack(&v1.m_x, bgfx::Attrib::Position, _decl, _vertices, i1); - bgfx::vertexUnpack(&v1.m_u, bgfx::Attrib::TexCoord0, _decl, _vertices, i1); + bgfx::vertexUnpack(&v1.m_x, bgfx::Attrib::Position, _layout, _vertices, i1); + bgfx::vertexUnpack(&v1.m_u, bgfx::Attrib::TexCoord0, _layout, _vertices, i1); - bgfx::vertexUnpack(&v2.m_x, bgfx::Attrib::Position, _decl, _vertices, i2); - bgfx::vertexUnpack(&v2.m_u, bgfx::Attrib::TexCoord0, _decl, _vertices, i2); + bgfx::vertexUnpack(&v2.m_x, bgfx::Attrib::Position, _layout, _vertices, i2); + bgfx::vertexUnpack(&v2.m_u, bgfx::Attrib::TexCoord0, _layout, _vertices, i2); const float bax = v1.m_x - v0.m_x; const float bay = v1.m_y - v0.m_y; @@ -338,7 +338,7 @@ void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexLayout _de const bx::Vec3 tanv = bx::load(&tangents[ii*6 + 3]); float nxyzw[4]; - bgfx::vertexUnpack(nxyzw, bgfx::Attrib::Normal, _decl, _vertices, ii); + bgfx::vertexUnpack(nxyzw, bgfx::Attrib::Normal, _layout, _vertices, ii); const bx::Vec3 normal = bx::load(nxyzw); const float ndt = bx::dot(normal, tanu); @@ -349,7 +349,7 @@ void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexLayout _de bx::store(tangent, bx::normalize(tmp) ); tangent[3] = bx::dot(nxt, tanv) < 0.0f ? -1.0f : 1.0f; - bgfx::vertexPack(tangent, true, bgfx::Attrib::Tangent, _decl, _vertices, ii); + bgfx::vertexPack(tangent, true, bgfx::Attrib::Tangent, _layout, _vertices, ii); } delete [] tangents; @@ -375,7 +375,7 @@ void Group::reset() namespace bgfx { - int32_t read(bx::ReaderI* _reader, bgfx::VertexLayout& _decl, bx::Error* _err = NULL); + int32_t read(bx::ReaderI* _reader, bgfx::VertexLayout& _layout, bx::Error* _err = NULL); } void Mesh::load(bx::ReaderSeekerI* _reader, bool _ramcopy) @@ -406,9 +406,9 @@ void Mesh::load(bx::ReaderSeekerI* _reader, bool _ramcopy) read(_reader, group.m_aabb); read(_reader, group.m_obb); - read(_reader, m_decl); + read(_reader, m_layout); - uint16_t stride = m_decl.getStride(); + uint16_t stride = m_layout.getStride(); read(_reader, group.m_numVertices); const bgfx::Memory* mem = bgfx::alloc(group.m_numVertices*stride); @@ -418,7 +418,7 @@ void Mesh::load(bx::ReaderSeekerI* _reader, bool _ramcopy) group.m_vertices = (uint8_t*)BX_ALLOC(allocator, group.m_numVertices*stride); bx::memCopy(group.m_vertices, mem->data, mem->size); } - group.m_vbh = bgfx::createVertexBuffer(mem, m_decl); + group.m_vbh = bgfx::createVertexBuffer(mem, m_layout); } break; @@ -428,9 +428,9 @@ void Mesh::load(bx::ReaderSeekerI* _reader, bool _ramcopy) read(_reader, group.m_aabb); read(_reader, group.m_obb); - read(_reader, m_decl); + read(_reader, m_layout); - uint16_t stride = m_decl.getStride(); + uint16_t stride = m_layout.getStride(); read(_reader, group.m_numVertices); @@ -452,7 +452,7 @@ void Mesh::load(bx::ReaderSeekerI* _reader, bool _ramcopy) bx::memCopy(group.m_vertices, mem->data, mem->size); } - group.m_vbh = bgfx::createVertexBuffer(mem, m_decl); + group.m_vbh = bgfx::createVertexBuffer(mem, m_layout); } break; diff --git a/examples/common/bgfx_utils.h b/examples/common/bgfx_utils.h index 8b43b8060..25be9ffc6 100644 --- a/examples/common/bgfx_utils.h +++ b/examples/common/bgfx_utils.h @@ -35,18 +35,18 @@ bgfx::TextureHandle loadTexture(const char* _name, uint64_t _flags = BGFX_TEXTUR bimg::ImageContainer* imageLoad(const char* _filePath, bgfx::TextureFormat::Enum _dstFormat); /// -void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexLayout _decl, const uint16_t* _indices, uint32_t _numIndices); +void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexLayout _layout, const uint16_t* _indices, uint32_t _numIndices); /// Returns true if both internal transient index and vertex buffer have /// enough space. /// /// @param[in] _numVertices Number of vertices. -/// @param[in] _decl Vertex declaration. +/// @param[in] _layout Vertex layout. /// @param[in] _numIndices Number of indices. /// -inline bool checkAvailTransientBuffers(uint32_t _numVertices, const bgfx::VertexLayout& _decl, uint32_t _numIndices) +inline bool checkAvailTransientBuffers(uint32_t _numVertices, const bgfx::VertexLayout& _layout, uint32_t _numIndices) { - return _numVertices == bgfx::getAvailTransientVertexBuffer(_numVertices, _decl) + return _numVertices == bgfx::getAvailTransientVertexBuffer(_numVertices, _layout) && (0 == _numIndices || _numIndices == bgfx::getAvailTransientIndexBuffer(_numIndices) ) ; } @@ -123,7 +123,7 @@ struct Mesh void submit(bgfx::ViewId _id, bgfx::ProgramHandle _program, const float* _mtx, uint64_t _state) const; void submit(const MeshState*const* _state, uint8_t _numPasses, const float* _mtx, uint16_t _numMatrices) const; - bgfx::VertexLayout m_decl; + bgfx::VertexLayout m_layout; GroupArray m_groups; }; diff --git a/examples/common/debugdraw/debugdraw.cpp b/examples/common/debugdraw/debugdraw.cpp index f2db4f1cb..ecb94fe0f 100644 --- a/examples/common/debugdraw/debugdraw.cpp +++ b/examples/common/debugdraw/debugdraw.cpp @@ -29,7 +29,7 @@ struct DebugVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::TexCoord0, 1, bgfx::AttribType::Float) @@ -37,10 +37,10 @@ struct DebugVertex .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout DebugVertex::ms_decl; +bgfx::VertexLayout DebugVertex::ms_layout; struct DebugUvVertex { @@ -53,7 +53,7 @@ struct DebugUvVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float) @@ -61,10 +61,10 @@ struct DebugUvVertex .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout DebugUvVertex::ms_decl; +bgfx::VertexLayout DebugUvVertex::ms_layout; struct DebugShapeVertex { @@ -75,17 +75,17 @@ struct DebugShapeVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Indices, 4, bgfx::AttribType::Uint8) .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout DebugShapeVertex::ms_decl; +bgfx::VertexLayout DebugShapeVertex::ms_layout; struct DebugMeshVertex { @@ -95,16 +95,16 @@ struct DebugMeshVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout DebugMeshVertex::ms_decl; +bgfx::VertexLayout DebugMeshVertex::ms_layout; static DebugShapeVertex s_quadVertices[4] = { @@ -429,7 +429,7 @@ struct GeometryT Geometry& geometry = m_geometry[handle.idx]; geometry.m_vbh = bgfx::createVertexBuffer( bgfx::copy(_vertices, _numVertices*sizeof(DdVertex) ) - , DebugMeshVertex::ms_decl + , DebugMeshVertex::ms_layout ); geometry.m_topologyNumIndices[0] = _numIndices; @@ -642,7 +642,7 @@ struct DebugDrawShared void* vertices[DebugMesh::Count] = {}; uint16_t* indices[DebugMesh::Count] = {}; - uint16_t stride = DebugShapeVertex::ms_decl.getStride(); + uint16_t stride = DebugShapeVertex::ms_layout.getStride(); uint32_t startVertex = 0; uint32_t startIndex = 0; @@ -958,7 +958,7 @@ struct DebugDrawShared , sizeof(s_cubeIndices) ); - m_vbh = bgfx::createVertexBuffer(vb, DebugShapeVertex::ms_decl); + m_vbh = bgfx::createVertexBuffer(vb, DebugShapeVertex::ms_layout); m_ibh = bgfx::createIndexBuffer(ib); } @@ -1608,11 +1608,11 @@ struct DebugDrawEncoderImpl { flush(); - if (_numVertices == bgfx::getAvailTransientVertexBuffer(_numVertices, DebugMeshVertex::ms_decl) ) + if (_numVertices == bgfx::getAvailTransientVertexBuffer(_numVertices, DebugMeshVertex::ms_layout) ) { bgfx::TransientVertexBuffer tvb; - bgfx::allocTransientVertexBuffer(&tvb, _numVertices, DebugMeshVertex::ms_decl); - bx::memCopy(tvb.data, _vertices, _numVertices * DebugMeshVertex::ms_decl.m_stride); + bgfx::allocTransientVertexBuffer(&tvb, _numVertices, DebugMeshVertex::ms_layout); + bx::memCopy(tvb.data, _vertices, _numVertices * DebugMeshVertex::ms_layout.m_stride); m_encoder->setVertexBuffer(0, &tvb); const Attrib& attrib = m_attrib[m_stack]; @@ -2163,11 +2163,11 @@ struct DebugDrawEncoderImpl { if (0 != m_pos) { - if (checkAvailTransientBuffers(m_pos, DebugVertex::ms_decl, m_indexPos) ) + if (checkAvailTransientBuffers(m_pos, DebugVertex::ms_layout, m_indexPos) ) { bgfx::TransientVertexBuffer tvb; - bgfx::allocTransientVertexBuffer(&tvb, m_pos, DebugVertex::ms_decl); - bx::memCopy(tvb.data, m_cache, m_pos * DebugVertex::ms_decl.m_stride); + bgfx::allocTransientVertexBuffer(&tvb, m_pos, DebugVertex::ms_layout); + bx::memCopy(tvb.data, m_cache, m_pos * DebugVertex::ms_layout.m_stride); bgfx::TransientIndexBuffer tib; bgfx::allocTransientIndexBuffer(&tib, m_indexPos); @@ -2201,11 +2201,11 @@ struct DebugDrawEncoderImpl if (0 != m_posQuad) { const uint32_t numIndices = m_posQuad/4*6; - if (checkAvailTransientBuffers(m_posQuad, DebugUvVertex::ms_decl, numIndices) ) + if (checkAvailTransientBuffers(m_posQuad, DebugUvVertex::ms_layout, numIndices) ) { bgfx::TransientVertexBuffer tvb; - bgfx::allocTransientVertexBuffer(&tvb, m_posQuad, DebugUvVertex::ms_decl); - bx::memCopy(tvb.data, m_cacheQuad, m_posQuad * DebugUvVertex::ms_decl.m_stride); + bgfx::allocTransientVertexBuffer(&tvb, m_posQuad, DebugUvVertex::ms_layout); + bx::memCopy(tvb.data, m_cacheQuad, m_posQuad * DebugUvVertex::ms_layout.m_stride); bgfx::TransientIndexBuffer tib; bgfx::allocTransientIndexBuffer(&tib, numIndices); diff --git a/examples/common/example-glue.cpp b/examples/common/example-glue.cpp index 534a16bfa..0c4f84f93 100644 --- a/examples/common/example-glue.cpp +++ b/examples/common/example-glue.cpp @@ -368,7 +368,7 @@ void showExampleDialog(entry::AppI* _app, const char* _errorText) resourceBar(" T", "Textures", stats->numTextures, caps->limits.maxTextures, maxWidth, itemHeight); resourceBar(" U", "Uniforms", stats->numUniforms, caps->limits.maxUniforms, maxWidth, itemHeight); resourceBar(" VB", "Vertex buffers", stats->numVertexBuffers, caps->limits.maxVertexBuffers, maxWidth, itemHeight); - resourceBar(" VD", "Vertex declarations", stats->numVertexLayouts, caps->limits.maxVertexLayouts, maxWidth, itemHeight); + resourceBar(" VL", "Vertex layouts", stats->numVertexLayouts, caps->limits.maxVertexLayouts, maxWidth, itemHeight); ImGui::PopFont(); } diff --git a/examples/common/font/text_buffer_manager.cpp b/examples/common/font/text_buffer_manager.cpp index 415f6db29..92c2143ad 100644 --- a/examples/common/font/text_buffer_manager.cpp +++ b/examples/common/font/text_buffer_manager.cpp @@ -598,7 +598,7 @@ TextBufferManager::TextBufferManager(FontManager* _fontManager) , true ); - m_vertexDecl + m_vertexLayout .begin() .add(bgfx::Attrib::Position, 2, bgfx::AttribType::Float) .add(bgfx::Attrib::TexCoord0, 4, bgfx::AttribType::Int16, true) @@ -738,7 +738,7 @@ void TextBufferManager::submitTextBuffer(TextBufferHandle _handle, bgfx::ViewId vbh = bgfx::createVertexBuffer( bgfx::copy(bc.textBuffer->getVertexBuffer(), vertexSize) - , m_vertexDecl + , m_vertexLayout ); bc.vertexBufferHandleIdx = vbh.idx; @@ -768,7 +768,7 @@ void TextBufferManager::submitTextBuffer(TextBufferHandle _handle, bgfx::ViewId vbh = bgfx::createDynamicVertexBuffer( bgfx::copy(bc.textBuffer->getVertexBuffer(), vertexSize) - , m_vertexDecl + , m_vertexLayout ); bc.indexBufferHandleIdx = ibh.idx; @@ -802,7 +802,7 @@ void TextBufferManager::submitTextBuffer(TextBufferHandle _handle, bgfx::ViewId bgfx::TransientIndexBuffer tib; bgfx::TransientVertexBuffer tvb; bgfx::allocTransientIndexBuffer(&tib, bc.textBuffer->getIndexCount() ); - bgfx::allocTransientVertexBuffer(&tvb, bc.textBuffer->getVertexCount(), m_vertexDecl); + bgfx::allocTransientVertexBuffer(&tvb, bc.textBuffer->getVertexCount(), m_vertexLayout); bx::memCopy(tib.data, bc.textBuffer->getIndexBuffer(), indexSize); bx::memCopy(tvb.data, bc.textBuffer->getVertexBuffer(), vertexSize); bgfx::setVertexBuffer(0, &tvb, 0, bc.textBuffer->getVertexCount() ); diff --git a/examples/common/font/text_buffer_manager.h b/examples/common/font/text_buffer_manager.h index 5baf2ef9a..612259589 100644 --- a/examples/common/font/text_buffer_manager.h +++ b/examples/common/font/text_buffer_manager.h @@ -87,7 +87,7 @@ private: BufferCache* m_textBuffers; bx::HandleAllocT m_textBufferHandles; FontManager* m_fontManager; - bgfx::VertexLayout m_vertexDecl; + bgfx::VertexLayout m_vertexLayout; bgfx::UniformHandle s_texColor; bgfx::ProgramHandle m_basicProgram; bgfx::ProgramHandle m_distanceProgram; diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index 4978ad5fb..34558323f 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -89,13 +89,13 @@ struct OcornutImguiContext uint32_t numVertices = (uint32_t)drawList->VtxBuffer.size(); uint32_t numIndices = (uint32_t)drawList->IdxBuffer.size(); - if (!checkAvailTransientBuffers(numVertices, m_decl, numIndices) ) + if (!checkAvailTransientBuffers(numVertices, m_layout, numIndices) ) { // not enough space in transient buffer just quit drawing the rest... break; } - bgfx::allocTransientVertexBuffer(&tvb, numVertices, m_decl); + bgfx::allocTransientVertexBuffer(&tvb, numVertices, m_layout); bgfx::allocTransientIndexBuffer(&tib, numIndices); ImDrawVert* verts = (ImDrawVert*)tvb.data; @@ -247,7 +247,7 @@ struct OcornutImguiContext , true ); - m_decl + m_layout .begin() .add(bgfx::Attrib::Position, 2, bgfx::AttribType::Float) .add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float) @@ -391,7 +391,7 @@ struct OcornutImguiContext ImGuiContext* m_imgui; bx::AllocatorI* m_allocator; - bgfx::VertexLayout m_decl; + bgfx::VertexLayout m_layout; bgfx::ProgramHandle m_program; bgfx::ProgramHandle m_imageProgram; bgfx::TextureHandle m_texture; diff --git a/examples/common/nanovg/nanovg_bgfx.cpp b/examples/common/nanovg/nanovg_bgfx.cpp index e4cc54b07..81f6b0948 100644 --- a/examples/common/nanovg/nanovg_bgfx.cpp +++ b/examples/common/nanovg/nanovg_bgfx.cpp @@ -48,7 +48,7 @@ static const bgfx::EmbeddedShader s_embeddedShaders[] = namespace { - static bgfx::VertexLayout s_nvgDecl; + static bgfx::VertexLayout s_nvgLayout; enum GLNVGshaderType { @@ -282,7 +282,7 @@ namespace gl->u_halfTexel.idx = bgfx::kInvalidHandle; } - s_nvgDecl + s_nvgLayout .begin() .add(bgfx::Attrib::Position, 2, bgfx::AttribType::Float) .add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float) @@ -762,7 +762,7 @@ namespace if (gl->ncalls > 0) { - bgfx::allocTransientVertexBuffer(&gl->tvb, gl->nverts, s_nvgDecl); + bgfx::allocTransientVertexBuffer(&gl->tvb, gl->nverts, s_nvgLayout); int allocated = gl->tvb.size/gl->tvb.stride; diff --git a/examples/common/ps/particle_system.cpp b/examples/common/ps/particle_system.cpp index bf38c657e..c285e5959 100644 --- a/examples/common/ps/particle_system.cpp +++ b/examples/common/ps/particle_system.cpp @@ -37,7 +37,7 @@ struct PosColorTexCoord0Vertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true) @@ -45,10 +45,10 @@ struct PosColorTexCoord0Vertex .end(); } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosColorTexCoord0Vertex::ms_decl; +bgfx::VertexLayout PosColorTexCoord0Vertex::ms_layout; void EmitterUniforms::reset() { @@ -535,7 +535,7 @@ namespace ps bgfx::TransientVertexBuffer tvb; bgfx::TransientIndexBuffer tib; - const uint32_t numVertices = bgfx::getAvailTransientVertexBuffer(m_num*4, PosColorTexCoord0Vertex::ms_decl); + const uint32_t numVertices = bgfx::getAvailTransientVertexBuffer(m_num*4, PosColorTexCoord0Vertex::ms_layout); const uint32_t numIndices = bgfx::getAvailTransientIndexBuffer(m_num*6); const uint32_t max = bx::uint32_min(numVertices/4, numIndices/6); BX_WARN(m_num == max @@ -547,7 +547,7 @@ namespace ps if (0 < max) { bgfx::allocTransientBuffers(&tvb - , PosColorTexCoord0Vertex::ms_decl + , PosColorTexCoord0Vertex::ms_layout , max*4 , &tib , max*6 diff --git a/include/bgfx/bgfx.h b/include/bgfx/bgfx.h index ba4a8fd68..9b1deac31 100644 --- a/include/bgfx/bgfx.h +++ b/include/bgfx/bgfx.h @@ -811,12 +811,12 @@ namespace bgfx /// struct TransientVertexBuffer { - uint8_t* data; //!< Pointer to data. - uint32_t size; //!< Data size. - uint32_t startVertex; //!< First vertex. - uint16_t stride; //!< Vertex stride. - VertexBufferHandle handle; //!< Vertex buffer handle. - VertexLayoutHandle decl; //!< Vertex layout handle. + uint8_t* data; //!< Pointer to data. + uint32_t size; //!< Data size. + uint32_t startVertex; //!< First vertex. + uint16_t stride; //!< Vertex stride. + VertexBufferHandle handle; //!< Vertex buffer handle. + VertexLayoutHandle layoutHandle; //!< Vertex layout handle. }; /// Instance data buffer info. @@ -1225,7 +1225,7 @@ namespace bgfx /// @param[in] _handle Vertex buffer. /// @param[in] _startVertex First vertex to render. /// @param[in] _numVertices Number of vertices to render. - /// @param[in] _declHandle VertexLayout handle for aliasing vertex buffer. + /// @param[in] _layoutHandle VertexLayout handle for aliasing vertex buffer. /// /// @attention C99 equivalent is `bgfx_encoder_set_vertex_buffer`. /// @@ -1234,7 +1234,7 @@ namespace bgfx , VertexBufferHandle _handle , uint32_t _startVertex , uint32_t _numVertices - , VertexLayoutHandle _declHandle = BGFX_INVALID_HANDLE + , VertexLayoutHandle _layoutHandle = BGFX_INVALID_HANDLE ); /// Set vertex buffer for draw primitive. @@ -1255,7 +1255,7 @@ namespace bgfx /// @param[in] _handle Dynamic vertex buffer. /// @param[in] _startVertex First vertex to render. /// @param[in] _numVertices Number of vertices to render. - /// @param[in] _declHandle VertexLayout handle for aliasing vertex buffer. + /// @param[in] _layoutHandle VertexLayout handle for aliasing vertex buffer. /// /// @attention C99 equivalent is `bgfx_encoder_set_dynamic_vertex_buffer`. /// @@ -1264,7 +1264,7 @@ namespace bgfx , DynamicVertexBufferHandle _handle , uint32_t _startVertex , uint32_t _numVertices - , VertexLayoutHandle _declHandle = BGFX_INVALID_HANDLE + , VertexLayoutHandle _layoutHandle = BGFX_INVALID_HANDLE ); /// Set vertex buffer for draw primitive. @@ -1285,7 +1285,7 @@ namespace bgfx /// @param[in] _tvb Transient vertex buffer. /// @param[in] _startVertex First vertex to render. /// @param[in] _numVertices Number of vertices to render. - /// @param[in] _declHandle VertexLayout handle for aliasing vertex buffer. + /// @param[in] _layoutHandle VertexLayout handle for aliasing vertex buffer. /// /// @attention C99 equivalent is `bgfx_encoder_set_transient_vertex_buffer`. /// @@ -1294,7 +1294,7 @@ namespace bgfx , const TransientVertexBuffer* _tvb , uint32_t _startVertex , uint32_t _numVertices - , VertexLayoutHandle _declHandle = BGFX_INVALID_HANDLE + , VertexLayoutHandle _layoutHandle = BGFX_INVALID_HANDLE ); /// Set number of vertices for auto generated vertices use in conjuction @@ -1664,7 +1664,7 @@ namespace bgfx /// Vertex layout. /// - /// @attention C99 equivalent is `bgfx_vertex_decl_t`. + /// @attention C99 equivalent is `bgfx_vertex_layout_t`. /// struct VertexLayout { @@ -1672,13 +1672,13 @@ namespace bgfx /// Start VertexLayout. /// - /// @attention C99 equivalent is `bgfx_vertex_decl_begin`. + /// @attention C99 equivalent is `bgfx_vertex_layout_begin`. /// VertexLayout& begin(RendererType::Enum _renderer = RendererType::Noop); /// End VertexLayout. /// - /// @attention C99 equivalent is `bgfx_vertex_decl_end`. + /// @attention C99 equivalent is `bgfx_vertex_layout_end`. /// void end(); @@ -1698,7 +1698,7 @@ namespace bgfx /// @remarks /// Must be called between begin/end. /// - /// @attention C99 equivalent is `bgfx_vertex_decl_add`. + /// @attention C99 equivalent is `bgfx_vertex_layout_add`. /// VertexLayout& add( Attrib::Enum _attrib @@ -1710,13 +1710,13 @@ namespace bgfx /// Skip _num bytes in vertex stream. /// - /// @attention C99 equivalent is `bgfx_vertex_decl_skip`. + /// @attention C99 equivalent is `bgfx_vertex_layout_skip`. /// VertexLayout& skip(uint8_t _num); /// Decode attribute. /// - /// @attention C99 equivalent is `bgfx_vertex_decl_decode`. + /// @attention C99 equivalent is `bgfx_vertex_layout_decode`. /// void decode( Attrib::Enum _attrib @@ -1728,7 +1728,7 @@ namespace bgfx /// Returns true if VertexLayout contains attribute. /// - /// @attention C99 equivalent is `bgfx_vertex_decl_has`. + /// @attention C99 equivalent is `bgfx_vertex_layout_has`. /// bool has(Attrib::Enum _attrib) const { return UINT16_MAX != m_attributes[_attrib]; } @@ -1752,7 +1752,7 @@ namespace bgfx /// @param[in] _input Value to be packed into vertex stream. /// @param[in] _inputNormalized True if input value is already normalized. /// @param[in] _attr Attribute to pack. - /// @param[in] _decl Vertex stream layout. + /// @param[in] _layout Vertex stream layout. /// @param[in] _data Destination vertex stream where data will be packed. /// @param[in] _index Vertex index that will be modified. /// @@ -1762,7 +1762,7 @@ namespace bgfx const float _input[4] , bool _inputNormalized , Attrib::Enum _attr - , const VertexLayout& _decl + , const VertexLayout& _layout , void* _data , uint32_t _index = 0 ); @@ -1771,7 +1771,7 @@ namespace bgfx /// /// @param[out] _output Result of unpacking. /// @param[in] _attr Attribute to unpack. - /// @param[in] _decl Vertex stream layout. + /// @param[in] _layout Vertex stream layout. /// @param[in] _data Source vertex stream from where data will be unpacked. /// @param[in] _index Vertex index that will be unpacked. /// @@ -1780,25 +1780,25 @@ namespace bgfx void vertexUnpack( float _output[4] , Attrib::Enum _attr - , const VertexLayout& _decl + , const VertexLayout& _layout , const void* _data , uint32_t _index = 0 ); /// Converts vertex stream data from one vertex stream format to another. /// - /// @param[in] _destDecl Destination vertex stream layout. + /// @param[in] _destLayout Destination vertex stream layout. /// @param[in] _destData Destination vertex stream. - /// @param[in] _srcDecl Source vertex stream layout. + /// @param[in] _srcLayout Source vertex stream layout. /// @param[in] _srcData Source vertex stream data. /// @param[in] _num Number of vertices to convert from source to destination. /// /// @attention C99 equivalent is `bgfx_vertex_convert`. /// void vertexConvert( - const VertexLayout& _destDecl + const VertexLayout& _destLayout , void* _destData - , const VertexLayout& _srcDecl + , const VertexLayout& _srcLayout , const void* _srcData , uint32_t _num = 1 ); @@ -1807,7 +1807,7 @@ namespace bgfx /// /// @param[in] _output Welded vertices remapping table. The size of buffer /// must be the same as number of vertices. - /// @param[in] _decl Vertex stream layout. + /// @param[in] _layout Vertex stream layout. /// @param[in] _data Vertex stream. /// @param[in] _num Number of vertices in vertex stream. /// @param[in] _epsilon Error tolerance for vertex position comparison. @@ -1817,7 +1817,7 @@ namespace bgfx /// uint16_t weldVertices( uint16_t* _output - , const VertexLayout& _decl + , const VertexLayout& _layout , const void* _data , uint16_t _num , float _epsilon = 0.001f @@ -2170,7 +2170,7 @@ namespace bgfx /// /// @attention C99 equivalent is `bgfx_create_vertex_layout`. /// - VertexLayoutHandle createVertexLayout(const VertexLayout& _decl); + VertexLayoutHandle createVertexLayout(const VertexLayout& _layout); /// Destroy vertex layout. /// @@ -2181,7 +2181,7 @@ namespace bgfx /// Create static vertex buffer. /// /// @param[in] _mem Vertex buffer data. - /// @param[in] _decl Vertex layout. + /// @param[in] _layout Vertex layout. /// @param[in] _flags Buffer creation flags. /// - `BGFX_BUFFER_NONE` - No flags. /// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. @@ -2200,7 +2200,7 @@ namespace bgfx /// VertexBufferHandle createVertexBuffer( const Memory* _mem - , const VertexLayout& _decl + , const VertexLayout& _layout , uint16_t _flags = BGFX_BUFFER_NONE ); @@ -2300,7 +2300,7 @@ namespace bgfx /// Create empty dynamic vertex buffer. /// /// @param[in] _num Number of vertices. - /// @param[in] _decl Vertex layout. + /// @param[in] _layout Vertex layout. /// @param[in] _flags Buffer creation flags. /// - `BGFX_BUFFER_NONE` - No flags. /// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. @@ -2319,14 +2319,14 @@ namespace bgfx /// DynamicVertexBufferHandle createDynamicVertexBuffer( uint32_t _num - , const VertexLayout& _decl + , const VertexLayout& _layout , uint16_t _flags = BGFX_BUFFER_NONE ); /// Create dynamic vertex buffer and initialize it. /// /// @param[in] _mem Vertex buffer data. - /// @param[in] _decl Vertex layout. + /// @param[in] _layout Vertex layout. /// @param[in] _flags Buffer creation flags. /// - `BGFX_BUFFER_NONE` - No flags. /// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. @@ -2345,7 +2345,7 @@ namespace bgfx /// DynamicVertexBufferHandle createDynamicVertexBuffer( const Memory* _mem - , const VertexLayout& _decl + , const VertexLayout& _layout , uint16_t _flags = BGFX_BUFFER_NONE ); @@ -2382,13 +2382,13 @@ namespace bgfx /// Returns number of requested or maximum available vertices. /// /// @param[in] _num Number of required vertices. - /// @param[in] _decl Vertex layout. + /// @param[in] _layout Vertex layout. /// /// @attention C99 equivalent is `bgfx_get_avail_transient_vertex_buffer`. /// uint32_t getAvailTransientVertexBuffer( uint32_t _num - , const VertexLayout& _decl + , const VertexLayout& _layout ); /// Returns number of requested or maximum available instance buffer slots. @@ -2426,14 +2426,14 @@ namespace bgfx /// for the duration of frame, and it can be reused for multiple draw /// calls. /// @param[in] _num Number of vertices to allocate. - /// @param[in] _decl Vertex layout. + /// @param[in] _layout Vertex layout. /// /// @attention C99 equivalent is `bgfx_alloc_transient_vertex_buffer`. /// void allocTransientVertexBuffer( TransientVertexBuffer* _tvb , uint32_t _num - , const VertexLayout& _decl + , const VertexLayout& _layout ); /// Check for required space and allocate transient vertex and index @@ -2447,7 +2447,7 @@ namespace bgfx /// bool allocTransientBuffers( TransientVertexBuffer* _tvb - , const VertexLayout& _decl + , const VertexLayout& _layout , uint32_t _numVertices , TransientIndexBuffer* _tib , uint32_t _numIndices @@ -3621,7 +3621,7 @@ namespace bgfx /// @param[in] _handle Vertex buffer. /// @param[in] _startVertex First vertex to render. /// @param[in] _numVertices Number of vertices to render. - /// @param[in] _declHandle VertexLayout handle for aliasing vertex buffer. + /// @param[in] _layoutHandle VertexLayout handle for aliasing vertex buffer. /// /// @attention C99 equivalent is `bgfx_set_vertex_buffer`. /// @@ -3630,7 +3630,7 @@ namespace bgfx , VertexBufferHandle _handle , uint32_t _startVertex , uint32_t _numVertices - , VertexLayoutHandle _declHandle = BGFX_INVALID_HANDLE + , VertexLayoutHandle _layoutHandle = BGFX_INVALID_HANDLE ); /// Set vertex buffer for draw primitive. @@ -3651,7 +3651,7 @@ namespace bgfx /// @param[in] _handle Dynamic vertex buffer. /// @param[in] _startVertex First vertex to render. /// @param[in] _numVertices Number of vertices to render. - /// @param[in] _declHandle VertexLayout handle for aliasing vertex buffer. + /// @param[in] _layoutHandle VertexLayout handle for aliasing vertex buffer. /// /// @attention C99 equivalent is `bgfx_set_dynamic_vertex_buffer`. /// @@ -3660,7 +3660,7 @@ namespace bgfx , DynamicVertexBufferHandle _handle , uint32_t _startVertex , uint32_t _numVertices - , VertexLayoutHandle _declHandle = BGFX_INVALID_HANDLE + , VertexLayoutHandle _layoutHandle = BGFX_INVALID_HANDLE ); /// Set vertex buffer for draw primitive. @@ -3681,7 +3681,7 @@ namespace bgfx /// @param[in] _tvb Transient vertex buffer. /// @param[in] _startVertex First vertex to render. /// @param[in] _numVertices Number of vertices to render. - /// @param[in] _declHandle VertexLayout handle for aliasing vertex buffer. + /// @param[in] _layoutHandle VertexLayout handle for aliasing vertex buffer. /// /// @attention C99 equivalent is `bgfx_set_transient_vertex_buffer`. /// @@ -3690,7 +3690,7 @@ namespace bgfx , const TransientVertexBuffer* _tvb , uint32_t _startVertex , uint32_t _numVertices - , VertexLayoutHandle _declHandle = BGFX_INVALID_HANDLE + , VertexLayoutHandle _layoutHandle = BGFX_INVALID_HANDLE ); /// Set number of vertices for auto generated vertices use in conjuction diff --git a/include/bgfx/c99/bgfx.h b/include/bgfx/c99/bgfx.h index 696ee719c..6af6ae19e 100644 --- a/include/bgfx/c99/bgfx.h +++ b/include/bgfx/c99/bgfx.h @@ -700,7 +700,7 @@ typedef struct bgfx_transient_vertex_buffer_s uint32_t startVertex; /** First vertex. */ uint16_t stride; /** Vertex stride. */ bgfx_vertex_buffer_handle_t handle; /** Vertex buffer handle. */ - bgfx_vertex_layout_handle_t decl; /** Vertex layout handle. */ + bgfx_vertex_layout_handle_t layoutHandle; /** Vertex layout handle. */ } bgfx_transient_vertex_buffer_t; @@ -949,43 +949,43 @@ BGFX_C_API void bgfx_vertex_layout_end(bgfx_vertex_layout_t* _this); * @param[in] _input Value to be packed into vertex stream. * @param[in] _inputNormalized `true` if input value is already normalized. * @param[in] _attr Attribute to pack. - * @param[in] _decl Vertex stream layout. + * @param[in] _layout Vertex stream layout. * @param[in] _data Destination vertex stream where data will be packed. * @param[in] _index Vertex index that will be modified. * */ -BGFX_C_API void bgfx_vertex_pack(const float _input[4], bool _inputNormalized, bgfx_attrib_t _attr, const bgfx_vertex_layout_t * _decl, void* _data, uint32_t _index); +BGFX_C_API void bgfx_vertex_pack(const float _input[4], bool _inputNormalized, bgfx_attrib_t _attr, const bgfx_vertex_layout_t * _layout, void* _data, uint32_t _index); /** * Unpack vertex attribute from vertex stream format. * * @param[out] _output Result of unpacking. * @param[in] _attr Attribute to unpack. - * @param[in] _decl Vertex stream layout. + * @param[in] _layout Vertex stream layout. * @param[in] _data Source vertex stream from where data will be unpacked. * @param[in] _index Vertex index that will be unpacked. * */ -BGFX_C_API void bgfx_vertex_unpack(float _output[4], bgfx_attrib_t _attr, const bgfx_vertex_layout_t * _decl, const void* _data, uint32_t _index); +BGFX_C_API void bgfx_vertex_unpack(float _output[4], bgfx_attrib_t _attr, const bgfx_vertex_layout_t * _layout, const void* _data, uint32_t _index); /** * Converts vertex stream data from one vertex stream format to another. * - * @param[in] _dstDecl Destination vertex stream layout. + * @param[in] _dstLayout Destination vertex stream layout. * @param[in] _dstData Destination vertex stream. - * @param[in] _srcDecl Source vertex stream layout. + * @param[in] _srcLayout Source vertex stream layout. * @param[in] _srcData Source vertex stream data. * @param[in] _num Number of vertices to convert from source to destination. * */ -BGFX_C_API void bgfx_vertex_convert(const bgfx_vertex_layout_t * _dstDecl, void* _dstData, const bgfx_vertex_layout_t * _srcDecl, const void* _srcData, uint32_t _num); +BGFX_C_API void bgfx_vertex_convert(const bgfx_vertex_layout_t * _dstLayout, void* _dstData, const bgfx_vertex_layout_t * _srcLayout, const void* _srcData, uint32_t _num); /** * Weld vertices. * * @param[in] _output Welded vertices remapping table. The size of buffer * must be the same as number of vertices. - * @param[in] _decl Vertex stream layout. + * @param[in] _layout Vertex stream layout. * @param[in] _data Vertex stream. * @param[in] _num Number of vertices in vertex stream. * @param[in] _epsilon Error tolerance for vertex position comparison. @@ -993,7 +993,7 @@ BGFX_C_API void bgfx_vertex_convert(const bgfx_vertex_layout_t * _dstDecl, void* * @returns Number of unique vertices after vertex welding. * */ -BGFX_C_API uint16_t bgfx_weld_vertices(uint16_t* _output, const bgfx_vertex_layout_t * _decl, const void* _data, uint16_t _num, float _epsilon); +BGFX_C_API uint16_t bgfx_weld_vertices(uint16_t* _output, const bgfx_vertex_layout_t * _layout, const void* _data, uint16_t _num, float _epsilon); /** * Convert index buffer for use with different primitive topologies. @@ -1296,24 +1296,24 @@ BGFX_C_API void bgfx_destroy_index_buffer(bgfx_index_buffer_handle_t _handle); /** * Create vertex layout. * - * @param[in] _decl Vertex layout. + * @param[in] _layout Vertex layout. * */ -BGFX_C_API bgfx_vertex_layout_handle_t bgfx_create_vertex_layout(const bgfx_vertex_layout_t * _decl); +BGFX_C_API bgfx_vertex_layout_handle_t bgfx_create_vertex_layout(const bgfx_vertex_layout_t * _layout); /** * Destroy vertex layout. * - * @param[in] _handle Vertex layout handle. + * @param[in] _layoutHandle Vertex layout handle. * */ -BGFX_C_API void bgfx_destroy_vertex_decl(bgfx_vertex_layout_handle_t _handle); +BGFX_C_API void bgfx_destroy_vertex_layout(bgfx_vertex_layout_handle_t _layoutHandle); /** * Create static vertex buffer. * * @param[in] _mem Vertex buffer data. - * @param[in] _decl Vertex layout. + * @param[in] _layout Vertex layout. * @param[in] _flags Buffer creation flags. * - `BGFX_BUFFER_NONE` - No flags. * - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. @@ -1328,7 +1328,7 @@ BGFX_C_API void bgfx_destroy_vertex_decl(bgfx_vertex_layout_handle_t _handle); * @returns Static vertex buffer handle. * */ -BGFX_C_API bgfx_vertex_buffer_handle_t bgfx_create_vertex_buffer(const bgfx_memory_t* _mem, const bgfx_vertex_layout_t * _decl, uint16_t _flags); +BGFX_C_API bgfx_vertex_buffer_handle_t bgfx_create_vertex_buffer(const bgfx_memory_t* _mem, const bgfx_vertex_layout_t * _layout, uint16_t _flags); /** * Set static vertex buffer debug name. @@ -1415,7 +1415,7 @@ BGFX_C_API void bgfx_destroy_dynamic_index_buffer(bgfx_dynamic_index_buffer_hand * Create empty dynamic vertex buffer. * * @param[in] _num Number of vertices. - * @param[in] _decl Vertex layout. + * @param[in] _layout Vertex layout. * @param[in] _flags Buffer creation flags. * - `BGFX_BUFFER_NONE` - No flags. * - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. @@ -1432,13 +1432,13 @@ BGFX_C_API void bgfx_destroy_dynamic_index_buffer(bgfx_dynamic_index_buffer_hand * @returns Dynamic vertex buffer handle. * */ -BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer(uint32_t _num, const bgfx_vertex_layout_t* _decl, uint16_t _flags); +BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer(uint32_t _num, const bgfx_vertex_layout_t* _layout, uint16_t _flags); /** * Create dynamic vertex buffer and initialize it. * * @param[in] _mem Vertex buffer data. - * @param[in] _decl Vertex layout. + * @param[in] _layout Vertex layout. * @param[in] _flags Buffer creation flags. * - `BGFX_BUFFER_NONE` - No flags. * - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. @@ -1455,7 +1455,7 @@ BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer * @returns Dynamic vertex buffer handle. * */ -BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer_mem(const bgfx_memory_t* _mem, const bgfx_vertex_layout_t* _decl, uint16_t _flags); +BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer_mem(const bgfx_memory_t* _mem, const bgfx_vertex_layout_t* _layout, uint16_t _flags); /** * Update dynamic vertex buffer. @@ -1489,12 +1489,12 @@ BGFX_C_API uint32_t bgfx_get_avail_transient_index_buffer(uint32_t _num); * Returns number of requested or maximum available vertices. * * @param[in] _num Number of required vertices. - * @param[in] _decl Vertex layout. + * @param[in] _layout Vertex layout. * * @returns Number of requested or maximum available vertices. * */ -BGFX_C_API uint32_t bgfx_get_avail_transient_vertex_buffer(uint32_t _num, const bgfx_vertex_layout_t * _decl); +BGFX_C_API uint32_t bgfx_get_avail_transient_vertex_buffer(uint32_t _num, const bgfx_vertex_layout_t * _layout); /** * Returns number of requested or maximum available instance buffer slots. @@ -1527,10 +1527,10 @@ BGFX_C_API void bgfx_alloc_transient_index_buffer(bgfx_transient_index_buffer_t* * for the duration of frame, and it can be reused for multiple draw * calls. * @param[in] _num Number of vertices to allocate. - * @param[in] _decl Vertex layout. + * @param[in] _layout Vertex layout. * */ -BGFX_C_API void bgfx_alloc_transient_vertex_buffer(bgfx_transient_vertex_buffer_t* _tvb, uint32_t _num, const bgfx_vertex_layout_t * _decl); +BGFX_C_API void bgfx_alloc_transient_vertex_buffer(bgfx_transient_vertex_buffer_t* _tvb, uint32_t _num, const bgfx_vertex_layout_t * _layout); /** * Check for required space and allocate transient vertex and index @@ -1542,7 +1542,7 @@ BGFX_C_API void bgfx_alloc_transient_vertex_buffer(bgfx_transient_vertex_buffer_ * @param[out] _tvb TransientVertexBuffer structure is filled and is valid * for the duration of frame, and it can be reused for multiple draw * calls. - * @param[in] _decl Vertex layout. + * @param[in] _layout Vertex layout. * @param[in] _numVertices Number of vertices to allocate. * @param[out] _tib TransientIndexBuffer structure is filled and is valid * for the duration of frame, and it can be reused for multiple draw @@ -1550,7 +1550,7 @@ BGFX_C_API void bgfx_alloc_transient_vertex_buffer(bgfx_transient_vertex_buffer_ * @param[in] _numIndices Number of indices to allocate. * */ -BGFX_C_API bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_layout_t * _decl, uint32_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint32_t _numIndices); +BGFX_C_API bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_layout_t * _layout, uint32_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint32_t _numIndices); /** * Allocate instance data buffer. @@ -2435,10 +2435,10 @@ BGFX_C_API void bgfx_encoder_set_transient_index_buffer(bgfx_encoder_t* _this, c * @param[in] _handle Vertex buffer. * @param[in] _startVertex First vertex to render. * @param[in] _numVertices Number of vertices to render. - * @param[in] _declHandle VertexLayout handle for aliasing vertex buffer. + * @param[in] _layoutHandle VertexLayout handle for aliasing vertex buffer. * */ -BGFX_C_API void bgfx_encoder_set_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _declHandle); +BGFX_C_API void bgfx_encoder_set_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _layoutHandle); /** * Set vertex buffer for draw primitive. @@ -2447,10 +2447,10 @@ BGFX_C_API void bgfx_encoder_set_vertex_buffer(bgfx_encoder_t* _this, uint8_t _s * @param[in] _handle Dynamic vertex buffer. * @param[in] _startVertex First vertex to render. * @param[in] _numVertices Number of vertices to render. - * @param[in] _declHandle VertexLayout handle for aliasing vertex buffer. + * @param[in] _layoutHandle VertexLayout handle for aliasing vertex buffer. * */ -BGFX_C_API void bgfx_encoder_set_dynamic_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _declHandle); +BGFX_C_API void bgfx_encoder_set_dynamic_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _layoutHandle); /** * Set vertex buffer for draw primitive. @@ -2459,10 +2459,10 @@ BGFX_C_API void bgfx_encoder_set_dynamic_vertex_buffer(bgfx_encoder_t* _this, ui * @param[in] _tvb Transient vertex buffer. * @param[in] _startVertex First vertex to render. * @param[in] _numVertices Number of vertices to render. - * @param[in] _declHandle VertexLayout handle for aliasing vertex buffer. + * @param[in] _layoutHandle VertexLayout handle for aliasing vertex buffer. * */ -BGFX_C_API void bgfx_encoder_set_transient_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _declHandle); +BGFX_C_API void bgfx_encoder_set_transient_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _layoutHandle); /** * Set number of vertices for auto generated vertices use in conjuction @@ -3255,7 +3255,7 @@ typedef enum bgfx_function_id BGFX_FUNCTION_ID_SET_INDEX_BUFFER_NAME, BGFX_FUNCTION_ID_DESTROY_INDEX_BUFFER, BGFX_FUNCTION_ID_CREATE_VERTEX_LAYOUT, - BGFX_FUNCTION_ID_DESTROY_VERTEX_DECL, + BGFX_FUNCTION_ID_DESTROY_VERTEX_LAYOUT, BGFX_FUNCTION_ID_CREATE_VERTEX_BUFFER, BGFX_FUNCTION_ID_SET_VERTEX_BUFFER_NAME, BGFX_FUNCTION_ID_DESTROY_VERTEX_BUFFER, @@ -3418,10 +3418,10 @@ struct bgfx_interface_vtbl bool (*vertex_layout_has)(const bgfx_vertex_layout_t* _this, bgfx_attrib_t _attrib); bgfx_vertex_layout_t* (*vertex_layout_skip)(bgfx_vertex_layout_t* _this, uint8_t _num); void (*vertex_layout_end)(bgfx_vertex_layout_t* _this); - void (*vertex_pack)(const float _input[4], bool _inputNormalized, bgfx_attrib_t _attr, const bgfx_vertex_layout_t * _decl, void* _data, uint32_t _index); - void (*vertex_unpack)(float _output[4], bgfx_attrib_t _attr, const bgfx_vertex_layout_t * _decl, const void* _data, uint32_t _index); - void (*vertex_convert)(const bgfx_vertex_layout_t * _dstDecl, void* _dstData, const bgfx_vertex_layout_t * _srcDecl, const void* _srcData, uint32_t _num); - uint16_t (*weld_vertices)(uint16_t* _output, const bgfx_vertex_layout_t * _decl, const void* _data, uint16_t _num, float _epsilon); + void (*vertex_pack)(const float _input[4], bool _inputNormalized, bgfx_attrib_t _attr, const bgfx_vertex_layout_t * _layout, void* _data, uint32_t _index); + void (*vertex_unpack)(float _output[4], bgfx_attrib_t _attr, const bgfx_vertex_layout_t * _layout, const void* _data, uint32_t _index); + void (*vertex_convert)(const bgfx_vertex_layout_t * _dstLayout, void* _dstData, const bgfx_vertex_layout_t * _srcLayout, const void* _srcData, uint32_t _num); + uint16_t (*weld_vertices)(uint16_t* _output, const bgfx_vertex_layout_t * _layout, const void* _data, uint16_t _num, float _epsilon); uint32_t (*topology_convert)(bgfx_topology_convert_t _conversion, void* _dst, uint32_t _dstSize, const void* _indices, uint32_t _numIndices, bool _index32); void (*topology_sort_tri_list)(bgfx_topology_sort_t _sort, void* _dst, uint32_t _dstSize, const float _dir[3], const float _pos[3], const void* _vertices, uint32_t _stride, const void* _indices, uint32_t _numIndices, bool _index32); uint8_t (*get_supported_renderers)(uint8_t _max, bgfx_renderer_type_t* _enum); @@ -3446,25 +3446,25 @@ struct bgfx_interface_vtbl bgfx_index_buffer_handle_t (*create_index_buffer)(const bgfx_memory_t* _mem, uint16_t _flags); void (*set_index_buffer_name)(bgfx_index_buffer_handle_t _handle, const char* _name, int32_t _len); void (*destroy_index_buffer)(bgfx_index_buffer_handle_t _handle); - bgfx_vertex_layout_handle_t (*create_vertex_layout)(const bgfx_vertex_layout_t * _decl); - void (*destroy_vertex_decl)(bgfx_vertex_layout_handle_t _handle); - bgfx_vertex_buffer_handle_t (*create_vertex_buffer)(const bgfx_memory_t* _mem, const bgfx_vertex_layout_t * _decl, uint16_t _flags); + bgfx_vertex_layout_handle_t (*create_vertex_layout)(const bgfx_vertex_layout_t * _layout); + void (*destroy_vertex_layout)(bgfx_vertex_layout_handle_t _layoutHandle); + bgfx_vertex_buffer_handle_t (*create_vertex_buffer)(const bgfx_memory_t* _mem, const bgfx_vertex_layout_t * _layout, uint16_t _flags); void (*set_vertex_buffer_name)(bgfx_vertex_buffer_handle_t _handle, const char* _name, int32_t _len); void (*destroy_vertex_buffer)(bgfx_vertex_buffer_handle_t _handle); bgfx_dynamic_index_buffer_handle_t (*create_dynamic_index_buffer)(uint32_t _num, uint16_t _flags); bgfx_dynamic_index_buffer_handle_t (*create_dynamic_index_buffer_mem)(const bgfx_memory_t* _mem, uint16_t _flags); void (*update_dynamic_index_buffer)(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _startIndex, const bgfx_memory_t* _mem); void (*destroy_dynamic_index_buffer)(bgfx_dynamic_index_buffer_handle_t _handle); - bgfx_dynamic_vertex_buffer_handle_t (*create_dynamic_vertex_buffer)(uint32_t _num, const bgfx_vertex_layout_t* _decl, uint16_t _flags); - bgfx_dynamic_vertex_buffer_handle_t (*create_dynamic_vertex_buffer_mem)(const bgfx_memory_t* _mem, const bgfx_vertex_layout_t* _decl, uint16_t _flags); + bgfx_dynamic_vertex_buffer_handle_t (*create_dynamic_vertex_buffer)(uint32_t _num, const bgfx_vertex_layout_t* _layout, uint16_t _flags); + bgfx_dynamic_vertex_buffer_handle_t (*create_dynamic_vertex_buffer_mem)(const bgfx_memory_t* _mem, const bgfx_vertex_layout_t* _layout, uint16_t _flags); void (*update_dynamic_vertex_buffer)(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, const bgfx_memory_t* _mem); void (*destroy_dynamic_vertex_buffer)(bgfx_dynamic_vertex_buffer_handle_t _handle); uint32_t (*get_avail_transient_index_buffer)(uint32_t _num); - uint32_t (*get_avail_transient_vertex_buffer)(uint32_t _num, const bgfx_vertex_layout_t * _decl); + uint32_t (*get_avail_transient_vertex_buffer)(uint32_t _num, const bgfx_vertex_layout_t * _layout); uint32_t (*get_avail_instance_data_buffer)(uint32_t _num, uint16_t _stride); void (*alloc_transient_index_buffer)(bgfx_transient_index_buffer_t* _tib, uint32_t _num); - void (*alloc_transient_vertex_buffer)(bgfx_transient_vertex_buffer_t* _tvb, uint32_t _num, const bgfx_vertex_layout_t * _decl); - bool (*alloc_transient_buffers)(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_layout_t * _decl, uint32_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint32_t _numIndices); + void (*alloc_transient_vertex_buffer)(bgfx_transient_vertex_buffer_t* _tvb, uint32_t _num, const bgfx_vertex_layout_t * _layout); + bool (*alloc_transient_buffers)(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_layout_t * _layout, uint32_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint32_t _numIndices); void (*alloc_instance_data_buffer)(bgfx_instance_data_buffer_t* _idb, uint32_t _num, uint16_t _stride); bgfx_indirect_buffer_handle_t (*create_indirect_buffer)(uint32_t _num); void (*destroy_indirect_buffer)(bgfx_indirect_buffer_handle_t _handle); @@ -3530,9 +3530,9 @@ struct bgfx_interface_vtbl void (*encoder_set_index_buffer)(bgfx_encoder_t* _this, bgfx_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices); void (*encoder_set_dynamic_index_buffer)(bgfx_encoder_t* _this, bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices); void (*encoder_set_transient_index_buffer)(bgfx_encoder_t* _this, const bgfx_transient_index_buffer_t* _tib, uint32_t _firstIndex, uint32_t _numIndices); - void (*encoder_set_vertex_buffer)(bgfx_encoder_t* _this, uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _declHandle); - void (*encoder_set_dynamic_vertex_buffer)(bgfx_encoder_t* _this, uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _declHandle); - void (*encoder_set_transient_vertex_buffer)(bgfx_encoder_t* _this, uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _declHandle); + void (*encoder_set_vertex_buffer)(bgfx_encoder_t* _this, uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _layoutHandle); + void (*encoder_set_dynamic_vertex_buffer)(bgfx_encoder_t* _this, uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _layoutHandle); + void (*encoder_set_transient_vertex_buffer)(bgfx_encoder_t* _this, uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _layoutHandle); void (*encoder_set_vertex_count)(bgfx_encoder_t* _this, uint32_t _numVertices); void (*encoder_set_instance_data_buffer)(bgfx_encoder_t* _this, const bgfx_instance_data_buffer_t* _idb, uint32_t _start, uint32_t _num); void (*encoder_set_instance_data_from_vertex_buffer)(bgfx_encoder_t* _this, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num); diff --git a/scripts/bgfx.idl b/scripts/bgfx.idl index e1b1b5b8a..97e90ef47 100644 --- a/scripts/bgfx.idl +++ b/scripts/bgfx.idl @@ -788,12 +788,12 @@ struct.TransientIndexBuffer --- Transient vertex buffer. struct.TransientVertexBuffer - .data "uint8_t*" --- Pointer to data. - .size "uint32_t" --- Data size. - .startVertex "uint32_t" --- First vertex. - .stride "uint16_t" --- Vertex stride. - .handle "VertexBufferHandle" --- Vertex buffer handle. - .decl "VertexLayoutHandle" --- Vertex layout handle. + .data "uint8_t*" --- Pointer to data. + .size "uint32_t" --- Data size. + .startVertex "uint32_t" --- First vertex. + .stride "uint16_t" --- Vertex stride. + .handle "VertexBufferHandle" --- Vertex buffer handle. + .layoutHandle "VertexLayoutHandle" --- Vertex layout handle. --- Instance data buffer info. struct.InstanceDataBuffer @@ -892,7 +892,7 @@ struct.Stats .numTextures "uint16_t" --- Number of used textures. .numUniforms "uint16_t" --- Number of used uniforms. .numVertexBuffers "uint16_t" --- Number of used vertex buffers. - .numVertexLayouts "uint16_t" --- Number of used vertex layouts. + .numVertexLayouts "uint16_t" --- Number of used vertex layouts. .textureMemoryUsed "int64_t" --- Estimate of texture memory used. .rtMemoryUsed "int64_t" --- Estimate of render target memory used. @@ -1003,43 +1003,43 @@ func.VertexLayout.getSize { const, cpponly } --- Pack vertex attribute into vertex stream format. func.vertexPack "void" - .input "const float[4]" --- Value to be packed into vertex stream. - .inputNormalized "bool" --- `true` if input value is already normalized. - .attr "Attrib::Enum" --- Attribute to pack. - .decl "const VertexLayout &" --- Vertex stream layout. - .data "void*" --- Destination vertex stream where data will be packed. - .index "uint32_t" --- Vertex index that will be modified. + .input "const float[4]" --- Value to be packed into vertex stream. + .inputNormalized "bool" --- `true` if input value is already normalized. + .attr "Attrib::Enum" --- Attribute to pack. + .layout "const VertexLayout &" --- Vertex stream layout. + .data "void*" --- Destination vertex stream where data will be packed. + .index "uint32_t" --- Vertex index that will be modified. { default = 0 } --- Unpack vertex attribute from vertex stream format. func.vertexUnpack "void" - .output "float[4]" { out } --- Result of unpacking. - .attr "Attrib::Enum" --- Attribute to unpack. - .decl "const VertexLayout &" --- Vertex stream layout. - .data "const void*" --- Source vertex stream from where data will be unpacked. - .index "uint32_t" --- Vertex index that will be unpacked. + .output "float[4]" { out } --- Result of unpacking. + .attr "Attrib::Enum" --- Attribute to unpack. + .layout "const VertexLayout &" --- Vertex stream layout. + .data "const void*" --- Source vertex stream from where data will be unpacked. + .index "uint32_t" --- Vertex index that will be unpacked. { default = 0 } --- Converts vertex stream data from one vertex stream format to another. func.vertexConvert "void" - .dstDecl "const VertexLayout &" --- Destination vertex stream layout. - .dstData "void*" --- Destination vertex stream. - .srcDecl "const VertexLayout &" --- Source vertex stream layout. - .srcData "const void*" --- Source vertex stream data. - .num "uint32_t" --- Number of vertices to convert from source to destination. + .dstLayout "const VertexLayout &" --- Destination vertex stream layout. + .dstData "void*" --- Destination vertex stream. + .srcLayout "const VertexLayout &" --- Source vertex stream layout. + .srcData "const void*" --- Source vertex stream data. + .num "uint32_t" --- Number of vertices to convert from source to destination. { default = 1 } --- Weld vertices. func.weldVertices - "uint16_t" --- Number of unique vertices after vertex welding. - .output "uint16_t*" --- Welded vertices remapping table. The size of buffer - --- must be the same as number of vertices. - .decl "const VertexLayout &" --- Vertex stream layout. - .data "const void*" --- Vertex stream. - .num "uint16_t" --- Number of vertices in vertex stream. - .epsilon "float" --- Error tolerance for vertex position comparison. + "uint16_t" --- Number of unique vertices after vertex welding. + .output "uint16_t*" --- Welded vertices remapping table. The size of buffer + --- must be the same as number of vertices. + .layout "const VertexLayout &" --- Vertex stream layout. + .data "const void*" --- Vertex stream. + .num "uint16_t" --- Number of vertices in vertex stream. + .epsilon "float" --- Error tolerance for vertex position comparison. { default = "0.001f" } --- Convert index buffer for use with different primitive topologies. @@ -1282,28 +1282,28 @@ func.destroy { cname = "destroy_index_buffer" } --- Create vertex layout. func.createVertexLayout "VertexLayoutHandle" - .decl "const VertexLayout &" --- Vertex layout. + .layout "const VertexLayout &" --- Vertex layout. --- Destroy vertex layout. -func.destroy { cname = "destroy_vertex_decl" } +func.destroy { cname = "destroy_vertex_layout" } "void" - .handle "VertexLayoutHandle" --- Vertex layout handle. + .layoutHandle "VertexLayoutHandle" --- Vertex layout handle. --- Create static vertex buffer. func.createVertexBuffer - "VertexBufferHandle" --- Static vertex buffer handle. - .mem "const Memory*" --- Vertex buffer data. - .decl "const VertexLayout &" --- Vertex layout. - .flags "uint16_t" --- Buffer creation flags. - { default = "BGFX_BUFFER_NONE" } --- - `BGFX_BUFFER_NONE` - No flags. - --- - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. - --- - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer - --- is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. - --- - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. - --- - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of - --- data is passed. If this flag is not specified, and more data is passed on update, the buffer - --- will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers. - --- - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on index buffers. + "VertexBufferHandle" --- Static vertex buffer handle. + .mem "const Memory*" --- Vertex buffer data. + .layout "const VertexLayout &" --- Vertex layout. + .flags "uint16_t" --- Buffer creation flags. + { default = "BGFX_BUFFER_NONE" } --- - `BGFX_BUFFER_NONE` - No flags. + --- - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. + --- - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer + --- is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. + --- - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. + --- - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of + --- data is passed. If this flag is not specified, and more data is passed on update, the buffer + --- will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers. + --- - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on index buffers. --- Set static vertex buffer debug name. func.setName { cname = "set_vertex_buffer_name" } @@ -1366,39 +1366,39 @@ func.destroy { cname = "destroy_dynamic_index_buffer" } --- Create empty dynamic vertex buffer. func.createDynamicVertexBuffer - "DynamicVertexBufferHandle" --- Dynamic vertex buffer handle. - .num "uint32_t" --- Number of vertices. - .decl "const VertexLayout&" --- Vertex layout. - .flags "uint16_t" --- Buffer creation flags. - { default = "BGFX_BUFFER_NONE" } --- - `BGFX_BUFFER_NONE` - No flags. - --- - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. - --- - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer - --- is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. - --- - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. - --- - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of - --- data is passed. If this flag is not specified, and more data is passed on update, the buffer - --- will be trimmed to fit the existing buffer size. This flag has effect only on dynamic - --- buffers. - --- - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on - --- index buffers. + "DynamicVertexBufferHandle" --- Dynamic vertex buffer handle. + .num "uint32_t" --- Number of vertices. + .layout "const VertexLayout&" --- Vertex layout. + .flags "uint16_t" --- Buffer creation flags. + { default = "BGFX_BUFFER_NONE" } --- - `BGFX_BUFFER_NONE` - No flags. + --- - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. + --- - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer + --- is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. + --- - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. + --- - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of + --- data is passed. If this flag is not specified, and more data is passed on update, the buffer + --- will be trimmed to fit the existing buffer size. This flag has effect only on dynamic + --- buffers. + --- - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on + --- index buffers. --- Create dynamic vertex buffer and initialize it. func.createDynamicVertexBuffer { cname = "create_dynamic_vertex_buffer_mem" } - "DynamicVertexBufferHandle" --- Dynamic vertex buffer handle. - .mem "const Memory*" --- Vertex buffer data. - .decl "const VertexLayout&" --- Vertex layout. - .flags "uint16_t" --- Buffer creation flags. - { default = "BGFX_BUFFER_NONE" } --- - `BGFX_BUFFER_NONE` - No flags. - --- - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. - --- - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer - --- is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. - --- - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. - --- - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of - --- data is passed. If this flag is not specified, and more data is passed on update, the buffer - --- will be trimmed to fit the existing buffer size. This flag has effect only on dynamic - --- buffers. - --- - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on - --- index buffers. + "DynamicVertexBufferHandle" --- Dynamic vertex buffer handle. + .mem "const Memory*" --- Vertex buffer data. + .layout "const VertexLayout&" --- Vertex layout. + .flags "uint16_t" --- Buffer creation flags. + { default = "BGFX_BUFFER_NONE" } --- - `BGFX_BUFFER_NONE` - No flags. + --- - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. + --- - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer + --- is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. + --- - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. + --- - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of + --- data is passed. If this flag is not specified, and more data is passed on update, the buffer + --- will be trimmed to fit the existing buffer size. This flag has effect only on dynamic + --- buffers. + --- - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on + --- index buffers. --- Update dynamic vertex buffer. func.update { cname = "update_dynamic_vertex_buffer" } @@ -1419,9 +1419,9 @@ func.getAvailTransientIndexBuffer --- Returns number of requested or maximum available vertices. func.getAvailTransientVertexBuffer - "uint32_t" --- Number of requested or maximum available vertices. - .num "uint32_t" --- Number of required vertices. - .decl "const VertexLayout &" --- Vertex layout. + "uint32_t" --- Number of requested or maximum available vertices. + .num "uint32_t" --- Number of required vertices. + .layout "const VertexLayout &" --- Vertex layout. --- Returns number of requested or maximum available instance buffer slots. func.getAvailInstanceDataBuffer @@ -1444,11 +1444,11 @@ func.allocTransientIndexBuffer --- Allocate transient vertex buffer. func.allocTransientVertexBuffer "void" - .tvb "TransientVertexBuffer*" { out } --- TransientVertexBuffer structure is filled and is valid - --- for the duration of frame, and it can be reused for multiple draw - --- calls. - .num "uint32_t" --- Number of vertices to allocate. - .decl "const VertexLayout &" --- Vertex layout. + .tvb "TransientVertexBuffer*" { out } --- TransientVertexBuffer structure is filled and is valid + --- for the duration of frame, and it can be reused for multiple draw + --- calls. + .num "uint32_t" --- Number of vertices to allocate. + .layout "const VertexLayout &" --- Vertex layout. --- Check for required space and allocate transient vertex and index --- buffers. If both space requirements are satisfied function returns @@ -1459,15 +1459,15 @@ func.allocTransientVertexBuffer --- func.allocTransientBuffers "bool" - .tvb "TransientVertexBuffer*" { out } --- TransientVertexBuffer structure is filled and is valid - --- for the duration of frame, and it can be reused for multiple draw - --- calls. - .decl "const VertexLayout &" --- Vertex layout. - .numVertices "uint32_t" --- Number of vertices to allocate. - .tib "TransientIndexBuffer*" { out } --- TransientIndexBuffer structure is filled and is valid - --- for the duration of frame, and it can be reused for multiple draw - --- calls. - .numIndices "uint32_t" --- Number of indices to allocate. + .tvb "TransientVertexBuffer*" { out } --- TransientVertexBuffer structure is filled and is valid + --- for the duration of frame, and it can be reused for multiple draw + --- calls. + .layout "const VertexLayout &" --- Vertex layout. + .numVertices "uint32_t" --- Number of vertices to allocate. + .tib "TransientIndexBuffer*" { out } --- TransientIndexBuffer structure is filled and is valid + --- for the duration of frame, and it can be reused for multiple draw + --- calls. + .numIndices "uint32_t" --- Number of indices to allocate. --- Allocate instance data buffer. func.allocInstanceDataBuffer @@ -2207,11 +2207,11 @@ func.Encoder.setVertexBuffer { cpponly } --- Set vertex buffer for draw primitive. func.Encoder.setVertexBuffer "void" - .stream "uint8_t" --- Vertex stream. - .handle "VertexBufferHandle" --- Vertex buffer. - .startVertex "uint32_t" --- First vertex to render. - .numVertices "uint32_t" --- Number of vertices to render. - .declHandle "VertexLayoutHandle" --- VertexLayout handle for aliasing vertex buffer. + .stream "uint8_t" --- Vertex stream. + .handle "VertexBufferHandle" --- Vertex buffer. + .startVertex "uint32_t" --- First vertex to render. + .numVertices "uint32_t" --- Number of vertices to render. + .layoutHandle "VertexLayoutHandle" --- VertexLayout handle for aliasing vertex buffer. { default = "BGFX_INVALID_HANDLE" } --- Set vertex buffer for draw primitive. @@ -2223,11 +2223,11 @@ func.Encoder.setVertexBuffer { cpponly } --- Set vertex buffer for draw primitive. func.Encoder.setVertexBuffer { cname = "set_dynamic_vertex_buffer" } "void" - .stream "uint8_t" --- Vertex stream. - .handle "DynamicVertexBufferHandle" --- Dynamic vertex buffer. - .startVertex "uint32_t" --- First vertex to render. - .numVertices "uint32_t" --- Number of vertices to render. - .declHandle "VertexLayoutHandle" --- VertexLayout handle for aliasing vertex buffer. + .stream "uint8_t" --- Vertex stream. + .handle "DynamicVertexBufferHandle" --- Dynamic vertex buffer. + .startVertex "uint32_t" --- First vertex to render. + .numVertices "uint32_t" --- Number of vertices to render. + .layoutHandle "VertexLayoutHandle" --- VertexLayout handle for aliasing vertex buffer. { default = "BGFX_INVALID_HANDLE" } --- Set vertex buffer for draw primitive. @@ -2239,11 +2239,11 @@ func.Encoder.setVertexBuffer { cpponly } --- Set vertex buffer for draw primitive. func.Encoder.setVertexBuffer { cname = "set_transient_vertex_buffer" } "void" - .stream "uint8_t" --- Vertex stream. - .tvb "const TransientVertexBuffer*" --- Transient vertex buffer. - .startVertex "uint32_t" --- First vertex to render. - .numVertices "uint32_t" --- Number of vertices to render. - .declHandle "VertexLayoutHandle" --- VertexLayout handle for aliasing vertex buffer. + .stream "uint8_t" --- Vertex stream. + .tvb "const TransientVertexBuffer*" --- Transient vertex buffer. + .startVertex "uint32_t" --- First vertex to render. + .numVertices "uint32_t" --- Number of vertices to render. + .layoutHandle "VertexLayoutHandle" --- VertexLayout handle for aliasing vertex buffer. { default = "BGFX_INVALID_HANDLE" } --- Set number of vertices for auto generated vertices use in conjuction diff --git a/scripts/bgfx.natvis b/scripts/bgfx.natvis index b1cb554f4..2201f415a 100644 --- a/scripts/bgfx.natvis +++ b/scripts/bgfx.natvis @@ -111,7 +111,7 @@ {{ idx={idx} }} this,! - bgfx::s_ctx->m_declRef[idx] + bgfx::s_ctx->m_vertexLayoutRef[idx] diff --git a/src/bgfx.cpp b/src/bgfx.cpp index c8973795a..e546e0c28 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -511,25 +511,25 @@ namespace bgfx return handle; } - void dump(const VertexLayout& _decl) + void dump(const VertexLayout& _layout) { if (BX_ENABLED(BGFX_CONFIG_DEBUG) ) { BX_TRACE("vertexlayout %08x (%08x), stride %d" - , _decl.m_hash - , bx::hash(_decl.m_attributes) - , _decl.m_stride + , _layout.m_hash + , bx::hash(_layout.m_attributes) + , _layout.m_stride ); for (uint32_t attr = 0; attr < Attrib::Count; ++attr) { - if (UINT16_MAX != _decl.m_attributes[attr]) + if (UINT16_MAX != _layout.m_attributes[attr]) { uint8_t num; AttribType::Enum type; bool normalized; bool asInt; - _decl.decode(Attrib::Enum(attr), num, type, normalized, asInt); + _layout.decode(Attrib::Enum(attr), num, type, normalized, asInt); BX_TRACE("\tattr %d - %s, num %d, type %d, norm %d, asint %d, offset %d" , attr @@ -538,7 +538,7 @@ namespace bgfx , type , normalized , asInt - , _decl.m_offset[attr] + , _layout.m_offset[attr] ); } } @@ -648,7 +648,7 @@ namespace bgfx void TextVideoMemBlitter::init() { BGFX_CHECK_API_THREAD(); - m_decl + m_layout .begin() .add(Attrib::Position, 3, AttribType::Float) .add(Attrib::Color0, 4, AttribType::Uint8, true) @@ -681,7 +681,7 @@ namespace bgfx m_program = createProgram(vsh, fsh, true); - m_vb = s_ctx->createTransientVertexBuffer(numBatchVertices*m_decl.m_stride, &m_decl); + m_vb = s_ctx->createTransientVertexBuffer(numBatchVertices*m_layout.m_stride, &m_layout); m_ib = s_ctx->createTransientIndexBuffer(numBatchIndices*2); } @@ -816,7 +816,7 @@ namespace bgfx if (RendererType::Noop != g_caps.rendererType) { - m_decl + m_layout .begin() .add(Attrib::Position, 2, AttribType::Float) .end(); @@ -842,7 +842,7 @@ namespace bgfx float m_y; }; - const uint16_t stride = m_decl.m_stride; + const uint16_t stride = m_layout.m_stride; const bgfx::Memory* mem = bgfx::alloc(4 * stride); Vertex* vertex = (Vertex*)mem->data; BX_CHECK(stride == sizeof(Vertex), "Stride/Vertex mismatch (stride %d, sizeof(Vertex) %d)", stride, sizeof(Vertex)); @@ -859,7 +859,7 @@ namespace bgfx vertex->m_x = 1.0f; vertex->m_y = 1.0f; - m_vb = s_ctx->createVertexBuffer(mem, m_decl, 0); + m_vb = s_ctx->createVertexBuffer(mem, m_layout, 0); } } @@ -1818,7 +1818,7 @@ namespace bgfx m_clearColor[ii][3] = 1.0f; } - m_declRef.init(); + m_vertexLayoutRef.init(); CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::RendererInit); cmdbuf.write(_init); @@ -1847,7 +1847,7 @@ namespace bgfx getCommandBuffer(CommandBuffer::RendererShutdownEnd); frame(); frame(); - m_declRef.shutdown(m_vertexDeclHandle); + m_vertexLayoutRef.shutdown(m_layoutHandle); m_submit->destroy(); #if BGFX_CONFIG_MULTITHREADED m_render->destroy(); @@ -1938,13 +1938,13 @@ namespace bgfx m_dynVertexBufferAllocator.compact(); m_dynIndexBufferAllocator.compact(); - BX_CHECK(m_vertexDeclHandle.getNumHandles() == m_declRef.m_vertexDeclMap.getNumElements() + BX_CHECK(m_layoutHandle.getNumHandles() == m_vertexLayoutRef.m_layoutMap.getNumElements() , "VertexLayoutRef mismatch, num handles %d, handles in hash map %d." - , m_vertexDeclHandle.getNumHandles() - , m_declRef.m_vertexDeclMap.getNumElements() + , m_layoutHandle.getNumHandles() + , m_vertexLayoutRef.m_layoutMap.getNumElements() ); - m_declRef.shutdown(m_vertexDeclHandle); + m_vertexLayoutRef.shutdown(m_layoutHandle); #if BGFX_CONFIG_MULTITHREADED // Render thread shutdown sequence. @@ -2032,7 +2032,7 @@ namespace bgfx CHECK_HANDLE_LEAK ("DynamicIndexBufferHandle", m_dynamicIndexBufferHandle ); CHECK_HANDLE_LEAK ("DynamicVertexBufferHandle", m_dynamicVertexBufferHandle ); CHECK_HANDLE_LEAK_NAME ("IndexBufferHandle", m_indexBufferHandle, IndexBuffer, m_indexBuffers ); - CHECK_HANDLE_LEAK ("VertexLayoutHandle", m_vertexDeclHandle ); + CHECK_HANDLE_LEAK ("VertexLayoutHandle", m_layoutHandle ); CHECK_HANDLE_LEAK_NAME ("VertexBufferHandle", m_vertexBufferHandle, VertexBuffer, m_vertexBuffers ); CHECK_HANDLE_LEAK_RC_NAME("ShaderHandle", m_shaderHandle, ShaderRef, m_shaderRef ); CHECK_HANDLE_LEAK ("ProgramHandle", m_programHandle ); @@ -2078,9 +2078,9 @@ namespace bgfx destroyVertexBufferInternal(_frame->m_freeVertexBuffer.get(ii)); } - for (uint16_t ii = 0, num = _frame->m_freeVertexDecl.getNumQueued(); ii < num; ++ii) + for (uint16_t ii = 0, num = _frame->m_freeVertexLayout.getNumQueued(); ii < num; ++ii) { - m_vertexDeclHandle.free(_frame->m_freeVertexDecl.get(ii).idx); + m_layoutHandle.free(_frame->m_freeVertexLayout.get(ii).idx); } for (uint16_t ii = 0, num = _frame->m_freeShader.getNumQueued(); ii < num; ++ii) @@ -2727,10 +2727,10 @@ namespace bgfx VertexLayoutHandle handle; _cmdbuf.read(handle); - VertexLayout decl; - _cmdbuf.read(decl); + VertexLayout layout; + _cmdbuf.read(layout); - m_renderCtx->createVertexLayout(handle, decl); + m_renderCtx->createVertexLayout(handle, layout); } break; @@ -2755,13 +2755,13 @@ namespace bgfx const Memory* mem; _cmdbuf.read(mem); - VertexLayoutHandle declHandle; - _cmdbuf.read(declHandle); + VertexLayoutHandle layoutHandle; + _cmdbuf.read(layoutHandle); uint16_t flags; _cmdbuf.read(flags); - m_renderCtx->createVertexBuffer(handle, mem, declHandle, flags); + m_renderCtx->createVertexBuffer(handle, mem, layoutHandle, flags); release(mem); } @@ -3375,7 +3375,7 @@ namespace bgfx g_caps.limits.maxTextures = BGFX_CONFIG_MAX_TEXTURES; g_caps.limits.maxTextureSamplers = BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; g_caps.limits.maxComputeBindings = 0; - g_caps.limits.maxVertexLayouts = BGFX_CONFIG_MAX_VERTEX_DECLS; + g_caps.limits.maxVertexLayouts = BGFX_CONFIG_MAX_VERTEX_LAYOUTS; g_caps.limits.maxVertexStreams = 1; g_caps.limits.maxIndexBuffers = BGFX_CONFIG_MAX_INDEX_BUFFERS; g_caps.limits.maxVertexBuffers = BGFX_CONFIG_MAX_VERTEX_BUFFERS; @@ -3581,12 +3581,12 @@ namespace bgfx , VertexBufferHandle _handle , uint32_t _startVertex , uint32_t _numVertices - , VertexLayoutHandle _declHandle + , VertexLayoutHandle _layoutHandle ) { BGFX_CHECK_HANDLE("setVertexBuffer", s_ctx->m_vertexBufferHandle, _handle); - BGFX_CHECK_HANDLE_INVALID_OK("setVertexBuffer", s_ctx->m_vertexDeclHandle, _declHandle); - BGFX_ENCODER(setVertexBuffer(_stream, _handle, _startVertex, _numVertices, _declHandle) ); + BGFX_CHECK_HANDLE_INVALID_OK("setVertexBuffer", s_ctx->m_layoutHandle, _layoutHandle); + BGFX_ENCODER(setVertexBuffer(_stream, _handle, _startVertex, _numVertices, _layoutHandle) ); } void Encoder::setVertexBuffer(uint8_t _stream, VertexBufferHandle _handle) @@ -3599,13 +3599,13 @@ namespace bgfx , DynamicVertexBufferHandle _handle , uint32_t _startVertex , uint32_t _numVertices - , VertexLayoutHandle _declHandle + , VertexLayoutHandle _layoutHandle ) { BGFX_CHECK_HANDLE("setVertexBuffer", s_ctx->m_dynamicVertexBufferHandle, _handle); - BGFX_CHECK_HANDLE_INVALID_OK("setVertexBuffer", s_ctx->m_vertexDeclHandle, _declHandle); + BGFX_CHECK_HANDLE_INVALID_OK("setVertexBuffer", s_ctx->m_layoutHandle, _layoutHandle); const DynamicVertexBuffer& dvb = s_ctx->m_dynamicVertexBuffers[_handle.idx]; - BGFX_ENCODER(setVertexBuffer(_stream, dvb, _startVertex, _numVertices, _declHandle) ); + BGFX_ENCODER(setVertexBuffer(_stream, dvb, _startVertex, _numVertices, _layoutHandle) ); } void Encoder::setVertexBuffer(uint8_t _stream, DynamicVertexBufferHandle _handle) @@ -3618,13 +3618,13 @@ namespace bgfx , const TransientVertexBuffer* _tvb , uint32_t _startVertex , uint32_t _numVertices - , VertexLayoutHandle _declHandle + , VertexLayoutHandle _layoutHandle ) { BX_CHECK(NULL != _tvb, "_tvb can't be NULL"); BGFX_CHECK_HANDLE("setVertexBuffer", s_ctx->m_vertexBufferHandle, _tvb->handle); - BGFX_CHECK_HANDLE_INVALID_OK("setVertexBuffer", s_ctx->m_vertexDeclHandle, _declHandle); - BGFX_ENCODER(setVertexBuffer(_stream, _tvb, _startVertex, _numVertices, _declHandle) ); + BGFX_CHECK_HANDLE_INVALID_OK("setVertexBuffer", s_ctx->m_layoutHandle, _layoutHandle); + BGFX_ENCODER(setVertexBuffer(_stream, _tvb, _startVertex, _numVertices, _layoutHandle) ); } void Encoder::setVertexBuffer(uint8_t _stream, const TransientVertexBuffer* _tvb) @@ -3937,9 +3937,9 @@ namespace bgfx s_ctx->destroyIndexBuffer(_handle); } - VertexLayoutHandle createVertexLayout(const VertexLayout& _decl) + VertexLayoutHandle createVertexLayout(const VertexLayout& _layout) { - return s_ctx->createVertexLayout(_decl); + return s_ctx->createVertexLayout(_layout); } void destroy(VertexLayoutHandle _handle) @@ -3947,11 +3947,11 @@ namespace bgfx s_ctx->destroyVertexLayout(_handle); } - VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexLayout& _decl, uint16_t _flags) + VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexLayout& _layout, uint16_t _flags) { BX_CHECK(NULL != _mem, "_mem can't be NULL"); - BX_CHECK(isValid(_decl), "Invalid VertexLayout."); - return s_ctx->createVertexBuffer(_mem, _decl, _flags); + BX_CHECK(isValid(_layout), "Invalid VertexLayout."); + return s_ctx->createVertexBuffer(_mem, _layout, _flags); } void setName(VertexBufferHandle _handle, const char* _name, int32_t _len) @@ -3986,17 +3986,17 @@ namespace bgfx s_ctx->destroyDynamicIndexBuffer(_handle); } - DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexLayout& _decl, uint16_t _flags) + DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexLayout& _layout, uint16_t _flags) { - BX_CHECK(isValid(_decl), "Invalid VertexLayout."); - return s_ctx->createDynamicVertexBuffer(_num, _decl, _flags); + BX_CHECK(isValid(_layout), "Invalid VertexLayout."); + return s_ctx->createDynamicVertexBuffer(_num, _layout, _flags); } - DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexLayout& _decl, uint16_t _flags) + DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexLayout& _layout, uint16_t _flags) { BX_CHECK(NULL != _mem, "_mem can't be NULL"); - BX_CHECK(isValid(_decl), "Invalid VertexLayout."); - return s_ctx->createDynamicVertexBuffer(_mem, _decl, _flags); + BX_CHECK(isValid(_layout), "Invalid VertexLayout."); + return s_ctx->createDynamicVertexBuffer(_mem, _layout, _flags); } void update(DynamicVertexBufferHandle _handle, uint32_t _startVertex, const Memory* _mem) @@ -4016,11 +4016,11 @@ namespace bgfx return s_ctx->getAvailTransientIndexBuffer(_num); } - uint32_t getAvailTransientVertexBuffer(uint32_t _num, const VertexLayout& _decl) + uint32_t getAvailTransientVertexBuffer(uint32_t _num, const VertexLayout& _layout) { BX_CHECK(0 < _num, "Requesting 0 vertices."); - BX_CHECK(isValid(_decl), "Invalid VertexLayout."); - return s_ctx->getAvailTransientVertexBuffer(_num, _decl.m_stride); + BX_CHECK(isValid(_layout), "Invalid VertexLayout."); + return s_ctx->getAvailTransientVertexBuffer(_num, _layout.m_stride); } uint32_t getAvailInstanceDataBuffer(uint32_t _num, uint16_t _stride) @@ -4042,28 +4042,28 @@ namespace bgfx ); } - void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint32_t _num, const VertexLayout& _decl) + void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint32_t _num, const VertexLayout& _layout) { BX_CHECK(NULL != _tvb, "_tvb can't be NULL"); BX_CHECK(0 < _num, "Requesting 0 vertices."); - BX_CHECK(isValid(_decl), "Invalid VertexLayout."); - s_ctx->allocTransientVertexBuffer(_tvb, _num, _decl); - BX_CHECK(_num == _tvb->size / _decl.m_stride + BX_CHECK(isValid(_layout), "Invalid VertexLayout."); + s_ctx->allocTransientVertexBuffer(_tvb, _num, _layout); + BX_CHECK(_num == _tvb->size / _layout.m_stride , "Failed to allocate transient vertex buffer (requested %d, available %d). " "Use bgfx::getAvailTransient* functions to ensure availability." , _num - , _tvb->size / _decl.m_stride + , _tvb->size / _layout.m_stride ); } - bool allocTransientBuffers(bgfx::TransientVertexBuffer* _tvb, const bgfx::VertexLayout& _decl, uint32_t _numVertices, bgfx::TransientIndexBuffer* _tib, uint32_t _numIndices) + bool allocTransientBuffers(bgfx::TransientVertexBuffer* _tvb, const bgfx::VertexLayout& _layout, uint32_t _numVertices, bgfx::TransientIndexBuffer* _tib, uint32_t _numIndices) { BGFX_MUTEX_SCOPE(s_ctx->m_resourceApiLock); - if (_numVertices == getAvailTransientVertexBuffer(_numVertices, _decl) + if (_numVertices == getAvailTransientVertexBuffer(_numVertices, _layout) && _numIndices == getAvailTransientIndexBuffer(_numIndices) ) { - allocTransientVertexBuffer(_tvb, _numVertices, _decl); + allocTransientVertexBuffer(_tvb, _numVertices, _layout); allocTransientIndexBuffer(_tib, _numIndices); return true; } @@ -4833,11 +4833,11 @@ namespace bgfx , VertexBufferHandle _handle , uint32_t _startVertex , uint32_t _numVertices - , VertexLayoutHandle _declHandle + , VertexLayoutHandle _layoutHandle ) { BGFX_CHECK_API_THREAD(); - s_ctx->m_encoder0->setVertexBuffer(_stream, _handle, _startVertex, _numVertices, _declHandle); + s_ctx->m_encoder0->setVertexBuffer(_stream, _handle, _startVertex, _numVertices, _layoutHandle); } void setVertexBuffer(uint8_t _stream, VertexBufferHandle _handle) @@ -4850,11 +4850,11 @@ namespace bgfx , DynamicVertexBufferHandle _handle , uint32_t _startVertex , uint32_t _numVertices - , VertexLayoutHandle _declHandle + , VertexLayoutHandle _layoutHandle ) { BGFX_CHECK_API_THREAD(); - s_ctx->m_encoder0->setVertexBuffer(_stream, _handle, _startVertex, _numVertices, _declHandle); + s_ctx->m_encoder0->setVertexBuffer(_stream, _handle, _startVertex, _numVertices, _layoutHandle); } void setVertexBuffer(uint8_t _stream, DynamicVertexBufferHandle _handle) @@ -4867,11 +4867,11 @@ namespace bgfx , const TransientVertexBuffer* _tvb , uint32_t _startVertex , uint32_t _numVertices - , VertexLayoutHandle _declHandle + , VertexLayoutHandle _layoutHandle ) { BGFX_CHECK_API_THREAD(); - s_ctx->m_encoder0->setVertexBuffer(_stream, _tvb, _startVertex, _numVertices, _declHandle); + s_ctx->m_encoder0->setVertexBuffer(_stream, _tvb, _startVertex, _numVertices, _layoutHandle); } void setVertexBuffer(uint8_t _stream, const TransientVertexBuffer* _tvb) diff --git a/src/bgfx.idl.inl b/src/bgfx.idl.inl index 6956cda1c..03acfae93 100644 --- a/src/bgfx.idl.inl +++ b/src/bgfx.idl.inl @@ -91,29 +91,29 @@ BGFX_C_API void bgfx_vertex_layout_end(bgfx_vertex_layout_t* _this) This->end(); } -BGFX_C_API void bgfx_vertex_pack(const float _input[4], bool _inputNormalized, bgfx_attrib_t _attr, const bgfx_vertex_layout_t * _decl, void* _data, uint32_t _index) +BGFX_C_API void bgfx_vertex_pack(const float _input[4], bool _inputNormalized, bgfx_attrib_t _attr, const bgfx_vertex_layout_t * _layout, void* _data, uint32_t _index) { - const bgfx::VertexLayout & decl = *(const bgfx::VertexLayout *)_decl; - bgfx::vertexPack(_input, _inputNormalized, (bgfx::Attrib::Enum)_attr, decl, _data, _index); + const bgfx::VertexLayout & layout = *(const bgfx::VertexLayout *)_layout; + bgfx::vertexPack(_input, _inputNormalized, (bgfx::Attrib::Enum)_attr, layout, _data, _index); } -BGFX_C_API void bgfx_vertex_unpack(float _output[4], bgfx_attrib_t _attr, const bgfx_vertex_layout_t * _decl, const void* _data, uint32_t _index) +BGFX_C_API void bgfx_vertex_unpack(float _output[4], bgfx_attrib_t _attr, const bgfx_vertex_layout_t * _layout, const void* _data, uint32_t _index) { - const bgfx::VertexLayout & decl = *(const bgfx::VertexLayout *)_decl; - bgfx::vertexUnpack(_output, (bgfx::Attrib::Enum)_attr, decl, _data, _index); + const bgfx::VertexLayout & layout = *(const bgfx::VertexLayout *)_layout; + bgfx::vertexUnpack(_output, (bgfx::Attrib::Enum)_attr, layout, _data, _index); } -BGFX_C_API void bgfx_vertex_convert(const bgfx_vertex_layout_t * _dstDecl, void* _dstData, const bgfx_vertex_layout_t * _srcDecl, const void* _srcData, uint32_t _num) +BGFX_C_API void bgfx_vertex_convert(const bgfx_vertex_layout_t * _dstLayout, void* _dstData, const bgfx_vertex_layout_t * _srcLayout, const void* _srcData, uint32_t _num) { - const bgfx::VertexLayout & dstDecl = *(const bgfx::VertexLayout *)_dstDecl; - const bgfx::VertexLayout & srcDecl = *(const bgfx::VertexLayout *)_srcDecl; - bgfx::vertexConvert(dstDecl, _dstData, srcDecl, _srcData, _num); + const bgfx::VertexLayout & dstLayout = *(const bgfx::VertexLayout *)_dstLayout; + const bgfx::VertexLayout & srcLayout = *(const bgfx::VertexLayout *)_srcLayout; + bgfx::vertexConvert(dstLayout, _dstData, srcLayout, _srcData, _num); } -BGFX_C_API uint16_t bgfx_weld_vertices(uint16_t* _output, const bgfx_vertex_layout_t * _decl, const void* _data, uint16_t _num, float _epsilon) +BGFX_C_API uint16_t bgfx_weld_vertices(uint16_t* _output, const bgfx_vertex_layout_t * _layout, const void* _data, uint16_t _num, float _epsilon) { - const bgfx::VertexLayout & decl = *(const bgfx::VertexLayout *)_decl; - return bgfx::weldVertices(_output, decl, _data, _num, _epsilon); + const bgfx::VertexLayout & layout = *(const bgfx::VertexLayout *)_layout; + return bgfx::weldVertices(_output, layout, _data, _num, _epsilon); } BGFX_C_API uint32_t bgfx_topology_convert(bgfx_topology_convert_t _conversion, void* _dst, uint32_t _dstSize, const void* _indices, uint32_t _numIndices, bool _index32) @@ -237,25 +237,25 @@ BGFX_C_API void bgfx_destroy_index_buffer(bgfx_index_buffer_handle_t _handle) bgfx::destroy(handle.cpp); } -BGFX_C_API bgfx_vertex_layout_handle_t bgfx_create_vertex_layout(const bgfx_vertex_layout_t * _decl) +BGFX_C_API bgfx_vertex_layout_handle_t bgfx_create_vertex_layout(const bgfx_vertex_layout_t * _layout) { - const bgfx::VertexLayout & decl = *(const bgfx::VertexLayout *)_decl; + const bgfx::VertexLayout & layout = *(const bgfx::VertexLayout *)_layout; union { bgfx_vertex_layout_handle_t c; bgfx::VertexLayoutHandle cpp; } handle_ret; - handle_ret.cpp = bgfx::createVertexLayout(decl); + handle_ret.cpp = bgfx::createVertexLayout(layout); return handle_ret.c; } -BGFX_C_API void bgfx_destroy_vertex_decl(bgfx_vertex_layout_handle_t _handle) +BGFX_C_API void bgfx_destroy_vertex_layout(bgfx_vertex_layout_handle_t _layoutHandle) { - union { bgfx_vertex_layout_handle_t c; bgfx::VertexLayoutHandle cpp; } handle = { _handle }; - bgfx::destroy(handle.cpp); + union { bgfx_vertex_layout_handle_t c; bgfx::VertexLayoutHandle cpp; } layoutHandle = { _layoutHandle }; + bgfx::destroy(layoutHandle.cpp); } -BGFX_C_API bgfx_vertex_buffer_handle_t bgfx_create_vertex_buffer(const bgfx_memory_t* _mem, const bgfx_vertex_layout_t * _decl, uint16_t _flags) +BGFX_C_API bgfx_vertex_buffer_handle_t bgfx_create_vertex_buffer(const bgfx_memory_t* _mem, const bgfx_vertex_layout_t * _layout, uint16_t _flags) { - const bgfx::VertexLayout & decl = *(const bgfx::VertexLayout *)_decl; + const bgfx::VertexLayout & layout = *(const bgfx::VertexLayout *)_layout; union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle_ret; - handle_ret.cpp = bgfx::createVertexBuffer((const bgfx::Memory*)_mem, decl, _flags); + handle_ret.cpp = bgfx::createVertexBuffer((const bgfx::Memory*)_mem, layout, _flags); return handle_ret.c; } @@ -297,19 +297,19 @@ BGFX_C_API void bgfx_destroy_dynamic_index_buffer(bgfx_dynamic_index_buffer_hand bgfx::destroy(handle.cpp); } -BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer(uint32_t _num, const bgfx_vertex_layout_t* _decl, uint16_t _flags) +BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer(uint32_t _num, const bgfx_vertex_layout_t* _layout, uint16_t _flags) { - const bgfx::VertexLayout& decl = *(const bgfx::VertexLayout*)_decl; + const bgfx::VertexLayout& layout = *(const bgfx::VertexLayout*)_layout; union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle_ret; - handle_ret.cpp = bgfx::createDynamicVertexBuffer(_num, decl, _flags); + handle_ret.cpp = bgfx::createDynamicVertexBuffer(_num, layout, _flags); return handle_ret.c; } -BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer_mem(const bgfx_memory_t* _mem, const bgfx_vertex_layout_t* _decl, uint16_t _flags) +BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer_mem(const bgfx_memory_t* _mem, const bgfx_vertex_layout_t* _layout, uint16_t _flags) { - const bgfx::VertexLayout& decl = *(const bgfx::VertexLayout*)_decl; + const bgfx::VertexLayout& layout = *(const bgfx::VertexLayout*)_layout; union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle_ret; - handle_ret.cpp = bgfx::createDynamicVertexBuffer((const bgfx::Memory*)_mem, decl, _flags); + handle_ret.cpp = bgfx::createDynamicVertexBuffer((const bgfx::Memory*)_mem, layout, _flags); return handle_ret.c; } @@ -330,10 +330,10 @@ BGFX_C_API uint32_t bgfx_get_avail_transient_index_buffer(uint32_t _num) return bgfx::getAvailTransientIndexBuffer(_num); } -BGFX_C_API uint32_t bgfx_get_avail_transient_vertex_buffer(uint32_t _num, const bgfx_vertex_layout_t * _decl) +BGFX_C_API uint32_t bgfx_get_avail_transient_vertex_buffer(uint32_t _num, const bgfx_vertex_layout_t * _layout) { - const bgfx::VertexLayout & decl = *(const bgfx::VertexLayout *)_decl; - return bgfx::getAvailTransientVertexBuffer(_num, decl); + const bgfx::VertexLayout & layout = *(const bgfx::VertexLayout *)_layout; + return bgfx::getAvailTransientVertexBuffer(_num, layout); } BGFX_C_API uint32_t bgfx_get_avail_instance_data_buffer(uint32_t _num, uint16_t _stride) @@ -346,16 +346,16 @@ BGFX_C_API void bgfx_alloc_transient_index_buffer(bgfx_transient_index_buffer_t* bgfx::allocTransientIndexBuffer((bgfx::TransientIndexBuffer*)_tib, _num); } -BGFX_C_API void bgfx_alloc_transient_vertex_buffer(bgfx_transient_vertex_buffer_t* _tvb, uint32_t _num, const bgfx_vertex_layout_t * _decl) +BGFX_C_API void bgfx_alloc_transient_vertex_buffer(bgfx_transient_vertex_buffer_t* _tvb, uint32_t _num, const bgfx_vertex_layout_t * _layout) { - const bgfx::VertexLayout & decl = *(const bgfx::VertexLayout *)_decl; - bgfx::allocTransientVertexBuffer((bgfx::TransientVertexBuffer*)_tvb, _num, decl); + const bgfx::VertexLayout & layout = *(const bgfx::VertexLayout *)_layout; + bgfx::allocTransientVertexBuffer((bgfx::TransientVertexBuffer*)_tvb, _num, layout); } -BGFX_C_API bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_layout_t * _decl, uint32_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint32_t _numIndices) +BGFX_C_API bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_layout_t * _layout, uint32_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint32_t _numIndices) { - const bgfx::VertexLayout & decl = *(const bgfx::VertexLayout *)_decl; - return bgfx::allocTransientBuffers((bgfx::TransientVertexBuffer*)_tvb, decl, _numVertices, (bgfx::TransientIndexBuffer*)_tib, _numIndices); + const bgfx::VertexLayout & layout = *(const bgfx::VertexLayout *)_layout; + return bgfx::allocTransientBuffers((bgfx::TransientVertexBuffer*)_tvb, layout, _numVertices, (bgfx::TransientIndexBuffer*)_tib, _numIndices); } BGFX_C_API void bgfx_alloc_instance_data_buffer(bgfx_instance_data_buffer_t* _idb, uint32_t _num, uint16_t _stride) @@ -759,27 +759,27 @@ BGFX_C_API void bgfx_encoder_set_transient_index_buffer(bgfx_encoder_t* _this, c This->setIndexBuffer((const bgfx::TransientIndexBuffer*)_tib, _firstIndex, _numIndices); } -BGFX_C_API void bgfx_encoder_set_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _declHandle) +BGFX_C_API void bgfx_encoder_set_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _layoutHandle) { bgfx::Encoder* This = (bgfx::Encoder*)_this; union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle = { _handle }; - union { bgfx_vertex_layout_handle_t c; bgfx::VertexLayoutHandle cpp; } declHandle = { _declHandle }; - This->setVertexBuffer(_stream, handle.cpp, _startVertex, _numVertices, declHandle.cpp); + union { bgfx_vertex_layout_handle_t c; bgfx::VertexLayoutHandle cpp; } layoutHandle = { _layoutHandle }; + This->setVertexBuffer(_stream, handle.cpp, _startVertex, _numVertices, layoutHandle.cpp); } -BGFX_C_API void bgfx_encoder_set_dynamic_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _declHandle) +BGFX_C_API void bgfx_encoder_set_dynamic_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _layoutHandle) { bgfx::Encoder* This = (bgfx::Encoder*)_this; union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle }; - union { bgfx_vertex_layout_handle_t c; bgfx::VertexLayoutHandle cpp; } declHandle = { _declHandle }; - This->setVertexBuffer(_stream, handle.cpp, _startVertex, _numVertices, declHandle.cpp); + union { bgfx_vertex_layout_handle_t c; bgfx::VertexLayoutHandle cpp; } layoutHandle = { _layoutHandle }; + This->setVertexBuffer(_stream, handle.cpp, _startVertex, _numVertices, layoutHandle.cpp); } -BGFX_C_API void bgfx_encoder_set_transient_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _declHandle) +BGFX_C_API void bgfx_encoder_set_transient_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _layoutHandle) { bgfx::Encoder* This = (bgfx::Encoder*)_this; - union { bgfx_vertex_layout_handle_t c; bgfx::VertexLayoutHandle cpp; } declHandle = { _declHandle }; - This->setVertexBuffer(_stream, (const bgfx::TransientVertexBuffer*)_tvb, _startVertex, _numVertices, declHandle.cpp); + union { bgfx_vertex_layout_handle_t c; bgfx::VertexLayoutHandle cpp; } layoutHandle = { _layoutHandle }; + This->setVertexBuffer(_stream, (const bgfx::TransientVertexBuffer*)_tvb, _startVertex, _numVertices, layoutHandle.cpp); } BGFX_C_API void bgfx_encoder_set_vertex_count(bgfx_encoder_t* _this, uint32_t _numVertices) @@ -1238,7 +1238,7 @@ BGFX_C_API bgfx_interface_vtbl_t* bgfx_get_interface(uint32_t _version) bgfx_set_index_buffer_name, bgfx_destroy_index_buffer, bgfx_create_vertex_layout, - bgfx_destroy_vertex_decl, + bgfx_destroy_vertex_layout, bgfx_create_vertex_buffer, bgfx_set_vertex_buffer_name, bgfx_destroy_vertex_buffer, diff --git a/src/bgfx_p.h b/src/bgfx_p.h index cc09e1181..26bbc55b9 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -313,9 +313,9 @@ namespace bgfx const char* getTypeName(Handle _handle); - inline bool isValid(const VertexLayout& _decl) + inline bool isValid(const VertexLayout& _layout) { - return 0 != _decl.m_stride; + return 0 != _layout.m_stride; } struct Condition @@ -542,8 +542,8 @@ namespace bgfx return 1; } - /// Dump vertex declaration into debug output. - void dump(const VertexLayout& _decl); + /// Dump vertex layout into debug output. + void dump(const VertexLayout& _layout); struct TextVideoMem { @@ -657,7 +657,7 @@ namespace bgfx TextureHandle m_texture; TransientVertexBuffer* m_vb; TransientIndexBuffer* m_ib; - VertexLayout m_decl; + VertexLayout m_layout; ProgramHandle m_program; }; @@ -727,7 +727,7 @@ namespace bgfx void shutdown(); VertexBufferHandle m_vb; - VertexLayout m_decl; + VertexLayout m_layout; ProgramHandle m_program[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS]; }; @@ -1531,14 +1531,14 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA { void clear() { - m_startVertex = 0; - m_handle.idx = kInvalidHandle; - m_decl.idx = kInvalidHandle; + m_startVertex = 0; + m_handle.idx = kInvalidHandle; + m_layoutHandle.idx = kInvalidHandle; } uint32_t m_startVertex; VertexBufferHandle m_handle; - VertexLayoutHandle m_decl; + VertexLayoutHandle m_layoutHandle; }; BX_ALIGN_DECL_CACHE_LINE(struct) RenderBind @@ -1710,7 +1710,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA uint32_t m_startVertex; uint32_t m_numVertices; uint16_t m_stride; - VertexLayoutHandle m_decl; + VertexLayoutHandle m_layoutHandle; uint16_t m_flags; }; @@ -2026,7 +2026,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA bool free(VertexLayoutHandle _handle) { - return m_freeVertexDecl.queue(_handle); + return m_freeVertexLayout.queue(_handle); } bool free(VertexBufferHandle _handle) @@ -2062,7 +2062,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA void resetFreeHandles() { m_freeIndexBuffer.reset(); - m_freeVertexDecl.reset(); + m_freeVertexLayout.reset(); m_freeVertexBuffer.reset(); m_freeShader.reset(); m_freeProgram.reset(); @@ -2160,7 +2160,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA }; FreeHandle m_freeIndexBuffer; - FreeHandle m_freeVertexDecl; + FreeHandle m_freeVertexLayout; FreeHandle m_freeVertexBuffer; FreeHandle m_freeShader; FreeHandle m_freeProgram; @@ -2339,7 +2339,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA , VertexBufferHandle _handle , uint32_t _startVertex , uint32_t _numVertices - , VertexLayoutHandle _declHandle + , VertexLayoutHandle _layoutHandle ) { BX_CHECK(UINT8_MAX != m_draw.m_streamMask, ""); @@ -2349,7 +2349,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA Stream& stream = m_draw.m_stream[_stream]; stream.m_startVertex = _startVertex; stream.m_handle = _handle; - stream.m_decl = _declHandle; + stream.m_layoutHandle = _layoutHandle; m_numVertices[_stream] = _numVertices; } } @@ -2359,7 +2359,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA , const DynamicVertexBuffer& _dvb , uint32_t _startVertex , uint32_t _numVertices - , VertexLayoutHandle _declHandle + , VertexLayoutHandle _layoutHandle ) { BX_CHECK(UINT8_MAX != m_draw.m_streamMask, ""); @@ -2369,7 +2369,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA Stream& stream = m_draw.m_stream[_stream]; stream.m_startVertex = _dvb.m_startVertex + _startVertex; stream.m_handle = _dvb.m_handle; - stream.m_decl = isValid(_declHandle) ? _declHandle : _dvb.m_decl; + stream.m_layoutHandle = isValid(_layoutHandle) ? _layoutHandle : _dvb.m_layoutHandle; m_numVertices[_stream] = bx::min(bx::uint32_imax(0, _dvb.m_numVertices - _startVertex), _numVertices) ; @@ -2381,7 +2381,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA , const TransientVertexBuffer* _tvb , uint32_t _startVertex , uint32_t _numVertices - , VertexLayoutHandle _declHandle + , VertexLayoutHandle _layoutHandle ) { BX_CHECK(UINT8_MAX != m_draw.m_streamMask, ""); @@ -2391,10 +2391,8 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA Stream& stream = m_draw.m_stream[_stream]; stream.m_startVertex = _tvb->startVertex + _startVertex; stream.m_handle = _tvb->handle; - stream.m_decl = isValid(_declHandle) ? _declHandle : _tvb->decl; - m_numVertices[_stream] = - bx::min(bx::uint32_imax(0, _tvb->size/_tvb->stride - _startVertex), _numVertices) - ; + stream.m_layoutHandle = isValid(_layoutHandle) ? _layoutHandle : _tvb->layoutHandle; + m_numVertices[_stream] = bx::min(bx::uint32_imax(0, _tvb->size/_tvb->stride - _startVertex), _numVertices); } } @@ -2403,10 +2401,10 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA BX_CHECK(0 == m_draw.m_streamMask, "Vertex buffer already set."); m_draw.m_streamMask = UINT8_MAX; Stream& stream = m_draw.m_stream[0]; - stream.m_startVertex = 0; - stream.m_handle.idx = kInvalidHandle; - stream.m_decl.idx = kInvalidHandle; - m_numVertices[0] = _numVertices; + stream.m_startVertex = 0; + stream.m_handle.idx = kInvalidHandle; + stream.m_layoutHandle.idx = kInvalidHandle; + m_numVertices[0] = _numVertices; } void setInstanceDataBuffer(const InstanceDataBuffer* _idb, uint32_t _start, uint32_t _num) @@ -2549,7 +2547,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA void init() { - bx::memSet(m_vertexDeclRef, 0, sizeof(m_vertexDeclRef) ); + bx::memSet(m_layoutRef, 0, sizeof(m_layoutRef) ); bx::memSet(m_vertexBufferRef, 0xff, sizeof(m_vertexBufferRef) ); bx::memSet(m_dynamicVertexBufferRef, 0xff, sizeof(m_dynamicVertexBufferRef) ); } @@ -2560,52 +2558,52 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA for (uint16_t ii = 0, num = _handleAlloc.getNumHandles(); ii < num; ++ii) { VertexLayoutHandle handle = { _handleAlloc.getHandleAt(ii) }; - m_vertexDeclRef[handle.idx] = 0; - m_vertexDeclMap.removeByHandle(handle.idx); + m_layoutRef[handle.idx] = 0; + m_layoutMap.removeByHandle(handle.idx); _handleAlloc.free(handle.idx); } - m_vertexDeclMap.reset(); + m_layoutMap.reset(); } VertexLayoutHandle find(uint32_t _hash) { - VertexLayoutHandle handle = { m_vertexDeclMap.find(_hash) }; + VertexLayoutHandle handle = { m_layoutMap.find(_hash) }; return handle; } - void add(VertexLayoutHandle _declHandle, uint32_t _hash) + void add(VertexLayoutHandle _layoutHandle, uint32_t _hash) { - m_vertexDeclRef[_declHandle.idx]++; - m_vertexDeclMap.insert(_hash, _declHandle.idx); + m_layoutRef[_layoutHandle.idx]++; + m_layoutMap.insert(_hash, _layoutHandle.idx); } - void add(VertexBufferHandle _handle, VertexLayoutHandle _declHandle, uint32_t _hash) + void add(VertexBufferHandle _handle, VertexLayoutHandle _layoutHandle, uint32_t _hash) { BX_CHECK(m_vertexBufferRef[_handle.idx].idx == kInvalidHandle, ""); - m_vertexBufferRef[_handle.idx] = _declHandle; - m_vertexDeclRef[_declHandle.idx]++; - m_vertexDeclMap.insert(_hash, _declHandle.idx); + m_vertexBufferRef[_handle.idx] = _layoutHandle; + m_layoutRef[_layoutHandle.idx]++; + m_layoutMap.insert(_hash, _layoutHandle.idx); } - void add(DynamicVertexBufferHandle _handle, VertexLayoutHandle _declHandle, uint32_t _hash) + void add(DynamicVertexBufferHandle _handle, VertexLayoutHandle _layoutHandle, uint32_t _hash) { BX_CHECK(m_dynamicVertexBufferRef[_handle.idx].idx == kInvalidHandle, ""); - m_dynamicVertexBufferRef[_handle.idx] = _declHandle; - m_vertexDeclRef[_declHandle.idx]++; - m_vertexDeclMap.insert(_hash, _declHandle.idx); + m_dynamicVertexBufferRef[_handle.idx] = _layoutHandle; + m_layoutRef[_layoutHandle.idx]++; + m_layoutMap.insert(_hash, _layoutHandle.idx); } - VertexLayoutHandle release(VertexLayoutHandle _declHandle) + VertexLayoutHandle release(VertexLayoutHandle _layoutHandle) { - if (isValid(_declHandle) ) + if (isValid(_layoutHandle) ) { - m_vertexDeclRef[_declHandle.idx]--; + m_layoutRef[_layoutHandle.idx]--; - if (0 == m_vertexDeclRef[_declHandle.idx]) + if (0 == m_layoutRef[_layoutHandle.idx]) { - m_vertexDeclMap.removeByHandle(_declHandle.idx); - return _declHandle; + m_layoutMap.removeByHandle(_layoutHandle.idx); + return _layoutHandle; } } @@ -2614,26 +2612,26 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA VertexLayoutHandle release(VertexBufferHandle _handle) { - VertexLayoutHandle declHandle = m_vertexBufferRef[_handle.idx]; - declHandle = release(declHandle); + VertexLayoutHandle layoutHandle = m_vertexBufferRef[_handle.idx]; + layoutHandle = release(layoutHandle); m_vertexBufferRef[_handle.idx].idx = kInvalidHandle; - return declHandle; + return layoutHandle; } VertexLayoutHandle release(DynamicVertexBufferHandle _handle) { - VertexLayoutHandle declHandle = m_dynamicVertexBufferRef[_handle.idx]; - declHandle = release(declHandle); + VertexLayoutHandle layoutHandle = m_dynamicVertexBufferRef[_handle.idx]; + layoutHandle = release(layoutHandle); m_dynamicVertexBufferRef[_handle.idx].idx = kInvalidHandle; - return declHandle; + return layoutHandle; } - typedef bx::HandleHashMapT VertexLayoutMap; - VertexLayoutMap m_vertexDeclMap; + typedef bx::HandleHashMapT VertexLayoutMap; + VertexLayoutMap m_layoutMap; - uint16_t m_vertexDeclRef[BGFX_CONFIG_MAX_VERTEX_DECLS]; + uint16_t m_layoutRef[BGFX_CONFIG_MAX_VERTEX_LAYOUTS]; VertexLayoutHandle m_vertexBufferRef[BGFX_CONFIG_MAX_VERTEX_BUFFERS]; VertexLayoutHandle m_dynamicVertexBufferRef[BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS]; }; @@ -2772,9 +2770,9 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA virtual void flip() = 0; virtual void createIndexBuffer(IndexBufferHandle _handle, const Memory* _mem, uint16_t _flags) = 0; virtual void destroyIndexBuffer(IndexBufferHandle _handle) = 0; - virtual void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _decl) = 0; + virtual void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _layout) = 0; virtual void destroyVertexLayout(VertexLayoutHandle _handle) = 0; - virtual void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _declHandle, uint16_t _flags) = 0; + virtual void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _layoutHandle, uint16_t _flags) = 0; virtual void destroyVertexBuffer(VertexBufferHandle _handle) = 0; virtual void createDynamicIndexBuffer(IndexBufferHandle _handle, uint32_t _size, uint16_t _flags) = 0; virtual void updateDynamicIndexBuffer(IndexBufferHandle _handle, uint32_t _offset, uint32_t _size, const Memory* _mem) = 0; @@ -2964,7 +2962,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA stats.numTextures = m_textureHandle.getNumHandles(); stats.numUniforms = m_uniformHandle.getNumHandles(); stats.numVertexBuffers = m_vertexBufferHandle.getNumHandles(); - stats.numVertexLayouts = m_vertexDeclHandle.getNumHandles(); + stats.numVertexLayouts = m_layoutHandle.getNumHandles(); stats.textureMemoryUsed = m_textureMemoryUsed; stats.rtMemoryUsed = m_rtMemoryUsed; @@ -3026,38 +3024,38 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA cmdbuf.write(_handle); } - VertexLayoutHandle findVertexLayout(const VertexLayout& _decl) + VertexLayoutHandle findVertexLayout(const VertexLayout& _layout) { - VertexLayoutHandle declHandle = m_declRef.find(_decl.m_hash); + VertexLayoutHandle layoutHandle = m_vertexLayoutRef.find(_layout.m_hash); - if (!isValid(declHandle) ) + if (!isValid(layoutHandle) ) { - declHandle.idx = m_vertexDeclHandle.alloc(); - if (!isValid(declHandle) ) + layoutHandle.idx = m_layoutHandle.alloc(); + if (!isValid(layoutHandle) ) { - return declHandle; + return layoutHandle; } CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateVertexLayout); - cmdbuf.write(declHandle); - cmdbuf.write(_decl); + cmdbuf.write(layoutHandle); + cmdbuf.write(_layout); } - return declHandle; + return layoutHandle; } - BGFX_API_FUNC(VertexLayoutHandle createVertexLayout(const VertexLayout& _decl) ) + BGFX_API_FUNC(VertexLayoutHandle createVertexLayout(const VertexLayout& _layout) ) { BGFX_MUTEX_SCOPE(m_resourceApiLock); - VertexLayoutHandle handle = findVertexLayout(_decl); + VertexLayoutHandle handle = findVertexLayout(_layout); if (!isValid(handle) ) { - BX_TRACE("WARNING: Failed to allocate vertex decl handle (BGFX_CONFIG_MAX_VERTEX_DECLS, max: %d).", BGFX_CONFIG_MAX_VERTEX_DECLS); + BX_TRACE("WARNING: Failed to allocate vertex layout handle (BGFX_CONFIG_MAX_VERTEX_LAYOUTS, max: %d).", BGFX_CONFIG_MAX_VERTEX_LAYOUTS); return BGFX_INVALID_HANDLE; } - m_declRef.add(handle, _decl.m_hash); + m_vertexLayoutRef.add(handle, _layout.m_hash); return handle; } @@ -3065,10 +3063,10 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA BGFX_API_FUNC(void destroyVertexLayout(VertexLayoutHandle _handle) ) { BGFX_MUTEX_SCOPE(m_resourceApiLock); - m_declRef.release(_handle); + m_vertexLayoutRef.release(_handle); } - BGFX_API_FUNC(VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexLayout& _decl, uint16_t _flags) ) + BGFX_API_FUNC(VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexLayout& _layout, uint16_t _flags) ) { BGFX_MUTEX_SCOPE(m_resourceApiLock); @@ -3076,24 +3074,24 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA if (isValid(handle) ) { - VertexLayoutHandle declHandle = findVertexLayout(_decl); - if (!isValid(declHandle) ) + VertexLayoutHandle layoutHandle = findVertexLayout(_layout); + if (!isValid(layoutHandle) ) { - BX_TRACE("WARNING: Failed to allocate vertex decl handle (BGFX_CONFIG_MAX_VERTEX_DECLS, max: %d).", BGFX_CONFIG_MAX_VERTEX_DECLS); + BX_TRACE("WARNING: Failed to allocate vertex layout handle (BGFX_CONFIG_MAX_VERTEX_LAYOUTS, max: %d).", BGFX_CONFIG_MAX_VERTEX_LAYOUTS); m_vertexBufferHandle.free(handle.idx); return BGFX_INVALID_HANDLE; } - m_declRef.add(handle, declHandle, _decl.m_hash); + m_vertexLayoutRef.add(handle, layoutHandle, _layout.m_hash); VertexBuffer& vb = m_vertexBuffers[handle.idx]; vb.m_size = _mem->size; - vb.m_stride = _decl.m_stride; + vb.m_stride = _layout.m_stride; CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateVertexBuffer); cmdbuf.write(handle); cmdbuf.write(_mem); - cmdbuf.write(declHandle); + cmdbuf.write(layoutHandle); cmdbuf.write(_flags); setDebugName(convert(handle) ); @@ -3136,12 +3134,12 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA void destroyVertexBufferInternal(VertexBufferHandle _handle) { - VertexLayoutHandle declHandle = m_declRef.release(_handle); - if (isValid(declHandle) ) + VertexLayoutHandle layoutHandle = m_vertexLayoutRef.release(_handle); + if (isValid(layoutHandle) ) { CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyVertexLayout); - cmdbuf.write(declHandle); - m_render->free(declHandle); + cmdbuf.write(layoutHandle); + m_render->free(layoutHandle); } m_vertexBufferHandle.free(_handle.idx); @@ -3353,14 +3351,14 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA return ptr; } - BGFX_API_FUNC(DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexLayout& _decl, uint16_t _flags) ) + BGFX_API_FUNC(DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexLayout& _layout, uint16_t _flags) ) { BGFX_MUTEX_SCOPE(m_resourceApiLock); - VertexLayoutHandle declHandle = findVertexLayout(_decl); - if (!isValid(declHandle) ) + VertexLayoutHandle layoutHandle = findVertexLayout(_layout); + if (!isValid(layoutHandle) ) { - BX_TRACE("WARNING: Failed to allocate vertex decl handle (BGFX_CONFIG_MAX_VERTEX_DECLS, max: %d).", BGFX_CONFIG_MAX_VERTEX_DECLS); + BX_TRACE("WARNING: Failed to allocate vertex layout handle (BGFX_CONFIG_MAX_VERTEX_LAYOUTS, max: %d).", BGFX_CONFIG_MAX_VERTEX_LAYOUTS); return BGFX_INVALID_HANDLE; } @@ -3371,7 +3369,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA return BGFX_INVALID_HANDLE; } - const uint32_t size = bx::strideAlign<16>(_num*_decl.m_stride, _decl.m_stride)+_decl.m_stride; + const uint32_t size = bx::strideAlign<16>(_num*_layout.m_stride, _layout.m_stride)+_layout.m_stride; uint64_t ptr = 0; if (0 != (_flags & BGFX_BUFFER_COMPUTE_READ_WRITE) ) @@ -3408,25 +3406,25 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA } DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[handle.idx]; - dvb.m_handle.idx = uint16_t(ptr>>32); - dvb.m_offset = uint32_t(ptr); - dvb.m_size = _num * _decl.m_stride; - dvb.m_startVertex = bx::strideAlign(dvb.m_offset, _decl.m_stride)/_decl.m_stride; - dvb.m_numVertices = _num; - dvb.m_stride = _decl.m_stride; - dvb.m_decl = declHandle; - dvb.m_flags = _flags; - m_declRef.add(handle, declHandle, _decl.m_hash); + dvb.m_handle.idx = uint16_t(ptr>>32); + dvb.m_offset = uint32_t(ptr); + dvb.m_size = _num * _layout.m_stride; + dvb.m_startVertex = bx::strideAlign(dvb.m_offset, _layout.m_stride)/_layout.m_stride; + dvb.m_numVertices = _num; + dvb.m_stride = _layout.m_stride; + dvb.m_layoutHandle = layoutHandle; + dvb.m_flags = _flags; + m_vertexLayoutRef.add(handle, layoutHandle, _layout.m_hash); return handle; } - BGFX_API_FUNC(DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexLayout& _decl, uint16_t _flags) ) + BGFX_API_FUNC(DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexLayout& _layout, uint16_t _flags) ) { BGFX_MUTEX_SCOPE(m_resourceApiLock); - uint32_t numVertices = _mem->size/_decl.m_stride; - DynamicVertexBufferHandle handle = createDynamicVertexBuffer(numVertices, _decl, _flags); + uint32_t numVertices = _mem->size/_layout.m_stride; + DynamicVertexBufferHandle handle = createDynamicVertexBuffer(numVertices, _layout, _flags); if (!isValid(handle) ) { @@ -3492,14 +3490,14 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA void destroyDynamicVertexBufferInternal(DynamicVertexBufferHandle _handle) { - VertexLayoutHandle declHandle = m_declRef.release(_handle); - BGFX_CHECK_HANDLE_INVALID_OK("destroyDynamicVertexBufferInternal", m_vertexDeclHandle, declHandle); + VertexLayoutHandle layoutHandle = m_vertexLayoutRef.release(_handle); + BGFX_CHECK_HANDLE_INVALID_OK("destroyDynamicVertexBufferInternal", m_layoutHandle, layoutHandle); - if (isValid(declHandle) ) + if (isValid(layoutHandle) ) { CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyVertexLayout); - cmdbuf.write(declHandle); - m_render->free(declHandle); + cmdbuf.write(layoutHandle); + m_render->free(layoutHandle); } DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[_handle.idx]; @@ -3587,7 +3585,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA _tib->startIndex = bx::strideAlign(offset, 2)/2; } - TransientVertexBuffer* createTransientVertexBuffer(uint32_t _size, const VertexLayout* _decl = NULL) + TransientVertexBuffer* createTransientVertexBuffer(uint32_t _size, const VertexLayout* _layout = NULL) { TransientVertexBuffer* tvb = NULL; @@ -3597,14 +3595,14 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA if (isValid(handle) ) { uint16_t stride = 0; - VertexLayoutHandle declHandle = BGFX_INVALID_HANDLE; + VertexLayoutHandle layoutHandle = BGFX_INVALID_HANDLE; - if (NULL != _decl) + if (NULL != _layout) { - declHandle = findVertexLayout(*_decl); - m_declRef.add(handle, declHandle, _decl->m_hash); + layoutHandle = findVertexLayout(*_layout); + m_vertexLayoutRef.add(handle, layoutHandle, _layout->m_hash); - stride = _decl->m_stride; + stride = _layout->m_stride; } CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateDynamicVertexBuffer); @@ -3620,7 +3618,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA tvb->startVertex = 0; tvb->stride = stride; tvb->handle = handle; - tvb->decl = declHandle; + tvb->layoutHandle = layoutHandle; setDebugName(convert(handle), "Transient Vertex Buffer"); } @@ -3637,32 +3635,32 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA BX_ALIGNED_FREE(g_allocator, _tvb, 16); } - BGFX_API_FUNC(void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint32_t _num, const VertexLayout& _decl) ) + BGFX_API_FUNC(void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint32_t _num, const VertexLayout& _layout) ) { BGFX_MUTEX_SCOPE(m_resourceApiLock); - VertexLayoutHandle declHandle = m_declRef.find(_decl.m_hash); + VertexLayoutHandle layoutHandle = m_vertexLayoutRef.find(_layout.m_hash); TransientVertexBuffer& dvb = *m_submit->m_transientVb; - if (!isValid(declHandle) ) + if (!isValid(layoutHandle) ) { - VertexLayoutHandle temp = { m_vertexDeclHandle.alloc() }; - declHandle = temp; + VertexLayoutHandle temp = { m_layoutHandle.alloc() }; + layoutHandle = temp; CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateVertexLayout); - cmdbuf.write(declHandle); - cmdbuf.write(_decl); - m_declRef.add(declHandle, _decl.m_hash); + cmdbuf.write(layoutHandle); + cmdbuf.write(_layout); + m_vertexLayoutRef.add(layoutHandle, _layout.m_hash); } - uint32_t offset = m_submit->allocTransientVertexBuffer(_num, _decl.m_stride); + uint32_t offset = m_submit->allocTransientVertexBuffer(_num, _layout.m_stride); _tvb->data = &dvb.data[offset]; - _tvb->size = _num * _decl.m_stride; - _tvb->startVertex = bx::strideAlign(offset, _decl.m_stride)/_decl.m_stride; - _tvb->stride = _decl.m_stride; + _tvb->size = _num * _layout.m_stride; + _tvb->startVertex = bx::strideAlign(offset, _layout.m_stride)/_layout.m_stride; + _tvb->stride = _layout.m_stride; _tvb->handle = dvb.handle; - _tvb->decl = declHandle; + _tvb->layoutHandle = layoutHandle; } BGFX_API_FUNC(void allocInstanceDataBuffer(InstanceDataBuffer* _idb, uint32_t _num, uint16_t _stride) ) @@ -4925,7 +4923,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA bx::HandleAllocT m_dynamicVertexBufferHandle; bx::HandleAllocT m_indexBufferHandle; - bx::HandleAllocT m_vertexDeclHandle; + bx::HandleAllocT m_layoutHandle; bx::HandleAllocT m_vertexBufferHandle; bx::HandleAllocT m_shaderHandle; @@ -4949,7 +4947,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA TextureRef m_textureRef[BGFX_CONFIG_MAX_TEXTURES]; FrameBufferRef m_frameBufferRef[BGFX_CONFIG_MAX_FRAME_BUFFERS]; - VertexLayoutRef m_declRef; + VertexLayoutRef m_vertexLayoutRef; ViewId m_viewRemap[BGFX_CONFIG_MAX_VIEWS]; uint32_t m_seq[BGFX_CONFIG_MAX_VIEWS]; diff --git a/src/config.h b/src/config.h index 4bc9e24c7..3b1d57fcb 100644 --- a/src/config.h +++ b/src/config.h @@ -227,9 +227,9 @@ BX_STATIC_ASSERT(bx::isPowerOf2(BGFX_CONFIG_MAX_VIEWS), "BGFX_CONFIG_MAX_VIEWS m # define BGFX_CONFIG_MAX_VIEW_NAME 256 #endif // BGFX_CONFIG_MAX_VIEW_NAME -#ifndef BGFX_CONFIG_MAX_VERTEX_DECLS -# define BGFX_CONFIG_MAX_VERTEX_DECLS 64 -#endif // BGFX_CONFIG_MAX_VERTEX_DECLS +#ifndef BGFX_CONFIG_MAX_VERTEX_LAYOUTS +# define BGFX_CONFIG_MAX_VERTEX_LAYOUTS 64 +#endif // BGFX_CONFIG_MAX_VERTEX_LAYOUTS #ifndef BGFX_CONFIG_MAX_INDEX_BUFFERS # define BGFX_CONFIG_MAX_INDEX_BUFFERS (4<<10) diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 6ff92100e..e6b94e07a 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -348,19 +348,19 @@ namespace bgfx { namespace d3d11 }; BX_STATIC_ASSERT(AttribType::Count == BX_COUNTOF(s_attribType) ); - static D3D11_INPUT_ELEMENT_DESC* fillVertexLayout(uint8_t _stream, D3D11_INPUT_ELEMENT_DESC* _out, const VertexLayout& _decl) + static D3D11_INPUT_ELEMENT_DESC* fillVertexLayout(uint8_t _stream, D3D11_INPUT_ELEMENT_DESC* _out, const VertexLayout& _layout) { D3D11_INPUT_ELEMENT_DESC* elem = _out; for (uint32_t attr = 0; attr < Attrib::Count; ++attr) { - if (UINT16_MAX != _decl.m_attributes[attr]) + if (UINT16_MAX != _layout.m_attributes[attr]) { bx::memCopy(elem, &s_attrib[attr], sizeof(D3D11_INPUT_ELEMENT_DESC) ); elem->InputSlot = _stream; - if (0 == _decl.m_attributes[attr]) + if (0 == _layout.m_attributes[attr]) { elem->AlignedByteOffset = 0; } @@ -370,9 +370,9 @@ namespace bgfx { namespace d3d11 AttribType::Enum type; bool normalized; bool asInt; - _decl.decode(Attrib::Enum(attr), num, type, normalized, asInt); + _layout.decode(Attrib::Enum(attr), num, type, normalized, asInt); elem->Format = s_attribType[type][num-1][normalized]; - elem->AlignedByteOffset = _decl.m_offset[attr]; + elem->AlignedByteOffset = _layout.m_offset[attr]; } ++elem; @@ -1688,20 +1688,20 @@ namespace bgfx { namespace d3d11 m_indexBuffers[_handle.idx].destroy(); } - void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _decl) override + void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _layout) override { - VertexLayout& decl = m_vertexDecls[_handle.idx]; - bx::memCopy(&decl, &_decl, sizeof(VertexLayout) ); - dump(decl); + VertexLayout& layout = m_vertexLayouts[_handle.idx]; + bx::memCopy(&layout, &_layout, sizeof(VertexLayout) ); + dump(layout); } void destroyVertexLayout(VertexLayoutHandle /*_handle*/) override { } - void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _declHandle, uint16_t _flags) override + void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _layoutHandle, uint16_t _flags) override { - m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _declHandle, _flags); + m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _layoutHandle, _flags); } void destroyVertexBuffer(VertexBufferHandle _handle) override @@ -1726,8 +1726,8 @@ namespace bgfx { namespace d3d11 void createDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size, uint16_t _flags) override { - VertexLayoutHandle decl = BGFX_INVALID_HANDLE; - m_vertexBuffers[_handle.idx].create(_size, NULL, decl, _flags); + VertexLayoutHandle layoutHandle = BGFX_INVALID_HANDLE; + m_vertexBuffers[_handle.idx].create(_size, NULL, layoutHandle, _flags); } void updateDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _offset, uint32_t _size, const Memory* _mem) override @@ -2095,11 +2095,11 @@ namespace bgfx { namespace d3d11 deviceCtx->PSSetConstantBuffers(0, 1, &program.m_fsh->m_buffer); VertexBufferD3D11& vb = m_vertexBuffers[_blitter.m_vb->handle.idx]; - VertexLayout& vertexDecl = m_vertexDecls[_blitter.m_vb->decl.idx]; - uint32_t stride = vertexDecl.m_stride; + VertexLayout& layout = m_vertexLayouts[_blitter.m_vb->layout.idx]; + uint32_t stride = layout.m_stride; uint32_t offset = 0; deviceCtx->IASetVertexBuffers(0, 1, &vb.m_ptr, &stride, &offset); - setInputLayout(vertexDecl, program, 0); + setInputLayout(layout, program, 0); IndexBufferD3D11& ib = m_indexBuffers[_blitter.m_ib->handle.idx]; deviceCtx->IASetIndexBuffer(ib.m_ptr, DXGI_FORMAT_R16_UINT, 0); @@ -2124,7 +2124,7 @@ namespace bgfx { namespace d3d11 ID3D11DeviceContext* deviceCtx = m_deviceCtx; m_indexBuffers [_blitter.m_ib->handle.idx].update(0, _numIndices*2, _blitter.m_ib->data, true); - m_vertexBuffers[_blitter.m_vb->handle.idx].update(0, numVertices*_blitter.m_decl.m_stride, _blitter.m_vb->data, true); + m_vertexBuffers[_blitter.m_vb->handle.idx].update(0, numVertices*_blitter.m_layout.m_stride, _blitter.m_vb->data, true); deviceCtx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); deviceCtx->DrawIndexed(_numIndices, 0, 0); @@ -2578,14 +2578,14 @@ namespace bgfx { namespace d3d11 } } - void setInputLayout(uint8_t _numStreams, const VertexLayout** _vertexDecls, const ProgramD3D11& _program, uint16_t _numInstanceData) + void setInputLayout(uint8_t _numStreams, const VertexLayout** _layouts, const ProgramD3D11& _program, uint16_t _numInstanceData) { bx::HashMurmur2A murmur; murmur.begin(); murmur.add(_numInstanceData); for (uint8_t stream = 0; stream < _numStreams; ++stream) { - murmur.add(_vertexDecls[stream]->m_hash); + murmur.add(_layouts[stream]->m_hash); } uint64_t layoutHash = (uint64_t(_program.m_vsh->m_hash)<<32) | murmur.end(); @@ -2600,19 +2600,19 @@ namespace bgfx { namespace d3d11 for (uint8_t stream = 0; stream < _numStreams; ++stream) { - VertexLayout decl; - bx::memCopy(&decl, _vertexDecls[stream], sizeof(VertexLayout) ); + VertexLayout layout; + bx::memCopy(&layout, _layouts[stream], sizeof(VertexLayout) ); const bool last = stream == _numStreams-1; for (uint32_t ii = 0; ii < Attrib::Count; ++ii) { uint16_t mask = attrMask[ii]; - uint16_t attr = (decl.m_attributes[ii] & mask); + uint16_t attr = (layout.m_attributes[ii] & mask); if (0 == attr || UINT16_MAX == attr) { - decl.m_attributes[ii] = last ? ~attr : UINT16_MAX; + layout.m_attributes[ii] = last ? ~attr : UINT16_MAX; } else { @@ -2620,7 +2620,7 @@ namespace bgfx { namespace d3d11 } } - elem = fillVertexLayout(stream, elem, decl); + elem = fillVertexLayout(stream, elem, layout); } uint32_t num = uint32_t(elem-vertexElements); @@ -2668,10 +2668,10 @@ namespace bgfx { namespace d3d11 m_deviceCtx->IASetInputLayout(layout); } - void setInputLayout(const VertexLayout& _vertexDecl, const ProgramD3D11& _program, uint16_t _numInstanceData) + void setInputLayout(const VertexLayout& _layout, const ProgramD3D11& _program, uint16_t _numInstanceData) { - const VertexLayout* decls[1] = { &_vertexDecl }; - setInputLayout(BX_COUNTOF(decls), decls, _program, _numInstanceData); + const VertexLayout* layouts[1] = { &_layout }; + setInputLayout(BX_COUNTOF(layouts), layouts, _program, _numInstanceData); } void setBlendState(uint64_t _state, uint32_t _rgba = 0) @@ -3409,13 +3409,13 @@ namespace bgfx { namespace d3d11 } VertexBufferD3D11& vb = m_vertexBuffers[_clearQuad.m_vb.idx]; - const VertexLayout& vertexDecl = _clearQuad.m_decl; + const VertexLayout& layout = _clearQuad.m_layout; - const uint32_t stride = vertexDecl.m_stride; + const uint32_t stride = layout.m_stride; const uint32_t offset = 0; deviceCtx->IASetVertexBuffers(0, 1, &vb.m_ptr, &stride, &offset); - setInputLayout(vertexDecl, program, 0); + setInputLayout(layout, program, 0); deviceCtx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); deviceCtx->Draw(4, 0); @@ -3473,7 +3473,7 @@ namespace bgfx { namespace d3d11 ShaderD3D11 m_shaders[BGFX_CONFIG_MAX_SHADERS]; ProgramD3D11 m_program[BGFX_CONFIG_MAX_PROGRAMS]; TextureD3D11 m_textures[BGFX_CONFIG_MAX_TEXTURES]; - VertexLayout m_vertexDecls[BGFX_CONFIG_MAX_VERTEX_DECLS]; + VertexLayout m_vertexLayouts[BGFX_CONFIG_MAX_VERTEX_LAYOUTS]; FrameBufferD3D11 m_frameBuffers[BGFX_CONFIG_MAX_FRAME_BUFFERS]; void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS]; Matrix4 m_predefinedUniforms[PredefinedUniform::Count]; @@ -3827,11 +3827,11 @@ namespace bgfx { namespace d3d11 #endif // 0 } - void VertexBufferD3D11::create(uint32_t _size, void* _data, VertexLayoutHandle _declHandle, uint16_t _flags) + void VertexBufferD3D11::create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle, uint16_t _flags) { - m_decl = _declHandle; - uint16_t stride = isValid(_declHandle) - ? s_renderD3D11->m_vertexDecls[_declHandle.idx].m_stride + m_layout = _layoutHandle; + uint16_t stride = isValid(_layoutHandle) + ? s_renderD3D11->m_vertexLayouts[_layoutHandle.idx].m_stride : 0 ; @@ -5877,7 +5877,7 @@ namespace bgfx { namespace d3d11 ID3D11Buffer* buffers[BGFX_CONFIG_MAX_VERTEX_STREAMS]; uint32_t strides[BGFX_CONFIG_MAX_VERTEX_STREAMS]; uint32_t offsets[BGFX_CONFIG_MAX_VERTEX_STREAMS]; - const VertexLayout* decls[BGFX_CONFIG_MAX_VERTEX_STREAMS]; + const VertexLayout* layouts[BGFX_CONFIG_MAX_VERTEX_STREAMS]; uint32_t numVertices = draw.m_numVertices; uint8_t numStreams = 0; @@ -5893,22 +5893,22 @@ namespace bgfx { namespace d3d11 streamMask >>= ntz; idx += ntz; - currentState.m_stream[idx].m_decl = draw.m_stream[idx].m_decl; + currentState.m_stream[idx].m_layout = draw.m_stream[idx].m_layout; currentState.m_stream[idx].m_handle = draw.m_stream[idx].m_handle; currentState.m_stream[idx].m_startVertex = draw.m_stream[idx].m_startVertex; const uint16_t handle = draw.m_stream[idx].m_handle.idx; const VertexBufferD3D11& vb = m_vertexBuffers[handle]; - const uint16_t decl = isValid(draw.m_stream[idx].m_decl) - ? draw.m_stream[idx].m_decl.idx - : vb.m_decl.idx; - const VertexLayout& vertexDecl = m_vertexDecls[decl]; - const uint32_t stride = vertexDecl.m_stride; + const uint16_t decl = isValid(draw.m_stream[idx].m_layout) + ? draw.m_stream[idx].m_layout.idx + : vb.m_layout.idx; + const VertexLayout& layout = m_vertexLayouts[decl]; + const uint32_t stride = layout.m_stride; buffers[numStreams] = vb.m_ptr; strides[numStreams] = stride; offsets[numStreams] = draw.m_stream[idx].m_startVertex * stride; - decls[numStreams] = &vertexDecl; + layouts[numStreams] = &layout; numVertices = bx::uint32_min(UINT32_MAX == draw.m_numVertices ? vb.m_size/stride @@ -5929,12 +5929,12 @@ namespace bgfx { namespace d3d11 const VertexBufferD3D11& inst = m_vertexBuffers[draw.m_instanceDataBuffer.idx]; const uint32_t instStride = draw.m_instanceDataStride; deviceCtx->IASetVertexBuffers(numStreams, 1, &inst.m_ptr, &instStride, &draw.m_instanceDataOffset); - setInputLayout(numStreams, decls, m_program[currentProgram.idx], uint16_t(instStride/16) ); + setInputLayout(numStreams, layouts, m_program[currentProgram.idx], uint16_t(instStride/16) ); } else { deviceCtx->IASetVertexBuffers(numStreams, 1, s_zero.m_buffer, s_zero.m_zero, s_zero.m_zero); - setInputLayout(numStreams, decls, m_program[currentProgram.idx], 0); + setInputLayout(numStreams, layouts, m_program[currentProgram.idx], 0); } } else diff --git a/src/renderer_d3d11.h b/src/renderer_d3d11.h index f292cfbe0..a6efe141f 100644 --- a/src/renderer_d3d11.h +++ b/src/renderer_d3d11.h @@ -127,9 +127,9 @@ namespace bgfx { namespace d3d11 { } - void create(uint32_t _size, void* _data, VertexLayoutHandle _declHandle, uint16_t _flags); + void create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle, uint16_t _flags); - VertexLayoutHandle m_decl; + VertexLayoutHandle m_layoutHandle; }; struct ShaderD3D11 diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index 5cc18d2aa..c65230646 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -332,19 +332,19 @@ namespace bgfx { namespace d3d12 }; BX_STATIC_ASSERT(AttribType::Count == BX_COUNTOF(s_attribType) ); - static D3D12_INPUT_ELEMENT_DESC* fillVertexLayout(uint8_t _stream, D3D12_INPUT_ELEMENT_DESC* _out, const VertexLayout& _decl) + static D3D12_INPUT_ELEMENT_DESC* fillVertexLayout(uint8_t _stream, D3D12_INPUT_ELEMENT_DESC* _out, const VertexLayout& _layout) { D3D12_INPUT_ELEMENT_DESC* elem = _out; for (uint32_t attr = 0; attr < Attrib::Count; ++attr) { - if (UINT16_MAX != _decl.m_attributes[attr]) + if (UINT16_MAX != _layout.m_attributes[attr]) { bx::memCopy(elem, &s_attrib[attr], sizeof(D3D12_INPUT_ELEMENT_DESC) ); elem->InputSlot = _stream; - if (0 == _decl.m_attributes[attr]) + if (0 == _layout.m_attributes[attr]) { elem->AlignedByteOffset = 0; } @@ -354,9 +354,9 @@ namespace bgfx { namespace d3d12 AttribType::Enum type; bool normalized; bool asInt; - _decl.decode(Attrib::Enum(attr), num, type, normalized, asInt); + _layout.decode(Attrib::Enum(attr), num, type, normalized, asInt); elem->Format = s_attribType[type][num-1][normalized]; - elem->AlignedByteOffset = _decl.m_offset[attr]; + elem->AlignedByteOffset = _layout.m_offset[attr]; } ++elem; @@ -1530,20 +1530,20 @@ namespace bgfx { namespace d3d12 m_indexBuffers[_handle.idx].destroy(); } - void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _decl) override + void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _layout) override { - VertexLayout& decl = m_vertexDecls[_handle.idx]; - bx::memCopy(&decl, &_decl, sizeof(VertexLayout) ); - dump(decl); + VertexLayout& layout = m_vertexLayouts[_handle.idx]; + bx::memCopy(&layout, &_layout, sizeof(VertexLayout) ); + dump(layout); } void destroyVertexLayout(VertexLayoutHandle /*_handle*/) override { } - void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _declHandle, uint16_t _flags) override + void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _layoutHandle, uint16_t _flags) override { - m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _declHandle, _flags); + m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _layoutHandle, _flags); } void destroyVertexBuffer(VertexBufferHandle _handle) override @@ -1568,8 +1568,8 @@ namespace bgfx { namespace d3d12 void createDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size, uint16_t _flags) override { - VertexLayoutHandle decl = BGFX_INVALID_HANDLE; - m_vertexBuffers[_handle.idx].create(_size, NULL, decl, _flags); + VertexLayoutHandle layoutHandle = BGFX_INVALID_HANDLE; + m_vertexBuffers[_handle.idx].create(_size, NULL, layoutHandle, _flags); } void updateDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _offset, uint32_t _size, const Memory* _mem) override @@ -1954,11 +1954,11 @@ namespace bgfx { namespace d3d12 | BGFX_STATE_DEPTH_TEST_ALWAYS ; - const VertexLayout* decls[1] = { &m_vertexDecls[_blitter.m_vb->decl.idx] }; + const VertexLayout* layouts[1] = { &m_vertexLayouts[_blitter.m_vb->layout.idx] }; ID3D12PipelineState* pso = getPipelineState(state , packStencil(BGFX_STENCIL_DEFAULT, BGFX_STENCIL_DEFAULT) , 1 - , decls + , layouts , _blitter.m_program , 0 ); @@ -1993,10 +1993,10 @@ namespace bgfx { namespace d3d12 m_commandList->SetGraphicsRootDescriptorTable(Rdt::SRV, srvHandle); VertexBufferD3D12& vb = m_vertexBuffers[_blitter.m_vb->handle.idx]; - const VertexLayout& vertexDecl = m_vertexDecls[_blitter.m_vb->decl.idx]; + const VertexLayout& layout = m_vertexLayouts[_blitter.m_vb->layout.idx]; D3D12_VERTEX_BUFFER_VIEW viewDesc; viewDesc.BufferLocation = vb.m_gpuVA; - viewDesc.StrideInBytes = vertexDecl.m_stride; + viewDesc.StrideInBytes = layout.m_stride; viewDesc.SizeInBytes = vb.m_size; m_commandList->IASetVertexBuffers(0, 1, &viewDesc); @@ -2016,7 +2016,7 @@ namespace bgfx { namespace d3d12 if (0 < numVertices) { m_indexBuffers [_blitter.m_ib->handle.idx].update(m_commandList, 0, _numIndices*2, _blitter.m_ib->data); - m_vertexBuffers[_blitter.m_vb->handle.idx].update(m_commandList, 0, numVertices*_blitter.m_decl.m_stride, _blitter.m_vb->data, true); + m_vertexBuffers[_blitter.m_vb->handle.idx].update(m_commandList, 0, numVertices*_blitter.m_layout.m_stride, _blitter.m_vb->data, true); m_commandList->DrawIndexedInstanced(_numIndices , 1 @@ -2604,7 +2604,7 @@ namespace bgfx { namespace d3d12 _desc.BackFace.StencilFunc = s_cmpFunc[(bstencil&BGFX_STENCIL_TEST_MASK) >> BGFX_STENCIL_TEST_SHIFT]; } - uint32_t setInputLayout(D3D12_INPUT_ELEMENT_DESC* _vertexElements, uint8_t _numStreams, const VertexLayout** _vertexDecls, const ProgramD3D12& _program, uint16_t _numInstanceData) + uint32_t setInputLayout(D3D12_INPUT_ELEMENT_DESC* _vertexElements, uint8_t _numStreams, const VertexLayout** _layouts, const ProgramD3D12& _program, uint16_t _numInstanceData) { uint16_t attrMask[Attrib::Count]; bx::memCopy(attrMask, _program.m_vsh->m_attrMask, sizeof(attrMask)); @@ -2613,19 +2613,19 @@ namespace bgfx { namespace d3d12 for (uint8_t stream = 0; stream < _numStreams; ++stream) { - VertexLayout decl; - bx::memCopy(&decl, _vertexDecls[stream], sizeof(VertexLayout)); + VertexLayout layout; + bx::memCopy(&layout, _layouts[stream], sizeof(VertexLayout)); const bool last = stream == _numStreams-1; for (uint32_t ii = 0; ii < Attrib::Count; ++ii) { uint16_t mask = attrMask[ii]; - uint16_t attr = (decl.m_attributes[ii] & mask); + uint16_t attr = (layout.m_attributes[ii] & mask); if (0 == attr || UINT16_MAX == attr) { - decl.m_attributes[ii] = last ? ~attr : UINT16_MAX; + layout.m_attributes[ii] = last ? ~attr : UINT16_MAX; } else { @@ -2633,7 +2633,7 @@ namespace bgfx { namespace d3d12 } } - elem = fillVertexLayout(stream, elem, decl); + elem = fillVertexLayout(stream, elem, layout); } uint32_t num = uint32_t(elem-_vertexElements); @@ -2671,10 +2671,10 @@ namespace bgfx { namespace d3d12 return uint32_t(elem-_vertexElements); } - uint32_t setInputLayout(D3D12_INPUT_ELEMENT_DESC* _vertexElements, const VertexLayout& _vertexDecl, const ProgramD3D12& _program, uint16_t _numInstanceData) + uint32_t setInputLayout(D3D12_INPUT_ELEMENT_DESC* _vertexElements, const VertexLayout& _layout, const ProgramD3D12& _program, uint16_t _numInstanceData) { - const VertexLayout* decls[1] = { &_vertexDecl }; - return setInputLayout(_vertexElements, BX_COUNTOF(decls), decls, _program, _numInstanceData); + const VertexLayout* layouts[1] = { &_layout }; + return setInputLayout(_vertexElements, BX_COUNTOF(layouts), layouts, _program, _numInstanceData); } static void patchCb0(DxbcInstruction& _instruction, void* _userData) @@ -2792,7 +2792,7 @@ namespace bgfx { namespace d3d12 uint64_t _state , uint64_t _stencil , uint8_t _numStreams - , const VertexLayout** _vertexDecls + , const VertexLayout** _layouts , ProgramHandle _program , uint8_t _numInstanceData ) @@ -2817,17 +2817,17 @@ namespace bgfx { namespace d3d12 _stencil &= packStencil(~BGFX_STENCIL_FUNC_REF_MASK, ~BGFX_STENCIL_FUNC_REF_MASK); - VertexLayout decl; + VertexLayout layout; if (0 < _numStreams) { - bx::memCopy(&decl, _vertexDecls[0], sizeof(VertexLayout) ); + bx::memCopy(&layout, _layouts[0], sizeof(VertexLayout) ); const uint16_t* attrMask = program.m_vsh->m_attrMask; for (uint32_t ii = 0; ii < Attrib::Count; ++ii) { uint16_t mask = attrMask[ii]; - uint16_t attr = (decl.m_attributes[ii] & mask); - decl.m_attributes[ii] = attr == 0 ? UINT16_MAX : attr == UINT16_MAX ? 0 : attr; + uint16_t attr = (layout.m_attributes[ii] & mask); + layout.m_attributes[ii] = attr == 0 ? UINT16_MAX : attr == UINT16_MAX ? 0 : attr; } } @@ -2845,10 +2845,10 @@ namespace bgfx { namespace d3d12 for (uint32_t ii = 0; ii < _numStreams; ++ii) { - murmur.add(_vertexDecls[ii]->m_hash); + murmur.add(_layouts[ii]->m_hash); } - murmur.add(decl.m_attributes, sizeof(decl.m_attributes) ); + murmur.add(layout.m_attributes, sizeof(layout.m_attributes) ); murmur.add(m_fbh.idx); murmur.add(_numInstanceData); const uint32_t hash = murmur.end(); @@ -2964,7 +2964,7 @@ namespace bgfx { namespace d3d12 setDepthStencilState(desc.DepthStencilState, _state, _stencil); D3D12_INPUT_ELEMENT_DESC vertexElements[Attrib::Count + 1 + BGFX_CONFIG_MAX_INSTANCE_DATA_COUNT]; - desc.InputLayout.NumElements = setInputLayout(vertexElements, _numStreams, _vertexDecls, program, _numInstanceData); + desc.InputLayout.NumElements = setInputLayout(vertexElements, _numStreams, _layouts, program, _numInstanceData); desc.InputLayout.pInputElementDescs = 0 == desc.InputLayout.NumElements ? NULL : vertexElements @@ -3356,7 +3356,7 @@ namespace bgfx { namespace d3d12 ShaderD3D12 m_shaders[BGFX_CONFIG_MAX_SHADERS]; ProgramD3D12 m_program[BGFX_CONFIG_MAX_PROGRAMS]; TextureD3D12 m_textures[BGFX_CONFIG_MAX_TEXTURES]; - VertexLayout m_vertexDecls[BGFX_CONFIG_MAX_VERTEX_DECLS]; + VertexLayout m_vertexLayouts[BGFX_CONFIG_MAX_VERTEX_LAYOUTS]; FrameBufferD3D12 m_frameBuffers[BGFX_CONFIG_MAX_FRAME_BUFFERS]; void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS]; Matrix4 m_predefinedUniforms[PredefinedUniform::Count]; @@ -3970,13 +3970,13 @@ namespace bgfx { namespace d3d12 VertexBufferD3D12& vb = s_renderD3D12->m_vertexBuffers[handle]; vb.setState(_commandList, D3D12_RESOURCE_STATE_GENERIC_READ); - uint16_t decl = !isValid(vb.m_decl) ? stream.m_decl.idx : vb.m_decl.idx; - const VertexLayout& vertexDecl = s_renderD3D12->m_vertexDecls[decl]; - uint32_t stride = vertexDecl.m_stride; + uint16_t decl = !isValid(vb.m_layout) ? stream.m_layout.idx : vb.m_layout.idx; + const VertexLayout& layout = s_renderD3D12->m_vertexLayouts[decl]; + uint32_t stride = layout.m_stride; D3D12_VERTEX_BUFFER_VIEW& vbv = _vbv[numStreams]; vbv.BufferLocation = vb.m_gpuVA + stream.m_startVertex * stride; - vbv.StrideInBytes = vertexDecl.m_stride; + vbv.StrideInBytes = layout.m_stride; vbv.SizeInBytes = vb.m_size; _outNumVertices = bx::uint32_min(UINT32_MAX == _draw.m_numVertices @@ -4442,10 +4442,10 @@ namespace bgfx { namespace d3d12 return _state; } - void VertexBufferD3D12::create(uint32_t _size, void* _data, VertexLayoutHandle _declHandle, uint16_t _flags) + void VertexBufferD3D12::create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle, uint16_t _flags) { BufferD3D12::create(_size, _data, _flags, true); - m_decl = _declHandle; + m_layout = _layoutHandle; } void ShaderD3D12::create(const Memory* _mem) @@ -6254,7 +6254,7 @@ namespace bgfx { namespace d3d12 || f3 == (state & f3) ; - const VertexLayout* decls[BGFX_CONFIG_MAX_VERTEX_STREAMS]; + const VertexLayout* layouts[BGFX_CONFIG_MAX_VERTEX_STREAMS]; uint8_t numStreams = 0; if (UINT8_MAX != draw.m_streamMask) @@ -6268,18 +6268,18 @@ namespace bgfx { namespace d3d12 streamMask >>= ntz; idx += ntz; - currentState.m_stream[idx].m_decl = draw.m_stream[idx].m_decl; + currentState.m_stream[idx].m_layout = draw.m_stream[idx].m_layout; currentState.m_stream[idx].m_handle = draw.m_stream[idx].m_handle; currentState.m_stream[idx].m_startVertex = draw.m_stream[idx].m_startVertex; uint16_t handle = draw.m_stream[idx].m_handle.idx; const VertexBufferD3D12& vb = m_vertexBuffers[handle]; - const uint16_t decl = isValid(draw.m_stream[idx].m_decl) - ? draw.m_stream[idx].m_decl.idx - : vb.m_decl.idx; - const VertexLayout& vertexDecl = m_vertexDecls[decl]; + const uint16_t decl = isValid(draw.m_stream[idx].m_layout) + ? draw.m_stream[idx].m_layout.idx + : vb.m_layout.idx; + const VertexLayout& layout = m_vertexLayouts[decl]; - decls[numStreams] = &vertexDecl; + layouts[numStreams] = &layout; } } @@ -6287,7 +6287,7 @@ namespace bgfx { namespace d3d12 getPipelineState(state , draw.m_stencil , numStreams - , decls + , layouts , key.m_program , uint8_t(draw.m_instanceDataStride/16) ); diff --git a/src/renderer_d3d12.h b/src/renderer_d3d12.h index ac14b7b60..aee806db3 100644 --- a/src/renderer_d3d12.h +++ b/src/renderer_d3d12.h @@ -224,9 +224,9 @@ namespace bgfx { namespace d3d12 struct VertexBufferD3D12 : public BufferD3D12 { - void create(uint32_t _size, void* _data, VertexLayoutHandle _declHandle, uint16_t _flags); + void create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle, uint16_t _flags); - VertexLayoutHandle m_decl; + VertexLayoutHandle m_layoutHandle; }; struct ShaderD3D12 diff --git a/src/renderer_d3d9.cpp b/src/renderer_d3d9.cpp index 84f328703..cc7bfb7f0 100644 --- a/src/renderer_d3d9.cpp +++ b/src/renderer_d3d9.cpp @@ -335,25 +335,25 @@ namespace bgfx { namespace d3d9 }; BX_STATIC_ASSERT(AttribType::Count == BX_COUNTOF(s_attribType) ); - static D3DVERTEXELEMENT9* fillVertexLayout(uint8_t _stream, D3DVERTEXELEMENT9* _out, const VertexLayout& _decl) + static D3DVERTEXELEMENT9* fillVertexLayout(uint8_t _stream, D3DVERTEXELEMENT9* _out, const VertexLayout& _layout) { D3DVERTEXELEMENT9* elem = _out; for (uint32_t attr = 0; attr < Attrib::Count; ++attr) { - if (UINT16_MAX != _decl.m_attributes[attr]) + if (UINT16_MAX != _layout.m_attributes[attr]) { uint8_t num; AttribType::Enum type; bool normalized; bool asInt; - _decl.decode(Attrib::Enum(attr), num, type, normalized, asInt); + _layout.decode(Attrib::Enum(attr), num, type, normalized, asInt); bx::memCopy(elem, &s_attrib[attr], sizeof(D3DVERTEXELEMENT9) ); elem->Stream = _stream; elem->Type = s_attribType[type][num-1][normalized]; - elem->Offset = _decl.m_offset[attr]; + elem->Offset = _layout.m_offset[attr]; ++elem; } } @@ -998,20 +998,20 @@ namespace bgfx { namespace d3d9 m_indexBuffers[_handle.idx].destroy(); } - void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _decl) override + void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _layout) override { - VertexLayout& decl = m_vertexDecls[_handle.idx]; - bx::memCopy(&decl, &_decl, sizeof(VertexLayout) ); - dump(decl); + VertexLayout& layout = m_vertexLayouts[_handle.idx]; + bx::memCopy(&layout, &_layout, sizeof(VertexLayout) ); + dump(layout); } void destroyVertexLayout(VertexLayoutHandle /*_handle*/) override { } - void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _declHandle, uint16_t /*_flags*/) override + void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _layoutHandle, uint16_t /*_flags*/) override { - m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _declHandle); + m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _layoutHandle); } void destroyVertexBuffer(VertexBufferHandle _handle) override @@ -1036,8 +1036,8 @@ namespace bgfx { namespace d3d9 void createDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size, uint16_t /*_flags*/) override { - VertexLayoutHandle decl = BGFX_INVALID_HANDLE; - m_vertexBuffers[_handle.idx].create(_size, NULL, decl); + VertexLayoutHandle layoutHandle = BGFX_INVALID_HANDLE; + m_vertexBuffers[_handle.idx].create(_size, NULL, layoutHandle); } void updateDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _offset, uint32_t _size, const Memory* _mem) override @@ -1373,9 +1373,9 @@ namespace bgfx { namespace d3d9 DX_CHECK(device->SetPixelShader(program.m_fsh->m_pixelShader) ); VertexBufferD3D9& vb = m_vertexBuffers[_blitter.m_vb->handle.idx]; - VertexLayout& vertexDecl = m_vertexDecls[_blitter.m_vb->decl.idx]; - DX_CHECK(device->SetStreamSource(0, vb.m_ptr, 0, vertexDecl.m_stride) ); - setInputLayout(vertexDecl, 0); + VertexLayout& layout = m_vertexLayouts[_blitter.m_vb->layout.idx]; + DX_CHECK(device->SetStreamSource(0, vb.m_ptr, 0, layout.m_stride) ); + setInputLayout(layout, 0); IndexBufferD3D9& ib = m_indexBuffers[_blitter.m_ib->handle.idx]; DX_CHECK(device->SetIndices(ib.m_ptr) ); @@ -1396,7 +1396,7 @@ namespace bgfx { namespace d3d9 if (0 < numVertices) { m_indexBuffers[_blitter.m_ib->handle.idx].update(0, _numIndices * 2, _blitter.m_ib->data, true); - m_vertexBuffers[_blitter.m_vb->handle.idx].update(0, numVertices*_blitter.m_decl.m_stride, _blitter.m_vb->data, true); + m_vertexBuffers[_blitter.m_vb->handle.idx].update(0, numVertices*_blitter.m_layout.m_stride, _blitter.m_vb->data, true); DX_CHECK(m_device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST , 0 @@ -2088,8 +2088,8 @@ namespace bgfx { namespace d3d9 } VertexBufferD3D9& vb = m_vertexBuffers[_clearQuad.m_vb.idx]; - VertexLayout& vertexDecl = _clearQuad.m_decl; - uint32_t stride = _clearQuad.m_decl.m_stride; + VertexLayout& layout = _clearQuad.m_layout; + uint32_t stride = _clearQuad.m_layout.m_stride; ProgramD3D9& program = m_program[_clearQuad.m_program[numMrt-1].idx]; device->SetVertexShader(program.m_vsh->m_vertexShader); @@ -2129,7 +2129,7 @@ namespace bgfx { namespace d3d9 DX_CHECK(device->SetStreamSource(0, vb.m_ptr, 0, stride) ); DX_CHECK(device->SetStreamSourceFreq(0, 1) ); DX_CHECK(device->SetStreamSource(1, NULL, 0, 0) ); - setInputLayout(vertexDecl, 0); + setInputLayout(layout, 0); DX_CHECK(device->SetIndices(NULL) ); DX_CHECK(device->DrawPrimitive(D3DPT_TRIANGLESTRIP , 0 @@ -2138,14 +2138,14 @@ namespace bgfx { namespace d3d9 } } - void setInputLayout(uint8_t _numStreams, const VertexLayout** _vertexDecls, uint16_t _numInstanceData) + void setInputLayout(uint8_t _numStreams, const VertexLayout** _layouts, uint16_t _numInstanceData) { bx::HashMurmur2A murmur; murmur.begin(); murmur.add(_numInstanceData); for (uint8_t stream = 0; stream < _numStreams; ++stream) { - murmur.add(_vertexDecls[stream]->m_hash); + murmur.add(_layouts[stream]->m_hash); } uint64_t layoutHash = murmur.end(); @@ -2157,7 +2157,7 @@ namespace bgfx { namespace d3d9 for (uint8_t stream = 0; stream < _numStreams; ++stream) { - elem = fillVertexLayout(stream, elem, *_vertexDecls[stream]); + elem = fillVertexLayout(stream, elem, *_layouts[stream]); } const D3DVERTEXELEMENT9 inst = { _numStreams, 0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 }; @@ -2180,10 +2180,10 @@ namespace bgfx { namespace d3d9 DX_CHECK(m_device->SetVertexDeclaration(layout) ); } - void setInputLayout(const VertexLayout& _vertexDecl, uint16_t _numInstanceData) + void setInputLayout(const VertexLayout& _layout, uint16_t _numInstanceData) { - const VertexLayout* decls[1] = { &_vertexDecl }; - setInputLayout(BX_COUNTOF(decls), decls, _numInstanceData); + const VertexLayout* layouts[1] = { &_layout }; + setInputLayout(BX_COUNTOF(layouts), layouts, _numInstanceData); } D3DCAPS9 m_caps; @@ -2237,7 +2237,7 @@ namespace bgfx { namespace d3d9 ShaderD3D9 m_shaders[BGFX_CONFIG_MAX_SHADERS]; ProgramD3D9 m_program[BGFX_CONFIG_MAX_PROGRAMS]; TextureD3D9 m_textures[BGFX_CONFIG_MAX_TEXTURES]; - VertexLayout m_vertexDecls[BGFX_CONFIG_MAX_VERTEX_DECLS]; + VertexLayout m_vertexLayouts[BGFX_CONFIG_MAX_VERTEX_LAYOUTS]; FrameBufferD3D9 m_frameBuffers[BGFX_CONFIG_MAX_FRAME_BUFFERS]; UniformRegistry m_uniformReg; void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS]; @@ -2341,10 +2341,10 @@ namespace bgfx { namespace d3d9 } } - void VertexBufferD3D9::create(uint32_t _size, void* _data, VertexLayoutHandle _declHandle) + void VertexBufferD3D9::create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle) { m_size = _size; - m_decl = _declHandle; + m_layout = _layoutHandle; uint32_t usage = D3DUSAGE_WRITEONLY; D3DPOOL pool = s_renderD3D9->m_pool; @@ -4214,7 +4214,7 @@ namespace bgfx { namespace d3d9 currentState.m_instanceDataOffset = draw.m_instanceDataOffset; currentState.m_instanceDataStride = draw.m_instanceDataStride; - const VertexLayout* decls[BGFX_CONFIG_MAX_VERTEX_STREAMS]; + const VertexLayout* layouts[BGFX_CONFIG_MAX_VERTEX_STREAMS]; const bool instanced = true && isValid(draw.m_instanceDataBuffer) @@ -4237,19 +4237,19 @@ namespace bgfx { namespace d3d9 streamMask >>= ntz; idx += ntz; - currentState.m_stream[idx].m_decl = draw.m_stream[idx].m_decl; + currentState.m_stream[idx].m_layout = draw.m_stream[idx].m_layout; currentState.m_stream[idx].m_handle = draw.m_stream[idx].m_handle; currentState.m_stream[idx].m_startVertex = draw.m_stream[idx].m_startVertex; const uint16_t handle = draw.m_stream[idx].m_handle.idx; const VertexBufferD3D9& vb = m_vertexBuffers[handle]; - const uint16_t decl = isValid(draw.m_stream[idx].m_decl) - ? draw.m_stream[idx].m_decl.idx - : vb.m_decl.idx; - const VertexLayout& vertexDecl = m_vertexDecls[decl]; - const uint32_t stride = vertexDecl.m_stride; + const uint16_t decl = isValid(draw.m_stream[idx].m_layout) + ? draw.m_stream[idx].m_layout.idx + : vb.m_layout.idx; + const VertexLayout& layout = m_vertexLayouts[decl]; + const uint32_t stride = layout.m_stride; - decls[numStreams] = &vertexDecl; + layouts[numStreams] = &layout; numVertices = bx::uint32_min(UINT32_MAX == draw.m_numVertices ? vb.m_size/stride @@ -4270,12 +4270,12 @@ namespace bgfx { namespace d3d9 const VertexBufferD3D9& inst = m_vertexBuffers[draw.m_instanceDataBuffer.idx]; DX_CHECK(device->SetStreamSourceFreq(numStreams, UINT(D3DSTREAMSOURCE_INSTANCEDATA|1) ) ); DX_CHECK(device->SetStreamSource(numStreams, inst.m_ptr, draw.m_instanceDataOffset, draw.m_instanceDataStride) ); - setInputLayout(numStreams, decls, draw.m_instanceDataStride/16); + setInputLayout(numStreams, layouts, draw.m_instanceDataStride/16); } else { DX_CHECK(device->SetStreamSource(numStreams, NULL, 0, 0) ); - setInputLayout(numStreams, decls, 0); + setInputLayout(numStreams, layouts, 0); } } else diff --git a/src/renderer_d3d9.h b/src/renderer_d3d9.h index 9cb97c158..198b54b87 100644 --- a/src/renderer_d3d9.h +++ b/src/renderer_d3d9.h @@ -191,7 +191,7 @@ namespace bgfx { namespace d3d9 { } - void create(uint32_t _size, void* _data, VertexLayoutHandle _declHandle); + void create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle); void update(uint32_t _offset, uint32_t _size, void* _data, bool _discard = false) { if (NULL != m_dynamic @@ -232,7 +232,7 @@ namespace bgfx { namespace d3d9 IDirect3DVertexBuffer9* m_ptr; uint8_t* m_dynamic; uint32_t m_size; - VertexLayoutHandle m_decl; + VertexLayoutHandle m_layoutHandle; }; struct ShaderD3D9 diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index dadbca09e..f87015633 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -2686,20 +2686,20 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) ); m_indexBuffers[_handle.idx].destroy(); } - void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _decl) override + void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _layout) override { - VertexLayout& decl = m_vertexDecls[_handle.idx]; - bx::memCopy(&decl, &_decl, sizeof(VertexLayout) ); - dump(decl); + VertexLayout& layout = m_vertexLayouts[_handle.idx]; + bx::memCopy(&layout, &_layout, sizeof(VertexLayout) ); + dump(layout); } void destroyVertexLayout(VertexLayoutHandle /*_handle*/) override { } - void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _declHandle, uint16_t _flags) override + void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _layoutHandle, uint16_t _flags) override { - m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _declHandle, _flags); + m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _layoutHandle, _flags); } void destroyVertexBuffer(VertexBufferHandle _handle) override @@ -2724,8 +2724,8 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) ); void createDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size, uint16_t _flags) override { - VertexLayoutHandle decl = BGFX_INVALID_HANDLE; - m_vertexBuffers[_handle.idx].create(_size, NULL, decl, _flags); + VertexLayoutHandle layoutHandle = BGFX_INVALID_HANDLE; + m_vertexBuffers[_handle.idx].create(_size, NULL, layoutHandle, _flags); } void updateDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _offset, uint32_t _size, const Memory* _mem) override @@ -3111,7 +3111,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) ); if (0 < numVertices) { m_indexBuffers[_blitter.m_ib->handle.idx].update(0, _numIndices*2, _blitter.m_ib->data); - m_vertexBuffers[_blitter.m_vb->handle.idx].update(0, numVertices*_blitter.m_decl.m_stride, _blitter.m_vb->data); + m_vertexBuffers[_blitter.m_vb->handle.idx].update(0, numVertices*_blitter.m_layout.m_stride, _blitter.m_vb->data); VertexBufferGL& vb = m_vertexBuffers[_blitter.m_vb->handle.idx]; GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, vb.m_id) ); @@ -3121,7 +3121,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) ); ProgramGL& program = m_program[_blitter.m_program.idx]; program.bindAttributesBegin(); - program.bindAttributes(_blitter.m_decl, 0); + program.bindAttributes(_blitter.m_layout, 0); program.bindAttributesEnd(); GL_CHECK(glDrawElements(GL_TRIANGLES @@ -3794,14 +3794,14 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) ); } VertexBufferGL& vb = m_vertexBuffers[_clearQuad.m_vb.idx]; - VertexLayout& vertexDecl = _clearQuad.m_decl; + VertexLayout& layout = _clearQuad.m_layout; GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, vb.m_id) ); ProgramGL& program = m_program[_clearQuad.m_program[numMrt-1].idx]; GL_CHECK(glUseProgram(program.m_id) ); program.bindAttributesBegin(); - program.bindAttributes(vertexDecl, 0); + program.bindAttributes(layout, 0); program.bindAttributesEnd(); if (m_clearQuadColor.idx == kInvalidHandle) @@ -3868,7 +3868,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) ); ShaderGL m_shaders[BGFX_CONFIG_MAX_SHADERS]; ProgramGL m_program[BGFX_CONFIG_MAX_PROGRAMS]; TextureGL m_textures[BGFX_CONFIG_MAX_TEXTURES]; - VertexLayout m_vertexDecls[BGFX_CONFIG_MAX_VERTEX_DECLS]; + VertexLayout m_vertexLayouts[BGFX_CONFIG_MAX_VERTEX_LAYOUTS]; FrameBufferGL m_frameBuffers[BGFX_CONFIG_MAX_FRAME_BUFFERS]; UniformRegistry m_uniformReg; void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS]; @@ -4508,7 +4508,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) ); m_instanceData[used] = 0xffff; } - void ProgramGL::bindAttributes(const VertexLayout& _vertexDecl, uint32_t _baseVertex) + void ProgramGL::bindAttributes(const VertexLayout& _layout, uint32_t _baseVertex) { for (uint32_t ii = 0, iiEnd = m_usedCount; ii < iiEnd; ++ii) { @@ -4519,16 +4519,16 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) ); AttribType::Enum type; bool normalized; bool asInt; - _vertexDecl.decode(attr, num, type, normalized, asInt); + _layout.decode(attr, num, type, normalized, asInt); if (-1 != loc) { - if (UINT16_MAX != _vertexDecl.m_attributes[attr]) + if (UINT16_MAX != _layout.m_attributes[attr]) { GL_CHECK(glEnableVertexAttribArray(loc) ); GL_CHECK(glVertexAttribDivisor(loc, 0) ); - uint32_t baseVertex = _baseVertex*_vertexDecl.m_stride + _vertexDecl.m_offset[attr]; + uint32_t baseVertex = _baseVertex*_layout.m_stride + _layout.m_offset[attr]; if ( (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL >= 30) || BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES >= 31) ) && (AttribType::Uint8 == type || AttribType::Int16 == type) && !normalized) @@ -4536,7 +4536,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) ); GL_CHECK(glVertexAttribIPointer(loc , num , s_attribType[type] - , _vertexDecl.m_stride + , _layout.m_stride , (void*)(uintptr_t)baseVertex) ); } @@ -4546,7 +4546,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) ); , num , s_attribType[type] , normalized - , _vertexDecl.m_stride + , _layout.m_stride , (void*)(uintptr_t)baseVertex) ); } @@ -7230,11 +7230,11 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) ); currentState.m_stream[idx].m_startVertex = draw.m_stream[idx].m_startVertex; const VertexBufferGL& vb = m_vertexBuffers[draw.m_stream[idx].m_handle.idx]; - const uint16_t decl = isValid(draw.m_stream[idx].m_decl) - ? draw.m_stream[idx].m_decl.idx - : vb.m_decl.idx; + const uint16_t decl = isValid(draw.m_stream[idx].m_layoutHandle) + ? draw.m_stream[idx].m_layoutHandle.idx + : vb.m_layoutHandle.idx; GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, vb.m_id) ); - program.bindAttributes(m_vertexDecls[decl], draw.m_stream[idx].m_startVertex); + program.bindAttributes(m_vertexLayouts[decl], draw.m_stream[idx].m_startVertex); } } @@ -7264,10 +7264,10 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) ); idx += ntz; const VertexBufferGL& vb = m_vertexBuffers[draw.m_stream[idx].m_handle.idx]; - uint16_t decl = !isValid(vb.m_decl) ? draw.m_stream[idx].m_decl.idx : vb.m_decl.idx; - const VertexLayout& vertexDecl = m_vertexDecls[decl]; + uint16_t decl = !isValid(vb.m_layoutHandle) ? draw.m_stream[idx].m_layoutHandle.idx : vb.m_layoutHandle.idx; + const VertexLayout& layout = m_vertexLayouts[decl]; - numVertices = bx::uint32_min(numVertices, vb.m_size/vertexDecl.m_stride); + numVertices = bx::uint32_min(numVertices, vb.m_size/layout.m_stride); } } diff --git a/src/renderer_gl.h b/src/renderer_gl.h index 595c6b0be..4bb313ad3 100644 --- a/src/renderer_gl.h +++ b/src/renderer_gl.h @@ -1214,10 +1214,10 @@ namespace bgfx { namespace gl struct VertexBufferGL { - void create(uint32_t _size, void* _data, VertexLayoutHandle _declHandle, uint16_t _flags) + void create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle, uint16_t _flags) { m_size = _size; - m_decl = _declHandle; + m_layoutHandle = _layoutHandle; const bool drawIndirect = 0 != (_flags & BGFX_BUFFER_DRAW_INDIRECT); m_target = drawIndirect ? GL_DRAW_INDIRECT_BUFFER : GL_ARRAY_BUFFER; @@ -1241,7 +1241,7 @@ namespace bgfx { namespace gl { // orphan buffer... destroy(); - create(m_size, NULL, m_decl, 0); + create(m_size, NULL, m_layoutHandle, 0); } GL_CHECK(glBindBuffer(m_target, m_id) ); @@ -1258,7 +1258,7 @@ namespace bgfx { namespace gl GLuint m_id; GLenum m_target; uint32_t m_size; - VertexLayoutHandle m_decl; + VertexLayoutHandle m_layoutHandle; }; struct TextureGL @@ -1375,7 +1375,7 @@ namespace bgfx { namespace gl bx::memCopy(m_unboundUsedAttrib, m_used, sizeof(m_unboundUsedAttrib) ); } - void bindAttributes(const VertexLayout& _vertexDecl, uint32_t _baseVertex = 0); + void bindAttributes(const VertexLayout& layout, uint32_t _baseVertex = 0); void bindAttributesEnd() { diff --git a/src/renderer_mtl.h b/src/renderer_mtl.h index a4eb63edc..2f536c037 100644 --- a/src/renderer_mtl.h +++ b/src/renderer_mtl.h @@ -822,9 +822,9 @@ namespace bgfx { namespace mtl { } - void create(uint32_t _size, void* _data, VertexLayoutHandle _declHandle, uint16_t _flags); + void create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle, uint16_t _flags); - VertexLayoutHandle m_decl; + VertexLayoutHandle m_layoutHandle; }; diff --git a/src/renderer_mtl.mm b/src/renderer_mtl.mm index fac9741ed..0657d78f3 100644 --- a/src/renderer_mtl.mm +++ b/src/renderer_mtl.mm @@ -732,20 +732,20 @@ namespace bgfx { namespace mtl m_indexBuffers[_handle.idx].destroy(); } - void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _decl) override + void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _layout) override { - VertexLayout& decl = m_vertexDecls[_handle.idx]; - bx::memCopy(&decl, &_decl, sizeof(VertexLayout) ); - dump(decl); + VertexLayout& layout = m_vertexLayouts[_handle.idx]; + bx::memCopy(&layout, &_layout, sizeof(VertexLayout) ); + dump(layout); } void destroyVertexLayout(VertexLayoutHandle /*_handle*/) override { } - void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _declHandle, uint16_t _flags) override + void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _layoutHandle, uint16_t _flags) override { - m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _declHandle, _flags); + m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _layoutHandle, _flags); } void destroyVertexBuffer(VertexBufferHandle _handle) override @@ -770,8 +770,8 @@ namespace bgfx { namespace mtl void createDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size, uint16_t _flags) override { - VertexLayoutHandle decl = BGFX_INVALID_HANDLE; - m_vertexBuffers[_handle.idx].create(_size, NULL, decl, _flags); + VertexLayoutHandle layoutHandle = BGFX_INVALID_HANDLE; + m_vertexBuffers[_handle.idx].create(_size, NULL, layoutHandle, _flags); } void updateDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _offset, uint32_t _size, const Memory* _mem) override @@ -1097,7 +1097,7 @@ namespace bgfx { namespace mtl ); m_vertexBuffers[_blitter.m_vb->handle.idx].update( 0 - , numVertices*_blitter.m_decl.m_stride + , numVertices*_blitter.m_layout.m_stride , _blitter.m_vb->data , true ); @@ -1143,7 +1143,7 @@ namespace bgfx { namespace mtl state , 0 , fbh - , _blitter.m_vb->decl + , _blitter.m_vb->layoutHandle , _blitter.m_program , 0 ); @@ -1512,13 +1512,13 @@ namespace bgfx { namespace mtl numMrt = bx::uint32_max(1, fb.m_num); } - const VertexLayout* decl = &_clearQuad.m_decl; + const VertexLayout* layout = &_clearQuad.m_layout; const PipelineStateMtl* pso = getPipelineState( state , 0 , fbh , 1 - , &decl + , &layout , _clearQuad.m_program[numMrt-1] , 0 ); @@ -1905,7 +1905,7 @@ namespace bgfx { namespace mtl , uint32_t _rgba , FrameBufferHandle _fbh , uint8_t _numStreams - , const VertexLayout** _vertexDecls + , const VertexLayout** _layouts , ProgramHandle _program , uint8_t _numInstanceData ) @@ -1947,7 +1947,7 @@ namespace bgfx { namespace mtl for (uint8_t ii = 0; ii < _numStreams; ++ii) { - murmur.add(_vertexDecls[ii]->m_hash); + murmur.add(_layouts[ii]->m_hash); } uint32_t hash = murmur.end(); @@ -2082,7 +2082,7 @@ namespace bgfx { namespace mtl uint8_t stream = 0; for (; stream < _numStreams; ++stream) { - const VertexLayout& vertexDecl = *_vertexDecls[stream]; + const VertexLayout& layout = *_layouts[stream]; bool streamUsed = false; for (uint32_t ii = 0; Attrib::Count != program.m_used[ii]; ++ii) { @@ -2095,14 +2095,14 @@ namespace bgfx { namespace mtl AttribType::Enum type; bool normalized; bool asInt; - vertexDecl.decode(attr, num, type, normalized, asInt); + layout.decode(attr, num, type, normalized, asInt); BX_CHECK(num <= 4, "num must be <= 4"); - if (UINT16_MAX != vertexDecl.m_attributes[attr]) + if (UINT16_MAX != layout.m_attributes[attr]) { vertexDesc.attributes[loc].format = s_attribType[type][num-1][normalized?1:0]; vertexDesc.attributes[loc].bufferIndex = stream+1; - vertexDesc.attributes[loc].offset = vertexDecl.m_offset[attr]; + vertexDesc.attributes[loc].offset = layout.m_offset[attr]; BX_TRACE("attrib: %s format: %d offset: %d", s_attribName[attr], (int)vertexDesc.attributes[loc].format, (int)vertexDesc.attributes[loc].offset); @@ -2111,7 +2111,7 @@ namespace bgfx { namespace mtl } } if (streamUsed) { - vertexDesc.layouts[stream+1].stride = vertexDecl.getStride(); + vertexDesc.layouts[stream+1].stride = layout.getStride(); vertexDesc.layouts[stream+1].stepFunction = MTLVertexStepFunctionPerVertex; } } @@ -2166,18 +2166,18 @@ namespace bgfx { namespace mtl uint64_t _state , uint32_t _rgba , FrameBufferHandle _fbh - , VertexLayoutHandle _declHandle + , VertexLayoutHandle _layoutHandle , ProgramHandle _program , uint16_t _numInstanceData ) { - const VertexLayout* decl = &m_vertexDecls[_declHandle.idx]; + const VertexLayout* layout = &m_vertexLayouts[_layoutHandle.idx]; return getPipelineState( _state , _rgba , _fbh , 1 - , &decl + , &layout , _program , _numInstanceData ); @@ -2311,7 +2311,7 @@ namespace bgfx { namespace mtl TextureMtl m_textures[BGFX_CONFIG_MAX_TEXTURES]; FrameBufferMtl m_mainFrameBuffer; FrameBufferMtl m_frameBuffers[BGFX_CONFIG_MAX_FRAME_BUFFERS]; - VertexLayout m_vertexDecls[BGFX_CONFIG_MAX_VERTEX_DECLS]; + VertexLayout m_vertexLayouts[BGFX_CONFIG_MAX_VERTEX_LAYOUTS]; UniformRegistry m_uniformReg; void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS]; @@ -2576,11 +2576,11 @@ namespace bgfx { namespace mtl } } - void VertexBufferMtl::create(uint32_t _size, void* _data, VertexLayoutHandle _declHandle, uint16_t _flags) + void VertexBufferMtl::create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle, uint16_t _flags) { - m_decl = _declHandle; - uint16_t stride = isValid(_declHandle) - ? s_renderMtl->m_vertexDecls[_declHandle.idx].m_stride + m_layoutHandle = _layoutHandle; + uint16_t stride = isValid(_layoutHandle) + ? s_renderMtl->m_vertexLayouts[_layoutHandle.idx].m_stride : 0 ; @@ -4275,7 +4275,7 @@ namespace bgfx { namespace mtl currentState.m_instanceDataOffset = draw.m_instanceDataOffset; currentState.m_instanceDataStride = draw.m_instanceDataStride; - const VertexLayout* decls[BGFX_CONFIG_MAX_VERTEX_STREAMS]; + const VertexLayout* layouts[BGFX_CONFIG_MAX_VERTEX_STREAMS]; uint32_t numVertices = draw.m_numVertices; uint8_t numStreams = 0; @@ -4288,19 +4288,19 @@ namespace bgfx { namespace mtl streamMask >>= ntz; idx += ntz; - currentState.m_stream[idx].m_decl = draw.m_stream[idx].m_decl; - currentState.m_stream[idx].m_handle = draw.m_stream[idx].m_handle; - currentState.m_stream[idx].m_startVertex = draw.m_stream[idx].m_startVertex; + currentState.m_stream[idx].m_layoutHandle = draw.m_stream[idx].m_layoutHandle; + currentState.m_stream[idx].m_handle = draw.m_stream[idx].m_handle; + currentState.m_stream[idx].m_startVertex = draw.m_stream[idx].m_startVertex; const uint16_t handle = draw.m_stream[idx].m_handle.idx; const VertexBufferMtl& vb = m_vertexBuffers[handle]; - const uint16_t decl = isValid(draw.m_stream[idx].m_decl) - ? draw.m_stream[idx].m_decl.idx - : vb.m_decl.idx; - const VertexLayout& vertexDecl = m_vertexDecls[decl]; - const uint32_t stride = vertexDecl.m_stride; + const uint16_t decl = isValid(draw.m_stream[idx].m_layoutHandle) + ? draw.m_stream[idx].m_layoutHandle.idx + : vb.m_layoutHandle.idx; + const VertexLayout& layout = m_vertexLayouts[decl]; + const uint32_t stride = layout.m_stride; - decls[numStreams] = &vertexDecl; + layouts[numStreams] = &layout; numVertices = bx::uint32_min(UINT32_MAX == draw.m_numVertices ? vb.m_size/stride @@ -4329,7 +4329,7 @@ namespace bgfx { namespace mtl , draw.m_rgba , fbh , numStreams - , decls + , layouts , currentProgram , draw.m_instanceDataStride/16 ); @@ -4444,9 +4444,9 @@ namespace bgfx { namespace mtl if (UINT32_MAX == numVertices) { const VertexBufferMtl& vb = m_vertexBuffers[currentState.m_stream[0].m_handle.idx]; - uint16_t decl = !isValid(vb.m_decl) ? draw.m_stream[0].m_decl.idx : vb.m_decl.idx; - const VertexLayout& vertexDecl = m_vertexDecls[decl]; - numVertices = vb.m_size/vertexDecl.m_stride; + uint16_t decl = !isValid(vb.m_layoutHandle) ? draw.m_stream[0].m_layoutHandle.idx : vb.m_layoutHandle.idx; + const VertexLayout& layout = m_vertexLayouts[decl]; + numVertices = vb.m_size/layout.m_stride; } uint32_t numIndices = 0; diff --git a/src/renderer_noop.cpp b/src/renderer_noop.cpp index f6c2c8f19..b71223c53 100644 --- a/src/renderer_noop.cpp +++ b/src/renderer_noop.cpp @@ -100,7 +100,7 @@ namespace bgfx { namespace noop { } - void createVertexLayout(VertexLayoutHandle /*_handle*/, const VertexLayout& /*_decl*/) override + void createVertexLayout(VertexLayoutHandle /*_handle*/, const VertexLayout& /*_layout*/) override { } @@ -108,7 +108,7 @@ namespace bgfx { namespace noop { } - void createVertexBuffer(VertexBufferHandle /*_handle*/, const Memory* /*_mem*/, VertexLayoutHandle /*_declHandle*/, uint16_t /*_flags*/) override + void createVertexBuffer(VertexBufferHandle /*_handle*/, const Memory* /*_mem*/, VertexLayoutHandle /*_layoutHandle*/, uint16_t /*_flags*/) override { } diff --git a/src/renderer_vk.cpp b/src/renderer_vk.cpp index 021b7ba27..ee00be2c6 100644 --- a/src/renderer_vk.cpp +++ b/src/renderer_vk.cpp @@ -327,7 +327,7 @@ VK_IMPORT_DEVICE }; BX_STATIC_ASSERT(AttribType::Count == BX_COUNTOF(s_attribType) ); - void fillVertexLayout(const ShaderVK* _vsh, VkPipelineVertexInputStateCreateInfo& _vertexInputState, const VertexLayout& _decl) + void fillVertexLayout(const ShaderVK* _vsh, VkPipelineVertexInputStateCreateInfo& _vertexInputState, const VertexLayout& _layout) { uint32_t numBindings = _vertexInputState.vertexBindingDescriptionCount; uint32_t numAttribs = _vertexInputState.vertexAttributeDescriptionCount; @@ -335,12 +335,12 @@ VK_IMPORT_DEVICE VkVertexInputAttributeDescription* inputAttrib = const_cast(_vertexInputState.pVertexAttributeDescriptions + numAttribs); inputBinding->binding = numBindings; - inputBinding->stride = _decl.m_stride; + inputBinding->stride = _layout.m_stride; inputBinding->inputRate = VK_VERTEX_INPUT_RATE_VERTEX; for (uint32_t attr = 0; attr < Attrib::Count; ++attr) { - if (UINT16_MAX != _decl.m_attributes[attr]) + if (UINT16_MAX != _layout.m_attributes[attr]) { inputAttrib->location = _vsh->m_attrRemap[attr]; inputAttrib->binding = numBindings; @@ -349,9 +349,9 @@ VK_IMPORT_DEVICE AttribType::Enum type; bool normalized; bool asInt; - _decl.decode(Attrib::Enum(attr), num, type, normalized, asInt); + _layout.decode(Attrib::Enum(attr), num, type, normalized, asInt); inputAttrib->format = s_attribType[type][num-1][normalized]; - inputAttrib->offset = _decl.m_offset[attr]; + inputAttrib->offset = _layout.m_offset[attr]; ++inputAttrib; ++numAttribs; @@ -2329,20 +2329,20 @@ VK_IMPORT_DEVICE m_indexBuffers[_handle.idx].destroy(); } - void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _decl) override + void createVertexLayout(VertexLayoutHandle _handle, const VertexLayout& _layout) override { - VertexLayout& decl = m_vertexDecls[_handle.idx]; - bx::memCopy(&decl, &_decl, sizeof(VertexLayout) ); - dump(decl); + VertexLayout& layout = m_vertexLayouts[_handle.idx]; + bx::memCopy(&layout, &_layout, sizeof(VertexLayout) ); + dump(layout); } void destroyVertexLayout(VertexLayoutHandle /*_handle*/) override { } - void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _declHandle, uint16_t _flags) override + void createVertexBuffer(VertexBufferHandle _handle, const Memory* _mem, VertexLayoutHandle _layoutHandle, uint16_t _flags) override { - m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _declHandle, _flags); + m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _layoutHandle, _flags); } void destroyVertexBuffer(VertexBufferHandle _handle) override @@ -2368,8 +2368,8 @@ VK_IMPORT_DEVICE void createDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size, uint16_t _flags) override { - VertexLayoutHandle decl = BGFX_INVALID_HANDLE; - m_vertexBuffers[_handle.idx].create(_size, NULL, decl, _flags); + VertexLayoutHandle layoutHandle = BGFX_INVALID_HANDLE; + m_vertexBuffers[_handle.idx].create(_size, NULL, layoutHandle, _flags); } void updateDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _offset, uint32_t _size, const Memory* _mem) override @@ -2576,11 +2576,11 @@ VK_IMPORT_DEVICE | BGFX_STATE_DEPTH_TEST_ALWAYS ; - const VertexLayout* vertexDecl = &m_vertexDecls[_blitter.m_vb->decl.idx]; + const VertexLayout* layout = &m_vertexLayouts[_blitter.m_vb->layoutHandle.idx]; VkPipeline pso = getPipeline(state , packStencil(BGFX_STENCIL_DEFAULT, BGFX_STENCIL_DEFAULT) , 1 - , &vertexDecl + , &layout , _blitter.m_program , 0 ); @@ -2701,7 +2701,7 @@ VK_IMPORT_DEVICE if (0 < numVertices) { m_indexBuffers[_blitter.m_ib->handle.idx].update(m_commandBuffer, 0, _numIndices*2, _blitter.m_ib->data); - m_vertexBuffers[_blitter.m_vb->handle.idx].update(m_commandBuffer, 0, numVertices*_blitter.m_decl.m_stride, _blitter.m_vb->data, true); + m_vertexBuffers[_blitter.m_vb->handle.idx].update(m_commandBuffer, 0, numVertices*_blitter.m_layout.m_stride, _blitter.m_vb->data, true); vkCmdDrawIndexed(m_commandBuffer , _numIndices @@ -3091,7 +3091,7 @@ VK_IMPORT_DEVICE _desc.maxDepthBounds = 1.0f; } - void setInputLayout(VkPipelineVertexInputStateCreateInfo& _vertexInputState, uint8_t _numStream, const VertexLayout** _vertexDecl, const ProgramVK& _program, uint8_t _numInstanceData) + void setInputLayout(VkPipelineVertexInputStateCreateInfo& _vertexInputState, uint8_t _numStream, const VertexLayout** _layout, const ProgramVK& _program, uint8_t _numInstanceData) { _vertexInputState.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; _vertexInputState.pNext = NULL; @@ -3104,22 +3104,22 @@ VK_IMPORT_DEVICE bx::memCopy(unsettedAttr, _program.m_vsh->m_attrMask, sizeof(uint16_t) * Attrib::Count); for (uint8_t stream = 0; stream < _numStream; ++stream) { - VertexLayout decl; - bx::memCopy(&decl, _vertexDecl[stream], sizeof(VertexLayout) ); + VertexLayout layout; + bx::memCopy(&layout, _layout[stream], sizeof(VertexLayout) ); const uint16_t* attrMask = _program.m_vsh->m_attrMask; for (uint32_t ii = 0; ii < Attrib::Count; ++ii) { uint16_t mask = attrMask[ii]; - uint16_t attr = (decl.m_attributes[ii] & mask); - decl.m_attributes[ii] = attr == 0 || attr == UINT16_MAX ? UINT16_MAX : attr; + uint16_t attr = (layout.m_attributes[ii] & mask); + layout.m_attributes[ii] = attr == 0 || attr == UINT16_MAX ? UINT16_MAX : attr; if (unsettedAttr[ii] && attr != UINT16_MAX) { unsettedAttr[ii] = 0; } } - fillVertexLayout(_program.m_vsh, _vertexInputState, decl); + fillVertexLayout(_program.m_vsh, _vertexInputState, layout); } for (uint32_t ii = 0; ii < Attrib::Count; ++ii) @@ -3342,7 +3342,7 @@ VK_IMPORT_DEVICE return pipeline; } - VkPipeline getPipeline(uint64_t _state, uint64_t _stencil, uint8_t _numStreams, const VertexLayout** _vertexDecls, ProgramHandle _program, uint8_t _numInstanceData) + VkPipeline getPipeline(uint64_t _state, uint64_t _stencil, uint8_t _numStreams, const VertexLayout** _layouts, ProgramHandle _program, uint8_t _numInstanceData) { ProgramVK& program = m_program[_program.idx]; @@ -3364,17 +3364,17 @@ VK_IMPORT_DEVICE _stencil &= packStencil(~BGFX_STENCIL_FUNC_REF_MASK, ~BGFX_STENCIL_FUNC_REF_MASK); - VertexLayout decl; + VertexLayout layout; if (0 < _numStreams) { - bx::memCopy(&decl, _vertexDecls[0], sizeof(VertexLayout) ); + bx::memCopy(&layout, _layouts[0], sizeof(VertexLayout) ); const uint16_t* attrMask = program.m_vsh->m_attrMask; for (uint32_t ii = 0; ii < Attrib::Count; ++ii) { uint16_t mask = attrMask[ii]; - uint16_t attr = (decl.m_attributes[ii] & mask); - decl.m_attributes[ii] = attr == 0 ? UINT16_MAX : attr == UINT16_MAX ? 0 : attr; + uint16_t attr = (layout.m_attributes[ii] & mask); + layout.m_attributes[ii] = attr == 0 ? UINT16_MAX : attr == UINT16_MAX ? 0 : attr; } } @@ -3387,9 +3387,9 @@ VK_IMPORT_DEVICE murmur.add(program.m_fsh->m_hash); for (uint8_t ii = 0; ii < _numStreams; ++ii) { - murmur.add(_vertexDecls[ii]->m_hash); + murmur.add(_layouts[ii]->m_hash); } - murmur.add(decl.m_attributes, sizeof(decl.m_attributes) ); + murmur.add(layout.m_attributes, sizeof(layout.m_attributes) ); murmur.add(m_fbh.idx); murmur.add(_numInstanceData); const uint32_t hash = murmur.end(); @@ -3425,7 +3425,7 @@ VK_IMPORT_DEVICE VkPipelineVertexInputStateCreateInfo vertexInputState; vertexInputState.pVertexBindingDescriptions = inputBinding; vertexInputState.pVertexAttributeDescriptions = inputAttrib; - setInputLayout(vertexInputState, _numStreams, _vertexDecls, program, _numInstanceData); + setInputLayout(vertexInputState, _numStreams, _layouts, program, _numInstanceData); const VkDynamicState dynamicStates[] = { @@ -4065,7 +4065,7 @@ VK_IMPORT_DEVICE ShaderVK m_shaders[BGFX_CONFIG_MAX_SHADERS]; ProgramVK m_program[BGFX_CONFIG_MAX_PROGRAMS]; TextureVK m_textures[BGFX_CONFIG_MAX_TEXTURES]; - VertexLayout m_vertexDecls[BGFX_CONFIG_MAX_VERTEX_DECLS]; + VertexLayout m_vertexLayouts[BGFX_CONFIG_MAX_VERTEX_LAYOUTS]; FrameBufferVK m_frameBuffers[BGFX_CONFIG_MAX_FRAME_BUFFERS]; void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS]; Matrix4 m_predefinedUniforms[PredefinedUniform::Count]; @@ -4519,10 +4519,10 @@ VK_DESTROY } } - void VertexBufferVK::create(uint32_t _size, void* _data, VertexLayoutHandle _declHandle, uint16_t _flags) + void VertexBufferVK::create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle, uint16_t _flags) { BufferVK::create(_size, _data, _flags, true); - m_decl = _declHandle; + m_layoutHandle = _layoutHandle; } void ShaderVK::create(const Memory* _mem) @@ -6078,7 +6078,7 @@ VK_DESTROY || f3 == (state & f3) ; - const VertexLayout* decls[BGFX_CONFIG_MAX_VERTEX_STREAMS]; + const VertexLayout* layouts[BGFX_CONFIG_MAX_VERTEX_STREAMS]; uint8_t numStreams = 0; if (UINT8_MAX != draw.m_streamMask) { @@ -6091,18 +6091,18 @@ VK_DESTROY streamMask >>= ntz; idx += ntz; - currentState.m_stream[idx].m_decl = draw.m_stream[idx].m_decl; - currentState.m_stream[idx].m_handle = draw.m_stream[idx].m_handle; - currentState.m_stream[idx].m_startVertex = draw.m_stream[idx].m_startVertex; + currentState.m_stream[idx].m_layoutHandle = draw.m_stream[idx].m_layoutHandle; + currentState.m_stream[idx].m_handle = draw.m_stream[idx].m_handle; + currentState.m_stream[idx].m_startVertex = draw.m_stream[idx].m_startVertex; uint16_t handle = draw.m_stream[idx].m_handle.idx; const VertexBufferVK& vb = m_vertexBuffers[handle]; - const uint16_t decl = isValid(draw.m_stream[idx].m_decl) - ? draw.m_stream[idx].m_decl.idx - : vb.m_decl.idx; - const VertexLayout& vertexDecl = m_vertexDecls[decl]; + const uint16_t decl = isValid(draw.m_stream[idx].m_layoutHandle) + ? draw.m_stream[idx].m_layoutHandle.idx + : vb.m_layoutHandle.idx; + const VertexLayout& layout = m_vertexLayouts[decl]; - decls[numStreams] = &vertexDecl; + layouts[numStreams] = &layout; } } @@ -6110,7 +6110,7 @@ VK_DESTROY getPipeline(state , draw.m_stencil , numStreams - , decls + , layouts , key.m_program , uint8_t(draw.m_instanceDataStride/16) ); @@ -6304,10 +6304,10 @@ VK_DESTROY if (!isValid(draw.m_indexBuffer) ) { const VertexBufferVK& vertexBuffer = m_vertexBuffers[draw.m_stream[0].m_handle.idx]; - const VertexLayout& vertexDecl = m_vertexDecls[draw.m_stream[0].m_decl.idx]; + const VertexLayout& layout = m_vertexLayouts[draw.m_stream[0].m_layoutHandle.idx]; const uint32_t numVertices = UINT32_MAX == draw.m_numVertices - ? vertexBuffer.m_size / vertexDecl.m_stride + ? vertexBuffer.m_size / layout.m_stride : draw.m_numVertices ; vkCmdDraw(m_commandBuffer diff --git a/src/renderer_vk.h b/src/renderer_vk.h index 36da1e82c..97ee71069 100644 --- a/src/renderer_vk.h +++ b/src/renderer_vk.h @@ -384,9 +384,9 @@ VK_DESTROY struct VertexBufferVK : public BufferVK { - void create(uint32_t _size, void* _data, VertexLayoutHandle _declHandle, uint16_t _flags); + void create(uint32_t _size, void* _data, VertexLayoutHandle _layoutHandle, uint16_t _flags); - VertexLayoutHandle m_decl; + VertexLayoutHandle m_layoutHandle; }; struct ShaderVK diff --git a/src/vertexdecl.cpp b/src/vertexdecl.cpp index b1d4b2fc7..099b4b036 100644 --- a/src/vertexdecl.cpp +++ b/src/vertexdecl.cpp @@ -241,7 +241,7 @@ namespace bgfx return s_attribTypeToId[_attr].id; } - int32_t write(bx::WriterI* _writer, const VertexLayout& _decl, bx::Error* _err) + int32_t write(bx::WriterI* _writer, const VertexLayout& _layout, bx::Error* _err) { BX_ERROR_SCOPE(_err); @@ -250,22 +250,22 @@ namespace bgfx for (uint32_t attr = 0; attr < Attrib::Count; ++attr) { - numAttrs += UINT16_MAX == _decl.m_attributes[attr] ? 0 : 1; + numAttrs += UINT16_MAX == _layout.m_attributes[attr] ? 0 : 1; } total += bx::write(_writer, numAttrs, _err); - total += bx::write(_writer, _decl.m_stride, _err); + total += bx::write(_writer, _layout.m_stride, _err); for (uint32_t attr = 0; attr < Attrib::Count; ++attr) { - if (UINT16_MAX != _decl.m_attributes[attr]) + if (UINT16_MAX != _layout.m_attributes[attr]) { uint8_t num; AttribType::Enum type; bool normalized; bool asInt; - _decl.decode(Attrib::Enum(attr), num, type, normalized, asInt); - total += bx::write(_writer, _decl.m_offset[attr], _err); + _layout.decode(Attrib::Enum(attr), num, type, normalized, asInt); + total += bx::write(_writer, _layout.m_offset[attr], _err); total += bx::write(_writer, s_attribToId[attr].id, _err); total += bx::write(_writer, num, _err); total += bx::write(_writer, s_attribTypeToId[type].id, _err); @@ -277,7 +277,7 @@ namespace bgfx return total; } - int32_t read(bx::ReaderI* _reader, VertexLayout& _decl, bx::Error* _err) + int32_t read(bx::ReaderI* _reader, VertexLayout& _layout, bx::Error* _err) { BX_ERROR_SCOPE(_err); @@ -294,7 +294,7 @@ namespace bgfx return total; } - _decl.begin(); + _layout.begin(); for (uint32_t ii = 0; ii < numAttrs; ++ii) { @@ -326,32 +326,32 @@ namespace bgfx if (Attrib::Count != attr && AttribType::Count != type) { - _decl.add(attr, num, type, normalized, asInt); - _decl.m_offset[attr] = offset; + _layout.add(attr, num, type, normalized, asInt); + _layout.m_offset[attr] = offset; } } - _decl.end(); - _decl.m_stride = stride; + _layout.end(); + _layout.m_stride = stride; return total; } - void vertexPack(const float _input[4], bool _inputNormalized, Attrib::Enum _attr, const VertexLayout& _decl, void* _data, uint32_t _index) + void vertexPack(const float _input[4], bool _inputNormalized, Attrib::Enum _attr, const VertexLayout& _layout, void* _data, uint32_t _index) { - if (!_decl.has(_attr) ) + if (!_layout.has(_attr) ) { return; } - uint32_t stride = _decl.getStride(); - uint8_t* data = (uint8_t*)_data + _index*stride + _decl.getOffset(_attr); + uint32_t stride = _layout.getStride(); + uint8_t* data = (uint8_t*)_data + _index*stride + _layout.getOffset(_attr); uint8_t num; AttribType::Enum type; bool normalized; bool asInt; - _decl.decode(_attr, num, type, normalized, asInt); + _layout.decode(_attr, num, type, normalized, asInt); switch (type) { @@ -493,22 +493,22 @@ namespace bgfx } } - void vertexUnpack(float _output[4], Attrib::Enum _attr, const VertexLayout& _decl, const void* _data, uint32_t _index) + void vertexUnpack(float _output[4], Attrib::Enum _attr, const VertexLayout& _layout, const void* _data, uint32_t _index) { - if (!_decl.has(_attr) ) + if (!_layout.has(_attr) ) { bx::memSet(_output, 0, 4*sizeof(float) ); return; } - uint32_t stride = _decl.getStride(); - uint8_t* data = (uint8_t*)_data + _index*stride + _decl.getOffset(_attr); + uint32_t stride = _layout.getStride(); + uint8_t* data = (uint8_t*)_data + _index*stride + _layout.getOffset(_attr); uint8_t num; AttribType::Enum type; bool normalized; bool asInt; - _decl.decode(_attr, num, type, normalized, asInt); + _layout.decode(_attr, num, type, normalized, asInt); switch (type) { @@ -619,11 +619,11 @@ namespace bgfx } } - void vertexConvert(const VertexLayout& _destDecl, void* _destData, const VertexLayout& _srcDecl, const void* _srcData, uint32_t _num) + void vertexConvert(const VertexLayout& _destLayout, void* _destData, const VertexLayout& _srcLayout, const void* _srcData, uint32_t _num) { - if (_destDecl.m_hash == _srcDecl.m_hash) + if (_destLayout.m_hash == _srcLayout.m_hash) { - bx::memCopy(_destData, _srcData, _srcDecl.getSize(_num) ); + bx::memCopy(_destData, _srcData, _srcLayout.getSize(_num) ); return; } @@ -650,23 +650,23 @@ namespace bgfx { Attrib::Enum attr = (Attrib::Enum)ii; - if (_destDecl.has(attr) ) + if (_destLayout.has(attr) ) { ConvertOp& cop = convertOp[numOps]; cop.attr = attr; - cop.dest = _destDecl.getOffset(attr); + cop.dest = _destLayout.getOffset(attr); uint8_t num; AttribType::Enum type; bool normalized; bool asInt; - _destDecl.decode(attr, num, type, normalized, asInt); + _destLayout.decode(attr, num, type, normalized, asInt); cop.size = (*s_attribTypeSize[0])[type][num-1]; - if (_srcDecl.has(attr) ) + if (_srcLayout.has(attr) ) { - cop.src = _srcDecl.getOffset(attr); - cop.op = _destDecl.m_attributes[attr] == _srcDecl.m_attributes[attr] ? ConvertOp::Copy : ConvertOp::Convert; + cop.src = _srcLayout.getOffset(attr); + cop.op = _destLayout.m_attributes[attr] == _srcLayout.m_attributes[attr] ? ConvertOp::Copy : ConvertOp::Convert; } else { @@ -680,10 +680,10 @@ namespace bgfx if (0 < numOps) { const uint8_t* src = (const uint8_t*)_srcData; - uint32_t srcStride = _srcDecl.getStride(); + uint32_t srcStride = _srcLayout.getStride(); uint8_t* dest = (uint8_t*)_destData; - uint32_t destStride = _destDecl.getStride(); + uint32_t destStride = _destLayout.getStride(); float unpacked[4]; @@ -704,8 +704,8 @@ namespace bgfx break; case ConvertOp::Convert: - vertexUnpack(unpacked, cop.attr, _srcDecl, src); - vertexPack(unpacked, true, cop.attr, _destDecl, dest); + vertexUnpack(unpacked, cop.attr, _srcLayout, src); + vertexPack(unpacked, true, cop.attr, _destLayout, dest); break; } } @@ -724,7 +724,7 @@ namespace bgfx return xx*xx + yy*yy + zz*zz; } - uint16_t weldVerticesRef(uint16_t* _output, const VertexLayout& _decl, const void* _data, uint16_t _num, float _epsilon) + uint16_t weldVerticesRef(uint16_t* _output, const VertexLayout& _layout, const void* _data, uint16_t _num, float _epsilon) { // Brute force slow vertex welding... const float epsilonSq = _epsilon*_epsilon; @@ -743,7 +743,7 @@ namespace bgfx ++numVertices; float pos[4]; - vertexUnpack(pos, Attrib::Position, _decl, _data, ii); + vertexUnpack(pos, Attrib::Position, _layout, _data, ii); for (uint32_t jj = 0; jj < _num; ++jj) { @@ -753,7 +753,7 @@ namespace bgfx } float test[4]; - vertexUnpack(test, Attrib::Position, _decl, _data, jj); + vertexUnpack(test, Attrib::Position, _layout, _data, jj); if (sqLength(test, pos) < epsilonSq) { @@ -765,7 +765,7 @@ namespace bgfx return (uint16_t)numVertices; } - uint16_t weldVertices(uint16_t* _output, const VertexLayout& _decl, const void* _data, uint16_t _num, float _epsilon) + uint16_t weldVertices(uint16_t* _output, const VertexLayout& _layout, const void* _data, uint16_t _num, float _epsilon) { const uint32_t hashSize = bx::uint32_nextpow2(_num); const uint32_t hashMask = hashSize-1; @@ -782,14 +782,14 @@ namespace bgfx for (uint32_t ii = 0; ii < _num; ++ii) { float pos[4]; - vertexUnpack(pos, Attrib::Position, _decl, _data, ii); + vertexUnpack(pos, Attrib::Position, _layout, _data, ii); uint32_t hashValue = bx::hash(pos, 3*sizeof(float) ) & hashMask; uint16_t offset = hashTable[hashValue]; for (; UINT16_MAX != offset; offset = next[offset]) { float test[4]; - vertexUnpack(test, Attrib::Position, _decl, _data, _output[offset]); + vertexUnpack(test, Attrib::Position, _layout, _data, _output[offset]); if (sqLength(test, pos) < epsilonSq) { diff --git a/src/vertexdecl.h b/src/vertexdecl.h index 1ea34bc13..46c656cad 100644 --- a/src/vertexdecl.h +++ b/src/vertexdecl.h @@ -30,10 +30,10 @@ namespace bgfx AttribType::Enum idToAttribType(uint16_t id); /// - int32_t write(bx::WriterI* _writer, const bgfx::VertexLayout& _decl, bx::Error* _err = NULL); + int32_t write(bx::WriterI* _writer, const bgfx::VertexLayout& _layout, bx::Error* _err = NULL); /// - int32_t read(bx::ReaderI* _reader, bgfx::VertexLayout& _decl, bx::Error* _err = NULL); + int32_t read(bx::ReaderI* _reader, bgfx::VertexLayout& _layout, bx::Error* _err = NULL); } // namespace bgfx diff --git a/tools/geometryc/geometryc.cpp b/tools/geometryc/geometryc.cpp index 2d625682e..71eb22547 100644 --- a/tools/geometryc/geometryc.cpp +++ b/tools/geometryc/geometryc.cpp @@ -150,7 +150,7 @@ void writeCompressedVertices(bx::WriterI* _writer, const uint8_t* _vertices, ui free(compressedVertices); } -void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexLayout _decl, const uint16_t* _indices, uint32_t _numIndices) +void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexLayout _layout, const uint16_t* _indices, uint32_t _numIndices) { struct PosTexcoord { @@ -178,14 +178,14 @@ void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexLayout _de uint32_t i1 = indices[1]; uint32_t i2 = indices[2]; - bgfx::vertexUnpack(&v0.m_x, bgfx::Attrib::Position, _decl, _vertices, i0); - bgfx::vertexUnpack(&v0.m_u, bgfx::Attrib::TexCoord0, _decl, _vertices, i0); + bgfx::vertexUnpack(&v0.m_x, bgfx::Attrib::Position, _layout, _vertices, i0); + bgfx::vertexUnpack(&v0.m_u, bgfx::Attrib::TexCoord0, _layout, _vertices, i0); - bgfx::vertexUnpack(&v1.m_x, bgfx::Attrib::Position, _decl, _vertices, i1); - bgfx::vertexUnpack(&v1.m_u, bgfx::Attrib::TexCoord0, _decl, _vertices, i1); + bgfx::vertexUnpack(&v1.m_x, bgfx::Attrib::Position, _layout, _vertices, i1); + bgfx::vertexUnpack(&v1.m_u, bgfx::Attrib::TexCoord0, _layout, _vertices, i1); - bgfx::vertexUnpack(&v2.m_x, bgfx::Attrib::Position, _decl, _vertices, i2); - bgfx::vertexUnpack(&v2.m_u, bgfx::Attrib::TexCoord0, _decl, _vertices, i2); + bgfx::vertexUnpack(&v2.m_x, bgfx::Attrib::Position, _layout, _vertices, i2); + bgfx::vertexUnpack(&v2.m_u, bgfx::Attrib::TexCoord0, _layout, _vertices, i2); const float bax = v1.m_x - v0.m_x; const float bay = v1.m_y - v0.m_y; @@ -230,7 +230,7 @@ void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexLayout _de const bx::Vec3 tanv = bx::load(&tangents[ii*6 + 3]); float nxyzw[4]; - bgfx::vertexUnpack(nxyzw, bgfx::Attrib::Normal, _decl, _vertices, ii); + bgfx::vertexUnpack(nxyzw, bgfx::Attrib::Normal, _layout, _vertices, ii); const bx::Vec3 normal = bx::load(nxyzw); const float ndt = bx::dot(normal, tanu); @@ -241,7 +241,7 @@ void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexLayout _de bx::store(tangent, bx::normalize(tmp) ); tangent[3] = bx::dot(nxt, tanv) < 0.0f ? -1.0f : 1.0f; - bgfx::vertexPack(tangent, true, bgfx::Attrib::Tangent, _decl, _vertices, ii); + bgfx::vertexPack(tangent, true, bgfx::Attrib::Tangent, _layout, _vertices, ii); } delete [] tangents; @@ -276,7 +276,7 @@ void write(bx::WriterI* _writer, const void* _vertices, uint32_t _numVertices, u void write(bx::WriterI* _writer , const uint8_t* _vertices , uint32_t _numVertices - , const bgfx::VertexLayout& _decl + , const bgfx::VertexLayout& _layout , const uint16_t* _indices , uint32_t _numIndices , bool _compress @@ -287,14 +287,14 @@ void write(bx::WriterI* _writer using namespace bx; using namespace bgfx; - uint32_t stride = _decl.getStride(); + uint32_t stride = _layout.getStride(); if (_compress) { write(_writer, BGFX_CHUNK_MAGIC_VBC); write(_writer, _vertices, _numVertices, stride); - write(_writer, _decl); + write(_writer, _layout); write(_writer, uint16_t(_numVertices) ); writeCompressedVertices(_writer, _vertices, _numVertices, uint16_t(stride)); @@ -304,7 +304,7 @@ void write(bx::WriterI* _writer write(_writer, BGFX_CHUNK_MAGIC_VB); write(_writer, _vertices, _numVertices, stride); - write(_writer, _decl); + write(_writer, _layout); write(_writer, uint16_t(_numVertices) ); write(_writer, _vertices, _numVertices*stride); @@ -793,18 +793,18 @@ int main(int _argc, const char* _argv[]) } } - bgfx::VertexLayout decl; - decl.begin(); - decl.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float); + bgfx::VertexLayout layout; + layout.begin(); + layout.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float); if (hasColor) { - decl.add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true); + layout.add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true); } if (hasBc) { - decl.add(bgfx::Attrib::Color1, 4, bgfx::AttribType::Uint8, true); + layout.add(bgfx::Attrib::Color1, 4, bgfx::AttribType::Uint8, true); } if (hasTexcoord) @@ -813,11 +813,11 @@ int main(int _argc, const char* _argv[]) { default: case 0: - decl.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float); + layout.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float); break; case 1: - decl.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Half); + layout.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Half); break; } } @@ -830,26 +830,26 @@ int main(int _argc, const char* _argv[]) { default: case 0: - decl.add(bgfx::Attrib::Normal, 3, bgfx::AttribType::Float); + layout.add(bgfx::Attrib::Normal, 3, bgfx::AttribType::Float); if (hasTangent) { - decl.add(bgfx::Attrib::Tangent, 4, bgfx::AttribType::Float); + layout.add(bgfx::Attrib::Tangent, 4, bgfx::AttribType::Float); } break; case 1: - decl.add(bgfx::Attrib::Normal, 4, bgfx::AttribType::Uint8, true, true); + layout.add(bgfx::Attrib::Normal, 4, bgfx::AttribType::Uint8, true, true); if (hasTangent) { - decl.add(bgfx::Attrib::Tangent, 4, bgfx::AttribType::Uint8, true, true); + layout.add(bgfx::Attrib::Tangent, 4, bgfx::AttribType::Uint8, true, true); } break; } } - decl.end(); + layout.end(); - uint32_t stride = decl.getStride(); + uint32_t stride = layout.getStride(); uint8_t* vertexData = new uint8_t[triangles.size() * 3 * stride]; uint16_t* indexData = new uint16_t[triangles.size() * 3]; int32_t numVertices = 0; @@ -882,8 +882,8 @@ int main(int _argc, const char* _argv[]) prim.m_startVertex = 0; prim.m_startIndex = 0; - uint32_t positionOffset = decl.getOffset(bgfx::Attrib::Position); - uint32_t color0Offset = decl.getOffset(bgfx::Attrib::Color0); + uint32_t positionOffset = layout.getOffset(bgfx::Attrib::Position); + uint32_t color0Offset = layout.getOffset(bgfx::Attrib::Color0); Group sentinelGroup; sentinelGroup.m_startTriangle = 0; @@ -909,7 +909,7 @@ int main(int _argc, const char* _argv[]) if (hasTangent) { - calcTangents(vertexData, uint16_t(numVertices), decl, indexData, numIndices); + calcTangents(vertexData, uint16_t(numVertices), layout, indexData, numIndices); } triReorderElapsed -= bx::getHPCounter(); @@ -925,7 +925,7 @@ int main(int _argc, const char* _argv[]) write(&writer , vertexData , numVertices - , decl + , layout , indexData , numIndices , compress @@ -975,7 +975,7 @@ int main(int _argc, const char* _argv[]) (index.m_vbc == 1) ? 1.0f : 0.0f, (index.m_vbc == 2) ? 1.0f : 0.0f, }; - bgfx::vertexPack(bc, true, bgfx::Attrib::Color1, decl, vertices); + bgfx::vertexPack(bc, true, bgfx::Attrib::Color1, layout, vertices); } if (hasTexcoord) @@ -988,7 +988,7 @@ int main(int _argc, const char* _argv[]) uv[1] = -uv[1]; } - bgfx::vertexPack(uv, true, bgfx::Attrib::TexCoord0, decl, vertices); + bgfx::vertexPack(uv, true, bgfx::Attrib::TexCoord0, layout, vertices); } if (hasNormal) @@ -996,7 +996,7 @@ int main(int _argc, const char* _argv[]) float normal[4]; bx::store(normal, bx::normalize(bx::load(&normals[index.m_normal]) ) ); normal[3] = 0.0f; - bgfx::vertexPack(normal, true, bgfx::Attrib::Normal, decl, vertices); + bgfx::vertexPack(normal, true, bgfx::Attrib::Normal, layout, vertices); } uint32_t hash = bx::hash(vertices, stride); diff --git a/tools/texturev/texturev.cpp b/tools/texturev/texturev.cpp index 67f17cbff..f9cfa4c13 100644 --- a/tools/texturev/texturev.cpp +++ b/tools/texturev/texturev.cpp @@ -888,7 +888,7 @@ struct PosUvwColorVertex static void init() { - ms_decl + ms_layout .begin() .add(bgfx::Attrib::Position, 2, bgfx::AttribType::Float) .add(bgfx::Attrib::TexCoord0, 3, bgfx::AttribType::Float) @@ -906,10 +906,10 @@ struct PosUvwColorVertex m_abgr = _abgr; } - static bgfx::VertexLayout ms_decl; + static bgfx::VertexLayout ms_layout; }; -bgfx::VertexLayout PosUvwColorVertex::ms_decl; +bgfx::VertexLayout PosUvwColorVertex::ms_layout; static uint32_t addQuad(uint16_t* _indices, uint16_t _idx0, uint16_t _idx1, uint16_t _idx2, uint16_t _idx3) { @@ -937,10 +937,10 @@ void setGeometry( { if (Geometry::Quad == _type) { - if (6 == bgfx::getAvailTransientVertexBuffer(6, PosUvwColorVertex::ms_decl) ) + if (6 == bgfx::getAvailTransientVertexBuffer(6, PosUvwColorVertex::ms_layout) ) { bgfx::TransientVertexBuffer vb; - bgfx::allocTransientVertexBuffer(&vb, 6, PosUvwColorVertex::ms_decl); + bgfx::allocTransientVertexBuffer(&vb, 6, PosUvwColorVertex::ms_layout); PosUvwColorVertex* vertex = (PosUvwColorVertex*)vb.data; const float widthf = float(_width); @@ -971,10 +971,10 @@ void setGeometry( { const uint32_t numVertices = 14; const uint32_t numIndices = 36; - if (checkAvailTransientBuffers(numVertices, PosUvwColorVertex::ms_decl, numIndices) ) + if (checkAvailTransientBuffers(numVertices, PosUvwColorVertex::ms_layout, numIndices) ) { bgfx::TransientVertexBuffer tvb; - bgfx::allocTransientVertexBuffer(&tvb, numVertices, PosUvwColorVertex::ms_decl); + bgfx::allocTransientVertexBuffer(&tvb, numVertices, PosUvwColorVertex::ms_layout); bgfx::TransientIndexBuffer tib; bgfx::allocTransientIndexBuffer(&tib, numIndices);