mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-10-07 19:03:29 +00:00
VK/D3D11: Move the rarely used "u_rotation" uniform to the frame uniform buffer.
This uniform is used in two cases: * Non-buffered rendering in Vulkan, software transform * Non-buffered rendering in D3D11 level 9 on Windows Phone, software transform - which I don't think anyone builds for anymore Nice to not have it in the main uniform buffer, but mainly a demonstrator/test of moving stuff to the new frame-global buffer, and setting up the infrastructure.
This commit is contained in:
parent
10c6232b9b
commit
ad6725b684
@ -72,6 +72,10 @@ void CalcCullRange(float minValues[4], float maxValues[4], bool flipViewport, bo
|
||||
maxValues[3] = NAN;
|
||||
}
|
||||
|
||||
void FrameUpdateUniforms(UB_Frame *ub, bool useBufferedRendering) {
|
||||
ub->rotation = useBufferedRendering ? 0 : (float)g_display_rotation;
|
||||
}
|
||||
|
||||
void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipViewport, bool useBufferedRendering) {
|
||||
if (dirtyUniforms & DIRTY_TEXENV) {
|
||||
Uint8x3ToFloat3(ub->texEnvColor, gstate.texenvcolor);
|
||||
@ -139,7 +143,6 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView
|
||||
flippedMatrix = flippedMatrix * g_display_rot_matrix;
|
||||
}
|
||||
CopyMatrix4x4(ub->proj, flippedMatrix.getReadPtr());
|
||||
ub->rotation = useBufferedRendering ? 0 : (float)g_display_rotation;
|
||||
}
|
||||
|
||||
if (dirtyUniforms & DIRTY_PROJTHROUGHMATRIX) {
|
||||
@ -160,7 +163,6 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView
|
||||
}
|
||||
|
||||
CopyMatrix4x4(ub->proj_through, proj_through.getReadPtr());
|
||||
ub->rotation = useBufferedRendering ? 0 : (float)g_display_rotation;
|
||||
}
|
||||
|
||||
// Transform
|
||||
|
@ -27,7 +27,6 @@ struct alignas(16) UB_VS_FS_Base {
|
||||
float tex[12];
|
||||
float uvScaleOffset[4];
|
||||
float depthRange[4];
|
||||
// Rotation is used only for software transform.
|
||||
float matAmbient[4];
|
||||
float cullRangeMin[4];
|
||||
float cullRangeMax[4];
|
||||
@ -37,7 +36,7 @@ struct alignas(16) UB_VS_FS_Base {
|
||||
float fogColor[3]; uint32_t alphaColorRef;
|
||||
float texEnvColor[3]; uint32_t colorTestMask;
|
||||
float blendFixA[3]; float stencil;
|
||||
float blendFixB[3]; float rotation;
|
||||
float blendFixB[3]; float padUnused;
|
||||
float texClamp[4];
|
||||
float texClampOffset[2]; float fogCoef[2];
|
||||
// VR stuff is to go here, later. For normal drawing, we can then get away
|
||||
@ -62,7 +61,7 @@ R"( mat4 u_proj;
|
||||
vec3 u_fogcolor; uint u_alphacolorref;
|
||||
vec3 u_texenv; uint u_alphacolormask;
|
||||
vec3 u_blendFixA; float u_stencilReplaceValue;
|
||||
vec3 u_blendFixB; float u_rotation;
|
||||
vec3 u_blendFixB; float u_padUnused;
|
||||
vec4 u_texclamp;
|
||||
vec2 u_texclampoff;
|
||||
vec2 u_fogcoef;
|
||||
@ -132,13 +131,14 @@ R"( mat3x4 u_bone0; mat3x4 u_bone1; mat3x4 u_bone2; mat3x4 u_bone3; mat3x4 u_bon
|
||||
)";
|
||||
|
||||
|
||||
static const char * const ub_frame_globalstr =
|
||||
R"( vec4 stereoParams;
|
||||
static const char * const ub_frameStr =
|
||||
R"(
|
||||
float u_rotation;
|
||||
)";
|
||||
|
||||
// Frame-global uniforms.
|
||||
struct UB_FrameGlobal {
|
||||
float stereoParams[4];
|
||||
struct UB_Frame {
|
||||
float rotation; // This is only used when using software transform, and non-buffered, to support native screen rotation.
|
||||
};
|
||||
|
||||
void CalcCullRange(float minValues[4], float maxValues[4], bool flipViewport, bool hasNegZ);
|
||||
@ -146,5 +146,6 @@ void CalcCullRange(float minValues[4], float maxValues[4], bool flipViewport, bo
|
||||
void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipViewport, bool useBufferedRendering);
|
||||
void LightUpdateUniforms(UB_VS_Lights *ub, uint64_t dirtyUniforms);
|
||||
void BoneUpdateUniforms(UB_VS_Bones *ub, uint64_t dirtyUniforms);
|
||||
void FrameUpdateUniforms(UB_Frame *ub, bool useBufferedRendering);
|
||||
|
||||
uint32_t PackLightControlBits();
|
||||
|
@ -249,6 +249,11 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag
|
||||
|
||||
if (compat.shaderLanguage == GLSL_VULKAN) {
|
||||
WRITE(p, "\n");
|
||||
|
||||
if (!useHWTransform) {
|
||||
WRITE(p, "layout (std140, set = 0, binding = 0) uniform frameVars {\n%s};\n", ub_frameStr);
|
||||
}
|
||||
|
||||
WRITE(p, "layout (std140, set = 1, binding = 3) uniform baseVars {\n%s};\n", ub_baseStr);
|
||||
if (enableLighting || doShadeMapping)
|
||||
WRITE(p, "layout (std140, set = 1, binding = 4) uniform lightVars {\n%s};\n", ub_vs_lightsStr);
|
||||
|
@ -1021,7 +1021,9 @@ void DrawEngineVulkan::DoFlush() {
|
||||
void DrawEngineVulkan::UpdateUBOs(FrameData *frame) {
|
||||
if (!frame->frameDescSetUpdated) {
|
||||
// Push frame global constants.
|
||||
UB_FrameGlobal frameConstants{};
|
||||
UB_Frame frameConstants{};
|
||||
FrameUpdateUniforms(&frameConstants, framebufferManager_->UseBufferedRendering());
|
||||
|
||||
VkDescriptorBufferInfo frameConstantsBufInfo;
|
||||
frame->pushUBO->PushUBOData(frameConstants, &frameConstantsBufInfo);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user