From 8ee74e82600c783dd45f206a2c7491d5f3caef32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 12 Sep 2026 15:43:02 -0700 Subject: [PATCH] Optimized encoder bind state, and uniform updates. (#3976) --- src/bgfx.cpp | 3 +- src/bgfx_p.h | 103 ++++++++++++++++++++++++++++------------ src/renderer_d3d11.cpp | 36 +------------- src/renderer_d3d12.cpp | 35 -------------- src/renderer_gl.cpp | 29 ----------- src/renderer_mtl.cpp | 29 ----------- src/renderer_noop.cpp | 12 ----- src/renderer_vk.cpp | 34 ------------- src/renderer_webgpu.cpp | 35 -------------- 9 files changed, 74 insertions(+), 242 deletions(-) diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 197820bbb..f0ca52f46 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -3071,8 +3071,7 @@ namespace bgfx if (type & kUniformRefBit) { type &= ~kUniformRefBit; - const void* ptr; - bx::memCopy(&ptr, _uniformBuffer->read(sizeof(ptr) ), sizeof(ptr) ); + const void* ptr = bx::loadUnaligned(_uniformBuffer->read(sizeof(ptr) ) ); if (UniformType::Count > type) { _renderCtx->updateUniform(loc, ptr, g_uniformTypeSize[type]*num); diff --git a/src/bgfx_p.h b/src/bgfx_p.h index f0ae31a79..1de93f8fe 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -2267,9 +2267,7 @@ namespace bgfx uint32_t read() { - uint32_t result; - bx::memCopy(&result, read(sizeof(uint32_t) ), sizeof(uint32_t) ); - return result; + return bx::loadUnaligned(read(sizeof(uint32_t) ) ); } bool isEmpty() const @@ -2398,14 +2396,18 @@ namespace bgfx void reset() { - // Zero the whole struct, including any trailing padding, so it hashes and - // compares deterministically when used as a bind-state key. - bx::memSet(this, 0, sizeof(*this) ); m_samplerFlags = BGFX_SAMPLER_NONE; + m_offset = 0; m_size = UINT32_MAX; + m_firstLayer = 0; m_numLayers = UINT16_MAX; - m_idx = kInvalidHandle; - m_numMips = UINT8_MAX; + m_idx = kInvalidHandle; + m_type = 0; + m_format = 0; + m_access = 0; + m_firstMip = 0; + m_numMips = UINT8_MAX; + m_pad = 0; } void setTexture(TextureHandle _handle, uint32_t _samplerFlags, uint8_t _firstMip = 0, uint8_t _numMips = UINT8_MAX) @@ -2498,6 +2500,8 @@ namespace bgfx return kInvalidHandle != m_idx; } + bool operator==(const Binding& _rhs) const = default; + uint32_t m_samplerFlags; uint32_t m_offset; uint32_t m_size; @@ -2595,6 +2599,18 @@ namespace bgfx } }; + void clear(uint8_t _flags, uint32_t _mask) + { + if (0 != (_flags & BGFX_DISCARD_BINDINGS) ) + { + for (BitMaskToIndexIteratorT it(_mask); !it.isDone(); it.next() ) + { + Binding& bind = m_bind[it.idx]; + bind.reset(); + } + } + }; + Binding m_bind[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS]; }; @@ -3889,6 +3905,7 @@ namespace bgfx m_draw.clear(BGFX_DISCARD_ALL); m_compute.clear(BGFX_DISCARD_ALL); m_bind.clear(BGFX_DISCARD_ALL); + m_bindMask = 0; } void begin(Frame* _frame, uint8_t _idx) @@ -3985,10 +4002,12 @@ namespace bgfx void clearBind(uint8_t _flags) { - m_bind.clear(_flags); + m_bind.clear(_flags, m_bindMask); if (0 != (_flags & BGFX_DISCARD_BINDINGS) ) { + m_bindMask = 0; + if (UINT32_MAX == m_bindEmptyIdx) { m_bindEmptyIdx = bindStateIndex(); @@ -4275,10 +4294,11 @@ namespace bgfx void setBind(uint8_t _stage, const Binding& _bind) { Binding& dst = m_bind.m_bind[_stage]; - if (0 != bx::memCmp(&dst, &_bind, sizeof(Binding) ) ) + if (dst != _bind) { dst = _bind; - m_bindDirty = true; + m_bindDirty = true; + m_bindMask |= UINT32_C(1)<<_stage; } } @@ -4425,6 +4445,7 @@ namespace bgfx BindHashMap m_bindHashMap; uint32_t m_bindLlastIdx; uint32_t m_bindEmptyIdx; + uint32_t m_bindMask; bool m_bindDirty; int64_t m_cpuTimeBegin; @@ -5028,6 +5049,11 @@ namespace bgfx struct BX_NO_VTABLE RendererContextI { + RendererContextI() + { + bx::memSet(m_uniforms, 0, sizeof(m_uniforms) ); + } + virtual ~RendererContextI() = 0; virtual RendererType::Enum getRendererType() const = 0; virtual const char* getRendererName() const = 0; @@ -5058,23 +5084,7 @@ namespace bgfx virtual uintptr_t getInternal(TextureHandle _handle) = 0; virtual void destroyTexture(TextureHandle _handle) = 0; virtual void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const Attachment* _attachment) = 0; - virtual void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _format, TextureFormat::Enum _depthFormat) - { - BX_UNUSED(_handle, _nwh, _width, _height, _format, _depthFormat); - BX_ASSERT(false, "Not implemented!"); - } - - virtual void createFrameBuffer(FrameBufferHandle _handle, const SwapChain& _desc) - { - createFrameBuffer( - _handle - , _desc.nwh - , _desc.width - , _desc.height - , _desc.formatColor - , _desc.formatDepthStencil - ); - } + virtual void createFrameBuffer(FrameBufferHandle _handle, const SwapChain& _desc) = 0; virtual void resizeFrameBuffer(FrameBufferHandle _handle, const SwapChain& _desc) { @@ -5083,11 +5093,8 @@ namespace bgfx } virtual void destroyFrameBuffer(FrameBufferHandle _handle) = 0; - virtual void createUniform(UniformHandle _handle, UniformType::Enum _type, uint16_t _num, const char* _name) = 0; - virtual void destroyUniform(UniformHandle _handle) = 0; virtual void requestScreenShot(FrameBufferHandle _handle, const char* _filePath) = 0; virtual void updateViewName(ViewId _id, const char* _name) = 0; - virtual void updateUniform(uint16_t _loc, const void* _data, uint32_t _size) = 0; virtual void invalidateOcclusionQuery(OcclusionQueryHandle _handle) = 0; virtual void setMarker(const char* _name, uint16_t _len) = 0; virtual void setName(Handle _handle, const char* _name, uint16_t _len) = 0; @@ -5095,10 +5102,44 @@ namespace bgfx virtual void dbgTextRenderBegin(TextVideoMemBlitter& _blitter, FrameBufferHandle _handle) = 0; virtual void dbgTextRender(TextVideoMemBlitter& _blitter, uint32_t _numIndices) = 0; virtual void dbgTextRenderEnd(TextVideoMemBlitter& _blitter) = 0; + + void createUniform(UniformHandle _handle, UniformType::Enum _type, uint16_t _num, const char* _name) + { + if (NULL != m_uniforms[_handle.idx]) + { + bx::free(g_allocator, m_uniforms[_handle.idx]); + } + + const uint32_t size = bx::alignUp(g_uniformTypeSize[_type]*_num, 16); + void* data = bx::alloc(g_allocator, size); + bx::memSet(data, 0, size); + m_uniforms[_handle.idx] = data; + m_uniformReg.add(_handle, _name); + } + + void destroyUniform(UniformHandle _handle) + { + bx::free(g_allocator, m_uniforms[_handle.idx]); + m_uniforms[_handle.idx] = NULL; + m_uniformReg.remove(_handle); + } + + void updateUniform(uint16_t _loc, const void* _data, uint32_t _size) + { + bx::memCopy(m_uniforms[_loc], _data, _size); + } + + UniformRegistry m_uniformReg; + void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS]; }; inline RendererContextI::~RendererContextI() { + for (uint32_t ii = 0; ii < BX_COUNTOF(m_uniforms); ++ii) + { + bx::free(g_allocator, m_uniforms[ii]); + m_uniforms[ii] = NULL; + } } void rendererUpdateUniforms(RendererContextI* _renderCtx, UniformBuffer* _uniformBuffer, uint32_t _begin, uint32_t _end); diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 254fa584e..3e8aa8b1b 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -852,7 +852,6 @@ namespace bgfx { namespace d3d11 } m_fbh = BGFX_INVALID_HANDLE; - bx::memSet(m_uniforms, 0, sizeof(m_uniforms) ); bx::memSet(&m_mainSwapChain, 0, sizeof(m_mainSwapChain) ); m_ags = NULL; @@ -1760,12 +1759,6 @@ namespace bgfx { namespace d3d11 m_textures[ii].destroy(); } - for (uint32_t ii = 0; ii < BX_COUNTOF(m_uniforms); ++ii) - { - bx::free(g_allocator, m_uniforms[ii]); - m_uniforms[ii] = NULL; - } - DX_RELEASE(m_annotation, 1); dumpInfoQueue(); DX_RELEASE_W(m_infoQueue, 0); @@ -2083,27 +2076,6 @@ namespace bgfx { namespace d3d11 } } - void createUniform(UniformHandle _handle, UniformType::Enum _type, uint16_t _num, const char* _name) override - { - if (NULL != m_uniforms[_handle.idx]) - { - bx::free(g_allocator, m_uniforms[_handle.idx]); - } - - const uint32_t size = bx::alignUp(g_uniformTypeSize[_type]*_num, 16); - void* data = bx::alloc(g_allocator, size); - bx::memSet(data, 0, size); - m_uniforms[_handle.idx] = data; - m_uniformReg.add(_handle, _name); - } - - void destroyUniform(UniformHandle _handle) override - { - bx::free(g_allocator, m_uniforms[_handle.idx]); - m_uniforms[_handle.idx] = NULL; - m_uniformReg.remove(_handle); - } - void requestScreenShot(FrameBufferHandle _handle, const char* _filePath) override { FrameBufferD3D11& frameBuffer = getFrameBuffer(_handle); @@ -2223,11 +2195,6 @@ namespace bgfx { namespace d3d11 ); } - void updateUniform(uint16_t _loc, const void* _data, uint32_t _size) override - { - bx::memCopy(m_uniforms[_loc], _data, _size); - } - void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override { m_occlusionQuery.invalidate(_handle); @@ -3997,9 +3964,8 @@ namespace bgfx { namespace d3d11 ProgramD3D11 m_program[BGFX_CONFIG_MAX_PROGRAMS]; TextureD3D11 m_textures[BGFX_CONFIG_MAX_TEXTURES]; VertexLayout m_vertexLayouts[BGFX_CONFIG_MAX_VERTEX_LAYOUTS]; - FrameBufferD3D11 m_frameBuffers[BGFX_CONFIG_MAX_FRAME_BUFFERS+1]; void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS]; + FrameBufferD3D11 m_frameBuffers[BGFX_CONFIG_MAX_FRAME_BUFFERS+1]; Matrix4 m_predefinedUniforms[PredefinedUniform::Count]; - UniformRegistry m_uniformReg; StateCacheT m_blendStateCache; StateCacheT m_depthStencilStateCache; diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index a85e118a3..f32f16062 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -944,7 +944,6 @@ namespace bgfx { namespace d3d12 ); m_fbh = BGFX_INVALID_HANDLE; - bx::memSet(m_uniforms, 0, sizeof(m_uniforms) ); bx::memSet(&m_mainSwapChain, 0, sizeof(m_mainSwapChain) ); #if USE_D3D12_DYNAMIC_LIB @@ -2162,12 +2161,6 @@ namespace bgfx { namespace d3d12 m_textures[ii].destroy(); } - for (uint32_t ii = 0; ii < BX_COUNTOF(m_uniforms); ++ii) - { - bx::free(g_allocator, m_uniforms[ii]); - m_uniforms[ii] = NULL; - } - #if BX_PLATFORM_WINDOWS dumpInfoQueue(); DX_RELEASE_W(m_infoQueue, 0); @@ -2831,27 +2824,6 @@ namespace bgfx { namespace d3d12 } } - void createUniform(UniformHandle _handle, UniformType::Enum _type, uint16_t _num, const char* _name) override - { - if (NULL != m_uniforms[_handle.idx]) - { - bx::free(g_allocator, m_uniforms[_handle.idx]); - } - - const uint32_t size = bx::alignUp(g_uniformTypeSize[_type] * _num, 16); - void* data = bx::alloc(g_allocator, size); - bx::memSet(data, 0, size); - m_uniforms[_handle.idx] = data; - m_uniformReg.add(_handle, _name); - } - - void destroyUniform(UniformHandle _handle) override - { - bx::free(g_allocator, m_uniforms[_handle.idx]); - m_uniforms[_handle.idx] = NULL; - m_uniformReg.remove(_handle); - } - void requestScreenShot(FrameBufferHandle _handle, const char* _filePath) override { FrameBufferD3D12* swapFb = NULL; @@ -2977,11 +2949,6 @@ namespace bgfx { namespace d3d12 ); } - void updateUniform(uint16_t _loc, const void* _data, uint32_t _size) override - { - bx::memCopy(m_uniforms[_loc], _data, _size); - } - void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override { m_occlusionQuery.invalidate(_handle); @@ -4528,9 +4495,7 @@ namespace bgfx { namespace d3d12 TextureD3D12 m_textures[BGFX_CONFIG_MAX_TEXTURES]; VertexLayout m_vertexLayouts[BGFX_CONFIG_MAX_VERTEX_LAYOUTS]; FrameBufferD3D12 m_frameBuffers[BGFX_CONFIG_MAX_FRAME_BUFFERS+1]; - void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS]; Matrix4 m_predefinedUniforms[PredefinedUniform::Count]; - UniformRegistry m_uniformReg; StateCacheT m_pipelineStateCache; diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index d913e7552..21a7ce016 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -2297,7 +2297,6 @@ namespace bgfx { namespace gl } m_fbh = BGFX_INVALID_HANDLE; - bx::memSet(m_uniforms, 0, sizeof(m_uniforms) ); bx::memSet(&m_mainSwapChain, 0, sizeof(m_mainSwapChain) ); m_reset = _init.reset & ~BGFX_RESET_INTERNAL_FORCE; @@ -3711,27 +3710,6 @@ namespace bgfx { namespace gl } } - void createUniform(UniformHandle _handle, UniformType::Enum _type, uint16_t _num, const char* _name) override - { - if (NULL != m_uniforms[_handle.idx]) - { - bx::free(g_allocator, m_uniforms[_handle.idx]); - } - - const uint32_t size = bx::alignUp(g_uniformTypeSize[_type]*_num, 16); - void* data = bx::alloc(g_allocator, size); - bx::memSet(data, 0, size); - m_uniforms[_handle.idx] = data; - m_uniformReg.add(_handle, _name); - } - - void destroyUniform(UniformHandle _handle) override - { - bx::free(g_allocator, m_uniforms[_handle.idx]); - m_uniforms[_handle.idx] = NULL; - m_uniformReg.remove(_handle); - } - void requestScreenShot(FrameBufferHandle _handle, const char* _filePath) override { SwapChainGL* swapChain = NULL; @@ -3814,11 +3792,6 @@ namespace bgfx { namespace gl ); } - void updateUniform(uint16_t _loc, const void* _data, uint32_t _size) override - { - bx::memCopy(m_uniforms[_loc], _data, _size); - } - void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override { m_occlusionQuery.invalidate(_handle); @@ -5166,8 +5139,6 @@ namespace bgfx { namespace gl TextureGL m_textures[BGFX_CONFIG_MAX_TEXTURES]; 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]; TimerQueryGL m_gpuTimer; OcclusionQueryGL m_occlusionQuery; diff --git a/src/renderer_mtl.cpp b/src/renderer_mtl.cpp index 312d42962..f758e733b 100644 --- a/src/renderer_mtl.cpp +++ b/src/renderer_mtl.cpp @@ -919,7 +919,6 @@ static_assert(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNames CHECK_FEATURE_AVAILABLE(m_hasMaximumDrawableCount, iOS 11.2, macOS 10.13.2, macCatalyst 13.1, tvOS 11.2, VISION_OS_MINIMUM *); m_fbh = BGFX_INVALID_HANDLE; - bx::memSet(m_uniforms, 0, sizeof(m_uniforms) ); m_mainSwapChain = _init.swapChain; m_device = (MTL::Device*)g_platformData.context; @@ -1802,27 +1801,6 @@ static_assert(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNames } } - void createUniform(UniformHandle _handle, UniformType::Enum _type, uint16_t _num, const char* _name) override - { - if (NULL != m_uniforms[_handle.idx]) - { - bx::free(g_allocator, m_uniforms[_handle.idx]); - } - - const uint32_t size = bx::alignUp(g_uniformTypeSize[_type]*_num, 16); - void* data = bx::alloc(g_allocator, size); - bx::memSet(data, 0, size); - m_uniforms[_handle.idx] = data; - m_uniformReg.add(_handle, _name); - } - - void destroyUniform(UniformHandle _handle) override - { - bx::free(g_allocator, m_uniforms[_handle.idx]); - m_uniforms[_handle.idx] = NULL; - m_uniformReg.remove(_handle); - } - FrameBufferMtl& getFrameBuffer(FrameBufferHandle _fbh) { return isValid(_fbh) @@ -1894,11 +1872,6 @@ static_assert(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNames ); } - void updateUniform(uint16_t _loc, const void* _data, uint32_t _size) override - { - bx::memCopy(m_uniforms[_loc], _data, _size); - } - void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override { m_occlusionQuery.invalidate(_handle); @@ -3674,8 +3647,6 @@ static_assert(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNames FrameBufferMtl m_mainFrameBuffer; FrameBufferMtl m_frameBuffers[BGFX_CONFIG_MAX_FRAME_BUFFERS]; VertexLayout m_vertexLayouts[BGFX_CONFIG_MAX_VERTEX_LAYOUTS]; - UniformRegistry m_uniformReg; - void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS]; struct PipelineProgram { diff --git a/src/renderer_noop.cpp b/src/renderer_noop.cpp index 6d3669082..70f0f334e 100644 --- a/src/renderer_noop.cpp +++ b/src/renderer_noop.cpp @@ -198,14 +198,6 @@ namespace bgfx { namespace noop { } - void createUniform(UniformHandle /*_handle*/, UniformType::Enum /*_type*/, uint16_t /*_num*/, const char* /*_name*/) override - { - } - - void destroyUniform(UniformHandle /*_handle*/) override - { - } - void requestScreenShot(FrameBufferHandle /*_handle*/, const char* /*_filePath*/) override { } @@ -214,10 +206,6 @@ namespace bgfx { namespace noop { } - void updateUniform(uint16_t /*_loc*/, const void* /*_data*/, uint32_t /*_size*/) override - { - } - void invalidateOcclusionQuery(OcclusionQueryHandle /*_handle*/) override { } diff --git a/src/renderer_vk.cpp b/src/renderer_vk.cpp index 23ba5ef2e..4128fd68b 100644 --- a/src/renderer_vk.cpp +++ b/src/renderer_vk.cpp @@ -1317,7 +1317,6 @@ VK_IMPORT_DEVICE VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT swapchainMaintenance1Features = {}; m_fbh = BGFX_INVALID_HANDLE; - bx::memSet(m_uniforms, 0, sizeof(m_uniforms) ); bx::memSet(&m_mainSwapChain, 0, sizeof(m_mainSwapChain) ); bool imported = true; @@ -2540,12 +2539,6 @@ VK_IMPORT_DEVICE m_textures[ii].destroy(); } - for (uint32_t ii = 0; ii < BX_COUNTOF(m_uniforms); ++ii) - { - bx::free(g_allocator, m_uniforms[ii]); - m_uniforms[ii] = NULL; - } - m_backBuffer.destroy(); m_cmd.shutdown(); @@ -2897,26 +2890,6 @@ VK_IMPORT_DEVICE } } - void createUniform(UniformHandle _handle, UniformType::Enum _type, uint16_t _num, const char* _name) override - { - if (NULL != m_uniforms[_handle.idx]) - { - bx::free(g_allocator, m_uniforms[_handle.idx]); - } - - const uint32_t size = bx::alignUp(g_uniformTypeSize[_type] * _num, 16); - void* data = bx::alloc(g_allocator, size); - bx::memSet(data, 0, size); - m_uniforms[_handle.idx] = data; - m_uniformReg.add(_handle, _name); - } - - void destroyUniform(UniformHandle _handle) override - { - bx::free(g_allocator, m_uniforms[_handle.idx]); - m_uniforms[_handle.idx] = NULL; - } - void requestScreenShot(FrameBufferHandle _fbh, const char* _filePath) override { FrameBufferVK& frameBuffer = getFrameBuffer(_fbh); @@ -2966,11 +2939,6 @@ VK_IMPORT_DEVICE ); } - void updateUniform(uint16_t _loc, const void* _data, uint32_t _size) override - { - bx::memCopy(m_uniforms[_loc], _data, _size); - } - void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override { m_occlusionQuery.invalidate(_handle); @@ -5240,9 +5208,7 @@ VK_IMPORT_DEVICE 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]; - UniformRegistry m_uniformReg; StateCacheT m_pipelineStateCache; StateCacheT m_descriptorSetLayoutCache; diff --git a/src/renderer_webgpu.cpp b/src/renderer_webgpu.cpp index f7ace0d84..4bb23f4d4 100644 --- a/src/renderer_webgpu.cpp +++ b/src/renderer_webgpu.cpp @@ -1004,7 +1004,6 @@ WGPU_IMPORT ErrorState::Enum errorState = ErrorState::Default; // m_fbh = BGFX_INVALID_HANDLE; - bx::memSet(m_uniforms, 0, sizeof(m_uniforms) ); bx::memSet(&m_mainSwapChain, 0, sizeof(m_mainSwapChain) ); if (_init.debug @@ -1616,12 +1615,6 @@ WGPU_IMPORT m_textures[ii].destroy(); } - for (uint32_t ii = 0; ii < BX_COUNTOF(m_uniforms); ++ii) - { - bx::free(g_allocator, m_uniforms[ii]); - m_uniforms[ii] = NULL; - } - m_backBuffer.destroy(); m_gpuTimer.shutdown(); @@ -2196,27 +2189,6 @@ WGPU_IMPORT } } - void createUniform(UniformHandle _handle, UniformType::Enum _type, uint16_t _num, const char* _name) override - { - if (NULL != m_uniforms[_handle.idx]) - { - bx::free(g_allocator, m_uniforms[_handle.idx]); - } - - const uint32_t size = bx::alignUp(g_uniformTypeSize[_type]*_num, 16); - void* data = bx::alloc(g_allocator, size); - bx::memSet(data, 0, size); - m_uniforms[_handle.idx] = data; - m_uniformReg.add(_handle, _name); - } - - void destroyUniform(UniformHandle _handle) override - { - bx::free(g_allocator, m_uniforms[_handle.idx]); - m_uniforms[_handle.idx] = NULL; - m_uniformReg.remove(_handle); - } - FrameBufferWGPU& getFrameBuffer(FrameBufferHandle _fbh) { return isValid(_fbh) @@ -2359,11 +2331,6 @@ WGPU_IMPORT ); } - void updateUniform(uint16_t _loc, const void* _data, uint32_t _size) override - { - bx::memCopy(m_uniforms[_loc], _data, _size); - } - void invalidateOcclusionQuery(OcclusionQueryHandle _handle) override { m_occlusionQuery.invalidate(_handle); @@ -3959,9 +3926,7 @@ WGPU_IMPORT typedef stl::unordered_map BindGroupMap; BindGroupMap m_bindGroupMap; - void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS]; Matrix4 m_predefinedUniforms[PredefinedUniform::Count]; - UniformRegistry m_uniformReg; FrameBufferWGPU m_backBuffer;