Reduce default footprint: optional debug text, drop unused shader copies. (#3938)

This commit is contained in:
Branimir Karadžić
2026-08-29 22:32:32 -07:00
committed by GitHub
parent 4b4c138fb0
commit c949b911fc
16 changed files with 153 additions and 101 deletions
+6 -4
View File
@@ -1831,10 +1831,12 @@ struct InitLimits
// `Stats::numDrawCallsPeak` to size it.
uint numDrawCalls;
// Number of frames the draw-call peak (high-water mark) is observed
// before unused storage is released. Set to 0 to keep whatever has
// been allocated for the lifetime of the context. With
// `BGFX_CONFIG_DYNAMIC_FRAME_STORAGE` disabled nothing per frame is
// resized at all, and this only releases unused uniform buffer space.
// before unused storage is released. Also used for resource command
// buffers and uniform buffers. Set to 0 to keep whatever has been
// allocated for the lifetime of the context. With
// `BGFX_CONFIG_DYNAMIC_FRAME_STORAGE` disabled draw/blit/rect storage
// is not resized; unused uniform and resource command buffer space
// is still released.
uint numDrawCallPeakFrames;
// Minimum resource command buffer size.
uint minResourceCbSize;
+6 -4
View File
@@ -1295,10 +1295,12 @@ extern(C++, "bgfx") struct Init{
/**
Number of frames the draw-call peak (high-water mark) is observed
before unused storage is released. Set to 0 to keep whatever has
been allocated for the lifetime of the context. With
`BGFX_CONFIG_DYNAMIC_FRAME_STORAGE` disabled nothing per frame is
resized at all, and this only releases unused uniform buffer space.
before unused storage is released. Also used for resource command
buffers and uniform buffers. Set to 0 to keep whatever has been
allocated for the lifetime of the context. With
`BGFX_CONFIG_DYNAMIC_FRAME_STORAGE` disabled draw/blit/rect storage
is not resized; unused uniform and resource command buffer space
is still released.
*/
uint numDrawCallPeakFrames;
uint minResourceCBSize; ///Minimum resource command buffer size.
+6 -4
View File
@@ -1371,10 +1371,12 @@ class InitLimits(ctypes.Structure):
# `Stats::numDrawCallsPeak` to size it.
numDrawCalls: int
# Number of frames the draw-call peak (high-water mark) is observed
# before unused storage is released. Set to 0 to keep whatever has
# been allocated for the lifetime of the context. With
# `BGFX_CONFIG_DYNAMIC_FRAME_STORAGE` disabled nothing per frame is
# resized at all, and this only releases unused uniform buffer space.
# before unused storage is released. Also used for resource command
# buffers and uniform buffers. Set to 0 to keep whatever has been
# allocated for the lifetime of the context. With
# `BGFX_CONFIG_DYNAMIC_FRAME_STORAGE` disabled draw/blit/rect storage
# is not resized; unused uniform and resource command buffer space
# is still released.
numDrawCallPeakFrames: int
# Minimum resource command buffer size.
minResourceCbSize: int
+1 -3
View File
@@ -226,7 +226,7 @@ Buffer sizes
``BGFX_CONFIG_MAX_TRANSIENT_INDEX_BUFFER_SIZE`` - Maximum transient index buffer size. There is no growth; all transient indices must fit into this buffer. Default is 2 MB.
``BGFX_CONFIG_MIN_RESOURCE_COMMAND_BUFFER_SIZE`` - Minimum initial size of the resource command buffer (pre/post render commands for resource creation and updates). Default is 64 KB. The buffer grows as needed.
``BGFX_CONFIG_MIN_RESOURCE_COMMAND_BUFFER_SIZE`` - Minimum initial size of the resource command buffer (pre/post render commands for resource creation and updates). Default is 64 KB. The buffer grows as needed. After ``Init::Limits::numDrawCallPeakFrames`` (default 60) of observing the high-water mark it shrinks toward that peak, but not below this minimum. Set ``numDrawCallPeakFrames`` to 0 to keep the largest size for the lifetime of the context.
``BGFX_CONFIG_MIN_UNIFORM_BUFFER_SIZE`` - Minimum initial size in bytes of the per-encoder uniform buffer. Default is 128 KB. This buffer will resize on demand. Must be larger than ``BGFX_CONFIG_UNIFORM_BUFFER_RESIZE_THRESHOLD_SIZE``, otherwise the buffer resizes on first use.
@@ -284,8 +284,6 @@ Debugging and profiling
Miscellaneous
^^^^^^^^^^^^^
``BGFX_CONFIG_USE_TINYSTL`` - Enable use of tinystl instead of std containers for internal data structures. Default is 1. Reduces binary size and avoids std library dependency.
``BGFX_CONFIG_MIP_LOD_BIAS`` - Global MIP level-of-detail bias applied to all texture sampling. Default is 0. Positive values select coarser MIP levels, negative values select finer MIP levels.
``BGFX_CONFIG_DRAW_INDIRECT_STRIDE`` - Stride in bytes of each draw indirect command. Fixed at 32 bytes. Not configurable.
+6 -4
View File
@@ -754,10 +754,12 @@ namespace bgfx
/// back; submissions past it are dropped. See
/// `Stats::numDrawCallsPeak` to size it.
uint32_t numDrawCallPeakFrames; //!< Number of frames the draw-call peak (high-water mark) is observed
/// before unused storage is released. Set to 0 to keep whatever has
/// been allocated for the lifetime of the context. With
/// `BGFX_CONFIG_DYNAMIC_FRAME_STORAGE` disabled nothing per frame is
/// resized at all, and this only releases unused uniform buffer space.
/// before unused storage is released. Also used for resource command
/// buffers and uniform buffers. Set to 0 to keep whatever has been
/// allocated for the lifetime of the context. With
/// `BGFX_CONFIG_DYNAMIC_FRAME_STORAGE` disabled draw/blit/rect storage
/// is not resized; unused uniform and resource command buffer space
/// is still released.
uint32_t minResourceCbSize; //!< Minimum resource command buffer size.
uint32_t maxTransientVbSize; //!< Maximum transient vertex buffer size.
uint32_t maxTransientIbSize; //!< Maximum transient index buffer size.
+6 -4
View File
@@ -847,10 +847,12 @@ typedef struct bgfx_init_limits_s
/**
* Number of frames the draw-call peak (high-water mark) is observed
* before unused storage is released. Set to 0 to keep whatever has
* been allocated for the lifetime of the context. With
* `BGFX_CONFIG_DYNAMIC_FRAME_STORAGE` disabled nothing per frame is
* resized at all, and this only releases unused uniform buffer space.
* before unused storage is released. Also used for resource command
* buffers and uniform buffers. Set to 0 to keep whatever has been
* allocated for the lifetime of the context. With
* `BGFX_CONFIG_DYNAMIC_FRAME_STORAGE` disabled draw/blit/rect storage
* is not resized; unused uniform and resource command buffer space
* is still released.
*/
uint32_t numDrawCallPeakFrames;
uint32_t minResourceCbSize; /** Minimum resource command buffer size. */
+6 -4
View File
@@ -923,10 +923,12 @@ struct.Limits { ctor, namespace = "Init" }
--- back; submissions past it are dropped. See
--- `Stats::numDrawCallsPeak` to size it.
.numDrawCallPeakFrames "uint32_t" --- Number of frames the draw-call peak (high-water mark) is observed
--- before unused storage is released. Set to 0 to keep whatever has
--- been allocated for the lifetime of the context. With
--- `BGFX_CONFIG_DYNAMIC_FRAME_STORAGE` disabled nothing per frame is
--- resized at all, and this only releases unused uniform buffer space.
--- before unused storage is released. Also used for resource command
--- buffers and uniform buffers. Set to 0 to keep whatever has been
--- allocated for the lifetime of the context. With
--- `BGFX_CONFIG_DYNAMIC_FRAME_STORAGE` disabled draw/blit/rect storage
--- is not resized; unused uniform and resource command buffer space
--- is still released.
.minResourceCbSize "uint32_t" --- Minimum resource command buffer size.
.maxTransientVbSize "uint32_t" --- Maximum transient vertex buffer size.
.maxTransientIbSize "uint32_t" --- Maximum transient index buffer size.
+29 -8
View File
@@ -55,7 +55,6 @@ namespace bgfx
, _msg " Use bgfx::getCaps to check " #_caps " backend renderer capabilities." \
);
#if BGFX_CONFIG_USE_TINYSTL
void* TinyStlAllocator::static_allocate(size_t _bytes)
{
return bx::alloc(g_allocator, _bytes);
@@ -68,7 +67,6 @@ namespace bgfx
bx::free(g_allocator, _ptr);
}
}
#endif // BGFX_CONFIG_USE_TINYSTL
struct Superluminal
{
@@ -569,8 +567,10 @@ namespace bgfx
va_end(argList);
}
#if BGFX_CONFIG_DEBUG_TEXT
#include "vs_debugfont.bin.h"
#include "fs_debugfont.bin.h"
#endif // BGFX_CONFIG_DEBUG_TEXT
#include "vs_clear.bin.h"
#include "fs_clear0.bin.h"
#include "fs_clear1.bin.h"
@@ -599,8 +599,10 @@ namespace bgfx
static const EmbeddedShader s_embeddedShaders[] =
{
#if BGFX_CONFIG_DEBUG_TEXT
BGFX_EMBEDDED_SHADER(vs_debugfont),
BGFX_EMBEDDED_SHADER(fs_debugfont),
#endif // BGFX_CONFIG_DEBUG_TEXT
BGFX_EMBEDDED_SHADER(vs_clear),
BGFX_EMBEDDED_SHADER(fs_clear0),
BGFX_EMBEDDED_SHADER(fs_clear1),
@@ -691,6 +693,7 @@ namespace bgfx
}
}
#if BGFX_CONFIG_DEBUG_TEXT
#include "charset.h"
void charsetFillTexture(const uint8_t* _charset, uint8_t* _rgba, uint32_t _height, uint32_t _pitch, uint32_t _bpp)
@@ -710,6 +713,7 @@ namespace bgfx
}
}
}
#endif // BGFX_CONFIG_DEBUG_TEXT
static uint8_t parseAttrTo(char*& _ptr, char _to, uint8_t _default)
{
@@ -787,6 +791,7 @@ namespace bgfx
}
}
#if BGFX_CONFIG_DEBUG_TEXT
static constexpr uint32_t kNumCharsPerBatch = 1024;
static constexpr uint32_t kNumBatchVertices = kNumCharsPerBatch*4;
static constexpr uint32_t kNumBatchIndices = kNumCharsPerBatch*6;
@@ -990,6 +995,19 @@ namespace bgfx
_renderCtx->dbgTextRenderEnd(_blitter);
}
#else
void TextVideoMemBlitter::init(uint8_t /*_scale*/)
{
}
void TextVideoMemBlitter::shutdown()
{
}
void dbgTextSubmit(RendererContextI* /*_renderCtx*/, TextVideoMemBlitter& /*_blitter*/, const TextVideoMem& /*_mem*/)
{
}
#endif // BGFX_CONFIG_DEBUG_TEXT
void ClearQuad::init()
{
@@ -1838,7 +1856,7 @@ namespace bgfx
BGFX_PROFILER_SCOPE("bgfx/DedupBind", kColorSubmit);
Context::BindHashMap& bindHashMap = s_ctx->m_renderBindHashMap;
bindHashMap.clear();
bindHashMap.reset();
RenderItemCount* remap = s_ctx->m_tempValues;
@@ -2959,11 +2977,14 @@ namespace bgfx
bx::memSet(m_seq, 0, sizeof(m_seq) );
m_submit->m_textVideoMem->resize(
m_render->m_textVideoMem->m_small
, m_init.resolution.width
, m_init.resolution.height
);
if (BX_ENABLED(BGFX_CONFIG_DEBUG_TEXT) )
{
m_submit->m_textVideoMem->resize(
m_render->m_textVideoMem->m_small
, m_init.resolution.width
, m_init.resolution.height
);
}
const int64_t now = bx::getHPCounter();
m_submit->m_perfStats.cpuTimeFrame = now - m_frameTimeLast;
+55 -32
View File
@@ -154,7 +154,6 @@ namespace bgfx
| BGFX_CLEAR_COLOR_USE_PALETTE \
)
#if BGFX_CONFIG_USE_TINYSTL
namespace bgfx
{
struct TinyStlAllocator
@@ -163,11 +162,11 @@ namespace bgfx
static void static_deallocate(void* _ptr, size_t /*_bytes*/);
};
} // namespace bgfx
# define TINYSTL_ALLOCATOR bgfx::TinyStlAllocator
# include <tinystl/string.h>
# include <tinystl/unordered_map.h>
# include <tinystl/unordered_set.h>
# include <tinystl/vector.h>
#define TINYSTL_ALLOCATOR bgfx::TinyStlAllocator
#include <tinystl/string.h>
#include <tinystl/unordered_map.h>
#include <tinystl/unordered_set.h>
#include <tinystl/vector.h>
namespace tinystl
{
@@ -202,14 +201,6 @@ namespace tinystl
} // namespace tinystl
namespace stl = tinystl;
#else
# include <list>
# include <string>
# include <unordered_map>
# include <unordered_set>
# include <vector>
namespace stl = std;
#endif // BGFX_CONFIG_USE_TINYSTL
#if BX_PLATFORM_ANDROID
# include <android/native_window.h>
@@ -852,7 +843,10 @@ namespace bgfx
inline void dbgTextSubmit(RendererContextI* _renderCtx, TextVideoMemBlitter& _blitter, const TextVideoMem* _mem)
{
dbgTextSubmit(_renderCtx, _blitter, *_mem);
if (NULL != _mem)
{
dbgTextSubmit(_renderCtx, _blitter, *_mem);
}
}
template <uint32_t maxKeys>
@@ -1073,6 +1067,7 @@ namespace bgfx
, m_pos(0)
, m_size(0)
, m_minCapacity(0)
, m_peak(0)
{
resize();
finish();
@@ -1222,13 +1217,20 @@ namespace bgfx
uint8_t cmd = End;
write(cmd);
m_size = m_pos;
m_peak = bx::max(m_peak, m_pos);
m_pos = 0;
}
if (m_size < m_minCapacity
&& m_capacity != m_minCapacity)
void shrink()
{
const uint32_t keep = bx::alignUp(bx::max(m_peak, m_minCapacity), 1024);
if (keep < m_capacity)
{
resize();
resize(keep);
}
m_peak = 0;
}
uint8_t* m_buffer;
@@ -1236,6 +1238,7 @@ namespace bgfx
uint32_t m_size;
uint32_t m_capacity;
uint32_t m_minCapacity;
uint32_t m_peak;
};
//
@@ -3226,6 +3229,8 @@ namespace bgfx
m_renderBind.shrink(keep);
m_blitItem.shrink(m_peakBlit + 1 + kBlitBlock);
m_frameCache.m_rectCache.shrink(m_peakRect + 1 + kRectBlock);
m_cmdPre.shrink();
m_cmdPost.shrink();
for (uint32_t ii = 0, num = g_caps.limits.maxEncoders; ii < num; ++ii)
{
@@ -3260,7 +3265,11 @@ namespace bgfx
reset();
start(0);
m_textVideoMem = BX_NEW(g_allocator, TextVideoMem);
m_textVideoMem = NULL;
if (BX_ENABLED(BGFX_CONFIG_DEBUG_TEXT) )
{
m_textVideoMem = BX_NEW(g_allocator, TextVideoMem);
}
}
void destroy()
@@ -3605,7 +3614,7 @@ namespace bgfx
m_numSubmitted = 0;
m_numDropped = 0;
m_bindHashMap.clear();
m_bindHashMap.reset();
m_bindLlastIdx = 0;
m_bindEmptyIdx = UINT32_MAX;
m_bindDirty = true;
@@ -4926,27 +4935,36 @@ namespace bgfx
{
BGFX_MUTEX_SCOPE(m_resourceApiLock);
const uint8_t debugTextScale = m_init.resolution.debugTextScale;
m_submit->m_textVideoMem->resize(
_small
, (uint16_t)m_init.resolution.width / debugTextScale
, (uint16_t)m_init.resolution.height / debugTextScale
);
m_submit->m_textVideoMem->clear(_attr);
if (BX_ENABLED(BGFX_CONFIG_DEBUG_TEXT) )
{
const uint8_t debugTextScale = m_init.resolution.debugTextScale;
m_submit->m_textVideoMem->resize(
_small
, (uint16_t)m_init.resolution.width / debugTextScale
, (uint16_t)m_init.resolution.height / debugTextScale
);
m_submit->m_textVideoMem->clear(_attr);
}
}
BGFX_API_FUNC(void dbgTextPrintfVargs(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, va_list _argList) )
{
BGFX_MUTEX_SCOPE(m_resourceApiLock);
m_submit->m_textVideoMem->printfVargs(_x, _y, _attr, _format, _argList);
if (BX_ENABLED(BGFX_CONFIG_DEBUG_TEXT) )
{
m_submit->m_textVideoMem->printfVargs(_x, _y, _attr, _format, _argList);
}
}
BGFX_API_FUNC(void dbgTextImage(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const void* _data, uint16_t _pitch) )
{
BGFX_MUTEX_SCOPE(m_resourceApiLock);
m_submit->m_textVideoMem->image(_x, _y, _width, _height, _data, _pitch);
if (BX_ENABLED(BGFX_CONFIG_DEBUG_TEXT) )
{
m_submit->m_textVideoMem->image(_x, _y, _width, _height, _data, _pitch);
}
}
BGFX_API_FUNC(const Stats* getPerfStats() )
@@ -4957,9 +4975,14 @@ namespace bgfx
const Resolution& resolution = m_submit->m_resolution;
stats.width = uint16_t(resolution.width);
stats.height = uint16_t(resolution.height);
const TextVideoMem* tvm = m_submit->m_textVideoMem;
stats.textWidth = tvm->m_width;
stats.textHeight = tvm->m_height;
stats.textWidth = 0;
stats.textHeight = 0;
if (BX_ENABLED(BGFX_CONFIG_DEBUG_TEXT) )
{
const TextVideoMem* tvm = m_submit->m_textVideoMem;
stats.textWidth = tvm->m_width;
stats.textHeight = tvm->m_height;
}
stats.encoderStats = m_encoderStats;
stats.numDynamicIndexBuffers = m_dynamicIndexBufferHandle.getNumHandles();
+9 -8
View File
@@ -193,7 +193,7 @@
# define BGFX_CONFIG_GL_USE_WGL 0
#endif // BGFX_CONFIG_GL_USE_WGL
// Enable hardware video decoder.
/// Enable hardware video decoder.
#ifndef BGFX_CONFIG_VIDEO
# define BGFX_CONFIG_VIDEO 1
#endif // BGFX_CONFIG_VIDEO
@@ -247,12 +247,10 @@
# define BGFX_CONFIG_RENDERER_VULKAN_ROBUST_BUFFER_ACCESS 0
#endif // BGFX_CONFIG_RENDERER_VULKAN_ROBUST_BUFFER_ACCESS
/// Enable use of tinystl instead of std containers for internal data
/// structures. Default is 1 (enabled). Reduces binary size and avoids
/// std library dependency.
#ifndef BGFX_CONFIG_USE_TINYSTL
# define BGFX_CONFIG_USE_TINYSTL 1
#endif // BGFX_CONFIG_USE_TINYSTL
/// Enable debug text.
#ifndef BGFX_CONFIG_DEBUG_TEXT
# define BGFX_CONFIG_DEBUG_TEXT 1
#endif // BGFX_CONFIG_DEBUG_TEXT
/// Debug text maximum scale factor.
#ifndef BGFX_CONFIG_DEBUG_TEXT_MAX_SCALE
@@ -478,7 +476,10 @@ static_assert(BGFX_CONFIG_MAX_VERTEX_STREAMS < 32, "Must be less than 32!");
/// Minimum initial size in bytes of the resource command buffer (pre/post
/// render commands for resource creation and updates). Default is 64 KB.
/// The buffer grows as needed.
/// The buffer grows as needed. After `Init::Limits::numDrawCallPeakFrames`
/// of observing the high-water mark it shrinks toward that peak, but not
/// below this minimum. Set `numDrawCallPeakFrames` to 0 to keep the largest
/// size for the lifetime of the context.
#ifndef BGFX_CONFIG_MIN_RESOURCE_COMMAND_BUFFER_SIZE
# define BGFX_CONFIG_MIN_RESOURCE_COMMAND_BUFFER_SIZE (64<<10)
#endif // BGFX_CONFIG_MIN_RESOURCE_COMMAND_BUFFER_SIZE
+1 -8
View File
@@ -2010,14 +2010,7 @@ namespace bgfx { namespace d3d12
postReset();
m_batch.create(4<<10);
#if !BX_PLATFORM_LINUX
// ExecuteIndirect is a net loss on following GPU vendors:
m_batch.setIndirectMode(true
&& BGFX_PCI_ID_NVIDIA != m_dxgi.m_adapterDesc.VendorId
&& BGFX_PCI_ID_INTEL != m_dxgi.m_adapterDesc.VendorId
&& BGFX_PCI_ID_MICROSOFT != m_dxgi.m_adapterDesc.VendorId
);
#endif // !BX_PLATFORM_LINUX
m_batch.setIndirectMode(false /* ExecuteIndirect is a net loss on all GPU vendors... */);
m_gpuTimer.init();
m_occlusionQuery.init();
+2
View File
@@ -15,8 +15,10 @@ namespace bgfx
const uint8_t* BX_CONCATENATE(_name, _pssl) = &BX_CONCATENATE(_name, _int_pssl)[0]; \
const uint32_t BX_CONCATENATE(_name, _pssl_size) = 1
#if BGFX_CONFIG_DEBUG_TEXT
BGFX_DECLARE_EMBEDDED_SHADER(vs_debugfont);
BGFX_DECLARE_EMBEDDED_SHADER(fs_debugfont);
#endif // BGFX_CONFIG_DEBUG_TEXT
BGFX_DECLARE_EMBEDDED_SHADER(vs_clear);
BGFX_DECLARE_EMBEDDED_SHADER(fs_clear0);
BGFX_DECLARE_EMBEDDED_SHADER(fs_clear1);
+2
View File
@@ -15,8 +15,10 @@ namespace bgfx
const uint8_t* BX_CONCATENATE(_name, _nvn) = &BX_CONCATENATE(_name, _int_nvn)[0]; \
const uint32_t BX_CONCATENATE(_name, _nvn_size) = 1
#if BGFX_CONFIG_DEBUG_TEXT
BGFX_DECLARE_EMBEDDED_SHADER(vs_debugfont);
BGFX_DECLARE_EMBEDDED_SHADER(fs_debugfont);
#endif // BGFX_CONFIG_DEBUG_TEXT
BGFX_DECLARE_EMBEDDED_SHADER(vs_clear);
BGFX_DECLARE_EMBEDDED_SHADER(fs_clear0);
BGFX_DECLARE_EMBEDDED_SHADER(fs_clear1);
+9 -14
View File
@@ -5949,15 +5949,14 @@ VK_DESTROY
const void* code = reader.getDataPtr();
bx::skip(&reader, shaderSize+1);
m_code = alloc(shaderSize);
bx::memCopy(m_code->data, code, shaderSize);
const Memory* shaderCode = copy(code, shaderSize);
VkShaderModuleCreateInfo smci;
smci.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
smci.pNext = NULL;
smci.flags = 0;
smci.codeSize = m_code->size;
smci.pCode = (const uint32_t*)m_code->data;
smci.codeSize = shaderCode->size;
smci.pCode = (const uint32_t*)shaderCode->data;
BX_TRACE("%x", bx::hash<bx::HashMurmur3>(code, shaderSize) );
VK_CHECK(vkCreateShaderModule(
@@ -5967,6 +5966,8 @@ VK_DESTROY
, &m_module
) );
release(shaderCode);
bx::memSet(m_attrMask, 0, sizeof(m_attrMask) );
bx::memSet(m_attrRemap, 0, sizeof(m_attrRemap) );
@@ -5990,7 +5991,7 @@ VK_DESTROY
murmur.begin();
murmur.add(hashIn);
murmur.add(hashOut);
murmur.add(m_code->data, m_code->size);
murmur.add(code, shaderSize);
murmur.add(m_numAttrs);
murmur.add(m_attrMask, m_numAttrs);
murmur.add(m_attrRemap, m_numAttrs);
@@ -6070,13 +6071,7 @@ VK_DESTROY
}
m_numPredefined = 0;
if (NULL != m_code)
{
release(m_code);
m_code = NULL;
m_hash = 0;
}
m_hash = 0;
if (VK_NULL_HANDLE != m_module)
{
@@ -6086,7 +6081,7 @@ VK_DESTROY
void ProgramVK::create(const ShaderVK* _vsh, const ShaderVK* _fsh)
{
BX_ASSERT(NULL != _vsh->m_code, "Vertex shader doesn't exist.");
BX_ASSERT(VK_NULL_HANDLE != _vsh->m_module, "Vertex shader doesn't exist.");
m_vsh = _vsh;
bx::memCopy(
&m_predefined[0]
@@ -6097,7 +6092,7 @@ VK_DESTROY
if (NULL != _fsh)
{
BX_ASSERT(NULL != _fsh->m_code, "Fragment shader doesn't exist.");
BX_ASSERT(VK_NULL_HANDLE != _fsh->m_module, "Fragment shader doesn't exist.");
m_fsh = _fsh;
bx::memCopy(
&m_predefined[m_numPredefined]
+1 -3
View File
@@ -535,8 +535,7 @@ VK_DESTROY_FUNC(DescriptorSet);
struct ShaderVK
{
ShaderVK()
: m_code(NULL)
, m_module(VK_NULL_HANDLE)
: m_module(VK_NULL_HANDLE)
, m_constantBuffer(NULL)
, m_hash(0)
, m_numUniforms(0)
@@ -550,7 +549,6 @@ VK_DESTROY_FUNC(DescriptorSet);
void create(const Memory* _mem);
void destroy();
const Memory* m_code;
VkShaderModule m_module;
UniformBuffer* m_constantBuffer;
+8 -1
View File
@@ -4264,6 +4264,12 @@ WGPU_IMPORT
bx::read(&reader, m_size, &err);
bx::read(&reader, m_blockSize, &err);
if (bx::strFind(bx::StringView( (const char*)m_code->data, m_code->size), "rgba8unorm").isEmpty() )
{
release(m_code);
m_code = NULL;
}
}
void ShaderWGPU::destroy()
@@ -4289,7 +4295,8 @@ WGPU_IMPORT
WGPUShaderModule ShaderWGPU::getModule(bool _bgra8Storage) const
{
if (!_bgra8Storage)
if (!_bgra8Storage
|| NULL == m_code)
{
return m_module;
}