From fb74c9dfeb2ea55a2621ccd2df7d950b246bc9a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 7 Dec 2017 21:08:34 +0100 Subject: [PATCH] Clean up a small inconsistency --- GPU/Common/ShaderCommon.h | 1 - GPU/Common/ShaderUniforms.cpp | 12 +++++++----- GPU/Common/ShaderUniforms.h | 8 +++----- GPU/D3D11/GPU_D3D11.cpp | 2 -- GPU/Directx9/GPU_DX9.cpp | 2 -- GPU/GLES/GPU_GLES.cpp | 2 -- GPU/GPUCommon.cpp | 1 + GPU/Vulkan/GPU_Vulkan.cpp | 2 -- 8 files changed, 11 insertions(+), 19 deletions(-) diff --git a/GPU/Common/ShaderCommon.h b/GPU/Common/ShaderCommon.h index c78318f927..eaf5ef3596 100644 --- a/GPU/Common/ShaderCommon.h +++ b/GPU/Common/ShaderCommon.h @@ -54,7 +54,6 @@ enum : uint64_t { DIRTY_TEXENV = 1ULL << 4, DIRTY_ALPHACOLORREF = 1ULL << 5, - // 1 << 6 is free! Wait, not anymore... DIRTY_STENCILREPLACEVALUE = 1ULL << 6, DIRTY_ALPHACOLORMASK = 1ULL << 7, diff --git a/GPU/Common/ShaderUniforms.cpp b/GPU/Common/ShaderUniforms.cpp index 8100bdc868..4a7b960801 100644 --- a/GPU/Common/ShaderUniforms.cpp +++ b/GPU/Common/ShaderUniforms.cpp @@ -113,12 +113,10 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView ConvertMatrix4x3To3x4Transposed(ub->tex, gstate.tgenMatrix); } - // Combined two small uniforms - if (dirtyUniforms & (DIRTY_FOGCOEF | DIRTY_STENCILREPLACEVALUE)) { - float fogcoef_stencil[3] = { + if (dirtyUniforms & DIRTY_FOGCOEF) { + float fogcoef_stencil[2] = { getFloat24(gstate.fog1), getFloat24(gstate.fog2), - (float)gstate.getStencilTestRef()/255.0f }; if (my_isinf(fogcoef_stencil[1])) { // not really sure what a sensible value might be. @@ -136,7 +134,11 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView ERROR_LOG_REPORT_ONCE(fognan, G3D, "Unhandled fog NaN/INF combo: %f %f", fogcoef_stencil[0], fogcoef_stencil[1]); } #endif - CopyFloat3(ub->fogCoef_stencil, fogcoef_stencil); + CopyFloat2(ub->fogCoef, fogcoef_stencil); + } + + if (dirtyUniforms & DIRTY_STENCILREPLACEVALUE) { + ub->stencil = (float)gstate.getStencilTestRef() / 255.0; } // Note - this one is not in lighting but in transformCommon as it has uses beyond lighting diff --git a/GPU/Common/ShaderUniforms.h b/GPU/Common/ShaderUniforms.h index 55f08f7658..c8617e2ede 100644 --- a/GPU/Common/ShaderUniforms.h +++ b/GPU/Common/ShaderUniforms.h @@ -20,6 +20,7 @@ enum : uint64_t { // TODO: Split into two structs, one for software transform and one for hardware transform, to save space. // 512 bytes. Probably can't get to 256 (nVidia's UBO alignment). +// Every line here is a 4-float. struct UB_VS_FS_Base { float proj[16]; float proj_through[16]; @@ -28,12 +29,9 @@ struct UB_VS_FS_Base { float tex[12]; float uvScaleOffset[4]; float depthRange[4]; - float fogCoef_stencil[4]; + float fogCoef[2]; float stencil; float pad0; float matAmbient[4]; - int spline_count_u; - int spline_count_v; - int spline_type_u; - int spline_type_v; + int spline_count_u; int spline_count_v; int spline_type_u; int spline_type_v; // Fragment data float fogColor[4]; float texEnvColor[4]; diff --git a/GPU/D3D11/GPU_D3D11.cpp b/GPU/D3D11/GPU_D3D11.cpp index 915121d261..6fae089052 100644 --- a/GPU/D3D11/GPU_D3D11.cpp +++ b/GPU/D3D11/GPU_D3D11.cpp @@ -78,8 +78,6 @@ static const D3D11CommandTableEntry commandTable[] = { // Changes that dirty the current texture. { GE_CMD_TEXSIZE0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTE, 0, &GPUCommon::Execute_TexSize0 }, - { GE_CMD_STENCILTEST, FLAG_FLUSHBEFOREONCHANGE, DIRTY_STENCILREPLACEVALUE | DIRTY_FOGCOEF | DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE }, // These are combined in D3D11 - // Changing the vertex type requires us to flush. { GE_CMD_VERTEXTYPE, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPUCommon::Execute_VertexType }, diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index 131136ea7c..4afaa7238a 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -62,8 +62,6 @@ static const D3D9CommandTableEntry commandTable[] = { // Changes that dirty the current texture. { GE_CMD_TEXSIZE0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTE, 0, &GPUCommon::Execute_TexSize0 }, - { GE_CMD_STENCILTEST, FLAG_FLUSHBEFOREONCHANGE, DIRTY_STENCILREPLACEVALUE | DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE }, - // Changing the vertex type requires us to flush. { GE_CMD_VERTEXTYPE, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPUCommon::Execute_VertexType }, diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index f159844697..60afb26dbe 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -65,8 +65,6 @@ static const GLESCommandTableEntry commandTable[] = { // Changes that dirty the current texture. { GE_CMD_TEXSIZE0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTE, 0, &GPUCommon::Execute_TexSize0 }, - { GE_CMD_STENCILTEST, FLAG_FLUSHBEFOREONCHANGE, DIRTY_STENCILREPLACEVALUE | DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE }, - // Changing the vertex type requires us to flush. { GE_CMD_VERTEXTYPE, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPUCommon::Execute_VertexType }, diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 540dd80d6a..241ecc3e56 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -99,6 +99,7 @@ const CommonCommandTableEntry commonCommandTable[] = { { GE_CMD_CULLFACEENABLE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_RASTER_STATE }, { GE_CMD_DITHERENABLE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_RASTER_STATE }, { GE_CMD_STENCILOP, FLAG_FLUSHBEFOREONCHANGE, DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_FRAGMENTSHADER_STATE }, + { GE_CMD_STENCILTEST, FLAG_FLUSHBEFOREONCHANGE, DIRTY_STENCILREPLACEVALUE | DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE }, { GE_CMD_STENCILTESTENABLE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_FRAGMENTSHADER_STATE }, { GE_CMD_ALPHABLENDENABLE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_BLEND_STATE | DIRTY_FRAGMENTSHADER_STATE }, { GE_CMD_BLENDMODE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_BLEND_STATE | DIRTY_FRAGMENTSHADER_STATE }, diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 869ec3fb99..1140471a4d 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -60,8 +60,6 @@ static const VulkanCommandTableEntry commandTable[] = { // Changes that dirty the current texture. { GE_CMD_TEXSIZE0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTE, 0, &GPUCommon::Execute_TexSize0 }, - { GE_CMD_STENCILTEST, FLAG_FLUSHBEFOREONCHANGE, DIRTY_STENCILREPLACEVALUE | DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE }, - // Changing the vertex type requires us to flush. { GE_CMD_VERTEXTYPE, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPUCommon::Execute_VertexType },