Larger debug text for retina display (#3109)

* Add Init.Resolution.scaleDebug

* clamp scale to BGFX_CONFIG_MAX_SCALE_DEBUG

* update version

* Use textWdith/textHeight in helloworld
This commit is contained in:
云风
2023-06-14 09:17:38 +08:00
committed by GitHub
parent b5471d14f8
commit 498c34273b
12 changed files with 33 additions and 15 deletions

View File

@@ -669,7 +669,7 @@ namespace bgfx
static const uint32_t numBatchVertices = numCharsPerBatch*4;
static const uint32_t numBatchIndices = numCharsPerBatch*6;
void TextVideoMemBlitter::init()
void TextVideoMemBlitter::init(uint8_t scale)
{
BGFX_CHECK_API_THREAD();
m_layout
@@ -709,6 +709,7 @@ namespace bgfx
m_vb = s_ctx->createTransientVertexBuffer(numBatchVertices*m_layout.m_stride, &m_layout);
m_ib = s_ctx->createTransientIndexBuffer(numBatchIndices*2);
m_scale = bx::max<uint8_t>(scale, 1);
}
void TextVideoMemBlitter::shutdown()
@@ -789,7 +790,8 @@ namespace bgfx
const float texelHeightHalf = RendererType::Direct3D9 == g_caps.rendererType ? texelHeight*0.5f : 0.0f;
const float utop = (_mem.m_small ? 0.0f : 8.0f)*texelHeight + texelHeightHalf;
const float ubottom = (_mem.m_small ? 8.0f : 24.0f)*texelHeight + texelHeightHalf;
const float fontHeight = (_mem.m_small ? 8.0f : 16.0f);
const float fontHeight = (_mem.m_small ? 8.0f : 16.0f)*_blitter.m_scale;
const float fontWidth = 8.0f * _blitter.m_scale;
_renderCtx->blitSetup(_blitter);
@@ -828,10 +830,10 @@ namespace bgfx
Vertex vert[4] =
{
{ (xx )*8.0f, (yy )*fontHeight, 0.0f, fg, bg, (ch )*8.0f*texelWidth - texelWidthHalf, utop },
{ (xx+1)*8.0f, (yy )*fontHeight, 0.0f, fg, bg, (ch+1)*8.0f*texelWidth - texelWidthHalf, utop },
{ (xx+1)*8.0f, (yy+1)*fontHeight, 0.0f, fg, bg, (ch+1)*8.0f*texelWidth - texelWidthHalf, ubottom },
{ (xx )*8.0f, (yy+1)*fontHeight, 0.0f, fg, bg, (ch )*8.0f*texelWidth - texelWidthHalf, ubottom },
{ (xx )*fontWidth, (yy )*fontHeight, 0.0f, fg, bg, (ch )*8.0f*texelWidth - texelWidthHalf, utop },
{ (xx+1)*fontWidth, (yy )*fontHeight, 0.0f, fg, bg, (ch+1)*8.0f*texelWidth - texelWidthHalf, utop },
{ (xx+1)*fontWidth, (yy+1)*fontHeight, 0.0f, fg, bg, (ch+1)*8.0f*texelWidth - texelWidthHalf, ubottom },
{ (xx )*fontWidth, (yy+1)*fontHeight, 0.0f, fg, bg, (ch )*8.0f*texelWidth - texelWidthHalf, ubottom },
};
bx::memCopy(vertex, vert, sizeof(vert) );
@@ -1893,6 +1895,7 @@ namespace bgfx
m_init.resolution.reset &= ~BGFX_RESET_INTERNAL_FORCE;
m_init.resolution.numBackBuffers = bx::clamp<uint8_t>(_init.resolution.numBackBuffers, 2, BGFX_CONFIG_MAX_BACK_BUFFERS);
m_init.resolution.maxFrameLatency = bx::min<uint8_t>(_init.resolution.maxFrameLatency, BGFX_CONFIG_MAX_FRAME_LATENCY);
m_init.resolution.scaleDebug = bx::clamp<uint8_t>(_init.resolution.scaleDebug, 1, BGFX_CONFIG_MAX_SCALE_DEBUG);
dump(m_init.resolution);
if (true
@@ -2029,7 +2032,7 @@ namespace bgfx
dumpCaps();
m_textVideoMemBlitter.init();
m_textVideoMemBlitter.init(m_init.resolution.scaleDebug);
m_clearQuad.init();
m_submit->m_transientVb = createTransientVertexBuffer(_init.limits.transientVbSize);
@@ -3433,6 +3436,7 @@ namespace bgfx
, reset(BGFX_RESET_NONE)
, numBackBuffers(2)
, maxFrameLatency(0)
, scaleDebug(0)
{
}

View File

@@ -757,7 +757,7 @@ namespace bgfx
struct TextVideoMemBlitter
{
void init();
void init(uint8_t scale);
void shutdown();
TextureHandle m_texture;
@@ -765,6 +765,7 @@ namespace bgfx
TransientIndexBuffer* m_ib;
VertexLayout m_layout;
ProgramHandle m_program;
uint8_t m_scale;
};
struct RendererContextI;
@@ -3249,7 +3250,7 @@ namespace bgfx
{
BGFX_MUTEX_SCOPE(m_resourceApiLock);
m_submit->m_textVideoMem->resize(_small, (uint16_t)m_init.resolution.width, (uint16_t)m_init.resolution.height);
m_submit->m_textVideoMem->resize(_small, (uint16_t)m_init.resolution.width / m_init.resolution.scaleDebug , (uint16_t)m_init.resolution.height / m_init.resolution.scaleDebug );
m_submit->m_textVideoMem->clear(_attr);
}

View File

@@ -381,6 +381,10 @@ BX_STATIC_ASSERT(bx::isPowerOf2(BGFX_CONFIG_MAX_VIEWS), "BGFX_CONFIG_MAX_VIEWS m
# define BGFX_CONFIG_MAX_FRAME_LATENCY 3
#endif // BGFX_CONFIG_MAX_FRAME_LATENCY
#ifndef BGFX_CONFIG_MAX_SCALE_DEBUG
# define BGFX_CONFIG_MAX_SCALE_DEBUG 4
#endif // BGFX_CONFIG_MAX_SCALE_DEBUG
#ifndef BGFX_CONFIG_PREFER_DISCRETE_GPU
// On laptops with integrated and discrete GPU, prefer selection of discrete GPU.
// nVidia and AMD, on Windows only.