This commit is contained in:
Бранимир Караџић 2020-04-25 09:50:52 -07:00
parent 3ae6bcf37e
commit 7792a893af
6 changed files with 58 additions and 35 deletions

View File

@ -698,7 +698,7 @@ struct bgfx_caps_gpu_t
ushort deviceId; /// Device id.
}
/// Renderer capabilities limits.
/// Renderer runtime limits.
struct bgfx_caps_limits_t
{
uint maxDrawCalls; /// Maximum number of draw calls.
@ -742,7 +742,7 @@ struct bgfx_caps_t
bool originBottomLeft; /// True when NDC origin is at bottom left.
byte numGPUs; /// Number of enumerated GPUs.
bgfx_caps_gpu_t[4] gpu; /// Enumerated GPUs.
bgfx_caps_limits_t limits;
bgfx_caps_limits_t limits; /// Renderer runtime limits.
/**
* Supported texture format capabilities flags:
@ -813,6 +813,7 @@ struct bgfx_resolution_t
byte maxFrameLatency; /// Maximum frame latency.
}
/// Configurable runtime limits parameters.
struct bgfx_init_limits_t
{
ushort maxEncoders; /// Maximum number of encoder threads.
@ -851,7 +852,7 @@ struct bgfx_init_t
bool profile; /// Enable device for profiling.
bgfx_platform_data_t platformData; /// Platform data.
bgfx_resolution_t resolution; /// Backbuffer resolution and reset parameters. See: `bgfx::Resolution`.
bgfx_init_limits_t limits;
bgfx_init_limits_t limits; /// Configurable runtime limits parameters.
/**
* Provide application specific callback interface.

View File

@ -670,14 +670,20 @@ namespace bgfx
/// Backbuffer resolution and reset parameters. See: `bgfx::Resolution`.
Resolution resolution;
/// Configurable runtime limits parameters.
///
/// @attention C99 equivalent is `bgfx_init_limits_t`.
///
struct Limits
{
Limits();
uint16_t maxEncoders; //!< Maximum number of encoder threads.
uint32_t transientVbSize; //!< Maximum transient vertex buffer size.
uint32_t transientIbSize; //!< Maximum transient index buffer size.
};
Limits limits;
Limits limits; // Configurable runtime limits.
/// Provide application specific callback interface.
/// See: `bgfx::CallbackI`
@ -706,6 +712,8 @@ namespace bgfx
///
struct Memory
{
Memory() = delete;
uint8_t* data; //!< Pointer to data.
uint32_t size; //!< Data size.
};
@ -743,6 +751,10 @@ namespace bgfx
GPU gpu[4]; //!< Enumerated GPUs.
/// Renderer runtime limits.
///
/// @attention C99 equivalent is `bgfx_caps_limits_t`.
///
struct Limits
{
uint32_t maxDrawCalls; //!< Maximum number of draw calls.
@ -770,7 +782,7 @@ namespace bgfx
uint32_t transientIbSize; //!< Maximum transient index buffer size.
};
Limits limits;
Limits limits; //!< Renderer runtime limits.
/// Supported texture format capabilities flags:
/// - `BGFX_CAPS_FORMAT_TEXTURE_NONE` - Texture format is not supported.

View File

@ -487,7 +487,7 @@ typedef struct bgfx_caps_gpu_s
} bgfx_caps_gpu_t;
/**
* Renderer capabilities limits.
* Renderer runtime limits.
*
*/
typedef struct bgfx_caps_limits_s
@ -537,7 +537,7 @@ typedef struct bgfx_caps_s
bool originBottomLeft; /** True when NDC origin is at bottom left. */
uint8_t numGPUs; /** Number of enumerated GPUs. */
bgfx_caps_gpu_t gpu[4]; /** Enumerated GPUs. */
bgfx_caps_limits_t limits;
bgfx_caps_limits_t limits; /** Renderer runtime limits. */
/**
* Supported texture format capabilities flags:
@ -621,6 +621,10 @@ typedef struct bgfx_resolution_s
} bgfx_resolution_t;
/**
* Configurable runtime limits parameters.
*
*/
typedef struct bgfx_init_limits_s
{
uint16_t maxEncoders; /** Maximum number of encoder threads. */
@ -663,7 +667,7 @@ typedef struct bgfx_init_s
bool profile; /** Enable device for profiling. */
bgfx_platform_data_t platformData; /** Platform data. */
bgfx_resolution_t resolution; /** Backbuffer resolution and reset parameters. See: `bgfx::Resolution`. */
bgfx_init_limits_t limits;
bgfx_init_limits_t limits; /** Configurable runtime limits parameters. */
/**
* Provide application specific callback interface.

View File

@ -676,7 +676,7 @@ struct.GPU { namespace = "Caps" }
.vendorId "uint16_t" --- Vendor PCI id. See `BGFX_PCI_ID_*`.
.deviceId "uint16_t" --- Device id.
--- Renderer capabilities limits.
--- Renderer runtime limits.
struct.Limits { namespace = "Caps" }
.maxDrawCalls "uint32_t" --- Maximum number of draw calls.
.maxBlits "uint32_t" --- Maximum number of blit calls.
@ -713,7 +713,7 @@ struct.Caps
.originBottomLeft "bool" --- True when NDC origin is at bottom left.
.numGPUs "uint8_t" --- Number of enumerated GPUs.
.gpu "GPU[4]" --- Enumerated GPUs.
.limits "Limits"
.limits "Limits" --- Renderer runtime limits.
.formats "uint16_t[TextureFormat::Count]"
--- Supported texture format capabilities flags:
--- - `BGFX_CAPS_FORMAT_TEXTURE_NONE` - Texture format is not supported.
@ -762,6 +762,7 @@ struct.Resolution { ctor }
.numBackBuffers "uint8_t" --- Number of back buffers.
.maxFrameLatency "uint8_t" --- Maximum frame latency.
--- Configurable runtime limits parameters.
struct.Limits { namespace = "Init" }
.maxEncoders "uint16_t" --- Maximum number of encoder threads.
.transientVbSize "uint32_t" --- Maximum transient vertex buffer size.
@ -788,7 +789,7 @@ struct.Init { ctor }
.profile "bool" --- Enable device for profiling.
.platformData "PlatformData" --- Platform data.
.resolution "Resolution" --- Backbuffer resolution and reset parameters. See: `bgfx::Resolution`.
.limits "Limits"
.limits "Limits" --- Configurable runtime limits parameters.
.callback "CallbackI*" --- Provide application specific callback interface.
--- See: `bgfx::CallbackI`

View File

@ -1965,11 +1965,12 @@ namespace bgfx
m_dynVertexBufferAllocator.compact();
m_dynIndexBufferAllocator.compact();
BX_CHECK(m_layoutHandle.getNumHandles() == m_vertexLayoutRef.m_layoutMap.getNumElements()
, "VertexLayoutRef mismatch, num handles %d, handles in hash map %d."
, m_layoutHandle.getNumHandles()
, m_vertexLayoutRef.m_layoutMap.getNumElements()
);
BX_CHECK(
m_layoutHandle.getNumHandles() == m_vertexLayoutRef.m_vertexLayoutMap.getNumElements()
, "VertexLayoutRef mismatch, num handles %d, handles in hash map %d."
, m_layoutHandle.getNumHandles()
, m_vertexLayoutRef.m_vertexLayoutMap.getNumElements()
);
m_vertexLayoutRef.shutdown(m_layoutHandle);
@ -3307,6 +3308,13 @@ namespace bgfx
{
}
Init::Limits::Limits()
: maxEncoders(BGFX_CONFIG_DEFAULT_MAX_ENCODERS)
, transientVbSize(BGFX_CONFIG_TRANSIENT_VERTEX_BUFFER_SIZE)
, transientIbSize(BGFX_CONFIG_TRANSIENT_INDEX_BUFFER_SIZE)
{
}
Init::Init()
: type(RendererType::Count)
, vendorId(BGFX_PCI_ID_NONE)
@ -3316,9 +3324,6 @@ namespace bgfx
, callback(NULL)
, allocator(NULL)
{
limits.maxEncoders = BGFX_CONFIG_DEFAULT_MAX_ENCODERS;
limits.transientVbSize = BGFX_CONFIG_TRANSIENT_VERTEX_BUFFER_SIZE;
limits.transientIbSize = BGFX_CONFIG_TRANSIENT_INDEX_BUFFER_SIZE;
}
void Attachment::init(TextureHandle _handle, Access::Enum _access, uint16_t _layer, uint16_t _mip, uint8_t _resolve)

View File

@ -2578,7 +2578,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
void init()
{
bx::memSet(m_layoutRef, 0, sizeof(m_layoutRef) );
bx::memSet(m_vertexLayoutRef, 0, sizeof(m_vertexLayoutRef) );
bx::memSet(m_vertexBufferRef, 0xff, sizeof(m_vertexBufferRef) );
bx::memSet(m_dynamicVertexBufferRef, 0xff, sizeof(m_dynamicVertexBufferRef) );
}
@ -2589,51 +2589,51 @@ 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_layoutRef[handle.idx] = 0;
m_layoutMap.removeByHandle(handle.idx);
m_vertexLayoutRef[handle.idx] = 0;
m_vertexLayoutMap.removeByHandle(handle.idx);
_handleAlloc.free(handle.idx);
}
m_layoutMap.reset();
m_vertexLayoutMap.reset();
}
VertexLayoutHandle find(uint32_t _hash)
{
VertexLayoutHandle handle = { m_layoutMap.find(_hash) };
VertexLayoutHandle handle = { m_vertexLayoutMap.find(_hash) };
return handle;
}
void add(VertexLayoutHandle _layoutHandle, uint32_t _hash)
{
m_layoutRef[_layoutHandle.idx]++;
m_layoutMap.insert(_hash, _layoutHandle.idx);
m_vertexLayoutRef[_layoutHandle.idx]++;
m_vertexLayoutMap.insert(_hash, _layoutHandle.idx);
}
void add(VertexBufferHandle _handle, VertexLayoutHandle _layoutHandle, uint32_t _hash)
{
BX_CHECK(m_vertexBufferRef[_handle.idx].idx == kInvalidHandle, "");
m_vertexBufferRef[_handle.idx] = _layoutHandle;
m_layoutRef[_layoutHandle.idx]++;
m_layoutMap.insert(_hash, _layoutHandle.idx);
m_vertexLayoutRef[_layoutHandle.idx]++;
m_vertexLayoutMap.insert(_hash, _layoutHandle.idx);
}
void add(DynamicVertexBufferHandle _handle, VertexLayoutHandle _layoutHandle, uint32_t _hash)
{
BX_CHECK(m_dynamicVertexBufferRef[_handle.idx].idx == kInvalidHandle, "");
m_dynamicVertexBufferRef[_handle.idx] = _layoutHandle;
m_layoutRef[_layoutHandle.idx]++;
m_layoutMap.insert(_hash, _layoutHandle.idx);
m_vertexLayoutRef[_layoutHandle.idx]++;
m_vertexLayoutMap.insert(_hash, _layoutHandle.idx);
}
VertexLayoutHandle release(VertexLayoutHandle _layoutHandle)
{
if (isValid(_layoutHandle) )
{
m_layoutRef[_layoutHandle.idx]--;
m_vertexLayoutRef[_layoutHandle.idx]--;
if (0 == m_layoutRef[_layoutHandle.idx])
if (0 == m_vertexLayoutRef[_layoutHandle.idx])
{
m_layoutMap.removeByHandle(_layoutHandle.idx);
m_vertexLayoutMap.removeByHandle(_layoutHandle.idx);
return _layoutHandle;
}
}
@ -2660,9 +2660,9 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
}
typedef bx::HandleHashMapT<BGFX_CONFIG_MAX_VERTEX_LAYOUTS*2> VertexLayoutMap;
VertexLayoutMap m_layoutMap;
VertexLayoutMap m_vertexLayoutMap;
uint16_t m_layoutRef[BGFX_CONFIG_MAX_VERTEX_LAYOUTS];
uint16_t m_vertexLayoutRef[BGFX_CONFIG_MAX_VERTEX_LAYOUTS];
VertexLayoutHandle m_vertexBufferRef[BGFX_CONFIG_MAX_VERTEX_BUFFERS];
VertexLayoutHandle m_dynamicVertexBufferRef[BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS];
};