X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=external%2Fvulkancts%2Fframework%2Fvulkan%2FvkGlslToSpirV.cpp;h=96a80abb49117a15bb86da33a830f22694e73073;hb=de7ecd11b6156599ee528e12b7d3420d5465e141;hp=4202ddd3720b1ca3c7f274440bb6edb1d68470cb;hpb=5c62a113271e1127af8dc8ec9e5691b76076b9e1;p=platform%2Fupstream%2FVK-GL-CTS.git diff --git a/external/vulkancts/framework/vulkan/vkGlslToSpirV.cpp b/external/vulkancts/framework/vulkan/vkGlslToSpirV.cpp index 4202ddd..96a80ab 100644 --- a/external/vulkancts/framework/vulkan/vkGlslToSpirV.cpp +++ b/external/vulkancts/framework/vulkan/vkGlslToSpirV.cpp @@ -191,9 +191,7 @@ void getDefaultBuiltInResources (TBuiltInResource* builtin) builtin->maxSamples = 4; }; -} // anonymous - -int getNumShaderStages (const glu::ProgramSources& program) +int getNumShaderStages (const GlslSource& program) { int numShaderStages = 0; @@ -206,10 +204,37 @@ int getNumShaderStages (const glu::ProgramSources& program) return numShaderStages; } -bool compileGlslToSpirV (const glu::ProgramSources& program, std::vector* dst, glu::ShaderProgramInfo* buildInfo) +std::string getShaderStageSource (const GlslSource& program, glu::ShaderType shaderType) +{ + if (program.sources[shaderType].size() != 1) + TCU_THROW(InternalError, "Linking multiple compilation units is not supported"); + + if ((program.buildOptions.flags & GlslBuildOptions::FLAG_USE_STORAGE_BUFFER_STORAGE_CLASS) != 0) + { + // Hack to inject #pragma right after first #version statement + std::string src = program.sources[shaderType][0]; + size_t injectPos = 0; + + if (de::beginsWith(src, "#version")) + injectPos = src.find('\n') + 1; + + src.insert(injectPos, "#pragma use_storage_buffer\n"); + + return src; + } + else + return program.sources[shaderType][0]; +} + +} // anonymous + +bool compileGlslToSpirV (const GlslSource& program, std::vector* dst, glu::ShaderProgramInfo* buildInfo) { TBuiltInResource builtinRes; + if (program.buildOptions.targetVersion != SPIRV_VERSION_1_0) + TCU_THROW(InternalError, "Unsupported SPIR-V target version"); + if (getNumShaderStages(program) > 1) TCU_THROW(InternalError, "Linking multiple shader stages into a single SPIR-V binary is not supported"); @@ -221,7 +246,7 @@ bool compileGlslToSpirV (const glu::ProgramSources& program, std::vector*, glu::ShaderProgramInfo*) +bool compileGlslToSpirV (const GlslSource&, std::vector*, glu::ShaderProgramInfo*) { TCU_THROW(NotSupportedError, "GLSL to SPIR-V compilation not supported (DEQP_HAVE_GLSLANG not defined)"); }