Add different OpCopy* opcodes

This commit is contained in:
baldurk
2020-04-16 18:41:58 +01:00
parent f2cb1ddc53
commit 831ffbf226
5 changed files with 91 additions and 3 deletions
@@ -469,6 +469,18 @@ void ThreadState::StepNext(ShaderDebugState *state, const rdcarray<ThreadState>
break;
}
case Op::CopyMemory:
{
OpCopyMemory copy(it);
// ignore
(void)copy.memoryAccess0;
(void)copy.memoryAccess1;
WritePointerValue(copy.target, debugger.EvaluatePointerVariable(GetSrc(copy.source)));
break;
}
case Op::AccessChain:
case Op::InBoundsAccessChain:
{
@@ -1917,6 +1929,12 @@ void ThreadState::StepNext(ShaderDebugState *state, const rdcarray<ThreadState>
//
//////////////////////////////////////////////////////////////////////////////
case Op::MemoryBarrier:
case Op::ControlBarrier:
{
// do nothing for now
break;
}
case Op::Label:
case Op::SelectionMerge:
case Op::LoopMerge:
@@ -1991,6 +2009,16 @@ void ThreadState::StepNext(ShaderDebugState *state, const rdcarray<ThreadState>
//
//////////////////////////////////////////////////////////////////////////////
case Op::CopyObject:
case Op::CopyLogical:
{
// for our purposes differences in offset/decoration between types doesn't matter, so we can
// implement these two the same.
OpCopyObject copy(it);
SetDst(copy.result, GetSrc(copy.operand));
break;
}
case Op::ReadClockKHR:
{
const DataType &resultType = debugger.GetType(opdata.resultType);
+1
View File
@@ -122,6 +122,7 @@ typedef enum {
// See vulkan.h
shaderc_env_version_vulkan_1_0 = (((uint32_t)1 << 22)),
shaderc_env_version_vulkan_1_1 = (((uint32_t)1 << 22) | (1 << 12)),
shaderc_env_version_vulkan_1_2 = (((uint32_t)1 << 22) | (2 << 12)),
// For OpenGL, use the number from #version in shaders.
// TODO(dneto): Currently no difference between OpenGL 4.5 and 4.6.
// See glslang/Standalone/Standalone.cpp
+7
View File
@@ -278,6 +278,9 @@ std::vector<uint32_t> CompileShaderToSpv(const std::string &source_text, SPIRVTa
else if(target == SPIRVTarget::vulkan11)
shaderc_compile_options_set_target_env(opts, shaderc_target_env_vulkan,
shaderc_env_version_vulkan_1_1);
else if(target == SPIRVTarget::vulkan12)
shaderc_compile_options_set_target_env(opts, shaderc_target_env_vulkan,
shaderc_env_version_vulkan_1_2);
for(auto it : macros)
shaderc_compile_options_add_macro_definition(opts, it.first.c_str(), it.first.length(),
@@ -363,6 +366,8 @@ std::vector<uint32_t> CompileShaderToSpv(const std::string &source_text, SPIRVTa
command_line += " --target-env=opengl";
else if(target == SPIRVTarget::vulkan11)
command_line += " --target-env=vulkan1.1";
else if(target == SPIRVTarget::vulkan12)
command_line += " --target-env=vulkan1.2";
command_line += " -o ";
command_line += outfile;
@@ -401,6 +406,8 @@ std::vector<uint32_t> CompileShaderToSpv(const std::string &source_text, SPIRVTa
command_line += " -G --target-env opengl";
else if(target == SPIRVTarget::vulkan11)
command_line += " -V --target-env vulkan1.1";
else if(target == SPIRVTarget::vulkan12)
command_line += " -V --target-env vulkan1.2";
else if(target == SPIRVTarget::vulkan)
command_line += " -V --target-env vulkan1.0";
+1
View File
@@ -57,6 +57,7 @@ enum class SPIRVTarget
opengl,
vulkan,
vulkan11,
vulkan12,
};
enum class ShaderLang
{
+54 -3
View File
@@ -1518,6 +1518,26 @@ void main()
"%_w = OpConvertFToS %int %float_dyn_neg1_5\n"
"%_out_int4 = OpCompositeConstruct %int4 %_x %_y %_z %_w\n",
});
// test copies
append_tests({
"OpCopyMemory %Color %gl_FragCoord\n"
"; no_out\n",
"%frag = OpLoad %float4 %gl_FragCoord\n"
"%_out_float4 = OpCopyObject %float4 %frag\n",
});
// disabled while shaderc has a bug that doesn't respect the target environment
/*
if(vk_version >= 0x12)
{
append_tests({
"%frag = OpLoad %float4 %gl_FragCoord\n"
"%_out_float4 = OpCopyLogical %float4 %frag\n",
});
}
*/
}
std::string make_pixel_asm()
@@ -1659,6 +1679,8 @@ void main()
cases += test;
cases += "\n";
bool store_out = true;
if(test.find("%_out_float4") != std::string::npos)
{
// if the test outputted a float4, we can dump it directly
@@ -1734,12 +1756,17 @@ void main()
{
cases += fmt::format("%Color_{0} = OpConvertUToF %float4 %_out_uint4_{0}\n", i);
}
else if(test.find("; no_out") != std::string::npos)
{
store_out = false;
}
else
{
TEST_FATAL("Test with no recognised output");
}
cases += fmt::format("OpStore %Color %Color_{}\n", i);
if(store_out)
cases += fmt::format("OpStore %Color %Color_{}\n", i);
}
cases += "OpBranch %break\n";
@@ -1964,6 +1991,23 @@ void main()
return ret;
}
uint32_t vk_version = 0x10;
void Prepare(int argc, char **argv)
{
optDevExts.push_back(VK_KHR_SPIRV_1_4_EXTENSION_NAME);
VulkanGraphicsTest::Prepare(argc, argv);
vk_version = 0x10;
if(physProperties.apiVersion >= VK_MAKE_VERSION(1, 1, 0))
vk_version = 0x11;
if(physProperties.apiVersion >= VK_MAKE_VERSION(1, 2, 0))
vk_version = 0x12;
}
int main()
{
// initialise, create window, create context, etc
@@ -2043,8 +2087,15 @@ void main()
VkPipeline glslpipe = createGraphicsPipeline(pipeCreateInfo);
pipeCreateInfo.stages[1] =
CompileShaderModule(make_pixel_asm(), ShaderLang::spvasm, ShaderStage::frag, "main");
SPIRVTarget target = SPIRVTarget::vulkan;
if(vk_version >= 0x11)
target = SPIRVTarget::vulkan11;
if(vk_version >= 0x12)
target = SPIRVTarget::vulkan12;
pipeCreateInfo.stages[1] = CompileShaderModule(make_pixel_asm(), ShaderLang::spvasm,
ShaderStage::frag, "main", {}, target);
VkPipeline asmpipe = createGraphicsPipeline(pipeCreateInfo);