mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Share the uniform buffer declarations between D3D11 and VK.
This commit is contained in:
parent
f1dbd25de9
commit
17778131bd
4 changed files with 11 additions and 75 deletions
|
@ -51,6 +51,9 @@ const char *hlsl_preamble_fs =
|
|||
"#define vec4 float4\n"
|
||||
"#define uvec3 uint3\n"
|
||||
"#define ivec3 int3\n"
|
||||
"#define ivec4 int4\n"
|
||||
"#define mat4 float4x4\n"
|
||||
"#define mat3x4 float4x3\n" // note how the conventions are backwards
|
||||
"#define splat3(x) float3(x, x, x)\n"
|
||||
"#define mix lerp\n"
|
||||
"#define mod(x, y) fmod(x, y)\n";
|
||||
|
@ -246,7 +249,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
|
|||
WRITE(p, "Texture2D<vec4> fboTex : register(t1);\n");
|
||||
}
|
||||
}
|
||||
WRITE(p, "cbuffer base : register(b0) {\n%s};\n", cb_baseStr);
|
||||
WRITE(p, "cbuffer base : register(b0) {\n%s};\n", ub_baseStr);
|
||||
}
|
||||
|
||||
if (enableAlphaTest) {
|
||||
|
|
|
@ -72,34 +72,6 @@ R"( mat4 u_proj;
|
|||
vec2 u_texclampoff;
|
||||
)";
|
||||
|
||||
// HLSL code is shared so these names are changed to match those in DX9.
|
||||
static const char *cb_baseStr =
|
||||
R"( float4x4 u_proj;
|
||||
float4x4 u_proj_through;
|
||||
float4x3 u_view;
|
||||
float4x3 u_world;
|
||||
float4x3 u_texmtx;
|
||||
float4 u_uvscaleoffset;
|
||||
float4 u_depthRange;
|
||||
float2 u_fogcoef;
|
||||
float u_stencilReplaceValue;
|
||||
float4 u_matambientalpha;
|
||||
uint u_spline_counts;
|
||||
uint u_depal_mask_shift_off_fmt;
|
||||
int pad2;
|
||||
int pad3;
|
||||
float4 u_cullRangeMin;
|
||||
float4 u_cullRangeMax;
|
||||
float3 u_fogcolor;
|
||||
float3 u_texenv;
|
||||
int4 u_alphacolorref;
|
||||
uint4 u_alphacolormask;
|
||||
float3 u_blendFixA;
|
||||
float3 u_blendFixB;
|
||||
float4 u_texclamp;
|
||||
float2 u_texclampoff;
|
||||
)";
|
||||
|
||||
// 512 bytes. Would like to shrink more. Some colors only have 8-bit precision and we expand
|
||||
// them to float unnecessarily, could just as well expand in the shader.
|
||||
struct UB_VS_Lights {
|
||||
|
@ -151,42 +123,6 @@ R"( vec4 u_ambient;
|
|||
vec3 u_lightspecular3;
|
||||
)";
|
||||
|
||||
// HLSL code is shared so these names are changed to match those in DX9.
|
||||
static const char *cb_vs_lightsStr =
|
||||
R"( float4 u_ambient;
|
||||
float3 u_matdiffuse;
|
||||
float4 u_matspecular;
|
||||
float3 u_matemissive;
|
||||
float3 u_lightpos0;
|
||||
float3 u_lightpos1;
|
||||
float3 u_lightpos2;
|
||||
float3 u_lightpos3;
|
||||
float3 u_lightdir0;
|
||||
float3 u_lightdir1;
|
||||
float3 u_lightdir2;
|
||||
float3 u_lightdir3;
|
||||
float3 u_lightatt0;
|
||||
float3 u_lightatt1;
|
||||
float3 u_lightatt2;
|
||||
float3 u_lightatt3;
|
||||
float4 u_lightangle_spotCoef0;
|
||||
float4 u_lightangle_spotCoef1;
|
||||
float4 u_lightangle_spotCoef2;
|
||||
float4 u_lightangle_spotCoef3;
|
||||
float3 u_lightambient0;
|
||||
float3 u_lightambient1;
|
||||
float3 u_lightambient2;
|
||||
float3 u_lightambient3;
|
||||
float3 u_lightdiffuse0;
|
||||
float3 u_lightdiffuse1;
|
||||
float3 u_lightdiffuse2;
|
||||
float3 u_lightdiffuse3;
|
||||
float3 u_lightspecular0;
|
||||
float3 u_lightspecular1;
|
||||
float3 u_lightspecular2;
|
||||
float3 u_lightspecular3;
|
||||
)";
|
||||
|
||||
// With some cleverness, we could get away with uploading just half this when only the four or five first
|
||||
// bones are being used. This is 384b.
|
||||
struct UB_VS_Bones {
|
||||
|
@ -197,10 +133,6 @@ static const char *ub_vs_bonesStr =
|
|||
R"( mat3x4 u_bone0; mat3x4 u_bone1; mat3x4 u_bone2; mat3x4 u_bone3; mat3x4 u_bone4; mat3x4 u_bone5; mat3x4 u_bone6; mat3x4 u_bone7; mat3x4 u_bone8;
|
||||
)";
|
||||
|
||||
static const char *cb_vs_bonesStr =
|
||||
R"( mat3x4 u_bone0; mat3x4 u_bone1; mat3x4 u_bone2; mat3x4 u_bone3; mat3x4 u_bone4; mat3x4 u_bone5; mat3x4 u_bone6; mat3x4 u_bone7; mat3x4 u_bone8;
|
||||
)";
|
||||
|
||||
void CalcCullRange(float minValues[4], float maxValues[4], bool flipViewport, bool hasNegZ);
|
||||
|
||||
void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipViewport, bool useBufferedRendering);
|
||||
|
|
|
@ -173,9 +173,9 @@ bool GenerateVertexShaderHLSL(const VShaderID &id, char *buffer, ShaderLanguage
|
|||
WRITE(p, "vec4 u_cullRangeMax : register(c%i);\n", CONST_VS_CULLRANGEMAX);
|
||||
}
|
||||
} else {
|
||||
WRITE(p, "cbuffer base : register(b0) {\n%s};\n", cb_baseStr);
|
||||
WRITE(p, "cbuffer lights: register(b1) {\n%s};\n", cb_vs_lightsStr);
|
||||
WRITE(p, "cbuffer bones : register(b2) {\n%s};\n", cb_vs_bonesStr);
|
||||
WRITE(p, "cbuffer base : register(b0) {\n%s};\n", ub_baseStr);
|
||||
WRITE(p, "cbuffer lights: register(b1) {\n%s};\n", ub_vs_lightsStr);
|
||||
WRITE(p, "cbuffer bones : register(b2) {\n%s};\n", ub_vs_bonesStr);
|
||||
}
|
||||
|
||||
bool scaleUV = !isModeThrough && (uvGenMode == GE_TEXMAP_TEXTURE_COORDS || uvGenMode == GE_TEXMAP_UNKNOWN);
|
||||
|
|
|
@ -139,6 +139,7 @@ const char *hlsl_preamble_vs =
|
|||
"#define vec3 float3\n"
|
||||
"#define vec4 float4\n"
|
||||
"#define ivec2 int2\n"
|
||||
"#define ivec4 int4\n"
|
||||
"#define mat4 float4x4\n"
|
||||
"#define mat3x4 float4x3\n" // note how the conventions are backwards
|
||||
"#define splat3(x) vec3(x, x, x)\n"
|
||||
|
@ -297,9 +298,9 @@ bool GenerateVertexShaderGLSL(const VShaderID &id, char *buffer, const ShaderLan
|
|||
} else if (compat.shaderLanguage == HLSL_D3D11 || compat.shaderLanguage == HLSL_D3D9) {
|
||||
// Note: These two share some code after this hellishly large if/else.
|
||||
if (compat.shaderLanguage == HLSL_D3D11) {
|
||||
WRITE(p, "cbuffer base : register(b0) {\n%s};\n", cb_baseStr);
|
||||
WRITE(p, "cbuffer lights: register(b1) {\n%s};\n", cb_vs_lightsStr);
|
||||
WRITE(p, "cbuffer bones : register(b2) {\n%s};\n", cb_vs_bonesStr);
|
||||
WRITE(p, "cbuffer base : register(b0) {\n%s};\n", ub_baseStr);
|
||||
WRITE(p, "cbuffer lights: register(b1) {\n%s};\n", ub_vs_lightsStr);
|
||||
WRITE(p, "cbuffer bones : register(b2) {\n%s};\n", ub_vs_bonesStr);
|
||||
} else {
|
||||
WRITE(p, "#pragma warning( disable : 3571 )\n");
|
||||
if (isModeThrough) {
|
||||
|
|
Loading…
Add table
Reference in a new issue