#if defined(DEQP_HAVE_SPIRV_TOOLS)
-namespace
-{
-// Once spirv-tools upgrades past 972788bf239daff45ed0d2bb878e608c4106939c, we
-// won't need this singleton, as spvContextCreate() is thread-safe.
-static volatile deSingletonState s_spirvInitState = DE_SINGLETON_STATE_NOT_INITIALIZED;
-void initSpirVTools (void*)
-{
- spv_binary binary = DE_NULL;
- spv_diagnostic diagnostic = DE_NULL;
- // This dummy compilation initializes opcode tables for all the subsequent
- // ones. It should be the first spv call in the current process, and it
- // isn't thread-safe.
- spvTextToBinary("", 0, &binary, &diagnostic);
-}
-
-void prepareSpirvTools (void)
-{
- deInitSingleton(&s_spirvInitState, initSpirVTools, DE_NULL);
-}
-
-} // anonymous
void assembleSpirV (const SpirVAsmSource* program, std::vector<deUint8>* dst, SpirVProgramInfo* buildInfo)
{
- prepareSpirvTools();
+ spv_context context = spvContextCreate();
const std::string& spvSource = program->program.str();
spv_binary binary = DE_NULL;
spv_diagnostic diagnostic = DE_NULL;
const deUint64 compileStartTime = deGetMicroseconds();
- const spv_result_t compileOk = spvTextToBinary(spvSource.c_str(), spvSource.size(), &binary, &diagnostic);
+ const spv_result_t compileOk = spvTextToBinary(context, spvSource.c_str(), spvSource.size(), &binary, &diagnostic);
{
buildInfo->source = program;
#endif
spvBinaryDestroy(binary);
spvDiagnosticDestroy(diagnostic);
+ spvContextDestroy(context);
return;
}
negativeFloats[ndx] = -positiveFloats[ndx];
spec.assembly =
- "OpNop\n" // As the first instruction
-
- + string(s_ShaderPreamble) +
-
- "OpNop\n" // After OpEntryPoint but before any type definitions
+ string(s_ShaderPreamble) +
"OpSource GLSL 430\n"
"OpName %main \"main\"\n"
"OpDecorate %id BuiltIn GlobalInvocationId\n"
- + string(s_InputOutputBufferTraits) + string(s_CommonTypes) +
-
- "OpNop\n" // In the middle of type definitions
+ + string(s_InputOutputBufferTraits) + string(s_CommonTypes)
+ string(s_InputOutputBuffer) +
" OpFunctionEnd\n");
cases.push_back(CaseParameter("unknown_source", "OpSource Unknown 0"));
- cases.push_back(CaseParameter("wrong_source", "OpSource OpenCL 210"));
+ cases.push_back(CaseParameter("wrong_source", "OpSource OpenCL_C 210"));
cases.push_back(CaseParameter("normal_filename", "%fname = OpString \"filename\"\n"
"OpSource GLSL 430 %fname"));
cases.push_back(CaseParameter("empty_filename", "%fname = OpString \"\"\n"
string makeVertexShaderAssembly(const map<string, string>& fragments)
{
// \todo [2015-11-23 awoloszyn] Remove OpName once these have stabalized
-// \todo [2015-11-23 awoloszyn] Remove Smooth decoration when we move to SPIR-V 1.0
static const char vertexShaderBoilerplate[] =
"OpCapability Shader\n"
"OpMemoryModel Logical GLSL450\n"
"OpName %vertex_id \"gl_VertexID\"\n"
"OpName %instance_id \"gl_InstanceID\"\n"
"OpName %test_code \"testfun(vf4;\"\n"
- "OpDecorate %BP_vtxPosition Smooth\n"
"OpDecorate %BP_vtxPosition Location 2\n"
"OpDecorate %BP_Position Location 0\n"
- "OpDecorate %BP_vtxColor Smooth\n"
"OpDecorate %BP_vtxColor Location 1\n"
"OpDecorate %BP_color Location 1\n"
"OpDecorate %BP_vertex_id BuiltIn VertexId\n"
"OpCapability Tessellation\n"
"OpMemoryModel Logical GLSL450\n"
"OpEntryPoint TessellationEvaluation %BP_main \"main\" %BP_stream %BP_gl_tessCoord %BP_in_position %BP_out_color %BP_in_color \n"
- "OpExecutionMode %BP_main InputTriangles\n"
+ "OpExecutionMode %BP_main Triangles\n"
"${debug:opt}\n"
"OpName %BP_main \"main\"\n"
"OpName %BP_per_vertex_out \"gl_PerVertex\"\n"
"OpCapability Geometry\n"
"OpMemoryModel Logical GLSL450\n"
"OpEntryPoint Geometry %BP_main \"main\" %BP_out_gl_position %BP_gl_in %BP_out_color %BP_in_color\n"
- "OpExecutionMode %BP_main InputTriangles\n"
+ "OpExecutionMode %BP_main Triangles\n"
"OpExecutionMode %BP_main Invocations 0\n"
"OpExecutionMode %BP_main OutputTriangleStrip\n"
"OpExecutionMode %BP_main OutputVertices 3\n"
"%BP_transformed_in_color_0 = OpFunctionCall %v4f32 %test_code %BP_in_color_0\n"
"%BP_transformed_in_color_1 = OpFunctionCall %v4f32 %test_code %BP_in_color_1\n"
"%BP_transformed_in_color_2 = OpFunctionCall %v4f32 %test_code %BP_in_color_2\n"
+
"OpStore %BP_out_gl_position %BP_in_position_0\n"
"OpStore %BP_out_color %BP_transformed_in_color_0\n"
"OpEmitVertex\n"
//
// Derived from this GLSL:
//
-// layout(location = 0) in highp vec4 vtxColor;
-// layout(location = 1) out highp vec4 fragColor;
+// layout(location = 1) in highp vec4 vtxColor;
+// layout(location = 0) out highp vec4 fragColor;
// highp vec4 testfun(highp vec4 x) { return x; }
// void main(void) { fragColor = testfun(vtxColor); }
//
"OpName %BP_vtxColor \"vtxColor\"\n"
"OpName %test_code \"testfun(vf4;\"\n"
"OpDecorate %BP_fragColor Location 0\n"
- "OpDecorate %BP_vtxColor Smooth\n"
"OpDecorate %BP_vtxColor Location 1\n"
SPIRV_ASSEMBLY_TYPES
SPIRV_ASSEMBLY_CONSTANTS