PostProcessingShaderGen: Use ints instead of bools for options

This commit is contained in:
Connor McLaughlin 2020-09-16 11:49:58 +10:00
parent a02feeb8e8
commit 3bd9f85af8
3 changed files with 5 additions and 3 deletions

View File

@ -146,6 +146,7 @@ void ShaderGen::WriteHeader(std::stringstream& ss)
ss << "#define lerp mix\n"; ss << "#define lerp mix\n";
ss << "#define CONSTANT const\n"; ss << "#define CONSTANT const\n";
ss << "#define GLOBAL\n";
ss << "#define VECTOR_EQ(a, b) ((a) == (b))\n"; ss << "#define VECTOR_EQ(a, b) ((a) == (b))\n";
ss << "#define VECTOR_NEQ(a, b) ((a) != (b))\n"; ss << "#define VECTOR_NEQ(a, b) ((a) != (b))\n";
ss << "#define VECTOR_COMP_EQ(a, b) equal((a), (b))\n"; ss << "#define VECTOR_COMP_EQ(a, b) equal((a), (b))\n";
@ -181,6 +182,7 @@ void ShaderGen::WriteHeader(std::stringstream& ss)
ss << "#define mat3 float3x3\n"; ss << "#define mat3 float3x3\n";
ss << "#define mat4 float4x4\n"; ss << "#define mat4 float4x4\n";
ss << "#define CONSTANT static const\n"; ss << "#define CONSTANT static const\n";
ss << "#define GLOBAL static\n";
ss << "#define VECTOR_EQ(a, b) (all((a) == (b)))\n"; ss << "#define VECTOR_EQ(a, b) (all((a) == (b)))\n";
ss << "#define VECTOR_NEQ(a, b) (any((a) != (b)))\n"; ss << "#define VECTOR_NEQ(a, b) (any((a) != (b)))\n";
ss << "#define VECTOR_COMP_EQ(a, b) ((a) == (b))\n"; ss << "#define VECTOR_COMP_EQ(a, b) ((a) == (b))\n";

View File

@ -161,9 +161,9 @@ void PostProcessingShaderGen::WriteUniformBuffer(std::stringstream& ss, const Po
switch (option.type) switch (option.type)
{ {
case PostProcessingShader::Option::Type::Bool: case PostProcessingShader::Option::Type::Bool:
ss << " bool " << option.name << ";\n"; ss << " int " << option.name << ";\n";
for (u32 i = option.vector_size; i < PostProcessingShader::Option::MAX_VECTOR_COMPONENTS; i++) for (u32 i = option.vector_size; i < PostProcessingShader::Option::MAX_VECTOR_COMPONENTS; i++)
ss << " bool ubo_pad" << (pad_counter++) << ";\n"; ss << " int ubo_pad" << (pad_counter++) << ";\n";
break; break;
case PostProcessingShader::Option::Type::Int: case PostProcessingShader::Option::Type::Int:

View File

@ -925,7 +925,7 @@ void VulkanHostDisplay::ApplyPostProcessingChain(s32 final_left, s32 final_top,
if (use_push_constants) if (use_push_constants)
{ {
u8 buffer[PostProcessingShader::PUSH_CONSTANT_SIZE_THRESHOLD]; u8 buffer[PostProcessingShader::PUSH_CONSTANT_SIZE_THRESHOLD];
Assert(pps.uniforms_size < sizeof(buffer)); Assert(pps.uniforms_size <= sizeof(buffer));
m_post_processing_chain.GetShaderStage(i).FillUniformBuffer( m_post_processing_chain.GetShaderStage(i).FillUniformBuffer(
buffer, texture_width, texture_height, texture_view_x, texture_view_y, texture_view_width, texture_view_height, buffer, texture_width, texture_height, texture_view_x, texture_view_y, texture_view_width, texture_view_height,
texture_width, texture_width, 0.0f); texture_width, texture_width, 0.0f);