Removed D3D9. (#3191)

This commit is contained in:
Бранимир Караџић
2023-11-03 21:15:42 -07:00
committed by GitHub
parent 6a914f5b13
commit f14c14a485
333 changed files with 8957 additions and 23428 deletions

View File

@@ -177,8 +177,7 @@ static const uint16_t s_planeIndices[] =
1, 3, 2,
};
static bool s_flipV = false;
static float s_texelHalf = 0.0f;
static bool s_originBottomLeft = false;
static bgfx::UniformHandle s_texColor;
static bgfx::UniformHandle s_shadowMap[ShadowMapRenderTargets::Count];
@@ -858,7 +857,7 @@ struct PosColorTexCoord0Vertex
bgfx::VertexLayout PosColorTexCoord0Vertex::ms_layout;
void screenSpaceQuad(float _textureWidth, float _textureHeight, bool _originBottomLeft = true, float _width = 1.0f, float _height = 1.0f)
void screenSpaceQuad(bool _originBottomLeft = true, float _width = 1.0f, float _height = 1.0f)
{
if (3 == bgfx::getAvailTransientVertexBuffer(3, PosColorTexCoord0Vertex::ms_layout) )
{
@@ -873,13 +872,11 @@ void screenSpaceQuad(float _textureWidth, float _textureHeight, bool _originBott
const float miny = 0.0f;
const float maxy = _height*2.0f;
const float texelHalfW = s_texelHalf/_textureWidth;
const float texelHalfH = s_texelHalf/_textureHeight;
const float minu = -1.0f + texelHalfW;
const float maxu = 1.0f + texelHalfW;
const float minu = -1.0f;
const float maxu = 1.0f;
float minv = texelHalfH;
float maxv = 2.0f + texelHalfH;
float minv = 0.0f;
float maxv = 2.0f;
if (_originBottomLeft)
{
@@ -1168,22 +1165,7 @@ public:
// Enable debug text.
bgfx::setDebug(m_debug);
// Setup root path for binary shaders. Shader binaries are different
// for each renderer.
switch (bgfx::getRendererType() )
{
case bgfx::RendererType::Direct3D9:
s_texelHalf = 0.5f;
break;
case bgfx::RendererType::OpenGL:
case bgfx::RendererType::OpenGLES:
s_flipV = true;
break;
default:
break;
}
s_originBottomLeft = bgfx::getCaps()->originBottomLeft;
// Imgui.
imguiCreate();
@@ -2784,12 +2766,12 @@ public:
{
bgfx::setTexture(4, s_shadowMap[0], bgfx::getTexture(s_rtShadowMap[0]) );
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
screenSpaceQuad(currentShadowMapSizef, currentShadowMapSizef, s_flipV);
screenSpaceQuad(s_originBottomLeft);
bgfx::submit(RENDERVIEW_VBLUR_0_ID, s_programs.m_vBlur[depthType]);
bgfx::setTexture(4, s_shadowMap[0], bgfx::getTexture(s_rtBlur) );
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
screenSpaceQuad(currentShadowMapSizef, currentShadowMapSizef, s_flipV);
screenSpaceQuad(s_originBottomLeft);
bgfx::submit(RENDERVIEW_HBLUR_0_ID, s_programs.m_hBlur[depthType]);
if (LightType::DirectionalLight == m_settings.m_lightType)
@@ -2800,12 +2782,12 @@ public:
bgfx::setTexture(4, s_shadowMap[0], bgfx::getTexture(s_rtShadowMap[ii]) );
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
screenSpaceQuad(currentShadowMapSizef, currentShadowMapSizef, s_flipV);
screenSpaceQuad(s_originBottomLeft);
bgfx::submit(viewId, s_programs.m_vBlur[depthType]);
bgfx::setTexture(4, s_shadowMap[0], bgfx::getTexture(s_rtBlur) );
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
screenSpaceQuad(currentShadowMapSizef, currentShadowMapSizef, s_flipV);
screenSpaceQuad(s_originBottomLeft);
bgfx::submit(viewId+1, s_programs.m_hBlur[depthType]);
}
}
@@ -2816,7 +2798,7 @@ public:
// Setup shadow mtx.
float mtxShadow[16];
const float ymul = (s_flipV) ? 0.5f : -0.5f;
const float ymul = (s_originBottomLeft) ? 0.5f : -0.5f;
float zadd = (DepthImpl::Linear == m_settings.m_depthImpl) ? 0.0f : 0.5f;
const float mtxBias[16] =
@@ -2835,7 +2817,7 @@ public:
}
else if (LightType::PointLight == m_settings.m_lightType)
{
const float s = (s_flipV) ? 1.0f : -1.0f; //sign
const float s = (s_originBottomLeft) ? 1.0f : -1.0f; //sign
zadd = (DepthImpl::Linear == m_settings.m_depthImpl) ? 0.0f : 0.5f;
const float mtxCropBias[2][TetrahedronFaces::Count][16] =
@@ -2912,7 +2894,7 @@ public:
for (uint8_t ii = 0; ii < TetrahedronFaces::Count; ++ii)
{
ProjType::Enum projType = (m_settings.m_stencilPack) ? ProjType::Enum(ii>1) : ProjType::Horizontal;
uint8_t biasIndex = cropBiasIndices[m_settings.m_stencilPack][uint8_t(s_flipV)][ii];
uint8_t biasIndex = cropBiasIndices[m_settings.m_stencilPack][uint8_t(s_originBottomLeft)][ii];
float mtxTmp[16];
bx::mtxMul(mtxTmp, mtxYpr[ii], lightProj[projType]);
@@ -3040,7 +3022,7 @@ public:
{
bgfx::setTexture(4, s_shadowMap[0], bgfx::getTexture(s_rtShadowMap[0]) );
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
screenSpaceQuad(currentShadowMapSizef, currentShadowMapSizef, s_flipV);
screenSpaceQuad(s_originBottomLeft);
bgfx::submit(RENDERVIEW_DRAWDEPTH_0_ID, s_programs.m_drawDepth[depthType]);
if (LightType::DirectionalLight == m_settings.m_lightType)
@@ -3049,7 +3031,7 @@ public:
{
bgfx::setTexture(4, s_shadowMap[0], bgfx::getTexture(s_rtShadowMap[ii]) );
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
screenSpaceQuad(currentShadowMapSizef, currentShadowMapSizef, s_flipV);
screenSpaceQuad(s_originBottomLeft);
bgfx::submit(RENDERVIEW_DRAWDEPTH_0_ID+ii, s_programs.m_drawDepth[depthType]);
}
}