Skip to content

Commit

Permalink
D3D9 bool constants have a separate register space, oops.
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jan 9, 2023
1 parent 69411f3 commit 197c0d5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion GPU/Common/FragmentShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
if (texFunc == GE_TEXFUNC_BLEND) {
WRITE(p, "float3 u_texenv : register(c%i);\n", CONST_PS_TEXENV);
}
WRITE(p, "bool u_texAlpha : register(c%i);\n", CONST_PS_TEXALPHA);
WRITE(p, "bool u_texAlpha : register(b%i);\n", CONST_PS_TEXALPHA); // NOTE! "b" register, not "c"!
}
WRITE(p, "float3 u_fogcolor : register(c%i);\n", CONST_PS_FOGCOLOR);
if (texture3D) {
Expand Down
9 changes: 6 additions & 3 deletions GPU/Common/FragmentShaderGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

struct FShaderID;

// D3D9 constants
// D3D9 float constants

#define CONST_PS_TEXENV 0
#define CONST_PS_ALPHACOLORREF 1
Expand All @@ -36,10 +36,13 @@ struct FShaderID;
#define CONST_PS_TEXCLAMP 8
#define CONST_PS_TEXCLAMPOFF 9
#define CONST_PS_MIPBIAS 10
#define CONST_PS_TEXALPHA 11

// For stencil upload
#define CONST_PS_STENCILVALUE 12
#define BCONST_PS_STENCILVALUE 11

// D3D9 bool constants, they have their own register space.
#define CONST_PS_TEXALPHA 0


// Can technically be deduced from the fragment shader ID, but this is safer.
enum class FragmentShaderFlags : u32 {
Expand Down
5 changes: 2 additions & 3 deletions GPU/Common/ShaderId.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

#include "Common/CommonFuncs.h"

// TODO: There will be additional bits, indicating that groups of these will be
// sent to the shader and processed there. This will cut down the number of shaders ("ubershader approach")
// This is probably only really worth doing for lighting and bones.
// VS_BIT_LIGHT_UBERSHADER indicates that some groups of these will be
// sent to the shader and processed there. This cuts down the number of shaders ("ubershader approach").
enum VShaderBit : uint8_t {
VS_BIT_LMODE = 0,
VS_BIT_IS_THROUGH = 1,
Expand Down

0 comments on commit 197c0d5

Please sign in to comment.