mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-24 16:48:18 -05:00
Fixed MRT clear color.
This commit is contained in:
parent
62d36ebe8a
commit
bc3bb5c6a4
3 changed files with 28 additions and 22 deletions
|
@ -1894,7 +1894,7 @@ namespace bgfx
|
|||
{ KTX_RG32UI, KTX_ZERO, KTX_RG, KTX_UNSIGNED_INT, }, // RG32U
|
||||
{ KTX_RG32F, KTX_ZERO, KTX_RG, KTX_FLOAT, }, // RG32F
|
||||
{ KTX_RGB9_E5, KTX_ZERO, KTX_RGB, KTX_UNSIGNED_INT_5_9_9_9_REV, }, // RGB9E5F
|
||||
{ KTX_RGBA8, KTX_SRGB8_ALPHA8, KTX_BGRA, KTX_UNSIGNED_BYTE, }, // BGRA8
|
||||
{ KTX_BGRA, KTX_SRGB8_ALPHA8, KTX_BGRA, KTX_UNSIGNED_BYTE, }, // BGRA8
|
||||
{ KTX_RGBA8, KTX_SRGB8_ALPHA8, KTX_RGBA, KTX_UNSIGNED_BYTE, }, // RGBA8
|
||||
{ KTX_RGBA8I, KTX_ZERO, KTX_RGBA, KTX_BYTE, }, // RGBA8I
|
||||
{ KTX_RGBA8UI, KTX_ZERO, KTX_RGBA, KTX_UNSIGNED_BYTE, }, // RGBA8U
|
||||
|
@ -2475,7 +2475,6 @@ namespace bgfx
|
|||
const float4_t umask = float4_ild(0xff, 0xff00, 0xff0000, 0xff000000);
|
||||
const float4_t wflip = float4_ild(0, 0, 0, 0x80000000);
|
||||
const float4_t wadd = float4_ld(0.0f, 0.0f, 0.0f, 32768.0f*65536.0f);
|
||||
const float4_t linear = float4_ld(2.2f, 2.2f, 2.2f, 1.0f);
|
||||
|
||||
for (uint32_t yy = 0, ystep = _pitch; yy < dstheight; ++yy, src += ystep)
|
||||
{
|
||||
|
@ -2489,9 +2488,7 @@ namespace bgfx
|
|||
const float4_t abgr0c = float4_add(abgr0f, wadd);
|
||||
const float4_t abgr0n = float4_mul(abgr0c, unpack);
|
||||
|
||||
const float4_t abgr0l = float4_pow(abgr0n, linear);
|
||||
|
||||
float4_st(dst, abgr0l);
|
||||
float4_st(dst, abgr0n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1925,30 +1925,34 @@ namespace bgfx { namespace d3d9
|
|||
device->SetVertexShader(program.m_vsh->m_vertexShader);
|
||||
device->SetPixelShader(program.m_fsh->m_pixelShader);
|
||||
|
||||
float mrtClear[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS][4];
|
||||
|
||||
if (BGFX_CLEAR_COLOR_USE_PALETTE & _clear.m_flags)
|
||||
{
|
||||
float mrtClear[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS][4];
|
||||
for (uint32_t ii = 0; ii < numMrt; ++ii)
|
||||
{
|
||||
uint8_t index = (uint8_t)bx::uint32_min(BGFX_CONFIG_MAX_COLOR_PALETTE-1, _clear.m_index[ii]);
|
||||
uint8_t index = (uint8_t)bx::uint32_min(BGFX_CONFIG_MAX_COLOR_PALETTE - 1, _clear.m_index[ii]);
|
||||
memcpy(mrtClear[ii], _palette[index], 16);
|
||||
}
|
||||
|
||||
DX_CHECK(m_device->SetPixelShaderConstantF(0, mrtClear[0], numMrt) );
|
||||
}
|
||||
else
|
||||
{
|
||||
float rgba[4] =
|
||||
{
|
||||
_clear.m_index[0]*1.0f/255.0f,
|
||||
_clear.m_index[1]*1.0f/255.0f,
|
||||
_clear.m_index[2]*1.0f/255.0f,
|
||||
_clear.m_index[3]*1.0f/255.0f,
|
||||
_clear.m_index[0] * 1.0f / 255.0f,
|
||||
_clear.m_index[1] * 1.0f / 255.0f,
|
||||
_clear.m_index[2] * 1.0f / 255.0f,
|
||||
_clear.m_index[3] * 1.0f / 255.0f,
|
||||
};
|
||||
|
||||
DX_CHECK(m_device->SetPixelShaderConstantF(0, rgba, 1) );
|
||||
for (uint32_t ii = 0; ii < numMrt; ++ii)
|
||||
{
|
||||
memcpy(mrtClear[ii], rgba, 16);
|
||||
}
|
||||
}
|
||||
|
||||
DX_CHECK(device->SetPixelShaderConstantF(0, mrtClear[0], numMrt));
|
||||
|
||||
DX_CHECK(device->SetStreamSource(0, vb.m_ptr, 0, stride) );
|
||||
DX_CHECK(device->SetStreamSourceFreq(0, 1) );
|
||||
DX_CHECK(device->SetStreamSource(1, NULL, 0, 0) );
|
||||
|
|
|
@ -3171,29 +3171,34 @@ namespace bgfx { namespace gl
|
|||
GL_CHECK(glUseProgram(program.m_id) );
|
||||
program.bindAttributes(vertexDecl, 0);
|
||||
|
||||
float mrtClear[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS][4];
|
||||
|
||||
if (BGFX_CLEAR_COLOR_USE_PALETTE & _clear.m_flags)
|
||||
{
|
||||
float mrtClear[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS][4];
|
||||
for (uint32_t ii = 0; ii < numMrt; ++ii)
|
||||
{
|
||||
uint8_t index = (uint8_t)bx::uint32_min(BGFX_CONFIG_MAX_COLOR_PALETTE-1, _clear.m_index[ii]);
|
||||
memcpy(mrtClear[ii], _palette[index], 16);
|
||||
}
|
||||
|
||||
GL_CHECK(glUniform4fv(0, numMrt, mrtClear[0]) );
|
||||
}
|
||||
else
|
||||
{
|
||||
float rgba[4] =
|
||||
{
|
||||
_clear.m_index[0]*1.0f/255.0f,
|
||||
_clear.m_index[1]*1.0f/255.0f,
|
||||
_clear.m_index[2]*1.0f/255.0f,
|
||||
_clear.m_index[3]*1.0f/255.0f,
|
||||
_clear.m_index[0] * 1.0f / 255.0f,
|
||||
_clear.m_index[1] * 1.0f / 255.0f,
|
||||
_clear.m_index[2] * 1.0f / 255.0f,
|
||||
_clear.m_index[3] * 1.0f / 255.0f,
|
||||
};
|
||||
GL_CHECK(glUniform4fv(0, 1, rgba) );
|
||||
|
||||
for (uint32_t ii = 0; ii < numMrt; ++ii)
|
||||
{
|
||||
memcpy(mrtClear[ii], rgba, 16);
|
||||
}
|
||||
}
|
||||
|
||||
GL_CHECK(glUniform4fv(0, numMrt, mrtClear[0]) );
|
||||
|
||||
GL_CHECK(glDrawArrays(GL_TRIANGLE_STRIP
|
||||
, 0
|
||||
, 4
|
||||
|
|
Loading…
Reference in a new issue