[Piglit] [PATCH 33/35] arb_enhanced_layouts: Test doubles
Alejandro Piñeiro
apinheiro at igalia.com
Thu Aug 9 11:36:12 UTC 2018
From: Neil Roberts <nroberts at igalia.com>
v2: use shader_test file with the spirv assembly, instead of include a
SPIR-V binary binaries (Alejandro Piñeiro)
Signed-off-by: Neil Roberts <nroberts at igalia.com>
Signed-off-by: Alejandro Piñeiro <apinheiro at igalia.com>
---
tests/opengl.py | 2 +-
.../shader_test/vs_double.shader_test | 102 +++++++++++++++++++++
.../transform-feedback-layout-qualifiers.c | 99 ++++++++++++++++----
3 files changed, 184 insertions(+), 19 deletions(-)
create mode 100644 tests/spec/arb_enhanced_layouts/shader_test/vs_double.shader_test
diff --git a/tests/opengl.py b/tests/opengl.py
index 0b06d9505..b021b2a9e 100644
--- a/tests/opengl.py
+++ b/tests/opengl.py
@@ -2308,7 +2308,7 @@ with profile.test_list.group_manager(
'explicit-offset-bufferstorage')
g(['arb_enhanced_layouts-gs-stream-location-aliasing'],
'gs-stream-location-aliasing')
- for test in ['vs', 'vs_ifc', 'vs_named_ifc', 'vs_struct']:
+ for test in ['vs', 'vs_ifc', 'vs_named_ifc', 'vs_struct', 'vs_double']:
g(['arb_enhanced_layouts-transform-feedback-layout-qualifiers', test],
'arb_enhanced_layouts-transform-feedback-layout-qualifiers_' + test,
run_concurrent=False)
diff --git a/tests/spec/arb_enhanced_layouts/shader_test/vs_double.shader_test b/tests/spec/arb_enhanced_layouts/shader_test/vs_double.shader_test
new file mode 100644
index 000000000..6f19d0d13
--- /dev/null
+++ b/tests/spec/arb_enhanced_layouts/shader_test/vs_double.shader_test
@@ -0,0 +1,102 @@
+[require]
+SPIRV YES
+GLSL >= 4.50
+
+[vertex shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 41
+; Schema: 0
+ OpCapability Shader
+ OpCapability Float64
+ OpCapability TransformFeedback
+ %1 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Vertex %main "main" %_ %x1_out %x2_out %x3_out %gl_VertexID %gl_InstanceID
+ OpExecutionMode %main Xfb
+ OpSource GLSL 450
+ OpSourceExtension "GL_ARB_enhanced_layouts"
+ OpName %_ ""
+ OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
+ OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
+ OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
+ OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
+ OpDecorate %gl_PerVertex Block
+ OpDecorate %_ XfbBuffer 0
+ OpDecorate %_ XfbStride 56
+ OpDecorate %x1_out Location 0
+ OpDecorate %x1_out XfbBuffer 0
+ OpDecorate %x1_out XfbStride 56
+ OpDecorate %x1_out Offset 0
+ OpDecorate %x2_out Location 1
+ OpDecorate %x2_out XfbBuffer 0
+ OpDecorate %x2_out XfbStride 56
+ OpDecorate %x2_out Offset 8
+ OpDecorate %x3_out Location 2
+ OpDecorate %x3_out XfbBuffer 0
+ OpDecorate %x3_out XfbStride 56
+ OpDecorate %x3_out Offset 24
+ OpDecorate %gl_VertexID BuiltIn VertexId
+ OpDecorate %gl_InstanceID BuiltIn InstanceId
+ %void = OpTypeVoid
+ %3 = OpTypeFunction %void
+ %float = OpTypeFloat 32
+ %v4float = OpTypeVector %float 4
+ %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+%_arr_float_uint_1 = OpTypeArray %float %uint_1
+%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1
+%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
+ %_ = OpVariable %_ptr_Output_gl_PerVertex Output
+ %int = OpTypeInt 32 1
+ %int_0 = OpConstant %int 0
+ %float_0 = OpConstant %float 0
+ %17 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %double = OpTypeFloat 64
+%_ptr_Output_double = OpTypePointer Output %double
+ %x1_out = OpVariable %_ptr_Output_double Output
+ %double_1 = OpConstant %double 1
+ %v2double = OpTypeVector %double 2
+%_ptr_Output_v2double = OpTypePointer Output %v2double
+ %x2_out = OpVariable %_ptr_Output_v2double Output
+ %double_2 = OpConstant %double 2
+ %double_3 = OpConstant %double 3
+ %29 = OpConstantComposite %v2double %double_2 %double_3
+ %v4double = OpTypeVector %double 4
+%_ptr_Output_v4double = OpTypePointer Output %v4double
+ %x3_out = OpVariable %_ptr_Output_v4double Output
+ %double_4 = OpConstant %double 4
+ %double_5 = OpConstant %double 5
+ %double_6 = OpConstant %double 6
+ %double_7 = OpConstant %double 7
+ %37 = OpConstantComposite %v4double %double_4 %double_5 %double_6 %double_7
+%_ptr_Input_int = OpTypePointer Input %int
+%gl_VertexID = OpVariable %_ptr_Input_int Input
+%gl_InstanceID = OpVariable %_ptr_Input_int Input
+ %main = OpFunction %void None %3
+ %5 = OpLabel
+ %19 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+ OpStore %19 %17
+ OpStore %x1_out %double_1
+ OpStore %x2_out %29
+ OpStore %x3_out %37
+ OpReturn
+ OpFunctionEnd
+
+[vertex shader]
+#version 450
+#extension GL_ARB_enhanced_layouts: require
+
+layout(location = 0, xfb_offset = 0) out double x1_out;
+layout(location = 1, xfb_offset = 8) out dvec2 x2_out;
+layout(location = 2, xfb_offset = 24) out dvec4 x3_out;
+
+void main() {
+ gl_Position = vec4(0.0);
+ x1_out = 1.0lf;
+ x2_out = dvec2(2.0lf, 3.0lf);
+ x3_out = dvec4(4.0lf, 5.0lf, 6.0lf, 7.0lf);
+}
diff --git a/tests/spec/arb_enhanced_layouts/transform-feedback-layout-qualifiers.c b/tests/spec/arb_enhanced_layouts/transform-feedback-layout-qualifiers.c
index a18b95ccd..d95fd3536 100644
--- a/tests/spec/arb_enhanced_layouts/transform-feedback-layout-qualifiers.c
+++ b/tests/spec/arb_enhanced_layouts/transform-feedback-layout-qualifiers.c
@@ -46,6 +46,8 @@ static const char vs_pass_thru_text[] =
#define VS_TWO_SETS_STRUCT_NAME "vs_two_sets_struct.shader_test"
+#define VS_DOUBLE_NAME "vs_double.shader_test"
+
static const char gs_text_two_sets_tmpl[] =
"#version 150\n"
"#extension GL_ARB_enhanced_layouts: require\n"
@@ -81,10 +83,12 @@ struct test_config {
const char *shader_test_filename;
bool spirv;
GLint gs_invocation_n;
+ bool doubles;
};
#define BUF_1_FLOAT_N 6
#define BUF_2_FLOAT_N 5
+#define BUF_DOUBLE_N 7
static void
@@ -96,6 +100,7 @@ print_usage_and_exit(const char *prog_name)
" vs_ifc (vertex shader only, with interface block)\n"
" vs_named_ifc (vertex shader only, with named interface block)\n"
" vs_struct (vertex shader only, with structs)\n"
+ " vs_double (vertex shader only, using doubles)\n"
" gs (with geometry shader invoked once per stage)\n"
" gs_max (with geometry shader invoked max times per "
"stage)\n"
@@ -191,17 +196,11 @@ build_and_use_program(const struct test_config *config)
glUseProgram(prog);
}
-static bool
-probe_buffers(const GLuint *xfb, const GLuint *queries, unsigned primitive_n)
+static void
+probe_queries(const GLuint *queries,
+ unsigned primitive_n)
{
- bool pass;
- unsigned i;
GLuint query_result;
- float *first;
- float *second;
-
- const unsigned first_n = primitive_n * BUF_1_FLOAT_N;
- const unsigned second_n = primitive_n * BUF_2_FLOAT_N;
glGetQueryObjectuiv(queries[0], GL_QUERY_RESULT, &query_result);
if (query_result != primitive_n) {
@@ -216,6 +215,20 @@ probe_buffers(const GLuint *xfb, const GLuint *queries, unsigned primitive_n)
primitive_n, query_result);
piglit_report_result(PIGLIT_FAIL);
}
+}
+
+
+static bool
+probe_buffers_float(const GLuint *xfb,
+ unsigned primitive_n)
+{
+ bool pass;
+ unsigned i;
+ float *first;
+ float *second;
+
+ const unsigned first_n = primitive_n * BUF_1_FLOAT_N;
+ const unsigned second_n = primitive_n * BUF_2_FLOAT_N;
first = malloc(first_n * sizeof(float));
second = malloc(second_n * sizeof(float));
@@ -247,6 +260,31 @@ probe_buffers(const GLuint *xfb, const GLuint *queries, unsigned primitive_n)
return pass;
}
+static bool
+probe_buffers_double(const GLuint *xfb,
+ unsigned primitive_n)
+{
+ bool pass;
+ unsigned i, j;
+ double *first;
+
+ const unsigned first_n = primitive_n * BUF_DOUBLE_N;
+
+ first = malloc(first_n * sizeof(double));
+
+ for (i = 0; i < primitive_n; ++i) {
+ for (j = 0; j < BUF_DOUBLE_N; j++)
+ first[i * BUF_DOUBLE_N + j] = i + j + 1;
+ }
+
+ pass = piglit_probe_buffer_doubles(xfb[0], GL_TRANSFORM_FEEDBACK_BUFFER,
+ "first", 1, first_n, first);
+
+ free(first);
+
+ return pass;
+}
+
static void
parse_args(int argc, char **argv, struct test_config *config)
{
@@ -256,36 +294,49 @@ parse_args(int argc, char **argv, struct test_config *config)
const char *name;
const char *shader_test_filename;
unsigned gs_invocation_n;
+ bool doubles;
} test_types[] = {
{
"vs",
"vs_two_sets.shader_test",
- 0
+ 0,
+ false
},
{
"vs_ifc",
"vs_two_sets_ifc.shader_test",
- 0
+ 0,
+ false
},
{
"vs_named_ifc",
"vs_two_sets_named_ifc.shader_test",
- 0
+ 0,
+ false
},
{
"vs_struct",
"vs_two_sets_struct.shader_test",
- 0
+ 0,
+ false
+ },
+ {
+ "vs_double",
+ "vs_double.shader_test",
+ 0,
+ true,
},
{
"gs",
NULL,
- 1
+ 1,
+ false
},
{
"gs_max",
NULL,
- INT_MAX
+ INT_MAX,
+ false
}
};
@@ -298,6 +349,8 @@ parse_args(int argc, char **argv, struct test_config *config)
test_types[j].shader_test_filename,
config->gs_invocation_n =
test_types[j].gs_invocation_n;
+ config->doubles =
+ test_types[j].doubles;
option_was_handled = true;
goto option_handled;
}
@@ -356,6 +409,9 @@ piglit_init(int argc, char **argv)
}
}
+ if (config.doubles)
+ piglit_require_GLSL_version(450);
+
/* Zero invocations means the feedback is produced by vertex shader */
primitive_n = config.gs_invocation_n ? config.gs_invocation_n : 1;
@@ -365,8 +421,11 @@ piglit_init(int argc, char **argv)
glGenBuffers(ARRAY_SIZE(xfb), xfb);
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, xfb[0]);
glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER,
- primitive_n * BUF_1_FLOAT_N * sizeof(float), NULL,
- GL_STREAM_READ);
+ primitive_n *
+ MAX2(BUF_1_FLOAT_N * sizeof(float),
+ BUF_DOUBLE_N * sizeof(double)),
+ NULL,
+ GL_STREAM_READ);
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 2, xfb[1]);
glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER,
primitive_n * BUF_2_FLOAT_N * sizeof(float), NULL,
@@ -397,7 +456,11 @@ piglit_init(int argc, char **argv)
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
- pass = probe_buffers(xfb, queries, primitive_n);
+ probe_queries(queries, primitive_n);
+ if (config.doubles)
+ pass = probe_buffers_double(xfb, primitive_n);
+ else
+ pass = probe_buffers_float(xfb, primitive_n);
glDeleteBuffers(2, xfb);
glDeleteQueries(2, queries);
--
2.14.1
More information about the Piglit
mailing list