Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vk: Use VK_FORMAT_R8G8B8A8_UNORM for vertex colors #1690

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions core/rend/vulkan/oit/oit_pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,11 @@ class OITPipelineManager
static const vk::VertexInputAttributeDescription vertexInputAttributeDescriptions[] =
{
vk::VertexInputAttributeDescription(0, 0, vk::Format::eR32G32B32Sfloat, offsetof(Vertex, x)), // pos
vk::VertexInputAttributeDescription(1, 0, vk::Format::eR8G8B8A8Uint, offsetof(Vertex, col)), // base color
vk::VertexInputAttributeDescription(2, 0, vk::Format::eR8G8B8A8Uint, offsetof(Vertex, spc)), // offset color
vk::VertexInputAttributeDescription(1, 0, vk::Format::eR8G8B8A8Unorm, offsetof(Vertex, col)), // base color
vk::VertexInputAttributeDescription(2, 0, vk::Format::eR8G8B8A8Unorm, offsetof(Vertex, spc)), // offset color
vk::VertexInputAttributeDescription(3, 0, vk::Format::eR32G32Sfloat, offsetof(Vertex, u)), // tex coord
vk::VertexInputAttributeDescription(4, 0, vk::Format::eR8G8B8A8Uint, offsetof(Vertex, col1)), // base1 color
vk::VertexInputAttributeDescription(5, 0, vk::Format::eR8G8B8A8Uint, offsetof(Vertex, spc1)), // offset1 color
vk::VertexInputAttributeDescription(4, 0, vk::Format::eR8G8B8A8Unorm, offsetof(Vertex, col1)), // base1 color
vk::VertexInputAttributeDescription(5, 0, vk::Format::eR8G8B8A8Unorm, offsetof(Vertex, spc1)), // offset1 color
vk::VertexInputAttributeDescription(6, 0, vk::Format::eR32G32Sfloat, offsetof(Vertex, u1)), // tex1 coord
vk::VertexInputAttributeDescription(7, 0, vk::Format::eR32G32B32Sfloat, offsetof(Vertex, nx)), // naomi2 normal
};
Expand Down
32 changes: 16 additions & 16 deletions core/rend/vulkan/oit/oit_shaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ layout (push_constant) uniform constants
} pushConstants;

layout (location = 0) in vec4 in_pos;
layout (location = 1) in uvec4 in_base;
layout (location = 2) in uvec4 in_offs;
layout (location = 1) in vec4 in_base;
layout (location = 2) in vec4 in_offs;
layout (location = 3) in mediump vec2 in_uv;
layout (location = 4) in uvec4 in_base1; // New for OIT, only for OP/PT with 2-volume
layout (location = 5) in uvec4 in_offs1;
layout (location = 4) in vec4 in_base1; // New for OIT, only for OP/PT with 2-volume
layout (location = 5) in vec4 in_offs1;
layout (location = 6) in mediump vec2 in_uv1;

layout (location = 0) INTERPOLATION out highp vec4 vtx_base;
Expand All @@ -59,11 +59,11 @@ void main()
vpos /= vpos.z;
vpos.z = vpos.w;
#endif
vtx_base = vec4(in_base) / 255.0;
vtx_offs = vec4(in_offs) / 255.0;
vtx_base = in_base;
vtx_offs = in_offs;
vtx_uv = vec3(in_uv, vpos.z);
vtx_base1 = vec4(in_base1) / 255.0;
vtx_offs1 = vec4(in_offs1) / 255.0;
vtx_base1 = in_base1;
vtx_offs1 = in_offs1;
vtx_uv1 = in_uv1;
#if pp_Gouraud == 1 && DIV_POS_Z != 1
vtx_base *= vpos.z;
Expand Down Expand Up @@ -638,11 +638,11 @@ layout (push_constant) uniform constants
} pushConstants;

layout (location = 0) in vec4 in_pos;
layout (location = 1) in uvec4 in_base;
layout (location = 2) in uvec4 in_offs;
layout (location = 1) in vec4 in_base;
layout (location = 2) in vec4 in_offs;
layout (location = 3) in mediump vec2 in_uv;
layout (location = 4) in uvec4 in_base1;
layout (location = 5) in uvec4 in_offs1;
layout (location = 4) in vec4 in_base1;
layout (location = 5) in vec4 in_offs1;
layout (location = 6) in mediump vec2 in_uv1;
layout (location = 7) in vec3 in_normal;

Expand Down Expand Up @@ -677,16 +677,16 @@ void wDivide(inout vec4 vpos)
void main()
{
vec4 vpos = n2Uniform.mvMat * in_pos;
vtx_base = vec4(in_base) / 255.0;
vtx_offs = vec4(in_offs) / 255.0;
vtx_base = in_base;
vtx_offs = in_offs;

#if LIGHT_ON == 1
vec3 vnorm = normalize(mat3(n2Uniform.normalMat) * in_normal);
#endif

#if pp_TwoVolumes == 1
vtx_base1 = vec4(in_base1) / 255.0;
vtx_offs1 = vec4(in_offs1) / 255.0;
vtx_base1 = in_base1;
vtx_offs1 = in_offs1;
vtx_uv1 = in_uv1;
#if LIGHT_ON == 1
// FIXME need offset0 and offset1 for bump maps
Expand Down
2 changes: 1 addition & 1 deletion core/rend/vulkan/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ void OSDPipeline::CreatePipeline()
static const vk::VertexInputBindingDescription vertexInputBindingDescription(0, sizeof(OSDVertex));
static const std::array<vk::VertexInputAttributeDescription, 3> vertexInputAttributeDescriptions = {
vk::VertexInputAttributeDescription(0, 0, vk::Format::eR32G32Sfloat, offsetof(OSDVertex, x)), // pos
vk::VertexInputAttributeDescription(1, 0, vk::Format::eR8G8B8A8Uint, offsetof(OSDVertex, r)), // color
vk::VertexInputAttributeDescription(1, 0, vk::Format::eR8G8B8A8Unorm, offsetof(OSDVertex, r)), // color
vk::VertexInputAttributeDescription(2, 0, vk::Format::eR32G32Sfloat, offsetof(OSDVertex, u)), // tex coord
};
vk::PipelineVertexInputStateCreateInfo vertexInputStateCreateInfo(
Expand Down
4 changes: 2 additions & 2 deletions core/rend/vulkan/pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ class PipelineManager
static const vk::VertexInputAttributeDescription vertexInputAttributeDescriptions[] =
{
vk::VertexInputAttributeDescription(0, 0, vk::Format::eR32G32B32Sfloat, offsetof(Vertex, x)), // pos
vk::VertexInputAttributeDescription(1, 0, vk::Format::eR8G8B8A8Uint, offsetof(Vertex, col)), // base color
vk::VertexInputAttributeDescription(2, 0, vk::Format::eR8G8B8A8Uint, offsetof(Vertex, spc)), // offset color
vk::VertexInputAttributeDescription(1, 0, vk::Format::eR8G8B8A8Unorm, offsetof(Vertex, col)), // base color
vk::VertexInputAttributeDescription(2, 0, vk::Format::eR8G8B8A8Unorm, offsetof(Vertex, spc)), // offset color
vk::VertexInputAttributeDescription(3, 0, vk::Format::eR32G32Sfloat, offsetof(Vertex, u)), // tex coord
vk::VertexInputAttributeDescription(4, 0, vk::Format::eR32G32B32Sfloat, offsetof(Vertex, nx)), // naomi2 normal
};
Expand Down
14 changes: 7 additions & 7 deletions core/rend/vulkan/shaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ layout (std140, set = 0, binding = 0) uniform VertexShaderUniforms
} uniformBuffer;

layout (location = 0) in vec4 in_pos;
layout (location = 1) in uvec4 in_base;
layout (location = 2) in uvec4 in_offs;
layout (location = 1) in vec4 in_base;
layout (location = 2) in vec4 in_offs;
layout (location = 3) in mediump vec2 in_uv;

layout (location = 0) INTERPOLATION out highp vec4 vtx_base;
Expand All @@ -45,8 +45,8 @@ void main()
vpos /= vpos.z;
vpos.z = vpos.w;
#endif
vtx_base = vec4(in_base) / 255.0;
vtx_offs = vec4(in_offs) / 255.0;
vtx_base = in_base;
vtx_offs = in_offs;
vtx_uv = vec3(in_uv, vpos.z);
#if pp_Gouraud == 1 && DIV_POS_Z != 1
vtx_base *= vpos.z;
Expand Down Expand Up @@ -403,7 +403,7 @@ layout (location = 1) out mediump vec2 outUV;

void main()
{
outColor = inColor / 255.0;
outColor = inColor;
outUV = inUV;
gl_Position = inPos;
}
Expand Down Expand Up @@ -684,8 +684,8 @@ void wDivide(inout vec4 vpos)
void main()
{
vec4 vpos = n2Uniform.mvMat * in_pos;
vtx_base = vec4(in_base) / 255.0;
vtx_offs = vec4(in_offs) / 255.0;
vtx_base = in_base;
vtx_offs = in_offs;

vec3 vnorm = normalize(mat3(n2Uniform.normalMat) * in_normal);

Expand Down
Loading