Check that we can render secondary mesh data with only two components

* We need to be sure that we don't accidentally read RGB anyway.
This commit is contained in:
baldurk
2020-04-21 12:23:27 +01:00
parent 6042c500bc
commit 8ee6e43ed6
5 changed files with 83 additions and 25 deletions
+8 -4
View File
@@ -39,7 +39,8 @@ struct vertin
struct v2f
{
float4 pos : SV_POSITION;
float4 col : COLOR0;
float2 col2 : COLOR0;
float4 col : COLOR1;
};
cbuffer consts : register(b0)
@@ -59,9 +60,11 @@ v2f main(vertin IN, uint vid : SV_VertexID, uint inst : SV_InstanceID)
{
OUT.pos *= 0.3f;
OUT.pos.xy += 0.1f;
OUT.col.z = 1.0f;
OUT.col.x = 1.0f;
}
OUT.col2 = OUT.pos.xy;
return OUT;
}
@@ -72,12 +75,13 @@ v2f main(vertin IN, uint vid : SV_VertexID, uint inst : SV_InstanceID)
struct v2f
{
float4 pos : SV_POSITION;
float4 col : COLOR0;
float2 col2 : COLOR0;
float4 col : COLOR1;
};
float4 main(v2f IN) : SV_Target0
{
return IN.col;
return IN.col + 1.0e-20 * IN.col2.xyxy;
}
)EOSHADER";
+8 -4
View File
@@ -39,7 +39,8 @@ struct vertin
struct v2f
{
float4 pos : SV_POSITION;
float4 col : COLOR0;
float2 col2 : COLOR0;
float4 col : COLOR1;
};
cbuffer consts : register(b0)
@@ -59,9 +60,11 @@ v2f main(vertin IN, uint vid : SV_VertexID, uint inst : SV_InstanceID)
{
OUT.pos *= 0.3f;
OUT.pos.xy += 0.1f;
OUT.col.z = 1.0f;
OUT.col.x = 1.0f;
}
OUT.col2 = OUT.pos.xy;
return OUT;
}
@@ -72,12 +75,13 @@ v2f main(vertin IN, uint vid : SV_VertexID, uint inst : SV_InstanceID)
struct v2f
{
float4 pos : SV_POSITION;
float4 col : COLOR0;
float2 col2 : COLOR0;
float4 col : COLOR1;
};
float4 main(v2f IN) : SV_Target0
{
return IN.col;
return IN.col + 1.0e-20 * IN.col2.xyxy;
}
)EOSHADER";
+13 -7
View File
@@ -45,7 +45,8 @@ layout(binding = 0, std140) uniform constsbuf
vec4 offset;
};
out vec4 col;
layout(location = 0) out vec2 col2;
layout(location = 1) out vec4 col;
void main()
{
@@ -56,9 +57,10 @@ void main()
{
pos *= 0.3f;
pos.xy += vec2(0.1f);
col.z = 1.0f;
col.x = 1.0f;
}
col2 = pos.xy;
gl_Position = pos;
}
@@ -67,7 +69,8 @@ void main()
std::string multivertex = R"EOSHADER(
#version 460 core
out vec4 col;
layout(location = 0) out vec2 col2;
layout(location = 1) out vec4 col;
flat out uint basevtx;
flat out uint baseinst;
flat out uint draw;
@@ -80,7 +83,7 @@ void main()
vec4(0.5, 0.5, 0.0, 1.0));
gl_Position = verts[gl_VertexID%3];
col = vec4(1, 1, 0, 1);
col = vec4(0, 1, 1, 1);
basevtx = gl_BaseVertex;
baseinst = gl_BaseInstance;
@@ -93,13 +96,14 @@ void main()
std::string pixel = R"EOSHADER(
in vec4 col;
layout(location = 0) in vec2 col2;
layout(location = 1) in vec4 col;
layout(location = 0, index = 0) out vec4 Color;
void main()
{
Color = col;
Color = col + 1.0e-20 * col2.xyxy;
}
)EOSHADER";
@@ -119,7 +123,8 @@ void main()
layout(points) in;
layout(triangle_strip, max_vertices = 3) out;
out vec4 col;
layout(location = 0) out vec2 col2;
layout(location = 1) out vec4 col;
void main()
{
@@ -130,6 +135,7 @@ void main()
{
gl_Position = verts[i];
col = vec4(1, 0, 0, 1);
col2 = vec2(1, 0);
EmitVertex();
}
+8 -4
View File
@@ -45,7 +45,8 @@ layout(push_constant, std140) uniform pushbuf
vec4 offset;
};
layout(location = 0) out vec4 vertOutcol;
layout(location = 0) out vec2 vertOutCol2;
layout(location = 1) out vec4 vertOutcol;
void main()
{
@@ -56,9 +57,11 @@ void main()
{
pos *= 0.3f;
pos.xy += vec2(0.1f);
vertOutcol.z = 1.0f;
vertOutcol.x = 1.0f;
}
vertOutCol2.xy = pos.xy;
gl_Position = pos * vec4(1, -1, 1, 1);
#if defined(USE_POINTS)
gl_PointSize = 1.0f;
@@ -69,13 +72,14 @@ void main()
std::string pixel = R"EOSHADER(
layout(location = 0) in vec4 vertIncol;
layout(location = 0) in vec2 vertInCol2;
layout(location = 1) in vec4 vertIncol;
layout(location = 0, index = 0) out vec4 Color;
void main()
{
Color = vertIncol;
Color = vertIncol + 1.0e-20 * vertInCol2.xyxy;
}
)EOSHADER";
+46 -6
View File
@@ -77,6 +77,8 @@ class Mesh_Zoo():
self.out: rd.ReplayOutput = self.controller.CreateOutput(rd.CreateHeadlessWindowingData(200, 200),
rd.ReplayOutputType.Mesh)
pipe: rd.PipeState = self.controller.GetPipelineState()
self.cfg = rd.MeshDisplay()
cam: rd.Camera = rd.InitCamera(rd.CameraType.FPSLook)
@@ -91,9 +93,12 @@ class Mesh_Zoo():
inst0: rd.MeshFormat = self.controller.GetPostVSData(0, 0, self.cfg.type)
self.cfg.position = inst0
# Color is after position, float4 = 16 bytes
# after position we have float2 Color2 then float4 Color4
self.cfg.second = self.cfg.position
self.cfg.second.vertexByteOffset += 16
self.cfg.second.vertexByteOffset += 8
if pipe.HasAlignedPostVSData(self.cfg.type):
self.cfg.second.vertexByteOffset += 8
# Configure an ortho camera, even though we don't really have a camera
self.cfg.ortho = True
@@ -126,7 +131,7 @@ class Mesh_Zoo():
isredgreen = lambda col: isred(col) or isgreen(col) or col[2] == 0
iscyan = lambda col: col[1] == col[2] and col[0] < col[1]
isyellow = lambda col: col[0] == col[1] and col[2] < col[1]
self.cache_output()
@@ -187,6 +192,23 @@ class Mesh_Zoo():
rdtest.log.success("Rendering of highlighted vertices is as expected")
self.cfg.highlightVert = rd.MeshDisplay.NoHighlight
# If we render from the float2 color we shouldn't get any blue
self.cfg.second.vertexByteOffset = self.cfg.position.vertexByteOffset = inst0.vertexByteOffset
self.cfg.second.vertexByteOffset += 16
self.cfg.second.format.compCount = 2
self.cache_output()
# If we render from the float2 color we shouldn't get any blue since it's only a two-component value
self.check_region((85, 70, 85, 125), lambda x: all([isredgreen(i) for i in x]))
self.check_region((65, 100, 105, 100), lambda x: all([isredgreen(i) for i in x]))
self.check_region((65, 55, 105, 55), lambda x: x == [])
self.check_region((65, 125, 105, 125), lambda x: all([isredgreen(i) for i in x]))
rdtest.log.success("Rendering of float2 color secondary in instance 0 is as expected")
self.cfg.highlightVert = rd.MeshDisplay.NoHighlight
inst1: rd.MeshFormat = self.controller.GetPostVSData(1, 0, self.cfg.type)
@@ -194,19 +216,37 @@ class Mesh_Zoo():
self.cfg.second.vertexResourceId = self.cfg.position.vertexResourceId = inst1.vertexResourceId
self.cfg.second.vertexByteOffset = self.cfg.position.vertexByteOffset = inst1.vertexByteOffset
self.cfg.second.vertexByteOffset += 16
self.cfg.second.vertexByteOffset += 8
if pipe.HasAlignedPostVSData(self.cfg.type):
self.cfg.second.vertexByteOffset += 8
self.cache_output()
# The secondary color should be completely cyan
self.check_region((85, 70, 85, 125), lambda x: all([iscyan(i) for i in x]))
self.check_region((65, 100, 105, 100), lambda x: all([iscyan(i) for i in x]))
# The secondary color should be completely yellow
self.check_region((85, 70, 85, 125), lambda x: all([isyellow(i) for i in x]))
self.check_region((65, 100, 105, 100), lambda x: all([isyellow(i) for i in x]))
# this line segment isn't in the first instance
self.check_region((65, 55, 105, 55), lambda x: all([iscyan(i) for i in x]))
self.check_region((65, 55, 105, 55), lambda x: all([isyellow(i) for i in x]))
# this line segment isn't in the second instance
self.check_region((65, 125, 105, 125), lambda x: x == [])
rdtest.log.success("Secondary rendering of instance 1 is as expected")
# If we render from the float2 color we shouldn't get any blue
self.cfg.second.vertexByteOffset = self.cfg.position.vertexByteOffset = inst1.vertexByteOffset
self.cfg.second.vertexByteOffset += 16
self.cfg.second.format.compCount = 2
self.cache_output()
# If we render from the float2 color we shouldn't get any blue since it's only a two-component value
self.check_region((85, 70, 85, 125), lambda x: all([isredgreen(i) for i in x]))
self.check_region((65, 100, 105, 100), lambda x: all([isredgreen(i) for i in x]))
self.check_region((65, 55, 105, 55), lambda x: all([isredgreen(i) for i in x]))
self.check_region((65, 125, 105, 125), lambda x: x == [])
rdtest.log.success("Rendering of float2 color secondary in instance 1 is as expected")
self.cfg.solidShadeMode = rd.SolidShade.NoSolid
self.cfg.showAllInstances = True