mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
Added Init.fallback option. Cleanup. (#3522)
This commit is contained in:
committed by
GitHub
parent
3ddf1ed032
commit
241e9c3330
@@ -2237,6 +2237,7 @@ public static class bgfx
|
||||
public uint64 capabilities;
|
||||
public uint8 debug;
|
||||
public uint8 profile;
|
||||
public uint8 fallback;
|
||||
public PlatformData platformData;
|
||||
public Resolution resolution;
|
||||
public Limits limits;
|
||||
|
||||
@@ -1581,6 +1581,8 @@ struct Init
|
||||
bool debug;
|
||||
// Enable device for profiling.
|
||||
bool profile;
|
||||
// Enable fallback to next available renderer.
|
||||
bool fallback;
|
||||
// Platform data.
|
||||
PlatformData platformData;
|
||||
// Backbuffer resolution and reset parameters. See: `bgfx::Resolution`.
|
||||
|
||||
@@ -2211,6 +2211,7 @@ public static partial class bgfx
|
||||
public ulong capabilities;
|
||||
public byte debug;
|
||||
public byte profile;
|
||||
public byte fallback;
|
||||
public PlatformData platformData;
|
||||
public Resolution resolution;
|
||||
public Limits limits;
|
||||
|
||||
@@ -9,7 +9,7 @@ import bindbc.common.types: c_int64, c_uint64, va_list;
|
||||
import bindbc.bgfx.config;
|
||||
static import bgfx.impl;
|
||||
|
||||
enum uint apiVersion = 135;
|
||||
enum uint apiVersion = 136;
|
||||
|
||||
alias ViewID = ushort;
|
||||
|
||||
@@ -1199,6 +1199,7 @@ extern(C++, "bgfx") struct Init{
|
||||
c_uint64 capabilities; ///Capabilities initialization mask (default: UINT64_MAX).
|
||||
bool debug_; ///Enable device for debugging.
|
||||
bool profile; ///Enable device for profiling.
|
||||
bool fallback; ///Enable fallback to next available renderer.
|
||||
PlatformData platformData; ///Platform data.
|
||||
Resolution resolution; ///Backbuffer resolution and reset parameters. See: `bgfx::Resolution`.
|
||||
Limits limits; ///Configurable runtime limits parameters.
|
||||
|
||||
@@ -1419,6 +1419,7 @@ pub const Init = extern struct {
|
||||
capabilities: u64,
|
||||
debug: bool,
|
||||
profile: bool,
|
||||
fallback: bool,
|
||||
platformData: PlatformData,
|
||||
resolution: Resolution,
|
||||
limits: Limits,
|
||||
|
||||
@@ -739,8 +739,9 @@ namespace bgfx
|
||||
|
||||
uint64_t capabilities; //!< Capabilities initialization mask (default: UINT64_MAX).
|
||||
|
||||
bool debug; //!< Enable device for debugging.
|
||||
bool profile; //!< Enable device for profiling.
|
||||
bool debug; //!< Enable device for debugging.
|
||||
bool profile; //!< Enable device for profiling.
|
||||
bool fallback; //!< Enable fallback to next available renderer.
|
||||
|
||||
/// Platform data.
|
||||
PlatformData platformData;
|
||||
|
||||
@@ -742,6 +742,7 @@ typedef struct bgfx_init_s
|
||||
uint64_t capabilities; /** Capabilities initialization mask (default: UINT64_MAX). */
|
||||
bool debug; /** Enable device for debugging. */
|
||||
bool profile; /** Enable device for profiling. */
|
||||
bool fallback; /** Enable fallback to next available renderer. */
|
||||
bgfx_platform_data_t platformData; /** Platform data. */
|
||||
bgfx_resolution_t resolution; /** Backbuffer resolution and reset parameters. See: `bgfx::Resolution`. */
|
||||
bgfx_init_limits_t limits; /** Configurable runtime limits parameters. */
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#ifndef BGFX_DEFINES_H_HEADER_GUARD
|
||||
#define BGFX_DEFINES_H_HEADER_GUARD
|
||||
|
||||
#define BGFX_API_VERSION UINT32_C(135)
|
||||
#define BGFX_API_VERSION UINT32_C(136)
|
||||
|
||||
/**
|
||||
* Color RGB/alpha/depth write. When it's not specified write will be disabled.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
-- vim: syntax=lua
|
||||
-- bgfx interface
|
||||
|
||||
version(135)
|
||||
version(136)
|
||||
|
||||
typedef "bool"
|
||||
typedef "char"
|
||||
@@ -858,6 +858,7 @@ struct.Init { ctor }
|
||||
.capabilities "uint64_t" --- Capabilities initialization mask (default: UINT64_MAX).
|
||||
.debug "bool" --- Enable device for debugging.
|
||||
.profile "bool" --- Enable device for profiling.
|
||||
.fallback "bool" --- Enable fallback to next available renderer.
|
||||
.platformData "PlatformData" --- Platform data.
|
||||
.resolution "Resolution" --- Backbuffer resolution and reset parameters. See: `bgfx::Resolution`.
|
||||
.limits "Limits" --- Configurable runtime limits parameters.
|
||||
|
||||
112
src/bgfx.cpp
112
src/bgfx.cpp
@@ -737,10 +737,10 @@ namespace bgfx
|
||||
.add(Attrib::TexCoord0, 2, AttribType::Float)
|
||||
.end();
|
||||
|
||||
uint16_t width = 2048;
|
||||
uint16_t height = 24;
|
||||
uint8_t bpp = 1;
|
||||
uint32_t pitch = width*bpp;
|
||||
const uint16_t width = 2048;
|
||||
const uint16_t height = 24;
|
||||
const uint8_t bpp = 1;
|
||||
const uint32_t pitch = width*bpp;
|
||||
|
||||
const Memory* mem;
|
||||
|
||||
@@ -767,6 +767,7 @@ namespace bgfx
|
||||
m_vb = s_ctx->createTransientVertexBuffer(kNumBatchVertices*m_layout.m_stride, &m_layout);
|
||||
m_ib = s_ctx->createTransientIndexBuffer(kNumBatchIndices*2);
|
||||
m_scale = bx::max<uint8_t>(scale, 1);
|
||||
m_usedData = 0;
|
||||
}
|
||||
|
||||
void TextVideoMemBlitter::shutdown()
|
||||
@@ -825,7 +826,7 @@ namespace bgfx
|
||||
};
|
||||
static_assert(BX_COUNTOF(s_paletteLinear) == 16);
|
||||
|
||||
void blit(RendererContextI* _renderCtx, TextVideoMemBlitter& _blitter, const TextVideoMem& _mem)
|
||||
void dbgTextSubmit(RendererContextI* _renderCtx, TextVideoMemBlitter& _blitter, const TextVideoMem& _mem)
|
||||
{
|
||||
struct Vertex
|
||||
{
|
||||
@@ -848,7 +849,7 @@ namespace bgfx
|
||||
const float fontHeight = (_mem.m_small ? 8.0f : 16.0f)*_blitter.m_scale;
|
||||
const float fontWidth = 8.0f * _blitter.m_scale;
|
||||
|
||||
_renderCtx->blitSetup(_blitter);
|
||||
_renderCtx->dbgTextRenderBegin(_blitter);
|
||||
|
||||
const uint32_t* palette = 0 != (s_ctx->m_init.resolution.reset & BGFX_RESET_SRGB_BACKBUFFER)
|
||||
? s_paletteLinear
|
||||
@@ -857,10 +858,10 @@ namespace bgfx
|
||||
|
||||
for (;yy < _mem.m_height;)
|
||||
{
|
||||
Vertex* vertex = (Vertex*)_blitter.m_vb->data;
|
||||
Vertex* vertex = (Vertex *)_blitter.m_vb->data;
|
||||
uint16_t* indices = (uint16_t*)_blitter.m_ib->data;
|
||||
uint32_t startVertex = 0;
|
||||
uint32_t numIndices = 0;
|
||||
uint32_t numIndices = 0;
|
||||
|
||||
for (; yy < _mem.m_height && numIndices < kNumBatchIndices; ++yy)
|
||||
{
|
||||
@@ -883,7 +884,7 @@ namespace bgfx
|
||||
const uint32_t fg = palette[attr&0xf];
|
||||
const uint32_t bg = palette[(attr>>4)&0xf];
|
||||
|
||||
Vertex vert[4] =
|
||||
const Vertex vert[4] =
|
||||
{
|
||||
{ (xx )*fontWidth, (yy )*fontHeight, 0.0f, fg, bg, (ch )*8.0f*texelWidth, utop },
|
||||
{ (xx+1)*fontWidth, (yy )*fontHeight, 0.0f, fg, bg, (ch+1)*8.0f*texelWidth, utop },
|
||||
@@ -916,8 +917,10 @@ namespace bgfx
|
||||
}
|
||||
}
|
||||
|
||||
_renderCtx->blitRender(_blitter, numIndices);
|
||||
_renderCtx->dbgTextRender(_blitter, numIndices);
|
||||
}
|
||||
|
||||
_renderCtx->dbgTextRenderEnd(_blitter);
|
||||
}
|
||||
|
||||
void ClearQuad::init()
|
||||
@@ -926,7 +929,8 @@ namespace bgfx
|
||||
|
||||
if (RendererType::Noop != g_caps.rendererType)
|
||||
{
|
||||
m_layout
|
||||
VertexLayout layout;
|
||||
layout
|
||||
.begin()
|
||||
.add(Attrib::Position, 2, AttribType::Float)
|
||||
.end();
|
||||
@@ -954,7 +958,7 @@ namespace bgfx
|
||||
float m_y;
|
||||
};
|
||||
|
||||
const uint16_t stride = m_layout.m_stride;
|
||||
const uint16_t stride = layout.m_stride;
|
||||
const bgfx::Memory* mem = bgfx::alloc(4 * stride);
|
||||
Vertex* vertex = (Vertex*)mem->data;
|
||||
BX_ASSERT(stride == sizeof(Vertex), "Stride/Vertex mismatch (stride %d, sizeof(Vertex) %d)", stride, sizeof(Vertex));
|
||||
@@ -971,7 +975,8 @@ namespace bgfx
|
||||
vertex->m_x = 1.0f;
|
||||
vertex->m_y = 1.0f;
|
||||
|
||||
m_vb = s_ctx->createVertexBuffer(mem, m_layout, 0);
|
||||
m_layout = s_ctx->createVertexLayout(layout);
|
||||
m_vb = s_ctx->createVertexBuffer(mem, layout, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -991,6 +996,7 @@ namespace bgfx
|
||||
}
|
||||
|
||||
s_ctx->destroyVertexBuffer(m_vb);
|
||||
s_ctx->destroyVertexLayout(m_layout);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1351,15 +1357,9 @@ namespace bgfx
|
||||
if (UINT8_MAX != m_draw.m_streamMask)
|
||||
{
|
||||
uint32_t numVertices = UINT32_MAX;
|
||||
for (uint32_t idx = 0, streamMask = m_draw.m_streamMask
|
||||
; 0 != streamMask
|
||||
; streamMask >>= 1, idx += 1
|
||||
)
|
||||
for (BitMaskToIndexIteratorT it(m_draw.m_streamMask); !it.isDone(); it.next() )
|
||||
{
|
||||
const uint32_t ntz = bx::uint32_cnttz(streamMask);
|
||||
streamMask >>= ntz;
|
||||
idx += ntz;
|
||||
numVertices = bx::min(numVertices, m_numVertices[idx]);
|
||||
numVertices = bx::min(numVertices, m_numVertices[it.idx]);
|
||||
}
|
||||
|
||||
m_draw.m_numVertices = numVertices;
|
||||
@@ -1444,30 +1444,31 @@ namespace bgfx
|
||||
, "Exceed number of available blit items per frame. BGFX_CONFIG_MAX_BLIT_ITEMS is %d. Skipping blit."
|
||||
, BGFX_CONFIG_MAX_BLIT_ITEMS
|
||||
);
|
||||
if (m_frame->m_numBlitItems < BGFX_CONFIG_MAX_BLIT_ITEMS)
|
||||
const uint32_t blitItemIdx = bx::atomicFetchAndAddsat<uint32_t>(&m_frame->m_numBlitItems, 1, BGFX_CONFIG_MAX_BLIT_ITEMS);
|
||||
if (BGFX_CONFIG_MAX_BLIT_ITEMS-1 <= blitItemIdx)
|
||||
{
|
||||
uint16_t item = m_frame->m_numBlitItems++;
|
||||
|
||||
BlitItem& bi = m_frame->m_blitItem[item];
|
||||
bi.m_srcX = _srcX;
|
||||
bi.m_srcY = _srcY;
|
||||
bi.m_srcZ = _srcZ;
|
||||
bi.m_dstX = _dstX;
|
||||
bi.m_dstY = _dstY;
|
||||
bi.m_dstZ = _dstZ;
|
||||
bi.m_width = _width;
|
||||
bi.m_height = _height;
|
||||
bi.m_depth = _depth;
|
||||
bi.m_srcMip = _srcMip;
|
||||
bi.m_dstMip = _dstMip;
|
||||
bi.m_src = _src;
|
||||
bi.m_dst = _dst;
|
||||
|
||||
BlitKey key;
|
||||
key.m_view = _id;
|
||||
key.m_item = item;
|
||||
m_frame->m_blitKeys[item] = key.encode();
|
||||
return;
|
||||
}
|
||||
|
||||
BlitItem& bi = m_frame->m_blitItem[blitItemIdx];
|
||||
bi.m_srcX = _srcX;
|
||||
bi.m_srcY = _srcY;
|
||||
bi.m_srcZ = _srcZ;
|
||||
bi.m_dstX = _dstX;
|
||||
bi.m_dstY = _dstY;
|
||||
bi.m_dstZ = _dstZ;
|
||||
bi.m_width = _width;
|
||||
bi.m_height = _height;
|
||||
bi.m_depth = _depth;
|
||||
bi.m_srcMip = _srcMip;
|
||||
bi.m_dstMip = _dstMip;
|
||||
bi.m_src = _src;
|
||||
bi.m_dst = _dst;
|
||||
|
||||
BlitKey key;
|
||||
key.m_view = _id;
|
||||
key.m_item = bx::narrowCast<uint16_t>(blitItemIdx);
|
||||
m_frame->m_blitKeys[blitItemIdx] = key.encode();
|
||||
}
|
||||
|
||||
void Frame::sort()
|
||||
@@ -2479,7 +2480,7 @@ namespace bgfx
|
||||
, m_init.resolution.height
|
||||
);
|
||||
|
||||
int64_t now = bx::getHPCounter();
|
||||
const int64_t now = bx::getHPCounter();
|
||||
m_submit->m_perfStats.cpuTimeFrame = now - m_frameTimeLast;
|
||||
m_frameTimeLast = now;
|
||||
}
|
||||
@@ -2640,8 +2641,6 @@ namespace bgfx
|
||||
{
|
||||
const uint32_t pos = _cmdbuf.m_pos;
|
||||
|
||||
uint32_t currentKey = UINT32_MAX;
|
||||
|
||||
for (uint32_t ii = 0, num = m_textureUpdateBatch.m_num; ii < num; ++ii)
|
||||
{
|
||||
_cmdbuf.m_pos = m_textureUpdateBatch.m_values[ii];
|
||||
@@ -2670,27 +2669,11 @@ namespace bgfx
|
||||
const Memory* mem;
|
||||
_cmdbuf.read(mem);
|
||||
|
||||
uint32_t key = m_textureUpdateBatch.m_keys[ii];
|
||||
if (key != currentKey)
|
||||
{
|
||||
if (currentKey != UINT32_MAX)
|
||||
{
|
||||
m_renderCtx->updateTextureEnd();
|
||||
}
|
||||
currentKey = key;
|
||||
m_renderCtx->updateTextureBegin(handle, side, mip);
|
||||
}
|
||||
|
||||
m_renderCtx->updateTexture(handle, side, mip, rect, zz, depth, pitch, mem);
|
||||
|
||||
release(mem);
|
||||
}
|
||||
|
||||
if (currentKey != UINT32_MAX)
|
||||
{
|
||||
m_renderCtx->updateTextureEnd();
|
||||
}
|
||||
|
||||
m_textureUpdateBatch.reset();
|
||||
|
||||
_cmdbuf.m_pos = pos;
|
||||
@@ -2716,6 +2699,7 @@ namespace bgfx
|
||||
BGFX_RENDERER_CONTEXT(nvn);
|
||||
BGFX_RENDERER_CONTEXT(gl);
|
||||
BGFX_RENDERER_CONTEXT(vk);
|
||||
BGFX_RENDERER_CONTEXT(wgpu);
|
||||
|
||||
#undef BGFX_RENDERER_CONTEXT
|
||||
|
||||
@@ -2948,7 +2932,8 @@ namespace bgfx
|
||||
{
|
||||
RendererType::Enum renderer = RendererType::Enum(scores[ii] & 0xff);
|
||||
renderCtx = s_rendererCreator[renderer].createFn(_init);
|
||||
if (NULL != renderCtx)
|
||||
if (NULL != renderCtx
|
||||
|| !_init.fallback)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -3643,6 +3628,7 @@ namespace bgfx
|
||||
, capabilities(UINT64_MAX)
|
||||
, debug(BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
, profile(BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
|
||||
, fallback(true)
|
||||
, callback(NULL)
|
||||
, allocator(NULL)
|
||||
{
|
||||
|
||||
90
src/bgfx_p.h
90
src/bgfx_p.h
@@ -496,7 +496,7 @@ namespace bgfx
|
||||
uint16_t m_flags;
|
||||
};
|
||||
|
||||
struct Rect
|
||||
BX_ALIGN_DECL(8, struct) Rect
|
||||
{
|
||||
Rect()
|
||||
{
|
||||
@@ -520,21 +520,34 @@ namespace bgfx
|
||||
|
||||
bool isZero() const
|
||||
{
|
||||
static_assert(8 == sizeof(Rect), "");
|
||||
|
||||
uint64_t ui64 = *( (uint64_t*)this);
|
||||
return UINT64_C(0) == ui64;
|
||||
}
|
||||
|
||||
bool isZeroArea() const
|
||||
{
|
||||
return 0 == m_width
|
||||
return false
|
||||
|| 0 == m_width
|
||||
|| 0 == m_height
|
||||
;
|
||||
}
|
||||
|
||||
bool isEqual(const Rect& _other) const
|
||||
{
|
||||
return true
|
||||
&& m_x == _other.m_x
|
||||
&& m_y == _other.m_y
|
||||
&& m_width == _other.m_width
|
||||
&& m_height == _other.m_height
|
||||
;
|
||||
}
|
||||
|
||||
void set(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
|
||||
{
|
||||
m_x = _x;
|
||||
m_y = _y;
|
||||
m_x = _x;
|
||||
m_y = _y;
|
||||
m_width = _width;
|
||||
m_height = _height;
|
||||
}
|
||||
@@ -545,8 +558,8 @@ namespace bgfx
|
||||
const uint16_t sy = bx::max<uint16_t>(_a.m_y, _b.m_y);
|
||||
const uint16_t ex = bx::min<uint16_t>(_a.m_x + _a.m_width, _b.m_x + _b.m_width );
|
||||
const uint16_t ey = bx::min<uint16_t>(_a.m_y + _a.m_height, _b.m_y + _b.m_height);
|
||||
m_x = sx;
|
||||
m_y = sy;
|
||||
m_x = sx;
|
||||
m_y = sy;
|
||||
m_width = (uint16_t)bx::uint32_satsub(ex, sx);
|
||||
m_height = (uint16_t)bx::uint32_satsub(ey, sy);
|
||||
}
|
||||
@@ -627,6 +640,12 @@ namespace bgfx
|
||||
return uint32_t( (_stencil >> (32*_0or1) ) );
|
||||
}
|
||||
|
||||
static constexpr uint64_t kStencilNoRefMask = packStencil(~BGFX_STENCIL_FUNC_REF_MASK, ~BGFX_STENCIL_FUNC_REF_MASK);
|
||||
static constexpr uint64_t kStencilDisabled = packStencil(
|
||||
BGFX_STENCIL_TEST_ALWAYS | BGFX_STENCIL_OP_FAIL_S_KEEP | BGFX_STENCIL_OP_FAIL_Z_KEEP | BGFX_STENCIL_OP_PASS_Z_KEEP
|
||||
, BGFX_STENCIL_TEST_ALWAYS | BGFX_STENCIL_OP_FAIL_S_KEEP | BGFX_STENCIL_OP_FAIL_Z_KEEP | BGFX_STENCIL_OP_PASS_Z_KEEP
|
||||
);
|
||||
|
||||
inline constexpr bool needBorderColor(uint64_t _flags)
|
||||
{
|
||||
return BGFX_SAMPLER_U_BORDER == (_flags & BGFX_SAMPLER_U_BORDER)
|
||||
@@ -765,19 +784,21 @@ namespace bgfx
|
||||
|
||||
TextureHandle m_texture;
|
||||
TransientVertexBuffer* m_vb;
|
||||
TransientIndexBuffer* m_ib;
|
||||
VertexLayout m_layout;
|
||||
TransientIndexBuffer* m_ib;
|
||||
VertexLayout m_layout;
|
||||
ProgramHandle m_program;
|
||||
uint8_t m_scale;
|
||||
|
||||
uintptr_t m_usedData;
|
||||
};
|
||||
|
||||
struct RendererContextI;
|
||||
|
||||
extern void blit(RendererContextI* _renderCtx, TextVideoMemBlitter& _blitter, const TextVideoMem& _mem);
|
||||
extern void dbgTextSubmit(RendererContextI* _renderCtx, TextVideoMemBlitter& _blitter, const TextVideoMem& _mem);
|
||||
|
||||
inline void blit(RendererContextI* _renderCtx, TextVideoMemBlitter& _blitter, const TextVideoMem* _mem)
|
||||
inline void dbgTextSubmit(RendererContextI* _renderCtx, TextVideoMemBlitter& _blitter, const TextVideoMem* _mem)
|
||||
{
|
||||
blit(_renderCtx, _blitter, *_mem);
|
||||
dbgTextSubmit(_renderCtx, _blitter, *_mem);
|
||||
}
|
||||
|
||||
template <uint32_t maxKeys>
|
||||
@@ -790,8 +811,8 @@ namespace bgfx
|
||||
|
||||
void add(uint32_t _key, uint32_t _value)
|
||||
{
|
||||
uint32_t num = m_num++;
|
||||
m_keys[num] = _key;
|
||||
const uint32_t num = m_num++;
|
||||
m_keys [num] = _key;
|
||||
m_values[num] = _value;
|
||||
}
|
||||
|
||||
@@ -799,7 +820,7 @@ namespace bgfx
|
||||
{
|
||||
if (0 < m_num)
|
||||
{
|
||||
uint32_t* tempKeys = (uint32_t*)BX_STACK_ALLOC(sizeof(m_keys) );
|
||||
uint32_t* tempKeys = (uint32_t*)BX_STACK_ALLOC(sizeof(m_keys) );
|
||||
uint32_t* tempValues = (uint32_t*)BX_STACK_ALLOC(sizeof(m_values) );
|
||||
bx::radixSort(m_keys, tempKeys, m_values, tempValues, m_num);
|
||||
return true;
|
||||
@@ -823,6 +844,32 @@ namespace bgfx
|
||||
uint32_t m_values[maxKeys];
|
||||
};
|
||||
|
||||
template<typename MaskT>
|
||||
struct BitMaskToIndexIteratorT
|
||||
{
|
||||
BitMaskToIndexIteratorT(MaskT _mask)
|
||||
{
|
||||
const uint8_t ntz = bx::countTrailingZeros(_mask);
|
||||
mask = _mask >> ntz;
|
||||
idx = ntz;
|
||||
}
|
||||
|
||||
void next()
|
||||
{
|
||||
const uint8_t ntzPlus1 = bx::countTrailingZeros(mask>>1) + 1;
|
||||
mask >>= ntzPlus1;
|
||||
idx += ntzPlus1;
|
||||
}
|
||||
|
||||
bool isDone() const
|
||||
{
|
||||
return 0 == mask;
|
||||
}
|
||||
|
||||
MaskT mask;
|
||||
uint8_t idx;
|
||||
};
|
||||
|
||||
struct ClearQuad
|
||||
{
|
||||
ClearQuad()
|
||||
@@ -837,7 +884,7 @@ namespace bgfx
|
||||
void shutdown();
|
||||
|
||||
VertexBufferHandle m_vb;
|
||||
VertexLayout m_layout;
|
||||
VertexLayoutHandle m_layout;
|
||||
ProgramHandle m_program[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
|
||||
};
|
||||
|
||||
@@ -2537,7 +2584,7 @@ namespace bgfx
|
||||
UniformBuffer** m_uniformBuffer;
|
||||
|
||||
uint32_t m_numRenderItems;
|
||||
uint16_t m_numBlitItems;
|
||||
uint32_t m_numBlitItems;
|
||||
|
||||
uint32_t m_iboffset;
|
||||
uint32_t m_vboffset;
|
||||
@@ -3564,9 +3611,7 @@ namespace bgfx
|
||||
virtual void createProgram(ProgramHandle _handle, ShaderHandle _vsh, ShaderHandle _fsh) = 0;
|
||||
virtual void destroyProgram(ProgramHandle _handle) = 0;
|
||||
virtual void* createTexture(TextureHandle _handle, const Memory* _mem, uint64_t _flags, uint8_t _skip) = 0;
|
||||
virtual void updateTextureBegin(TextureHandle _handle, uint8_t _side, uint8_t _mip) = 0;
|
||||
virtual void updateTexture(TextureHandle _handle, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem) = 0;
|
||||
virtual void updateTextureEnd() = 0;
|
||||
virtual void readTexture(TextureHandle _handle, void* _data, uint8_t _mip) = 0;
|
||||
virtual void resizeTexture(TextureHandle _handle, uint16_t _width, uint16_t _height, uint8_t _numMips, uint16_t _numLayers) = 0;
|
||||
virtual void overrideInternal(TextureHandle _handle, uintptr_t _ptr, uint16_t _layerIndex) = 0;
|
||||
@@ -3584,8 +3629,9 @@ namespace bgfx
|
||||
virtual void setMarker(const char* _name, uint16_t _len) = 0;
|
||||
virtual void setName(Handle _handle, const char* _name, uint16_t _len) = 0;
|
||||
virtual void submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter) = 0;
|
||||
virtual void blitSetup(TextVideoMemBlitter& _blitter) = 0;
|
||||
virtual void blitRender(TextVideoMemBlitter& _blitter, uint32_t _numIndices) = 0;
|
||||
virtual void dbgTextRenderBegin(TextVideoMemBlitter& _blitter) = 0;
|
||||
virtual void dbgTextRender(TextVideoMemBlitter& _blitter, uint32_t _numIndices) = 0;
|
||||
virtual void dbgTextRenderEnd(TextVideoMemBlitter& _blitter) = 0;
|
||||
};
|
||||
|
||||
inline RendererContextI::~RendererContextI()
|
||||
@@ -4548,8 +4594,8 @@ namespace bgfx
|
||||
BX_WARN(isValid(handle), "Failed to allocate draw indirect buffer handle.");
|
||||
if (isValid(handle) )
|
||||
{
|
||||
uint32_t size = _num * BGFX_CONFIG_DRAW_INDIRECT_STRIDE;
|
||||
uint16_t flags = BGFX_BUFFER_DRAW_INDIRECT;
|
||||
const uint32_t size = _num * BGFX_CONFIG_DRAW_INDIRECT_STRIDE;
|
||||
const uint16_t flags = BGFX_BUFFER_DRAW_INDIRECT;
|
||||
|
||||
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateDynamicVertexBuffer);
|
||||
cmdbuf.write(handle);
|
||||
|
||||
@@ -94,8 +94,8 @@
|
||||
# define BGFX_CONFIG_RENDERER_OPENGLES (0 \
|
||||
|| BX_PLATFORM_ANDROID \
|
||||
|| BX_PLATFORM_EMSCRIPTEN \
|
||||
|| BX_PLATFORM_RPI \
|
||||
|| BX_PLATFORM_NX \
|
||||
|| BX_PLATFORM_RPI \
|
||||
? BGFX_CONFIG_RENDERER_OPENGLES_MIN_VERSION : 0)
|
||||
# endif // BGFX_CONFIG_RENDERER_OPENGLES
|
||||
|
||||
@@ -103,9 +103,9 @@
|
||||
# define BGFX_CONFIG_RENDERER_VULKAN (0 \
|
||||
|| BX_PLATFORM_ANDROID \
|
||||
|| BX_PLATFORM_LINUX \
|
||||
|| BX_PLATFORM_WINDOWS \
|
||||
|| BX_PLATFORM_NX \
|
||||
|| BX_PLATFORM_OSX \
|
||||
|| BX_PLATFORM_WINDOWS \
|
||||
? 1 : 0)
|
||||
# endif // BGFX_CONFIG_RENDERER_VULKAN
|
||||
|
||||
|
||||
@@ -503,14 +503,9 @@ namespace bgfx
|
||||
return true;
|
||||
}
|
||||
|
||||
for (uint32_t idx = 0, streamMask = _new.m_streamMask
|
||||
; 0 != streamMask
|
||||
; streamMask >>= 1, idx += 1
|
||||
)
|
||||
for (BitMaskToIndexIteratorT it(_new.m_streamMask); !it.isDone(); it.next() )
|
||||
{
|
||||
const uint32_t ntz = bx::uint32_cnttz(streamMask);
|
||||
streamMask >>= ntz;
|
||||
idx += ntz;
|
||||
const uint8_t idx = it.idx;
|
||||
|
||||
if (_current.m_stream[idx].m_handle.idx != _new.m_stream[idx].m_handle.idx
|
||||
|| _current.m_stream[idx].m_startVertex != _new.m_stream[idx].m_startVertex)
|
||||
@@ -544,7 +539,7 @@ namespace bgfx
|
||||
{
|
||||
if (m_enabled)
|
||||
{
|
||||
ViewStats& viewStats = m_frame->m_perfStats.viewStats[m_numViews];
|
||||
ViewStats& viewStats = m_frame->m_perfStats.viewStats[m_numViews];
|
||||
viewStats.cpuTimeBegin = bx::getHPCounter();
|
||||
|
||||
m_queryIdx = m_gpuTimer.begin(_view, m_frame->m_frameNum);
|
||||
@@ -567,10 +562,10 @@ namespace bgfx
|
||||
ViewStats& viewStats = m_frame->m_perfStats.viewStats[m_numViews];
|
||||
const typename Ty::Result& result = m_gpuTimer.m_result[viewStats.view];
|
||||
|
||||
viewStats.cpuTimeEnd = bx::getHPCounter();
|
||||
viewStats.cpuTimeEnd = bx::getHPCounter();
|
||||
viewStats.gpuTimeBegin = result.m_begin;
|
||||
viewStats.gpuTimeEnd = result.m_end;
|
||||
viewStats.gpuFrameNum = result.m_frameNum;
|
||||
viewStats.gpuTimeEnd = result.m_end;
|
||||
viewStats.gpuFrameNum = result.m_frameNum;
|
||||
|
||||
++m_numViews;
|
||||
m_queryIdx = UINT32_MAX;
|
||||
|
||||
@@ -1841,19 +1841,11 @@ namespace bgfx { namespace d3d11
|
||||
return m_textures[_handle.idx].create(_mem, _flags, _skip);
|
||||
}
|
||||
|
||||
void updateTextureBegin(TextureHandle /*_handle*/, uint8_t /*_side*/, uint8_t /*_mip*/) override
|
||||
{
|
||||
}
|
||||
|
||||
void updateTexture(TextureHandle _handle, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem) override
|
||||
{
|
||||
m_textures[_handle.idx].update(_side, _mip, _rect, _z, _depth, _pitch, _mem);
|
||||
}
|
||||
|
||||
void updateTextureEnd() override
|
||||
{
|
||||
}
|
||||
|
||||
void readTexture(TextureHandle _handle, void* _data, uint8_t _mip) override
|
||||
{
|
||||
const TextureD3D11& texture = m_textures[_handle.idx];
|
||||
@@ -2131,7 +2123,7 @@ namespace bgfx { namespace d3d11
|
||||
|
||||
void submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter) override;
|
||||
|
||||
void blitSetup(TextVideoMemBlitter& _blitter) override
|
||||
void dbgTextRenderBegin(TextVideoMemBlitter& _blitter) override
|
||||
{
|
||||
ID3D11DeviceContext* deviceCtx = m_deviceCtx;
|
||||
|
||||
@@ -2187,7 +2179,7 @@ namespace bgfx { namespace d3d11
|
||||
commitTextureStage();
|
||||
}
|
||||
|
||||
void blitRender(TextVideoMemBlitter& _blitter, uint32_t _numIndices) override
|
||||
void dbgTextRender(TextVideoMemBlitter& _blitter, uint32_t _numIndices) override
|
||||
{
|
||||
const uint32_t numVertices = _numIndices*4/6;
|
||||
if (0 < numVertices)
|
||||
@@ -2202,6 +2194,10 @@ namespace bgfx { namespace d3d11
|
||||
}
|
||||
}
|
||||
|
||||
void dbgTextRenderEnd(TextVideoMemBlitter& /*_blitter*/) override
|
||||
{
|
||||
}
|
||||
|
||||
void preReset()
|
||||
{
|
||||
m_needPresent = false;
|
||||
@@ -2898,7 +2894,7 @@ namespace bgfx { namespace d3d11
|
||||
|
||||
uint32_t fstencil = unpackStencil(0, _stencil);
|
||||
uint32_t ref = (fstencil&BGFX_STENCIL_FUNC_REF_MASK)>>BGFX_STENCIL_FUNC_REF_SHIFT;
|
||||
_stencil &= packStencil(~BGFX_STENCIL_FUNC_REF_MASK, ~BGFX_STENCIL_FUNC_REF_MASK);
|
||||
_stencil &= kStencilNoRefMask;
|
||||
|
||||
bx::HashMurmur2A murmur;
|
||||
murmur.begin();
|
||||
@@ -3453,7 +3449,7 @@ namespace bgfx { namespace d3d11
|
||||
}
|
||||
}
|
||||
|
||||
void clearQuad(ClearQuad& _clearQuad, const Rect& _rect, const Clear& _clear, const float _palette[][4])
|
||||
void clearQuad(const ClearQuad& _clearQuad, const Rect& _rect, const Clear& _clear, const float _palette[][4])
|
||||
{
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
@@ -3470,10 +3466,9 @@ namespace bgfx { namespace d3d11
|
||||
height = m_scd.height;
|
||||
}
|
||||
|
||||
if (0 == _rect.m_x
|
||||
&& 0 == _rect.m_y
|
||||
&& width == _rect.m_width
|
||||
&& height == _rect.m_height)
|
||||
const Rect fbRect(0, 0, bx::narrowCast<uint16_t>(width), bx::narrowCast<uint16_t>(height) );
|
||||
|
||||
if (_rect.isEqual(fbRect) )
|
||||
{
|
||||
clear(_clear, _palette);
|
||||
}
|
||||
@@ -3514,7 +3509,7 @@ namespace bgfx { namespace d3d11
|
||||
const ShaderD3D11* vsh = program.m_vsh;
|
||||
deviceCtx->VSSetShader(vsh->m_vertexShader, NULL, 0);
|
||||
deviceCtx->VSSetConstantBuffers(0, 1, &vsh->m_buffer);
|
||||
float mrtClearDepth[4] = { _clear.m_depth };
|
||||
const float mrtClearDepth[4] = { _clear.m_depth };
|
||||
deviceCtx->UpdateSubresource(vsh->m_buffer, 0, 0, mrtClearDepth, 0, 0);
|
||||
|
||||
if (NULL != m_currentColor)
|
||||
@@ -3555,8 +3550,8 @@ namespace bgfx { namespace d3d11
|
||||
deviceCtx->PSSetShader(NULL, NULL, 0);
|
||||
}
|
||||
|
||||
VertexBufferD3D11& vb = m_vertexBuffers[_clearQuad.m_vb.idx];
|
||||
const VertexLayout& layout = _clearQuad.m_layout;
|
||||
const VertexBufferD3D11& vb = m_vertexBuffers[_clearQuad.m_vb.idx];
|
||||
const VertexLayout& layout = m_vertexLayouts[_clearQuad.m_layout.idx];
|
||||
|
||||
const uint32_t stride = layout.m_stride;
|
||||
const uint32_t offset = 0;
|
||||
@@ -6260,14 +6255,12 @@ namespace bgfx { namespace d3d11
|
||||
|
||||
if (UINT8_MAX != draw.m_streamMask)
|
||||
{
|
||||
for (uint32_t idx = 0, streamMask = draw.m_streamMask
|
||||
; 0 != streamMask
|
||||
; streamMask >>= 1, idx += 1, ++numStreams
|
||||
for (BitMaskToIndexIteratorT it(draw.m_streamMask)
|
||||
; !it.isDone()
|
||||
; it.next(), numStreams++
|
||||
)
|
||||
{
|
||||
const uint32_t ntz = bx::uint32_cnttz(streamMask);
|
||||
streamMask >>= ntz;
|
||||
idx += ntz;
|
||||
const uint8_t idx = it.idx;
|
||||
|
||||
currentState.m_stream[idx].m_layoutHandle = draw.m_stream[idx].m_layoutHandle;
|
||||
currentState.m_stream[idx].m_handle = draw.m_stream[idx].m_handle;
|
||||
@@ -6476,11 +6469,11 @@ namespace bgfx { namespace d3d11
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasOcclusionQuery)
|
||||
{
|
||||
m_occlusionQuery.end();
|
||||
}
|
||||
if (hasOcclusionQuery)
|
||||
{
|
||||
m_occlusionQuery.end();
|
||||
}
|
||||
|
||||
statsNumPrimsSubmitted[primIndex] += numPrimsSubmitted;
|
||||
@@ -6694,7 +6687,7 @@ namespace bgfx { namespace d3d11
|
||||
max = frameTime;
|
||||
}
|
||||
|
||||
blit(this, _textVideoMemBlitter, tvm);
|
||||
dbgTextSubmit(this, _textVideoMemBlitter, tvm);
|
||||
|
||||
BGFX_D3D11_PROFILER_END();
|
||||
}
|
||||
@@ -6702,7 +6695,7 @@ namespace bgfx { namespace d3d11
|
||||
{
|
||||
BGFX_D3D11_PROFILER_BEGIN_LITERAL("debugtext", kColorFrame);
|
||||
|
||||
blit(this, _textVideoMemBlitter, _render->m_textVideoMem);
|
||||
dbgTextSubmit(this, _textVideoMemBlitter, _render->m_textVideoMem);
|
||||
|
||||
BGFX_D3D11_PROFILER_END();
|
||||
}
|
||||
|
||||
@@ -1868,7 +1868,7 @@ namespace bgfx { namespace d3d12
|
||||
hr = m_swapChain->Present(syncInterval, presentFlags);
|
||||
}
|
||||
|
||||
int64_t now = bx::getHPCounter();
|
||||
const int64_t now = bx::getHPCounter();
|
||||
m_presentElapsed = now - start;
|
||||
|
||||
m_lost = isLost(hr);
|
||||
@@ -1969,20 +1969,12 @@ namespace bgfx { namespace d3d12
|
||||
return m_textures[_handle.idx].create(_mem, _flags, _skip);
|
||||
}
|
||||
|
||||
void updateTextureBegin(TextureHandle /*_handle*/, uint8_t /*_side*/, uint8_t /*_mip*/) override
|
||||
{
|
||||
}
|
||||
|
||||
void updateTexture(TextureHandle _handle, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem) override
|
||||
{
|
||||
m_textures[_handle.idx].update(m_commandList, _side, _mip, _rect, _z, _depth, _pitch, _mem);
|
||||
}
|
||||
|
||||
void updateTextureEnd() override
|
||||
{
|
||||
}
|
||||
|
||||
void readTexture(TextureHandle _handle, void* _data, uint8_t _mip ) override
|
||||
void readTexture(TextureHandle _handle, void* _data, uint8_t _mip) override
|
||||
{
|
||||
const TextureD3D12& texture = m_textures[_handle.idx];
|
||||
|
||||
@@ -2005,8 +1997,8 @@ namespace bgfx { namespace d3d12
|
||||
|
||||
ID3D12Resource* readback = createCommittedResource(m_device, HeapProperty::ReadBack, total);
|
||||
|
||||
uint32_t srcWidth = bx::uint32_max(1, texture.m_width >>_mip);
|
||||
uint32_t srcHeight = bx::uint32_max(1, texture.m_height>>_mip);
|
||||
const uint32_t srcWidth = bx::max(1u, texture.m_width >>_mip);
|
||||
const uint32_t srcHeight = bx::max(1u, texture.m_height>>_mip);
|
||||
|
||||
D3D12_BOX box;
|
||||
box.left = 0;
|
||||
@@ -2287,7 +2279,7 @@ namespace bgfx { namespace d3d12
|
||||
|
||||
void submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter) override;
|
||||
|
||||
void blitSetup(TextVideoMemBlitter& _blitter) override
|
||||
void dbgTextRenderBegin(TextVideoMemBlitter& _blitter) override
|
||||
{
|
||||
const uint32_t width = m_scd.width;
|
||||
const uint32_t height = m_scd.height;
|
||||
@@ -2330,7 +2322,7 @@ namespace bgfx { namespace d3d12
|
||||
float proj[16];
|
||||
bx::mtxOrtho(proj, 0.0f, (float)width, (float)height, 0.0f, 0.0f, 1000.0f, 0.0f, false);
|
||||
|
||||
PredefinedUniform& predefined = m_program[_blitter.m_program.idx].m_predefined[0];
|
||||
const PredefinedUniform& predefined = m_program[_blitter.m_program.idx].m_predefined[0];
|
||||
uint8_t flags = predefined.m_type;
|
||||
setShaderUniform(flags, predefined.m_loc, proj, 4);
|
||||
|
||||
@@ -2347,15 +2339,15 @@ namespace bgfx { namespace d3d12
|
||||
m_commandList->SetGraphicsRootConstantBufferView(Rdt::CBV, gpuAddress);
|
||||
|
||||
TextureD3D12& texture = m_textures[_blitter.m_texture.idx];
|
||||
uint32_t samplerFlags[] = { uint32_t(texture.m_flags & BGFX_SAMPLER_BITS_MASK) };
|
||||
uint16_t samplerStateIdx = getSamplerState(samplerFlags, BX_COUNTOF(samplerFlags), NULL);
|
||||
const uint32_t samplerFlags[] = { uint32_t(texture.m_flags & BGFX_SAMPLER_BITS_MASK) };
|
||||
const uint16_t samplerStateIdx = getSamplerState(samplerFlags, BX_COUNTOF(samplerFlags), NULL);
|
||||
m_commandList->SetGraphicsRootDescriptorTable(Rdt::Sampler, m_samplerAllocator.get(samplerStateIdx) );
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE srvHandle;
|
||||
scratchBuffer.allocSrv(srvHandle, texture);
|
||||
m_commandList->SetGraphicsRootDescriptorTable(Rdt::SRV, srvHandle);
|
||||
|
||||
VertexBufferD3D12& vb = m_vertexBuffers[_blitter.m_vb->handle.idx];
|
||||
const VertexLayout& layout = m_vertexLayouts[_blitter.m_vb->layoutHandle.idx];
|
||||
const VertexBufferD3D12& vb = m_vertexBuffers[_blitter.m_vb->handle.idx];
|
||||
const VertexLayout& layout = m_vertexLayouts[_blitter.m_vb->layoutHandle.idx];
|
||||
D3D12_VERTEX_BUFFER_VIEW viewDesc;
|
||||
viewDesc.BufferLocation = vb.m_gpuVA;
|
||||
viewDesc.StrideInBytes = layout.m_stride;
|
||||
@@ -2372,7 +2364,7 @@ namespace bgfx { namespace d3d12
|
||||
m_commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
}
|
||||
|
||||
void blitRender(TextVideoMemBlitter& _blitter, uint32_t _numIndices) override
|
||||
void dbgTextRender(TextVideoMemBlitter& _blitter, uint32_t _numIndices) override
|
||||
{
|
||||
const uint32_t numVertices = _numIndices*4/6;
|
||||
if (0 < numVertices)
|
||||
@@ -2380,15 +2372,14 @@ namespace bgfx { namespace d3d12
|
||||
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_layout.m_stride, _blitter.m_vb->data, true);
|
||||
|
||||
m_commandList->DrawIndexedInstanced(_numIndices
|
||||
, 1
|
||||
, 0
|
||||
, 0
|
||||
, 0
|
||||
);
|
||||
m_commandList->DrawIndexedInstanced(_numIndices, 1, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void dbgTextRenderEnd(TextVideoMemBlitter& /*_blitter*/) override
|
||||
{
|
||||
}
|
||||
|
||||
void preReset()
|
||||
{
|
||||
finishAll();
|
||||
@@ -3221,7 +3212,7 @@ namespace bgfx { namespace d3d12
|
||||
| BGFX_STATE_PT_MASK
|
||||
;
|
||||
|
||||
_stencil &= packStencil(~BGFX_STENCIL_FUNC_REF_MASK, ~BGFX_STENCIL_FUNC_REF_MASK);
|
||||
_stencil &= kStencilNoRefMask;
|
||||
|
||||
VertexLayout layout;
|
||||
if (0 < _numStreams)
|
||||
@@ -4371,15 +4362,12 @@ namespace bgfx { namespace d3d12
|
||||
|
||||
if (UINT8_MAX != _draw.m_streamMask)
|
||||
{
|
||||
for (uint32_t idx = 0, streamMask = _draw.m_streamMask
|
||||
; 0 != streamMask
|
||||
; streamMask >>= 1, idx += 1, ++numStreams
|
||||
for (BitMaskToIndexIteratorT it(_draw.m_streamMask)
|
||||
; !it.isDone()
|
||||
; it.next(), numStreams++
|
||||
)
|
||||
{
|
||||
const uint32_t ntz = bx::uint32_cnttz(streamMask);
|
||||
streamMask >>= ntz;
|
||||
idx += ntz;
|
||||
|
||||
const uint8_t idx = it.idx;
|
||||
const Stream& stream = _draw.m_stream[idx];
|
||||
|
||||
uint16_t handle = stream.m_handle.idx;
|
||||
@@ -7027,14 +7015,12 @@ namespace bgfx { namespace d3d12
|
||||
uint8_t numStreams = 0;
|
||||
if (UINT8_MAX != draw.m_streamMask)
|
||||
{
|
||||
for (uint32_t idx = 0, streamMask = draw.m_streamMask
|
||||
; 0 != streamMask
|
||||
; streamMask >>= 1, idx += 1, ++numStreams
|
||||
for (BitMaskToIndexIteratorT it(draw.m_streamMask)
|
||||
; !it.isDone()
|
||||
; it.next(), numStreams++
|
||||
)
|
||||
{
|
||||
const uint32_t ntz = bx::uint32_cnttz(streamMask);
|
||||
streamMask >>= ntz;
|
||||
idx += ntz;
|
||||
const uint8_t idx = it.idx;
|
||||
|
||||
currentState.m_stream[idx].m_layoutHandle = draw.m_stream[idx].m_layoutHandle;
|
||||
currentState.m_stream[idx].m_handle = draw.m_stream[idx].m_handle;
|
||||
@@ -7577,7 +7563,7 @@ namespace bgfx { namespace d3d12
|
||||
presentMax = m_presentElapsed;
|
||||
}
|
||||
|
||||
blit(this, _textVideoMemBlitter, tvm);
|
||||
dbgTextSubmit(this, _textVideoMemBlitter, tvm);
|
||||
|
||||
BGFX_D3D12_PROFILER_END();
|
||||
}
|
||||
@@ -7585,7 +7571,7 @@ namespace bgfx { namespace d3d12
|
||||
{
|
||||
BGFX_D3D12_PROFILER_BEGIN_LITERAL("debugtext", kColorFrame);
|
||||
|
||||
blit(this, _textVideoMemBlitter, _render->m_textVideoMem);
|
||||
dbgTextSubmit(this, _textVideoMemBlitter, _render->m_textVideoMem);
|
||||
|
||||
BGFX_D3D12_PROFILER_END();
|
||||
}
|
||||
|
||||
@@ -3399,19 +3399,11 @@ namespace bgfx { namespace gl
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void updateTextureBegin(TextureHandle /*_handle*/, uint8_t /*_side*/, uint8_t /*_mip*/) override
|
||||
{
|
||||
}
|
||||
|
||||
void updateTexture(TextureHandle _handle, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem) override
|
||||
{
|
||||
m_textures[_handle.idx].update(_side, _mip, _rect, _z, _depth, _pitch, _mem);
|
||||
}
|
||||
|
||||
void updateTextureEnd() override
|
||||
{
|
||||
}
|
||||
|
||||
void readTexture(TextureHandle _handle, void* _data, uint8_t _mip) override
|
||||
{
|
||||
if (m_readBackSupported)
|
||||
@@ -3690,7 +3682,7 @@ namespace bgfx { namespace gl
|
||||
|
||||
void submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter) override;
|
||||
|
||||
void blitSetup(TextVideoMemBlitter& _blitter) override
|
||||
void dbgTextRenderBegin(TextVideoMemBlitter& _blitter) override
|
||||
{
|
||||
uint32_t width = m_resolution.width;
|
||||
uint32_t height = m_resolution.height;
|
||||
@@ -3728,7 +3720,7 @@ namespace bgfx { namespace gl
|
||||
}
|
||||
}
|
||||
|
||||
void blitRender(TextVideoMemBlitter& _blitter, uint32_t _numIndices) override
|
||||
void dbgTextRender(TextVideoMemBlitter& _blitter, uint32_t _numIndices) override
|
||||
{
|
||||
const uint32_t numVertices = _numIndices*4/6;
|
||||
if (0 < numVertices)
|
||||
@@ -3755,6 +3747,10 @@ namespace bgfx { namespace gl
|
||||
}
|
||||
}
|
||||
|
||||
void dbgTextRenderEnd(TextVideoMemBlitter& /*_blitter*/) override
|
||||
{
|
||||
}
|
||||
|
||||
void updateResolution(const Resolution& _resolution)
|
||||
{
|
||||
float maxAnisotropy = !!(_resolution.reset & BGFX_RESET_MAXANISOTROPY)
|
||||
@@ -4613,8 +4609,8 @@ namespace bgfx { namespace gl
|
||||
GL_CHECK(glDisable(GL_STENCIL_TEST) );
|
||||
}
|
||||
|
||||
VertexBufferGL& vb = m_vertexBuffers[_clearQuad.m_vb.idx];
|
||||
VertexLayout& layout = _clearQuad.m_layout;
|
||||
const VertexBufferGL& vb = m_vertexBuffers[_clearQuad.m_vb.idx];
|
||||
const VertexLayout& layout = m_vertexLayouts[_clearQuad.m_layout.idx];
|
||||
|
||||
GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, vb.m_id) );
|
||||
|
||||
@@ -8281,14 +8277,9 @@ namespace bgfx { namespace gl
|
||||
}
|
||||
|
||||
{
|
||||
for (uint32_t idx = 0, streamMask = draw.m_streamMask
|
||||
; 0 != streamMask
|
||||
; streamMask >>= 1, idx += 1
|
||||
)
|
||||
for (BitMaskToIndexIteratorT it(draw.m_streamMask); !it.isDone(); it.next() )
|
||||
{
|
||||
const uint32_t ntz = bx::uint32_cnttz(streamMask);
|
||||
streamMask >>= ntz;
|
||||
idx += ntz;
|
||||
const uint8_t idx = it.idx;
|
||||
|
||||
if (currentState.m_stream[idx].m_handle.idx != draw.m_stream[idx].m_handle.idx)
|
||||
{
|
||||
@@ -8353,14 +8344,9 @@ namespace bgfx { namespace gl
|
||||
|
||||
if (UINT8_MAX != draw.m_streamMask)
|
||||
{
|
||||
for (uint32_t idx = 0, streamMask = draw.m_streamMask
|
||||
; 0 != streamMask
|
||||
; streamMask >>= 1, idx += 1
|
||||
)
|
||||
for (BitMaskToIndexIteratorT it(draw.m_streamMask); !it.isDone(); it.next() )
|
||||
{
|
||||
const uint32_t ntz = bx::uint32_cnttz(streamMask);
|
||||
streamMask >>= ntz;
|
||||
idx += ntz;
|
||||
const uint8_t idx = it.idx;
|
||||
|
||||
const VertexBufferGL& vb = m_vertexBuffers[draw.m_stream[idx].m_handle.idx];
|
||||
const uint16_t decl = isValid(draw.m_stream[idx].m_layoutHandle)
|
||||
@@ -8385,16 +8371,12 @@ namespace bgfx { namespace gl
|
||||
if (0 != currentState.m_streamMask)
|
||||
{
|
||||
uint32_t numVertices = draw.m_numVertices;
|
||||
|
||||
if (UINT32_MAX == numVertices)
|
||||
{
|
||||
for (uint32_t idx = 0, streamMask = draw.m_streamMask
|
||||
; 0 != streamMask
|
||||
; streamMask >>= 1, idx += 1
|
||||
)
|
||||
for (BitMaskToIndexIteratorT it(draw.m_streamMask); !it.isDone(); it.next() )
|
||||
{
|
||||
const uint32_t ntz = bx::uint32_cnttz(streamMask);
|
||||
streamMask >>= ntz;
|
||||
idx += ntz;
|
||||
const uint8_t idx = it.idx;
|
||||
|
||||
const VertexBufferGL& vb = m_vertexBuffers[draw.m_stream[idx].m_handle.idx];
|
||||
uint16_t decl = !isValid(vb.m_layoutHandle) ? draw.m_stream[idx].m_layoutHandle.idx : vb.m_layoutHandle.idx;
|
||||
@@ -8840,7 +8822,7 @@ namespace bgfx { namespace gl
|
||||
max = frameTime;
|
||||
}
|
||||
|
||||
blit(this, _textVideoMemBlitter, tvm);
|
||||
dbgTextSubmit(this, _textVideoMemBlitter, tvm);
|
||||
|
||||
BGFX_GL_PROFILER_END();
|
||||
}
|
||||
@@ -8848,7 +8830,7 @@ namespace bgfx { namespace gl
|
||||
{
|
||||
BGFX_GL_PROFILER_BEGIN_LITERAL("debugtext", kColorFrame);
|
||||
|
||||
blit(this, _textVideoMemBlitter, _render->m_textVideoMem);
|
||||
dbgTextSubmit(this, _textVideoMemBlitter, _render->m_textVideoMem);
|
||||
|
||||
BGFX_GL_PROFILER_END();
|
||||
}
|
||||
|
||||
@@ -1082,19 +1082,11 @@ static_assert(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNames
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void updateTextureBegin(TextureHandle /*_handle*/, uint8_t /*_side*/, uint8_t /*_mip*/) override
|
||||
{
|
||||
}
|
||||
|
||||
void updateTexture(TextureHandle _handle, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem) override
|
||||
{
|
||||
m_textures[_handle.idx].update(_side, _mip, _rect, _z, _depth, _pitch, _mem);
|
||||
}
|
||||
|
||||
void updateTextureEnd() override
|
||||
{
|
||||
}
|
||||
|
||||
static MTLPixelFormat getSwapChainPixelFormat(SwapChainMtl* _swapChain)
|
||||
{
|
||||
return NULL != _swapChain
|
||||
@@ -1346,12 +1338,11 @@ static_assert(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNames
|
||||
|
||||
void submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter) override;
|
||||
|
||||
void blitSetup(TextVideoMemBlitter& _blitter) override
|
||||
void dbgTextRenderBegin(TextVideoMemBlitter& /*_blitter*/) override
|
||||
{
|
||||
BX_UNUSED(_blitter);
|
||||
}
|
||||
|
||||
void blitRender(TextVideoMemBlitter& _blitter, uint32_t _numIndices) override
|
||||
void dbgTextRender(TextVideoMemBlitter& _blitter, uint32_t _numIndices) override
|
||||
{
|
||||
const uint32_t numVertices = _numIndices*4/6;
|
||||
if (0 < numVertices)
|
||||
@@ -1466,6 +1457,10 @@ static_assert(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNames
|
||||
}
|
||||
}
|
||||
|
||||
void dbgTextRenderEnd(TextVideoMemBlitter& /*_blitter*/) override
|
||||
{
|
||||
}
|
||||
|
||||
bool isDeviceRemoved() override
|
||||
{
|
||||
return false;
|
||||
@@ -1796,13 +1791,14 @@ static_assert(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNames
|
||||
|
||||
uint32_t numMrt = 1;
|
||||
FrameBufferHandle fbh = m_fbh;
|
||||
if (isValid(fbh) && m_frameBuffers[fbh.idx].m_swapChain == NULL)
|
||||
if (isValid(fbh)
|
||||
&& NULL == m_frameBuffers[fbh.idx].m_swapChain)
|
||||
{
|
||||
const FrameBufferMtl& fb = m_frameBuffers[fbh.idx];
|
||||
numMrt = bx::uint32_max(1, fb.m_num);
|
||||
}
|
||||
|
||||
const VertexLayout* layout = &_clearQuad.m_layout;
|
||||
const VertexLayout* layout = &m_vertexLayouts[_clearQuad.m_layout.idx];
|
||||
const PipelineStateMtl* pso = getPipelineState(
|
||||
state
|
||||
, 0
|
||||
@@ -1836,8 +1832,8 @@ static_assert(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNames
|
||||
m_renderCommandEncoder.setFragmentBuffer(m_uniformBuffer, m_uniformBufferFragmentOffset, 0);
|
||||
}
|
||||
|
||||
const float mrtClearDepth[4] = { _clear.m_depth };
|
||||
float mrtClearColor[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS][4];
|
||||
float mrtClearDepth[4] = { _clear.m_depth };
|
||||
|
||||
if (BGFX_CLEAR_COLOR_USE_PALETTE & _clear.m_flags)
|
||||
{
|
||||
@@ -1921,6 +1917,7 @@ static_assert(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNames
|
||||
FrameBufferMtl& frameBuffer = m_frameBuffers[m_fbh.idx];
|
||||
frameBuffer.resolve();
|
||||
}
|
||||
|
||||
if (!isValid(_fbh)
|
||||
|| m_frameBuffers[_fbh.idx].m_swapChain)
|
||||
{
|
||||
@@ -2012,7 +2009,7 @@ static_assert(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNames
|
||||
uint32_t fstencil = unpackStencil(0, _stencil);
|
||||
uint32_t ref = (fstencil&BGFX_STENCIL_FUNC_REF_MASK)>>BGFX_STENCIL_FUNC_REF_SHIFT;
|
||||
|
||||
_stencil &= packStencil(~BGFX_STENCIL_FUNC_REF_MASK, ~BGFX_STENCIL_FUNC_REF_MASK);
|
||||
_stencil &= kStencilNoRefMask;
|
||||
|
||||
bx::HashMurmur2A murmur;
|
||||
murmur.begin();
|
||||
@@ -3250,7 +3247,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
depth >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MTL_RELEASE(desc, 0);
|
||||
|
||||
if (NULL != temp)
|
||||
@@ -4916,14 +4913,13 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
|
||||
uint32_t numVertices = draw.m_numVertices;
|
||||
uint8_t numStreams = 0;
|
||||
for (uint32_t idx = 0, streamMask = draw.m_streamMask
|
||||
; 0 != streamMask
|
||||
; streamMask >>= 1, idx += 1, ++numStreams
|
||||
|
||||
for (BitMaskToIndexIteratorT it(draw.m_streamMask)
|
||||
; !it.isDone()
|
||||
; it.next(), numStreams++
|
||||
)
|
||||
{
|
||||
const uint32_t ntz = bx::uint32_cnttz(streamMask);
|
||||
streamMask >>= ntz;
|
||||
idx += ntz;
|
||||
const uint8_t idx = it.idx;
|
||||
|
||||
currentState.m_stream[idx].m_layoutHandle = draw.m_stream[idx].m_layoutHandle;
|
||||
currentState.m_stream[idx].m_handle = draw.m_stream[idx].m_handle;
|
||||
@@ -5386,7 +5382,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
max = frameTime;
|
||||
}
|
||||
|
||||
blit(this, _textVideoMemBlitter, tvm);
|
||||
dbgTextSubmit(this, _textVideoMemBlitter, tvm);
|
||||
rce = m_renderCommandEncoder;
|
||||
|
||||
rce.popDebugGroup();
|
||||
@@ -5395,7 +5391,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
{
|
||||
rce.pushDebugGroup("debugtext");
|
||||
|
||||
blit(this, _textVideoMemBlitter, _render->m_textVideoMem);
|
||||
dbgTextSubmit(this, _textVideoMemBlitter, _render->m_textVideoMem);
|
||||
rce = m_renderCommandEncoder;
|
||||
|
||||
rce.popDebugGroup();
|
||||
|
||||
@@ -169,18 +169,10 @@ namespace bgfx { namespace noop
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void updateTextureBegin(TextureHandle /*_handle*/, uint8_t /*_side*/, uint8_t /*_mip*/) override
|
||||
{
|
||||
}
|
||||
|
||||
void updateTexture(TextureHandle /*_handle*/, uint8_t /*_side*/, uint8_t /*_mip*/, const Rect& /*_rect*/, uint16_t /*_z*/, uint16_t /*_depth*/, uint16_t /*_pitch*/, const Memory* /*_mem*/) override
|
||||
{
|
||||
}
|
||||
|
||||
void updateTextureEnd() override
|
||||
{
|
||||
}
|
||||
|
||||
void readTexture(TextureHandle /*_handle*/, void* /*_data*/, uint8_t /*_mip*/) override
|
||||
{
|
||||
}
|
||||
@@ -267,11 +259,15 @@ namespace bgfx { namespace noop
|
||||
perfStats.gpuMemoryUsed = -INT64_MAX;
|
||||
}
|
||||
|
||||
void blitSetup(TextVideoMemBlitter& /*_blitter*/) override
|
||||
void dbgTextRenderBegin(TextVideoMemBlitter& /*_blitter*/) override
|
||||
{
|
||||
}
|
||||
|
||||
void blitRender(TextVideoMemBlitter& /*_blitter*/, uint32_t /*_numIndices*/) override
|
||||
void dbgTextRender(TextVideoMemBlitter& /*_blitter*/, uint32_t /*_numIndices*/) override
|
||||
{
|
||||
}
|
||||
|
||||
void dbgTextRenderEnd(TextVideoMemBlitter& /*_blitter*/) override
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2311,7 +2311,7 @@ VK_IMPORT_DEVICE
|
||||
fb.present();
|
||||
}
|
||||
|
||||
int64_t now = bx::getHPCounter();
|
||||
const int64_t now = bx::getHPCounter();
|
||||
|
||||
m_presentElapsed += now - start;
|
||||
}
|
||||
@@ -2403,19 +2403,11 @@ VK_IMPORT_DEVICE
|
||||
return m_textures[_handle.idx].create(m_commandBuffer, _mem, _flags, _skip);
|
||||
}
|
||||
|
||||
void updateTextureBegin(TextureHandle /*_handle*/, uint8_t /*_side*/, uint8_t /*_mip*/) override
|
||||
{
|
||||
}
|
||||
|
||||
void updateTexture(TextureHandle _handle, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem) override
|
||||
{
|
||||
m_textures[_handle.idx].update(m_commandBuffer, _side, _mip, _rect, _z, _depth, _pitch, _mem);
|
||||
}
|
||||
|
||||
void updateTextureEnd() override
|
||||
{
|
||||
}
|
||||
|
||||
void readTexture(TextureHandle _handle, void* _data, uint8_t _mip) override
|
||||
{
|
||||
TextureVK& texture = m_textures[_handle.idx];
|
||||
@@ -2684,7 +2676,7 @@ VK_IMPORT_DEVICE
|
||||
|
||||
void submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter) override;
|
||||
|
||||
void blitSetup(TextVideoMemBlitter& _blitter) override
|
||||
void dbgTextRenderBegin(TextVideoMemBlitter& _blitter) override
|
||||
{
|
||||
const uint32_t width = m_backBuffer.m_width;
|
||||
const uint32_t height = m_backBuffer.m_height;
|
||||
@@ -2778,7 +2770,7 @@ VK_IMPORT_DEVICE
|
||||
);
|
||||
}
|
||||
|
||||
void blitRender(TextVideoMemBlitter& _blitter, uint32_t _numIndices) override
|
||||
void dbgTextRender(TextVideoMemBlitter& _blitter, uint32_t _numIndices) override
|
||||
{
|
||||
const uint32_t numVertices = _numIndices*4/6;
|
||||
|
||||
@@ -2806,6 +2798,10 @@ VK_IMPORT_DEVICE
|
||||
}
|
||||
}
|
||||
|
||||
void dbgTextRenderEnd(TextVideoMemBlitter& /*_blitter*/) override
|
||||
{
|
||||
}
|
||||
|
||||
void preReset()
|
||||
{
|
||||
for (uint32_t ii = 0; ii < BX_COUNTOF(m_frameBuffers); ++ii)
|
||||
@@ -3021,7 +3017,7 @@ VK_IMPORT_DEVICE
|
||||
|
||||
newFrameBuffer.acquire(m_commandBuffer);
|
||||
|
||||
int64_t now = bx::getHPCounter();
|
||||
const int64_t now = bx::getHPCounter();
|
||||
|
||||
if (NULL != newFrameBuffer.m_nwh)
|
||||
{
|
||||
@@ -3690,7 +3686,7 @@ VK_IMPORT_DEVICE
|
||||
| BGFX_STATE_PT_MASK
|
||||
;
|
||||
|
||||
_stencil &= packStencil(~BGFX_STENCIL_FUNC_REF_MASK, ~BGFX_STENCIL_FUNC_REF_MASK);
|
||||
_stencil &= kStencilNoRefMask;
|
||||
|
||||
VertexLayout layout;
|
||||
if (0 < _numStreams)
|
||||
@@ -5580,6 +5576,7 @@ retry:
|
||||
smci.codeSize = m_code->size;
|
||||
smci.pCode = (const uint32_t*)m_code->data;
|
||||
|
||||
BX_TRACE("%x", bx::hash<bx::HashMurmur3>(code, shaderSize) );
|
||||
VK_CHECK(vkCreateShaderModule(
|
||||
s_renderVK->m_device
|
||||
, &smci
|
||||
@@ -9150,11 +9147,8 @@ retry:
|
||||
}
|
||||
|
||||
if (beginRenderPass && (false
|
||||
|| _render->m_view[view].m_fbh.idx != fbh.idx
|
||||
|| _render->m_view[view].m_rect.m_x != viewState.m_rect.m_x
|
||||
|| _render->m_view[view].m_rect.m_y != viewState.m_rect.m_y
|
||||
|| _render->m_view[view].m_rect.m_width != viewState.m_rect.m_width
|
||||
|| _render->m_view[view].m_rect.m_height != viewState.m_rect.m_height
|
||||
|| _render->m_view[view].m_fbh.idx != fbh.idx
|
||||
|| !_render->m_view[view].m_rect.isEqual(viewState.m_rect)
|
||||
) )
|
||||
{
|
||||
vkCmdEndRenderPass(m_commandBuffer);
|
||||
@@ -9540,14 +9534,12 @@ retry:
|
||||
uint32_t numVertices = draw.m_numVertices;
|
||||
if (UINT8_MAX != draw.m_streamMask)
|
||||
{
|
||||
for (uint32_t idx = 0, streamMask = draw.m_streamMask
|
||||
; 0 != streamMask
|
||||
; streamMask >>= 1, idx += 1, ++numStreams
|
||||
for (BitMaskToIndexIteratorT it(draw.m_streamMask)
|
||||
; !it.isDone()
|
||||
; it.next(), numStreams++
|
||||
)
|
||||
{
|
||||
const uint32_t ntz = bx::uint32_cnttz(streamMask);
|
||||
streamMask >>= ntz;
|
||||
idx += ntz;
|
||||
const uint8_t idx = it.idx;
|
||||
|
||||
currentState.m_stream[idx] = draw.m_stream[idx];
|
||||
|
||||
@@ -10168,7 +10160,7 @@ retry:
|
||||
presentMax = m_presentElapsed;
|
||||
}
|
||||
|
||||
blit(this, _textVideoMemBlitter, tvm);
|
||||
dbgTextSubmit(this, _textVideoMemBlitter, tvm);
|
||||
|
||||
BGFX_VK_PROFILER_END();
|
||||
}
|
||||
@@ -10176,7 +10168,7 @@ retry:
|
||||
{
|
||||
BGFX_VK_PROFILER_BEGIN_LITERAL("debugtext", kColorFrame);
|
||||
|
||||
blit(this, _textVideoMemBlitter, _render->m_textVideoMem);
|
||||
dbgTextSubmit(this, _textVideoMemBlitter, _render->m_textVideoMem);
|
||||
|
||||
BGFX_VK_PROFILER_END();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user