diff options
| author | 2019-11-18 18:35:21 -0300 | |
|---|---|---|
| committer | 2019-11-22 21:28:48 -0300 | |
| commit | c8a48aacc0a2bfe87de74e0aa7842f5d1aec1558 (patch) | |
| tree | 472a1edcad13f148cf2dc7c25de0cd7b6206e83f /src/video_core/renderer_vulkan | |
| parent | gl_rasterizer: Bind graphics images to draw commands (diff) | |
| download | yuzu-c8a48aacc0a2bfe87de74e0aa7842f5d1aec1558.tar.gz yuzu-c8a48aacc0a2bfe87de74e0aa7842f5d1aec1558.tar.xz yuzu-c8a48aacc0a2bfe87de74e0aa7842f5d1aec1558.zip | |
video_core: Unify ProgramType and ShaderStage into ShaderType
Diffstat (limited to 'src/video_core/renderer_vulkan')
4 files changed, 25 insertions, 22 deletions
diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp index 463ed43ae..7f0eb6b74 100644 --- a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp +++ b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp | |||
| @@ -13,6 +13,8 @@ | |||
| 13 | 13 | ||
| 14 | namespace Vulkan::MaxwellToVK { | 14 | namespace Vulkan::MaxwellToVK { |
| 15 | 15 | ||
| 16 | using Maxwell = Tegra::Engines::Maxwell3D::Regs; | ||
| 17 | |||
| 16 | namespace Sampler { | 18 | namespace Sampler { |
| 17 | 19 | ||
| 18 | vk::Filter Filter(Tegra::Texture::TextureFilter filter) { | 20 | vk::Filter Filter(Tegra::Texture::TextureFilter filter) { |
| @@ -196,17 +198,17 @@ std::pair<vk::Format, bool> SurfaceFormat(const VKDevice& device, FormatType for | |||
| 196 | return {device.GetSupportedFormat(tuple.format, usage, format_type), tuple.attachable}; | 198 | return {device.GetSupportedFormat(tuple.format, usage, format_type), tuple.attachable}; |
| 197 | } | 199 | } |
| 198 | 200 | ||
| 199 | vk::ShaderStageFlagBits ShaderStage(Maxwell::ShaderStage stage) { | 201 | vk::ShaderStageFlagBits ShaderStage(Tegra::Engines::ShaderType stage) { |
| 200 | switch (stage) { | 202 | switch (stage) { |
| 201 | case Maxwell::ShaderStage::Vertex: | 203 | case Tegra::Engines::ShaderType::Vertex: |
| 202 | return vk::ShaderStageFlagBits::eVertex; | 204 | return vk::ShaderStageFlagBits::eVertex; |
| 203 | case Maxwell::ShaderStage::TesselationControl: | 205 | case Tegra::Engines::ShaderType::TesselationControl: |
| 204 | return vk::ShaderStageFlagBits::eTessellationControl; | 206 | return vk::ShaderStageFlagBits::eTessellationControl; |
| 205 | case Maxwell::ShaderStage::TesselationEval: | 207 | case Tegra::Engines::ShaderType::TesselationEval: |
| 206 | return vk::ShaderStageFlagBits::eTessellationEvaluation; | 208 | return vk::ShaderStageFlagBits::eTessellationEvaluation; |
| 207 | case Maxwell::ShaderStage::Geometry: | 209 | case Tegra::Engines::ShaderType::Geometry: |
| 208 | return vk::ShaderStageFlagBits::eGeometry; | 210 | return vk::ShaderStageFlagBits::eGeometry; |
| 209 | case Maxwell::ShaderStage::Fragment: | 211 | case Tegra::Engines::ShaderType::Fragment: |
| 210 | return vk::ShaderStageFlagBits::eFragment; | 212 | return vk::ShaderStageFlagBits::eFragment; |
| 211 | } | 213 | } |
| 212 | UNIMPLEMENTED_MSG("Unimplemented shader stage={}", static_cast<u32>(stage)); | 214 | UNIMPLEMENTED_MSG("Unimplemented shader stage={}", static_cast<u32>(stage)); |
diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.h b/src/video_core/renderer_vulkan/maxwell_to_vk.h index 5b0ffd87a..904a32e01 100644 --- a/src/video_core/renderer_vulkan/maxwell_to_vk.h +++ b/src/video_core/renderer_vulkan/maxwell_to_vk.h | |||
| @@ -32,7 +32,7 @@ vk::CompareOp DepthCompareFunction(Tegra::Texture::DepthCompareFunc depth_compar | |||
| 32 | std::pair<vk::Format, bool> SurfaceFormat(const VKDevice& device, FormatType format_type, | 32 | std::pair<vk::Format, bool> SurfaceFormat(const VKDevice& device, FormatType format_type, |
| 33 | PixelFormat pixel_format); | 33 | PixelFormat pixel_format); |
| 34 | 34 | ||
| 35 | vk::ShaderStageFlagBits ShaderStage(Maxwell::ShaderStage stage); | 35 | vk::ShaderStageFlagBits ShaderStage(Tegra::Engines::ShaderType stage); |
| 36 | 36 | ||
| 37 | vk::PrimitiveTopology PrimitiveTopology(Maxwell::PrimitiveTopology topology); | 37 | vk::PrimitiveTopology PrimitiveTopology(Maxwell::PrimitiveTopology topology); |
| 38 | 38 | ||
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp index 2850d5b59..80738d3d0 100644 --- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp +++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include "video_core/engines/maxwell_3d.h" | 17 | #include "video_core/engines/maxwell_3d.h" |
| 18 | #include "video_core/engines/shader_bytecode.h" | 18 | #include "video_core/engines/shader_bytecode.h" |
| 19 | #include "video_core/engines/shader_header.h" | 19 | #include "video_core/engines/shader_header.h" |
| 20 | #include "video_core/engines/shader_type.h" | ||
| 20 | #include "video_core/renderer_vulkan/vk_device.h" | 21 | #include "video_core/renderer_vulkan/vk_device.h" |
| 21 | #include "video_core/renderer_vulkan/vk_shader_decompiler.h" | 22 | #include "video_core/renderer_vulkan/vk_shader_decompiler.h" |
| 22 | #include "video_core/shader/node.h" | 23 | #include "video_core/shader/node.h" |
| @@ -25,13 +26,13 @@ | |||
| 25 | namespace Vulkan::VKShader { | 26 | namespace Vulkan::VKShader { |
| 26 | 27 | ||
| 27 | using Sirit::Id; | 28 | using Sirit::Id; |
| 29 | using Tegra::Engines::ShaderType; | ||
| 28 | using Tegra::Shader::Attribute; | 30 | using Tegra::Shader::Attribute; |
| 29 | using Tegra::Shader::AttributeUse; | 31 | using Tegra::Shader::AttributeUse; |
| 30 | using Tegra::Shader::Register; | 32 | using Tegra::Shader::Register; |
| 31 | using namespace VideoCommon::Shader; | 33 | using namespace VideoCommon::Shader; |
| 32 | 34 | ||
| 33 | using Maxwell = Tegra::Engines::Maxwell3D::Regs; | 35 | using Maxwell = Tegra::Engines::Maxwell3D::Regs; |
| 34 | using ShaderStage = Tegra::Engines::Maxwell3D::Regs::ShaderStage; | ||
| 35 | using Operation = const OperationNode&; | 36 | using Operation = const OperationNode&; |
| 36 | 37 | ||
| 37 | // TODO(Rodrigo): Use rasterizer's value | 38 | // TODO(Rodrigo): Use rasterizer's value |
| @@ -93,7 +94,7 @@ class ExprDecompiler; | |||
| 93 | 94 | ||
| 94 | class SPIRVDecompiler : public Sirit::Module { | 95 | class SPIRVDecompiler : public Sirit::Module { |
| 95 | public: | 96 | public: |
| 96 | explicit SPIRVDecompiler(const VKDevice& device, const ShaderIR& ir, ShaderStage stage) | 97 | explicit SPIRVDecompiler(const VKDevice& device, const ShaderIR& ir, ShaderType stage) |
| 97 | : Module(0x00010300), device{device}, ir{ir}, stage{stage}, header{ir.GetHeader()} { | 98 | : Module(0x00010300), device{device}, ir{ir}, stage{stage}, header{ir.GetHeader()} { |
| 98 | AddCapability(spv::Capability::Shader); | 99 | AddCapability(spv::Capability::Shader); |
| 99 | AddExtension("SPV_KHR_storage_buffer_storage_class"); | 100 | AddExtension("SPV_KHR_storage_buffer_storage_class"); |
| @@ -256,21 +257,21 @@ private: | |||
| 256 | } | 257 | } |
| 257 | 258 | ||
| 258 | void DeclareVertex() { | 259 | void DeclareVertex() { |
| 259 | if (stage != ShaderStage::Vertex) | 260 | if (stage != ShaderType::Vertex) |
| 260 | return; | 261 | return; |
| 261 | 262 | ||
| 262 | DeclareVertexRedeclarations(); | 263 | DeclareVertexRedeclarations(); |
| 263 | } | 264 | } |
| 264 | 265 | ||
| 265 | void DeclareGeometry() { | 266 | void DeclareGeometry() { |
| 266 | if (stage != ShaderStage::Geometry) | 267 | if (stage != ShaderType::Geometry) |
| 267 | return; | 268 | return; |
| 268 | 269 | ||
| 269 | UNIMPLEMENTED(); | 270 | UNIMPLEMENTED(); |
| 270 | } | 271 | } |
| 271 | 272 | ||
| 272 | void DeclareFragment() { | 273 | void DeclareFragment() { |
| 273 | if (stage != ShaderStage::Fragment) | 274 | if (stage != ShaderType::Fragment) |
| 274 | return; | 275 | return; |
| 275 | 276 | ||
| 276 | for (u32 rt = 0; rt < static_cast<u32>(frag_colors.size()); ++rt) { | 277 | for (u32 rt = 0; rt < static_cast<u32>(frag_colors.size()); ++rt) { |
| @@ -354,7 +355,7 @@ private: | |||
| 354 | continue; | 355 | continue; |
| 355 | } | 356 | } |
| 356 | 357 | ||
| 357 | UNIMPLEMENTED_IF(stage == ShaderStage::Geometry); | 358 | UNIMPLEMENTED_IF(stage == ShaderType::Geometry); |
| 358 | 359 | ||
| 359 | const u32 location = GetGenericAttributeLocation(index); | 360 | const u32 location = GetGenericAttributeLocation(index); |
| 360 | const Id id = OpVariable(t_in_float4, spv::StorageClass::Input); | 361 | const Id id = OpVariable(t_in_float4, spv::StorageClass::Input); |
| @@ -364,7 +365,7 @@ private: | |||
| 364 | 365 | ||
| 365 | Decorate(id, spv::Decoration::Location, location); | 366 | Decorate(id, spv::Decoration::Location, location); |
| 366 | 367 | ||
| 367 | if (stage != ShaderStage::Fragment) { | 368 | if (stage != ShaderType::Fragment) { |
| 368 | continue; | 369 | continue; |
| 369 | } | 370 | } |
| 370 | switch (header.ps.GetAttributeUse(location)) { | 371 | switch (header.ps.GetAttributeUse(location)) { |
| @@ -548,7 +549,7 @@ private: | |||
| 548 | 549 | ||
| 549 | switch (attribute) { | 550 | switch (attribute) { |
| 550 | case Attribute::Index::Position: | 551 | case Attribute::Index::Position: |
| 551 | if (stage != ShaderStage::Fragment) { | 552 | if (stage != ShaderType::Fragment) { |
| 552 | UNIMPLEMENTED(); | 553 | UNIMPLEMENTED(); |
| 553 | break; | 554 | break; |
| 554 | } else { | 555 | } else { |
| @@ -561,7 +562,7 @@ private: | |||
| 561 | // TODO(Subv): Find out what the values are for the first two elements when inside a | 562 | // TODO(Subv): Find out what the values are for the first two elements when inside a |
| 562 | // vertex shader, and what's the value of the fourth element when inside a Tess Eval | 563 | // vertex shader, and what's the value of the fourth element when inside a Tess Eval |
| 563 | // shader. | 564 | // shader. |
| 564 | ASSERT(stage == ShaderStage::Vertex); | 565 | ASSERT(stage == ShaderType::Vertex); |
| 565 | switch (element) { | 566 | switch (element) { |
| 566 | case 2: | 567 | case 2: |
| 567 | return BitcastFrom<Type::Uint>(Emit(OpLoad(t_uint, instance_index))); | 568 | return BitcastFrom<Type::Uint>(Emit(OpLoad(t_uint, instance_index))); |
| @@ -572,7 +573,7 @@ private: | |||
| 572 | return Constant(t_float, 0); | 573 | return Constant(t_float, 0); |
| 573 | case Attribute::Index::FrontFacing: | 574 | case Attribute::Index::FrontFacing: |
| 574 | // TODO(Subv): Find out what the values are for the other elements. | 575 | // TODO(Subv): Find out what the values are for the other elements. |
| 575 | ASSERT(stage == ShaderStage::Fragment); | 576 | ASSERT(stage == ShaderType::Fragment); |
| 576 | if (element == 3) { | 577 | if (element == 3) { |
| 577 | const Id is_front_facing = Emit(OpLoad(t_bool, front_facing)); | 578 | const Id is_front_facing = Emit(OpLoad(t_bool, front_facing)); |
| 578 | const Id true_value = | 579 | const Id true_value = |
| @@ -1075,7 +1076,7 @@ private: | |||
| 1075 | 1076 | ||
| 1076 | Id PreExit() { | 1077 | Id PreExit() { |
| 1077 | switch (stage) { | 1078 | switch (stage) { |
| 1078 | case ShaderStage::Vertex: { | 1079 | case ShaderType::Vertex: { |
| 1079 | // TODO(Rodrigo): We should use VK_EXT_depth_range_unrestricted instead, but it doesn't | 1080 | // TODO(Rodrigo): We should use VK_EXT_depth_range_unrestricted instead, but it doesn't |
| 1080 | // seem to be working on Nvidia's drivers and Intel (mesa and blob) doesn't support it. | 1081 | // seem to be working on Nvidia's drivers and Intel (mesa and blob) doesn't support it. |
| 1081 | const Id z_pointer = AccessElement(t_out_float, per_vertex, position_index, 2u); | 1082 | const Id z_pointer = AccessElement(t_out_float, per_vertex, position_index, 2u); |
| @@ -1085,7 +1086,7 @@ private: | |||
| 1085 | Emit(OpStore(z_pointer, depth)); | 1086 | Emit(OpStore(z_pointer, depth)); |
| 1086 | break; | 1087 | break; |
| 1087 | } | 1088 | } |
| 1088 | case ShaderStage::Fragment: { | 1089 | case ShaderType::Fragment: { |
| 1089 | const auto SafeGetRegister = [&](u32 reg) { | 1090 | const auto SafeGetRegister = [&](u32 reg) { |
| 1090 | // TODO(Rodrigo): Replace with contains once C++20 releases | 1091 | // TODO(Rodrigo): Replace with contains once C++20 releases |
| 1091 | if (const auto it = registers.find(reg); it != registers.end()) { | 1092 | if (const auto it = registers.find(reg); it != registers.end()) { |
| @@ -1511,7 +1512,7 @@ private: | |||
| 1511 | 1512 | ||
| 1512 | const VKDevice& device; | 1513 | const VKDevice& device; |
| 1513 | const ShaderIR& ir; | 1514 | const ShaderIR& ir; |
| 1514 | const ShaderStage stage; | 1515 | const ShaderType stage; |
| 1515 | const Tegra::Shader::Header header; | 1516 | const Tegra::Shader::Header header; |
| 1516 | u64 conditional_nest_count{}; | 1517 | u64 conditional_nest_count{}; |
| 1517 | u64 inside_branch{}; | 1518 | u64 inside_branch{}; |
| @@ -1843,7 +1844,7 @@ void SPIRVDecompiler::DecompileAST() { | |||
| 1843 | } | 1844 | } |
| 1844 | 1845 | ||
| 1845 | DecompilerResult Decompile(const VKDevice& device, const VideoCommon::Shader::ShaderIR& ir, | 1846 | DecompilerResult Decompile(const VKDevice& device, const VideoCommon::Shader::ShaderIR& ir, |
| 1846 | Maxwell::ShaderStage stage) { | 1847 | ShaderType stage) { |
| 1847 | auto decompiler = std::make_unique<SPIRVDecompiler>(device, ir, stage); | 1848 | auto decompiler = std::make_unique<SPIRVDecompiler>(device, ir, stage); |
| 1848 | decompiler->Decompile(); | 1849 | decompiler->Decompile(); |
| 1849 | return {std::move(decompiler), decompiler->GetShaderEntries()}; | 1850 | return {std::move(decompiler), decompiler->GetShaderEntries()}; |
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.h b/src/video_core/renderer_vulkan/vk_shader_decompiler.h index f90541cc1..203fc00d0 100644 --- a/src/video_core/renderer_vulkan/vk_shader_decompiler.h +++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.h | |||
| @@ -79,6 +79,6 @@ struct ShaderEntries { | |||
| 79 | using DecompilerResult = std::pair<std::unique_ptr<Sirit::Module>, ShaderEntries>; | 79 | using DecompilerResult = std::pair<std::unique_ptr<Sirit::Module>, ShaderEntries>; |
| 80 | 80 | ||
| 81 | DecompilerResult Decompile(const VKDevice& device, const VideoCommon::Shader::ShaderIR& ir, | 81 | DecompilerResult Decompile(const VKDevice& device, const VideoCommon::Shader::ShaderIR& ir, |
| 82 | Maxwell::ShaderStage stage); | 82 | Tegra::Engines::ShaderType stage); |
| 83 | 83 | ||
| 84 | } // namespace Vulkan::VKShader | 84 | } // namespace Vulkan::VKShader |