diff options
| author | 2019-11-18 18:35:21 -0300 | |
|---|---|---|
| committer | 2019-11-22 21:28:48 -0300 | |
| commit | c8a48aacc0a2bfe87de74e0aa7842f5d1aec1558 (patch) | |
| tree | 472a1edcad13f148cf2dc7c25de0cd7b6206e83f /src | |
| 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')
22 files changed, 262 insertions, 289 deletions
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 6f3f2aa9f..3b20c7d34 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt | |||
| @@ -22,6 +22,7 @@ add_library(video_core STATIC | |||
| 22 | engines/maxwell_dma.h | 22 | engines/maxwell_dma.h |
| 23 | engines/shader_bytecode.h | 23 | engines/shader_bytecode.h |
| 24 | engines/shader_header.h | 24 | engines/shader_header.h |
| 25 | engines/shader_type.h | ||
| 25 | gpu.cpp | 26 | gpu.cpp |
| 26 | gpu.h | 27 | gpu.h |
| 27 | gpu_asynch.cpp | 28 | gpu_asynch.cpp |
diff --git a/src/video_core/engines/const_buffer_engine_interface.h b/src/video_core/engines/const_buffer_engine_interface.h index ac27b6cbe..44b8b8d22 100644 --- a/src/video_core/engines/const_buffer_engine_interface.h +++ b/src/video_core/engines/const_buffer_engine_interface.h | |||
| @@ -8,19 +8,11 @@ | |||
| 8 | #include "common/bit_field.h" | 8 | #include "common/bit_field.h" |
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "video_core/engines/shader_bytecode.h" | 10 | #include "video_core/engines/shader_bytecode.h" |
| 11 | #include "video_core/engines/shader_type.h" | ||
| 11 | #include "video_core/textures/texture.h" | 12 | #include "video_core/textures/texture.h" |
| 12 | 13 | ||
| 13 | namespace Tegra::Engines { | 14 | namespace Tegra::Engines { |
| 14 | 15 | ||
| 15 | enum class ShaderType : u32 { | ||
| 16 | Vertex = 0, | ||
| 17 | TesselationControl = 1, | ||
| 18 | TesselationEval = 2, | ||
| 19 | Geometry = 3, | ||
| 20 | Fragment = 4, | ||
| 21 | Compute = 5, | ||
| 22 | }; | ||
| 23 | |||
| 24 | struct SamplerDescriptor { | 16 | struct SamplerDescriptor { |
| 25 | union { | 17 | union { |
| 26 | BitField<0, 20, Tegra::Shader::TextureType> texture_type; | 18 | BitField<0, 20, Tegra::Shader::TextureType> texture_type; |
diff --git a/src/video_core/engines/kepler_compute.cpp b/src/video_core/engines/kepler_compute.cpp index 3a39aeabe..110406f2f 100644 --- a/src/video_core/engines/kepler_compute.cpp +++ b/src/video_core/engines/kepler_compute.cpp | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include "core/core.h" | 8 | #include "core/core.h" |
| 9 | #include "video_core/engines/kepler_compute.h" | 9 | #include "video_core/engines/kepler_compute.h" |
| 10 | #include "video_core/engines/maxwell_3d.h" | 10 | #include "video_core/engines/maxwell_3d.h" |
| 11 | #include "video_core/engines/shader_type.h" | ||
| 11 | #include "video_core/memory_manager.h" | 12 | #include "video_core/memory_manager.h" |
| 12 | #include "video_core/rasterizer_interface.h" | 13 | #include "video_core/rasterizer_interface.h" |
| 13 | #include "video_core/renderer_base.h" | 14 | #include "video_core/renderer_base.h" |
diff --git a/src/video_core/engines/kepler_compute.h b/src/video_core/engines/kepler_compute.h index c526287b7..4ef3e0613 100644 --- a/src/video_core/engines/kepler_compute.h +++ b/src/video_core/engines/kepler_compute.h | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 13 | #include "video_core/engines/const_buffer_engine_interface.h" | 13 | #include "video_core/engines/const_buffer_engine_interface.h" |
| 14 | #include "video_core/engines/engine_upload.h" | 14 | #include "video_core/engines/engine_upload.h" |
| 15 | #include "video_core/engines/shader_type.h" | ||
| 15 | #include "video_core/gpu.h" | 16 | #include "video_core/gpu.h" |
| 16 | #include "video_core/textures/texture.h" | 17 | #include "video_core/textures/texture.h" |
| 17 | 18 | ||
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index a44c09003..15a7a9d6a 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "core/core_timing.h" | 9 | #include "core/core_timing.h" |
| 10 | #include "video_core/debug_utils/debug_utils.h" | 10 | #include "video_core/debug_utils/debug_utils.h" |
| 11 | #include "video_core/engines/maxwell_3d.h" | 11 | #include "video_core/engines/maxwell_3d.h" |
| 12 | #include "video_core/engines/shader_type.h" | ||
| 12 | #include "video_core/memory_manager.h" | 13 | #include "video_core/memory_manager.h" |
| 13 | #include "video_core/rasterizer_interface.h" | 14 | #include "video_core/rasterizer_interface.h" |
| 14 | #include "video_core/textures/texture.h" | 15 | #include "video_core/textures/texture.h" |
| @@ -368,24 +369,24 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) { | |||
| 368 | StartCBData(method); | 369 | StartCBData(method); |
| 369 | break; | 370 | break; |
| 370 | } | 371 | } |
| 371 | case MAXWELL3D_REG_INDEX(cb_bind[0].raw_config): { | 372 | case MAXWELL3D_REG_INDEX(cb_bind[0]): { |
| 372 | ProcessCBBind(Regs::ShaderStage::Vertex); | 373 | ProcessCBBind(0); |
| 373 | break; | 374 | break; |
| 374 | } | 375 | } |
| 375 | case MAXWELL3D_REG_INDEX(cb_bind[1].raw_config): { | 376 | case MAXWELL3D_REG_INDEX(cb_bind[1]): { |
| 376 | ProcessCBBind(Regs::ShaderStage::TesselationControl); | 377 | ProcessCBBind(1); |
| 377 | break; | 378 | break; |
| 378 | } | 379 | } |
| 379 | case MAXWELL3D_REG_INDEX(cb_bind[2].raw_config): { | 380 | case MAXWELL3D_REG_INDEX(cb_bind[2]): { |
| 380 | ProcessCBBind(Regs::ShaderStage::TesselationEval); | 381 | ProcessCBBind(2); |
| 381 | break; | 382 | break; |
| 382 | } | 383 | } |
| 383 | case MAXWELL3D_REG_INDEX(cb_bind[3].raw_config): { | 384 | case MAXWELL3D_REG_INDEX(cb_bind[3]): { |
| 384 | ProcessCBBind(Regs::ShaderStage::Geometry); | 385 | ProcessCBBind(3); |
| 385 | break; | 386 | break; |
| 386 | } | 387 | } |
| 387 | case MAXWELL3D_REG_INDEX(cb_bind[4].raw_config): { | 388 | case MAXWELL3D_REG_INDEX(cb_bind[4]): { |
| 388 | ProcessCBBind(Regs::ShaderStage::Fragment); | 389 | ProcessCBBind(4); |
| 389 | break; | 390 | break; |
| 390 | } | 391 | } |
| 391 | case MAXWELL3D_REG_INDEX(draw.vertex_end_gl): { | 392 | case MAXWELL3D_REG_INDEX(draw.vertex_end_gl): { |
| @@ -687,10 +688,10 @@ void Maxwell3D::DrawArrays() { | |||
| 687 | } | 688 | } |
| 688 | } | 689 | } |
| 689 | 690 | ||
| 690 | void Maxwell3D::ProcessCBBind(Regs::ShaderStage stage) { | 691 | void Maxwell3D::ProcessCBBind(std::size_t stage_index) { |
| 691 | // Bind the buffer currently in CB_ADDRESS to the specified index in the desired shader stage. | 692 | // Bind the buffer currently in CB_ADDRESS to the specified index in the desired shader stage. |
| 692 | auto& shader = state.shader_stages[static_cast<std::size_t>(stage)]; | 693 | auto& shader = state.shader_stages[stage_index]; |
| 693 | auto& bind_data = regs.cb_bind[static_cast<std::size_t>(stage)]; | 694 | auto& bind_data = regs.cb_bind[stage_index]; |
| 694 | 695 | ||
| 695 | ASSERT(bind_data.index < Regs::MaxConstBuffers); | 696 | ASSERT(bind_data.index < Regs::MaxConstBuffers); |
| 696 | auto& buffer = shader.const_buffers[bind_data.index]; | 697 | auto& buffer = shader.const_buffers[bind_data.index]; |
| @@ -757,9 +758,9 @@ Texture::FullTextureInfo Maxwell3D::GetTextureInfo(Texture::TextureHandle tex_ha | |||
| 757 | return Texture::FullTextureInfo{GetTICEntry(tex_handle.tic_id), GetTSCEntry(tex_handle.tsc_id)}; | 758 | return Texture::FullTextureInfo{GetTICEntry(tex_handle.tic_id), GetTSCEntry(tex_handle.tsc_id)}; |
| 758 | } | 759 | } |
| 759 | 760 | ||
| 760 | Texture::FullTextureInfo Maxwell3D::GetStageTexture(Regs::ShaderStage stage, | 761 | Texture::FullTextureInfo Maxwell3D::GetStageTexture(ShaderType stage, std::size_t offset) const { |
| 761 | std::size_t offset) const { | 762 | const auto stage_index = static_cast<std::size_t>(stage); |
| 762 | const auto& shader = state.shader_stages[static_cast<std::size_t>(stage)]; | 763 | const auto& shader = state.shader_stages[stage_index]; |
| 763 | const auto& tex_info_buffer = shader.const_buffers[regs.tex_cb_index]; | 764 | const auto& tex_info_buffer = shader.const_buffers[regs.tex_cb_index]; |
| 764 | ASSERT(tex_info_buffer.enabled && tex_info_buffer.address != 0); | 765 | ASSERT(tex_info_buffer.enabled && tex_info_buffer.address != 0); |
| 765 | 766 | ||
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 1aa7c274f..72994f4d2 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #include "video_core/engines/const_buffer_engine_interface.h" | 18 | #include "video_core/engines/const_buffer_engine_interface.h" |
| 19 | #include "video_core/engines/const_buffer_info.h" | 19 | #include "video_core/engines/const_buffer_info.h" |
| 20 | #include "video_core/engines/engine_upload.h" | 20 | #include "video_core/engines/engine_upload.h" |
| 21 | #include "video_core/engines/shader_type.h" | ||
| 21 | #include "video_core/gpu.h" | 22 | #include "video_core/gpu.h" |
| 22 | #include "video_core/macro_interpreter.h" | 23 | #include "video_core/macro_interpreter.h" |
| 23 | #include "video_core/textures/texture.h" | 24 | #include "video_core/textures/texture.h" |
| @@ -130,14 +131,6 @@ public: | |||
| 130 | Fragment = 5, | 131 | Fragment = 5, |
| 131 | }; | 132 | }; |
| 132 | 133 | ||
| 133 | enum class ShaderStage : u32 { | ||
| 134 | Vertex = 0, | ||
| 135 | TesselationControl = 1, | ||
| 136 | TesselationEval = 2, | ||
| 137 | Geometry = 3, | ||
| 138 | Fragment = 4, | ||
| 139 | }; | ||
| 140 | |||
| 141 | struct VertexAttribute { | 134 | struct VertexAttribute { |
| 142 | enum class Size : u32 { | 135 | enum class Size : u32 { |
| 143 | Invalid = 0x0, | 136 | Invalid = 0x0, |
| @@ -1254,7 +1247,7 @@ public: | |||
| 1254 | Texture::FullTextureInfo GetTextureInfo(Texture::TextureHandle tex_handle) const; | 1247 | Texture::FullTextureInfo GetTextureInfo(Texture::TextureHandle tex_handle) const; |
| 1255 | 1248 | ||
| 1256 | /// Returns the texture information for a specific texture in a specific shader stage. | 1249 | /// Returns the texture information for a specific texture in a specific shader stage. |
| 1257 | Texture::FullTextureInfo GetStageTexture(Regs::ShaderStage stage, std::size_t offset) const; | 1250 | Texture::FullTextureInfo GetStageTexture(ShaderType stage, std::size_t offset) const; |
| 1258 | 1251 | ||
| 1259 | u32 AccessConstBuffer32(ShaderType stage, u64 const_buffer, u64 offset) const override; | 1252 | u32 AccessConstBuffer32(ShaderType stage, u64 const_buffer, u64 offset) const override; |
| 1260 | 1253 | ||
| @@ -1376,7 +1369,7 @@ private: | |||
| 1376 | void FinishCBData(); | 1369 | void FinishCBData(); |
| 1377 | 1370 | ||
| 1378 | /// Handles a write to the CB_BIND register. | 1371 | /// Handles a write to the CB_BIND register. |
| 1379 | void ProcessCBBind(Regs::ShaderStage stage); | 1372 | void ProcessCBBind(std::size_t stage_index); |
| 1380 | 1373 | ||
| 1381 | /// Handles a write to the VERTEX_END_GL register, triggering a draw. | 1374 | /// Handles a write to the VERTEX_END_GL register, triggering a draw. |
| 1382 | void DrawArrays(); | 1375 | void DrawArrays(); |
diff --git a/src/video_core/engines/shader_type.h b/src/video_core/engines/shader_type.h new file mode 100644 index 000000000..239196ba9 --- /dev/null +++ b/src/video_core/engines/shader_type.h | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | // Copyright 2019 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 9 | namespace Tegra::Engines { | ||
| 10 | |||
| 11 | enum class ShaderType : u32 { | ||
| 12 | Vertex = 0, | ||
| 13 | TesselationControl = 1, | ||
| 14 | TesselationEval = 2, | ||
| 15 | Geometry = 3, | ||
| 16 | Fragment = 4, | ||
| 17 | Compute = 5, | ||
| 18 | }; | ||
| 19 | |||
| 20 | } // namespace Tegra::Engines | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 9ce20f8f4..8baa73ebf 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #include "core/settings.h" | 22 | #include "core/settings.h" |
| 23 | #include "video_core/engines/kepler_compute.h" | 23 | #include "video_core/engines/kepler_compute.h" |
| 24 | #include "video_core/engines/maxwell_3d.h" | 24 | #include "video_core/engines/maxwell_3d.h" |
| 25 | #include "video_core/engines/shader_type.h" | ||
| 25 | #include "video_core/memory_manager.h" | 26 | #include "video_core/memory_manager.h" |
| 26 | #include "video_core/renderer_opengl/gl_rasterizer.h" | 27 | #include "video_core/renderer_opengl/gl_rasterizer.h" |
| 27 | #include "video_core/renderer_opengl/gl_shader_cache.h" | 28 | #include "video_core/renderer_opengl/gl_shader_cache.h" |
| @@ -60,8 +61,7 @@ Tegra::Texture::FullTextureInfo GetTextureInfo(const Engine& engine, const Entry | |||
| 60 | return engine.GetTextureInfo(tex_handle); | 61 | return engine.GetTextureInfo(tex_handle); |
| 61 | } | 62 | } |
| 62 | if constexpr (std::is_same_v<Engine, Tegra::Engines::Maxwell3D>) { | 63 | if constexpr (std::is_same_v<Engine, Tegra::Engines::Maxwell3D>) { |
| 63 | const auto stage = static_cast<Maxwell::ShaderStage>(shader_type); | 64 | return engine.GetStageTexture(shader_type, entry.GetOffset()); |
| 64 | return engine.GetStageTexture(stage, entry.GetOffset()); | ||
| 65 | } else { | 65 | } else { |
| 66 | return engine.GetTexture(entry.GetOffset()); | 66 | return engine.GetTexture(entry.GetOffset()); |
| 67 | } | 67 | } |
| @@ -263,7 +263,7 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) { | |||
| 263 | 263 | ||
| 264 | for (std::size_t index = 0; index < Maxwell::MaxShaderProgram; ++index) { | 264 | for (std::size_t index = 0; index < Maxwell::MaxShaderProgram; ++index) { |
| 265 | const auto& shader_config = gpu.regs.shader_config[index]; | 265 | const auto& shader_config = gpu.regs.shader_config[index]; |
| 266 | const Maxwell::ShaderProgram program{static_cast<Maxwell::ShaderProgram>(index)}; | 266 | const auto program{static_cast<Maxwell::ShaderProgram>(index)}; |
| 267 | 267 | ||
| 268 | // Skip stages that are not enabled | 268 | // Skip stages that are not enabled |
| 269 | if (!gpu.regs.IsShaderConfigEnabled(index)) { | 269 | if (!gpu.regs.IsShaderConfigEnabled(index)) { |
| @@ -288,7 +288,7 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) { | |||
| 288 | Shader shader{shader_cache.GetStageProgram(program)}; | 288 | Shader shader{shader_cache.GetStageProgram(program)}; |
| 289 | 289 | ||
| 290 | // Stage indices are 0 - 5 | 290 | // Stage indices are 0 - 5 |
| 291 | const auto stage = static_cast<Maxwell::ShaderStage>(index == 0 ? 0 : index - 1); | 291 | const std::size_t stage = index == 0 ? 0 : index - 1; |
| 292 | SetupDrawConstBuffers(stage, shader); | 292 | SetupDrawConstBuffers(stage, shader); |
| 293 | SetupDrawGlobalMemory(stage, shader); | 293 | SetupDrawGlobalMemory(stage, shader); |
| 294 | SetupDrawTextures(stage, shader, base_bindings); | 294 | SetupDrawTextures(stage, shader, base_bindings); |
| @@ -856,11 +856,10 @@ bool RasterizerOpenGL::AccelerateDisplay(const Tegra::FramebufferConfig& config, | |||
| 856 | return true; | 856 | return true; |
| 857 | } | 857 | } |
| 858 | 858 | ||
| 859 | void RasterizerOpenGL::SetupDrawConstBuffers(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage, | 859 | void RasterizerOpenGL::SetupDrawConstBuffers(std::size_t stage_index, const Shader& shader) { |
| 860 | const Shader& shader) { | ||
| 861 | MICROPROFILE_SCOPE(OpenGL_UBO); | 860 | MICROPROFILE_SCOPE(OpenGL_UBO); |
| 862 | const auto& stages = system.GPU().Maxwell3D().state.shader_stages; | 861 | const auto& stages = system.GPU().Maxwell3D().state.shader_stages; |
| 863 | const auto& shader_stage = stages[static_cast<std::size_t>(stage)]; | 862 | const auto& shader_stage = stages[stage_index]; |
| 864 | for (const auto& entry : shader->GetShaderEntries().const_buffers) { | 863 | for (const auto& entry : shader->GetShaderEntries().const_buffers) { |
| 865 | const auto& buffer = shader_stage.const_buffers[entry.GetIndex()]; | 864 | const auto& buffer = shader_stage.const_buffers[entry.GetIndex()]; |
| 866 | SetupConstBuffer(buffer, entry); | 865 | SetupConstBuffer(buffer, entry); |
| @@ -899,11 +898,10 @@ void RasterizerOpenGL::SetupConstBuffer(const Tegra::Engines::ConstBufferInfo& b | |||
| 899 | bind_ubo_pushbuffer.Push(cbuf, offset, size); | 898 | bind_ubo_pushbuffer.Push(cbuf, offset, size); |
| 900 | } | 899 | } |
| 901 | 900 | ||
| 902 | void RasterizerOpenGL::SetupDrawGlobalMemory(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage, | 901 | void RasterizerOpenGL::SetupDrawGlobalMemory(std::size_t stage_index, const Shader& shader) { |
| 903 | const Shader& shader) { | ||
| 904 | auto& gpu{system.GPU()}; | 902 | auto& gpu{system.GPU()}; |
| 905 | auto& memory_manager{gpu.MemoryManager()}; | 903 | auto& memory_manager{gpu.MemoryManager()}; |
| 906 | const auto cbufs{gpu.Maxwell3D().state.shader_stages[static_cast<std::size_t>(stage)]}; | 904 | const auto cbufs{gpu.Maxwell3D().state.shader_stages[stage_index]}; |
| 907 | for (const auto& entry : shader->GetShaderEntries().global_memory_entries) { | 905 | for (const auto& entry : shader->GetShaderEntries().global_memory_entries) { |
| 908 | const auto addr{cbufs.const_buffers[entry.GetCbufIndex()].address + entry.GetCbufOffset()}; | 906 | const auto addr{cbufs.const_buffers[entry.GetCbufIndex()].address + entry.GetCbufOffset()}; |
| 909 | const auto gpu_addr{memory_manager.Read<u64>(addr)}; | 907 | const auto gpu_addr{memory_manager.Read<u64>(addr)}; |
| @@ -932,7 +930,7 @@ void RasterizerOpenGL::SetupGlobalMemory(const GLShader::GlobalMemoryEntry& entr | |||
| 932 | bind_ssbo_pushbuffer.Push(ssbo, buffer_offset, static_cast<GLsizeiptr>(size)); | 930 | bind_ssbo_pushbuffer.Push(ssbo, buffer_offset, static_cast<GLsizeiptr>(size)); |
| 933 | } | 931 | } |
| 934 | 932 | ||
| 935 | void RasterizerOpenGL::SetupDrawTextures(Maxwell::ShaderStage stage, const Shader& shader, | 933 | void RasterizerOpenGL::SetupDrawTextures(std::size_t stage_index, const Shader& shader, |
| 936 | BaseBindings base_bindings) { | 934 | BaseBindings base_bindings) { |
| 937 | MICROPROFILE_SCOPE(OpenGL_Texture); | 935 | MICROPROFILE_SCOPE(OpenGL_Texture); |
| 938 | const auto& gpu = system.GPU(); | 936 | const auto& gpu = system.GPU(); |
| @@ -945,7 +943,7 @@ void RasterizerOpenGL::SetupDrawTextures(Maxwell::ShaderStage stage, const Shade | |||
| 945 | const auto num_entries = static_cast<u32>(entries.size()); | 943 | const auto num_entries = static_cast<u32>(entries.size()); |
| 946 | for (u32 bindpoint = 0; bindpoint < num_entries; ++bindpoint) { | 944 | for (u32 bindpoint = 0; bindpoint < num_entries; ++bindpoint) { |
| 947 | const auto& entry = entries[bindpoint]; | 945 | const auto& entry = entries[bindpoint]; |
| 948 | const auto shader_type = static_cast<Tegra::Engines::ShaderType>(stage); | 946 | const auto shader_type = static_cast<Tegra::Engines::ShaderType>(stage_index); |
| 949 | const auto texture = GetTextureInfo(maxwell3d, entry, shader_type); | 947 | const auto texture = GetTextureInfo(maxwell3d, entry, shader_type); |
| 950 | SetupTexture(base_bindings.sampler + bindpoint, texture, entry); | 948 | SetupTexture(base_bindings.sampler + bindpoint, texture, entry); |
| 951 | } | 949 | } |
| @@ -988,7 +986,7 @@ void RasterizerOpenGL::SetupTexture(u32 binding, const Tegra::Texture::FullTextu | |||
| 988 | texture.tic.w_source); | 986 | texture.tic.w_source); |
| 989 | } | 987 | } |
| 990 | 988 | ||
| 991 | void RasterizerOpenGL::SetupDrawImages(Maxwell::ShaderStage stage, const Shader& shader, | 989 | void RasterizerOpenGL::SetupDrawImages(std::size_t stage_index, const Shader& shader, |
| 992 | BaseBindings base_bindings) { | 990 | BaseBindings base_bindings) { |
| 993 | const auto& maxwell3d = system.GPU().Maxwell3D(); | 991 | const auto& maxwell3d = system.GPU().Maxwell3D(); |
| 994 | const auto& entries = shader->GetShaderEntries().images; | 992 | const auto& entries = shader->GetShaderEntries().images; |
| @@ -996,7 +994,7 @@ void RasterizerOpenGL::SetupDrawImages(Maxwell::ShaderStage stage, const Shader& | |||
| 996 | const auto num_entries = static_cast<u32>(entries.size()); | 994 | const auto num_entries = static_cast<u32>(entries.size()); |
| 997 | for (u32 bindpoint = 0; bindpoint < num_entries; ++bindpoint) { | 995 | for (u32 bindpoint = 0; bindpoint < num_entries; ++bindpoint) { |
| 998 | const auto& entry = entries[bindpoint]; | 996 | const auto& entry = entries[bindpoint]; |
| 999 | const auto shader_type = static_cast<Tegra::Engines::ShaderType>(stage); | 997 | const auto shader_type = static_cast<Tegra::Engines::ShaderType>(stage_index); |
| 1000 | const auto tic = GetTextureInfo(maxwell3d, entry, shader_type).tic; | 998 | const auto tic = GetTextureInfo(maxwell3d, entry, shader_type).tic; |
| 1001 | SetupImage(base_bindings.image + bindpoint, tic, entry); | 999 | SetupImage(base_bindings.image + bindpoint, tic, entry); |
| 1002 | } | 1000 | } |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 267ed7803..6a2ce1586 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -83,8 +83,7 @@ private: | |||
| 83 | bool using_depth_fb, bool using_stencil_fb); | 83 | bool using_depth_fb, bool using_stencil_fb); |
| 84 | 84 | ||
| 85 | /// Configures the current constbuffers to use for the draw command. | 85 | /// Configures the current constbuffers to use for the draw command. |
| 86 | void SetupDrawConstBuffers(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage, | 86 | void SetupDrawConstBuffers(std::size_t stage_index, const Shader& shader); |
| 87 | const Shader& shader); | ||
| 88 | 87 | ||
| 89 | /// Configures the current constbuffers to use for the kernel invocation. | 88 | /// Configures the current constbuffers to use for the kernel invocation. |
| 90 | void SetupComputeConstBuffers(const Shader& kernel); | 89 | void SetupComputeConstBuffers(const Shader& kernel); |
| @@ -94,8 +93,7 @@ private: | |||
| 94 | const GLShader::ConstBufferEntry& entry); | 93 | const GLShader::ConstBufferEntry& entry); |
| 95 | 94 | ||
| 96 | /// Configures the current global memory entries to use for the draw command. | 95 | /// Configures the current global memory entries to use for the draw command. |
| 97 | void SetupDrawGlobalMemory(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage, | 96 | void SetupDrawGlobalMemory(std::size_t stage_index, const Shader& shader); |
| 98 | const Shader& shader); | ||
| 99 | 97 | ||
| 100 | /// Configures the current global memory entries to use for the kernel invocation. | 98 | /// Configures the current global memory entries to use for the kernel invocation. |
| 101 | void SetupComputeGlobalMemory(const Shader& kernel); | 99 | void SetupComputeGlobalMemory(const Shader& kernel); |
| @@ -108,7 +106,7 @@ private: | |||
| 108 | void DrawPrelude(); | 106 | void DrawPrelude(); |
| 109 | 107 | ||
| 110 | /// Configures the current textures to use for the draw command. | 108 | /// Configures the current textures to use for the draw command. |
| 111 | void SetupDrawTextures(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage, const Shader& shader, | 109 | void SetupDrawTextures(std::size_t stage_index, const Shader& shader, |
| 112 | BaseBindings base_bindings); | 110 | BaseBindings base_bindings); |
| 113 | 111 | ||
| 114 | /// Configures the textures used in a compute shader. | 112 | /// Configures the textures used in a compute shader. |
| @@ -119,8 +117,7 @@ private: | |||
| 119 | const GLShader::SamplerEntry& entry); | 117 | const GLShader::SamplerEntry& entry); |
| 120 | 118 | ||
| 121 | /// Configures images in a graphics shader. | 119 | /// Configures images in a graphics shader. |
| 122 | void SetupDrawImages(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage, const Shader& shader, | 120 | void SetupDrawImages(std::size_t stage_index, const Shader& shader, BaseBindings base_bindings); |
| 123 | BaseBindings base_bindings); | ||
| 124 | 121 | ||
| 125 | /// Configures images in a compute shader. | 122 | /// Configures images in a compute shader. |
| 126 | void SetupComputeImages(const Shader& shader); | 123 | void SetupComputeImages(const Shader& shader); |
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp index e7c92e45d..f474fb550 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include "core/frontend/emu_window.h" | 16 | #include "core/frontend/emu_window.h" |
| 17 | #include "video_core/engines/kepler_compute.h" | 17 | #include "video_core/engines/kepler_compute.h" |
| 18 | #include "video_core/engines/maxwell_3d.h" | 18 | #include "video_core/engines/maxwell_3d.h" |
| 19 | #include "video_core/engines/shader_type.h" | ||
| 19 | #include "video_core/memory_manager.h" | 20 | #include "video_core/memory_manager.h" |
| 20 | #include "video_core/renderer_opengl/gl_rasterizer.h" | 21 | #include "video_core/renderer_opengl/gl_rasterizer.h" |
| 21 | #include "video_core/renderer_opengl/gl_shader_cache.h" | 22 | #include "video_core/renderer_opengl/gl_shader_cache.h" |
| @@ -84,28 +85,26 @@ std::size_t CalculateProgramSize(const GLShader::ProgramCode& program) { | |||
| 84 | /// Gets the shader program code from memory for the specified address | 85 | /// Gets the shader program code from memory for the specified address |
| 85 | ProgramCode GetShaderCode(Tegra::MemoryManager& memory_manager, const GPUVAddr gpu_addr, | 86 | ProgramCode GetShaderCode(Tegra::MemoryManager& memory_manager, const GPUVAddr gpu_addr, |
| 86 | const u8* host_ptr) { | 87 | const u8* host_ptr) { |
| 87 | ProgramCode program_code(VideoCommon::Shader::MAX_PROGRAM_LENGTH); | 88 | ProgramCode code(VideoCommon::Shader::MAX_PROGRAM_LENGTH); |
| 88 | ASSERT_OR_EXECUTE(host_ptr != nullptr, { | 89 | ASSERT_OR_EXECUTE(host_ptr != nullptr, { |
| 89 | std::fill(program_code.begin(), program_code.end(), 0); | 90 | std::fill(code.begin(), code.end(), 0); |
| 90 | return program_code; | 91 | return code; |
| 91 | }); | 92 | }); |
| 92 | memory_manager.ReadBlockUnsafe(gpu_addr, program_code.data(), | 93 | memory_manager.ReadBlockUnsafe(gpu_addr, code.data(), code.size() * sizeof(u64)); |
| 93 | program_code.size() * sizeof(u64)); | 94 | code.resize(CalculateProgramSize(code)); |
| 94 | program_code.resize(CalculateProgramSize(program_code)); | 95 | return code; |
| 95 | return program_code; | ||
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | /// Gets the shader type from a Maxwell program type | 98 | /// Gets the shader type from a Maxwell program type |
| 99 | constexpr GLenum GetShaderType(ProgramType program_type) { | 99 | constexpr GLenum GetGLShaderType(ShaderType shader_type) { |
| 100 | switch (program_type) { | 100 | switch (shader_type) { |
| 101 | case ProgramType::VertexA: | 101 | case ShaderType::Vertex: |
| 102 | case ProgramType::VertexB: | ||
| 103 | return GL_VERTEX_SHADER; | 102 | return GL_VERTEX_SHADER; |
| 104 | case ProgramType::Geometry: | 103 | case ShaderType::Geometry: |
| 105 | return GL_GEOMETRY_SHADER; | 104 | return GL_GEOMETRY_SHADER; |
| 106 | case ProgramType::Fragment: | 105 | case ShaderType::Fragment: |
| 107 | return GL_FRAGMENT_SHADER; | 106 | return GL_FRAGMENT_SHADER; |
| 108 | case ProgramType::Compute: | 107 | case ShaderType::Compute: |
| 109 | return GL_COMPUTE_SHADER; | 108 | return GL_COMPUTE_SHADER; |
| 110 | default: | 109 | default: |
| 111 | return GL_NONE; | 110 | return GL_NONE; |
| @@ -135,30 +134,11 @@ constexpr std::tuple<const char*, const char*, u32> GetPrimitiveDescription(GLen | |||
| 135 | } | 134 | } |
| 136 | } | 135 | } |
| 137 | 136 | ||
| 138 | ProgramType GetProgramType(Maxwell::ShaderProgram program) { | ||
| 139 | switch (program) { | ||
| 140 | case Maxwell::ShaderProgram::VertexA: | ||
| 141 | return ProgramType::VertexA; | ||
| 142 | case Maxwell::ShaderProgram::VertexB: | ||
| 143 | return ProgramType::VertexB; | ||
| 144 | case Maxwell::ShaderProgram::TesselationControl: | ||
| 145 | return ProgramType::TessellationControl; | ||
| 146 | case Maxwell::ShaderProgram::TesselationEval: | ||
| 147 | return ProgramType::TessellationEval; | ||
| 148 | case Maxwell::ShaderProgram::Geometry: | ||
| 149 | return ProgramType::Geometry; | ||
| 150 | case Maxwell::ShaderProgram::Fragment: | ||
| 151 | return ProgramType::Fragment; | ||
| 152 | } | ||
| 153 | UNREACHABLE(); | ||
| 154 | return {}; | ||
| 155 | } | ||
| 156 | |||
| 157 | /// Hashes one (or two) program streams | 137 | /// Hashes one (or two) program streams |
| 158 | u64 GetUniqueIdentifier(ProgramType program_type, const ProgramCode& code, | 138 | u64 GetUniqueIdentifier(ShaderType shader_type, bool is_a, const ProgramCode& code, |
| 159 | const ProgramCode& code_b) { | 139 | const ProgramCode& code_b) { |
| 160 | u64 unique_identifier = boost::hash_value(code); | 140 | u64 unique_identifier = boost::hash_value(code); |
| 161 | if (program_type == ProgramType::VertexA) { | 141 | if (is_a) { |
| 162 | // VertexA programs include two programs | 142 | // VertexA programs include two programs |
| 163 | boost::hash_combine(unique_identifier, boost::hash_value(code_b)); | 143 | boost::hash_combine(unique_identifier, boost::hash_value(code_b)); |
| 164 | } | 144 | } |
| @@ -166,79 +146,74 @@ u64 GetUniqueIdentifier(ProgramType program_type, const ProgramCode& code, | |||
| 166 | } | 146 | } |
| 167 | 147 | ||
| 168 | /// Creates an unspecialized program from code streams | 148 | /// Creates an unspecialized program from code streams |
| 169 | std::string GenerateGLSL(const Device& device, ProgramType program_type, const ShaderIR& ir, | 149 | std::string GenerateGLSL(const Device& device, ShaderType shader_type, const ShaderIR& ir, |
| 170 | const std::optional<ShaderIR>& ir_b) { | 150 | const std::optional<ShaderIR>& ir_b) { |
| 171 | switch (program_type) { | 151 | switch (shader_type) { |
| 172 | case ProgramType::VertexA: | 152 | case ShaderType::Vertex: |
| 173 | case ProgramType::VertexB: | ||
| 174 | return GLShader::GenerateVertexShader(device, ir, ir_b ? &*ir_b : nullptr); | 153 | return GLShader::GenerateVertexShader(device, ir, ir_b ? &*ir_b : nullptr); |
| 175 | case ProgramType::Geometry: | 154 | case ShaderType::Geometry: |
| 176 | return GLShader::GenerateGeometryShader(device, ir); | 155 | return GLShader::GenerateGeometryShader(device, ir); |
| 177 | case ProgramType::Fragment: | 156 | case ShaderType::Fragment: |
| 178 | return GLShader::GenerateFragmentShader(device, ir); | 157 | return GLShader::GenerateFragmentShader(device, ir); |
| 179 | case ProgramType::Compute: | 158 | case ShaderType::Compute: |
| 180 | return GLShader::GenerateComputeShader(device, ir); | 159 | return GLShader::GenerateComputeShader(device, ir); |
| 181 | default: | 160 | default: |
| 182 | UNIMPLEMENTED_MSG("Unimplemented program_type={}", static_cast<u32>(program_type)); | 161 | UNIMPLEMENTED_MSG("Unimplemented shader_type={}", static_cast<u32>(shader_type)); |
| 183 | return {}; | 162 | return {}; |
| 184 | } | 163 | } |
| 185 | } | 164 | } |
| 186 | 165 | ||
| 187 | constexpr const char* GetProgramTypeName(ProgramType program_type) { | 166 | constexpr const char* GetShaderTypeName(ShaderType shader_type) { |
| 188 | switch (program_type) { | 167 | switch (shader_type) { |
| 189 | case ProgramType::VertexA: | 168 | case ShaderType::Vertex: |
| 190 | case ProgramType::VertexB: | ||
| 191 | return "VS"; | 169 | return "VS"; |
| 192 | case ProgramType::TessellationControl: | 170 | case ShaderType::TesselationControl: |
| 193 | return "TCS"; | 171 | return "HS"; |
| 194 | case ProgramType::TessellationEval: | 172 | case ShaderType::TesselationEval: |
| 195 | return "TES"; | 173 | return "DS"; |
| 196 | case ProgramType::Geometry: | 174 | case ShaderType::Geometry: |
| 197 | return "GS"; | 175 | return "GS"; |
| 198 | case ProgramType::Fragment: | 176 | case ShaderType::Fragment: |
| 199 | return "FS"; | 177 | return "FS"; |
| 200 | case ProgramType::Compute: | 178 | case ShaderType::Compute: |
| 201 | return "CS"; | 179 | return "CS"; |
| 202 | } | 180 | } |
| 203 | return "UNK"; | 181 | return "UNK"; |
| 204 | } | 182 | } |
| 205 | 183 | ||
| 206 | Tegra::Engines::ShaderType GetEnginesShaderType(ProgramType program_type) { | 184 | constexpr ShaderType GetShaderType(Maxwell::ShaderProgram program_type) { |
| 207 | switch (program_type) { | 185 | switch (program_type) { |
| 208 | case ProgramType::VertexA: | 186 | case Maxwell::ShaderProgram::VertexA: |
| 209 | case ProgramType::VertexB: | 187 | case Maxwell::ShaderProgram::VertexB: |
| 210 | return Tegra::Engines::ShaderType::Vertex; | 188 | return ShaderType::Vertex; |
| 211 | case ProgramType::TessellationControl: | 189 | case Maxwell::ShaderProgram::TesselationControl: |
| 212 | return Tegra::Engines::ShaderType::TesselationControl; | 190 | return ShaderType::TesselationControl; |
| 213 | case ProgramType::TessellationEval: | 191 | case Maxwell::ShaderProgram::TesselationEval: |
| 214 | return Tegra::Engines::ShaderType::TesselationEval; | 192 | return ShaderType::TesselationEval; |
| 215 | case ProgramType::Geometry: | 193 | case Maxwell::ShaderProgram::Geometry: |
| 216 | return Tegra::Engines::ShaderType::Geometry; | 194 | return ShaderType::Geometry; |
| 217 | case ProgramType::Fragment: | 195 | case Maxwell::ShaderProgram::Fragment: |
| 218 | return Tegra::Engines::ShaderType::Fragment; | 196 | return ShaderType::Fragment; |
| 219 | case ProgramType::Compute: | 197 | } |
| 220 | return Tegra::Engines::ShaderType::Compute; | ||
| 221 | } | ||
| 222 | UNREACHABLE(); | ||
| 223 | return {}; | 198 | return {}; |
| 224 | } | 199 | } |
| 225 | 200 | ||
| 226 | std::string GetShaderId(u64 unique_identifier, ProgramType program_type) { | 201 | std::string GetShaderId(u64 unique_identifier, ShaderType shader_type) { |
| 227 | return fmt::format("{}{:016X}", GetProgramTypeName(program_type), unique_identifier); | 202 | return fmt::format("{}{:016X}", GetShaderTypeName(shader_type), unique_identifier); |
| 228 | } | 203 | } |
| 229 | 204 | ||
| 230 | Tegra::Engines::ConstBufferEngineInterface& GetConstBufferEngineInterface( | 205 | Tegra::Engines::ConstBufferEngineInterface& GetConstBufferEngineInterface(Core::System& system, |
| 231 | Core::System& system, ProgramType program_type) { | 206 | ShaderType shader_type) { |
| 232 | if (program_type == ProgramType::Compute) { | 207 | if (shader_type == ShaderType::Compute) { |
| 233 | return system.GPU().KeplerCompute(); | 208 | return system.GPU().KeplerCompute(); |
| 234 | } else { | 209 | } else { |
| 235 | return system.GPU().Maxwell3D(); | 210 | return system.GPU().Maxwell3D(); |
| 236 | } | 211 | } |
| 237 | } | 212 | } |
| 238 | 213 | ||
| 239 | std::unique_ptr<ConstBufferLocker> MakeLocker(Core::System& system, ProgramType program_type) { | 214 | std::unique_ptr<ConstBufferLocker> MakeLocker(Core::System& system, ShaderType shader_type) { |
| 240 | return std::make_unique<ConstBufferLocker>(GetEnginesShaderType(program_type), | 215 | return std::make_unique<ConstBufferLocker>(shader_type, |
| 241 | GetConstBufferEngineInterface(system, program_type)); | 216 | GetConstBufferEngineInterface(system, shader_type)); |
| 242 | } | 217 | } |
| 243 | 218 | ||
| 244 | void FillLocker(ConstBufferLocker& locker, const ShaderDiskCacheUsage& usage) { | 219 | void FillLocker(ConstBufferLocker& locker, const ShaderDiskCacheUsage& usage) { |
| @@ -255,18 +230,18 @@ void FillLocker(ConstBufferLocker& locker, const ShaderDiskCacheUsage& usage) { | |||
| 255 | } | 230 | } |
| 256 | } | 231 | } |
| 257 | 232 | ||
| 258 | CachedProgram BuildShader(const Device& device, u64 unique_identifier, ProgramType program_type, | 233 | CachedProgram BuildShader(const Device& device, u64 unique_identifier, ShaderType shader_type, |
| 259 | const ProgramCode& program_code, const ProgramCode& program_code_b, | 234 | const ProgramCode& code, const ProgramCode& code_b, |
| 260 | ConstBufferLocker& locker, const ProgramVariant& variant, | 235 | ConstBufferLocker& locker, const ProgramVariant& variant, |
| 261 | bool hint_retrievable = false) { | 236 | bool hint_retrievable = false) { |
| 262 | LOG_INFO(Render_OpenGL, "called. {}", GetShaderId(unique_identifier, program_type)); | 237 | LOG_INFO(Render_OpenGL, "called. {}", GetShaderId(unique_identifier, shader_type)); |
| 263 | 238 | ||
| 264 | const bool is_compute = program_type == ProgramType::Compute; | 239 | const bool is_compute = shader_type == ShaderType::Compute; |
| 265 | const u32 main_offset = is_compute ? KERNEL_MAIN_OFFSET : STAGE_MAIN_OFFSET; | 240 | const u32 main_offset = is_compute ? KERNEL_MAIN_OFFSET : STAGE_MAIN_OFFSET; |
| 266 | const ShaderIR ir(program_code, main_offset, COMPILER_SETTINGS, locker); | 241 | const ShaderIR ir(code, main_offset, COMPILER_SETTINGS, locker); |
| 267 | std::optional<ShaderIR> ir_b; | 242 | std::optional<ShaderIR> ir_b; |
| 268 | if (!program_code_b.empty()) { | 243 | if (!code_b.empty()) { |
| 269 | ir_b.emplace(program_code_b, main_offset, COMPILER_SETTINGS, locker); | 244 | ir_b.emplace(code_b, main_offset, COMPILER_SETTINGS, locker); |
| 270 | } | 245 | } |
| 271 | const auto entries = GLShader::GetEntries(ir); | 246 | const auto entries = GLShader::GetEntries(ir); |
| 272 | 247 | ||
| @@ -274,7 +249,7 @@ CachedProgram BuildShader(const Device& device, u64 unique_identifier, ProgramTy | |||
| 274 | #version 430 core | 249 | #version 430 core |
| 275 | #extension GL_ARB_separate_shader_objects : enable | 250 | #extension GL_ARB_separate_shader_objects : enable |
| 276 | )", | 251 | )", |
| 277 | GetShaderId(unique_identifier, program_type)); | 252 | GetShaderId(unique_identifier, shader_type)); |
| 278 | if (device.HasShaderBallot()) { | 253 | if (device.HasShaderBallot()) { |
| 279 | source += "#extension GL_ARB_shader_ballot : require\n"; | 254 | source += "#extension GL_ARB_shader_ballot : require\n"; |
| 280 | } | 255 | } |
| @@ -313,14 +288,14 @@ CachedProgram BuildShader(const Device& device, u64 unique_identifier, ProgramTy | |||
| 313 | fmt::format("#define IMAGE_BINDING_{} {}\n", image.GetIndex(), base_bindings.image++); | 288 | fmt::format("#define IMAGE_BINDING_{} {}\n", image.GetIndex(), base_bindings.image++); |
| 314 | } | 289 | } |
| 315 | 290 | ||
| 316 | if (program_type == ProgramType::Geometry) { | 291 | if (shader_type == ShaderType::Geometry) { |
| 317 | const auto [glsl_topology, debug_name, max_vertices] = | 292 | const auto [glsl_topology, debug_name, max_vertices] = |
| 318 | GetPrimitiveDescription(variant.primitive_mode); | 293 | GetPrimitiveDescription(variant.primitive_mode); |
| 319 | 294 | ||
| 320 | source += fmt::format("layout ({}) in;\n\n", glsl_topology); | 295 | source += fmt::format("layout ({}) in;\n\n", glsl_topology); |
| 321 | source += fmt::format("#define MAX_VERTEX_INPUT {}\n", max_vertices); | 296 | source += fmt::format("#define MAX_VERTEX_INPUT {}\n", max_vertices); |
| 322 | } | 297 | } |
| 323 | if (program_type == ProgramType::Compute) { | 298 | if (shader_type == ShaderType::Compute) { |
| 324 | source += | 299 | source += |
| 325 | fmt::format("layout (local_size_x = {}, local_size_y = {}, local_size_z = {}) in;\n", | 300 | fmt::format("layout (local_size_x = {}, local_size_y = {}, local_size_z = {}) in;\n", |
| 326 | variant.block_x, variant.block_y, variant.block_z); | 301 | variant.block_x, variant.block_y, variant.block_z); |
| @@ -337,10 +312,10 @@ CachedProgram BuildShader(const Device& device, u64 unique_identifier, ProgramTy | |||
| 337 | } | 312 | } |
| 338 | 313 | ||
| 339 | source += '\n'; | 314 | source += '\n'; |
| 340 | source += GenerateGLSL(device, program_type, ir, ir_b); | 315 | source += GenerateGLSL(device, shader_type, ir, ir_b); |
| 341 | 316 | ||
| 342 | OGLShader shader; | 317 | OGLShader shader; |
| 343 | shader.Create(source.c_str(), GetShaderType(program_type)); | 318 | shader.Create(source.c_str(), GetGLShaderType(shader_type)); |
| 344 | 319 | ||
| 345 | auto program = std::make_shared<OGLProgram>(); | 320 | auto program = std::make_shared<OGLProgram>(); |
| 346 | program->Create(true, hint_retrievable, shader.handle); | 321 | program->Create(true, hint_retrievable, shader.handle); |
| @@ -363,18 +338,16 @@ std::unordered_set<GLenum> GetSupportedFormats() { | |||
| 363 | 338 | ||
| 364 | } // Anonymous namespace | 339 | } // Anonymous namespace |
| 365 | 340 | ||
| 366 | CachedShader::CachedShader(const ShaderParameters& params, ProgramType program_type, | 341 | CachedShader::CachedShader(const ShaderParameters& params, ShaderType shader_type, |
| 367 | GLShader::ShaderEntries entries, ProgramCode program_code, | 342 | GLShader::ShaderEntries entries, ProgramCode code, ProgramCode code_b) |
| 368 | ProgramCode program_code_b) | 343 | : RasterizerCacheObject{params.host_ptr}, system{params.system}, disk_cache{params.disk_cache}, |
| 369 | : RasterizerCacheObject{params.host_ptr}, system{params.system}, | 344 | device{params.device}, cpu_addr{params.cpu_addr}, unique_identifier{params.unique_identifier}, |
| 370 | disk_cache{params.disk_cache}, device{params.device}, cpu_addr{params.cpu_addr}, | 345 | shader_type{shader_type}, entries{entries}, code{std::move(code)}, code_b{std::move(code_b)} { |
| 371 | unique_identifier{params.unique_identifier}, program_type{program_type}, entries{entries}, | ||
| 372 | program_code{std::move(program_code)}, program_code_b{std::move(program_code_b)} { | ||
| 373 | if (!params.precompiled_variants) { | 346 | if (!params.precompiled_variants) { |
| 374 | return; | 347 | return; |
| 375 | } | 348 | } |
| 376 | for (const auto& pair : *params.precompiled_variants) { | 349 | for (const auto& pair : *params.precompiled_variants) { |
| 377 | auto locker = MakeLocker(system, program_type); | 350 | auto locker = MakeLocker(system, shader_type); |
| 378 | const auto& usage = pair->first; | 351 | const auto& usage = pair->first; |
| 379 | FillLocker(*locker, usage); | 352 | FillLocker(*locker, usage); |
| 380 | 353 | ||
| @@ -395,38 +368,37 @@ CachedShader::CachedShader(const ShaderParameters& params, ProgramType program_t | |||
| 395 | } | 368 | } |
| 396 | 369 | ||
| 397 | Shader CachedShader::CreateStageFromMemory(const ShaderParameters& params, | 370 | Shader CachedShader::CreateStageFromMemory(const ShaderParameters& params, |
| 398 | Maxwell::ShaderProgram program_type, | 371 | Maxwell::ShaderProgram program_type, ProgramCode code, |
| 399 | ProgramCode program_code, ProgramCode program_code_b) { | 372 | ProgramCode code_b) { |
| 400 | params.disk_cache.SaveRaw(ShaderDiskCacheRaw( | 373 | const auto shader_type = GetShaderType(program_type); |
| 401 | params.unique_identifier, GetProgramType(program_type), program_code, program_code_b)); | 374 | params.disk_cache.SaveRaw( |
| 402 | 375 | ShaderDiskCacheRaw(params.unique_identifier, shader_type, code, code_b)); | |
| 403 | ConstBufferLocker locker(GetEnginesShaderType(GetProgramType(program_type)), | 376 | |
| 404 | params.system.GPU().Maxwell3D()); | 377 | ConstBufferLocker locker(shader_type, params.system.GPU().Maxwell3D()); |
| 405 | const ShaderIR ir(program_code, STAGE_MAIN_OFFSET, COMPILER_SETTINGS, locker); | 378 | const ShaderIR ir(code, STAGE_MAIN_OFFSET, COMPILER_SETTINGS, locker); |
| 406 | // TODO(Rodrigo): Handle VertexA shaders | 379 | // TODO(Rodrigo): Handle VertexA shaders |
| 407 | // std::optional<ShaderIR> ir_b; | 380 | // std::optional<ShaderIR> ir_b; |
| 408 | // if (!program_code_b.empty()) { | 381 | // if (!code_b.empty()) { |
| 409 | // ir_b.emplace(program_code_b, STAGE_MAIN_OFFSET); | 382 | // ir_b.emplace(code_b, STAGE_MAIN_OFFSET); |
| 410 | // } | 383 | // } |
| 411 | return std::shared_ptr<CachedShader>( | 384 | return std::shared_ptr<CachedShader>(new CachedShader( |
| 412 | new CachedShader(params, GetProgramType(program_type), GLShader::GetEntries(ir), | 385 | params, shader_type, GLShader::GetEntries(ir), std::move(code), std::move(code_b))); |
| 413 | std::move(program_code), std::move(program_code_b))); | ||
| 414 | } | 386 | } |
| 415 | 387 | ||
| 416 | Shader CachedShader::CreateKernelFromMemory(const ShaderParameters& params, ProgramCode code) { | 388 | Shader CachedShader::CreateKernelFromMemory(const ShaderParameters& params, ProgramCode code) { |
| 417 | params.disk_cache.SaveRaw( | 389 | params.disk_cache.SaveRaw( |
| 418 | ShaderDiskCacheRaw(params.unique_identifier, ProgramType::Compute, code)); | 390 | ShaderDiskCacheRaw(params.unique_identifier, ShaderType::Compute, code)); |
| 419 | 391 | ||
| 420 | ConstBufferLocker locker(Tegra::Engines::ShaderType::Compute, | 392 | ConstBufferLocker locker(Tegra::Engines::ShaderType::Compute, |
| 421 | params.system.GPU().KeplerCompute()); | 393 | params.system.GPU().KeplerCompute()); |
| 422 | const ShaderIR ir(code, KERNEL_MAIN_OFFSET, COMPILER_SETTINGS, locker); | 394 | const ShaderIR ir(code, KERNEL_MAIN_OFFSET, COMPILER_SETTINGS, locker); |
| 423 | return std::shared_ptr<CachedShader>(new CachedShader( | 395 | return std::shared_ptr<CachedShader>(new CachedShader( |
| 424 | params, ProgramType::Compute, GLShader::GetEntries(ir), std::move(code), {})); | 396 | params, ShaderType::Compute, GLShader::GetEntries(ir), std::move(code), {})); |
| 425 | } | 397 | } |
| 426 | 398 | ||
| 427 | Shader CachedShader::CreateFromCache(const ShaderParameters& params, | 399 | Shader CachedShader::CreateFromCache(const ShaderParameters& params, |
| 428 | const UnspecializedShader& unspecialized) { | 400 | const UnspecializedShader& unspecialized) { |
| 429 | return std::shared_ptr<CachedShader>(new CachedShader(params, unspecialized.program_type, | 401 | return std::shared_ptr<CachedShader>(new CachedShader(params, unspecialized.type, |
| 430 | unspecialized.entries, unspecialized.code, | 402 | unspecialized.entries, unspecialized.code, |
| 431 | unspecialized.code_b)); | 403 | unspecialized.code_b)); |
| 432 | } | 404 | } |
| @@ -437,7 +409,7 @@ std::tuple<GLuint, BaseBindings> CachedShader::GetHandle(const ProgramVariant& v | |||
| 437 | const auto [entry, is_cache_miss] = curr_locker_variant->programs.try_emplace(variant); | 409 | const auto [entry, is_cache_miss] = curr_locker_variant->programs.try_emplace(variant); |
| 438 | auto& program = entry->second; | 410 | auto& program = entry->second; |
| 439 | if (is_cache_miss) { | 411 | if (is_cache_miss) { |
| 440 | program = BuildShader(device, unique_identifier, program_type, program_code, program_code_b, | 412 | program = BuildShader(device, unique_identifier, shader_type, code, code_b, |
| 441 | *curr_locker_variant->locker, variant); | 413 | *curr_locker_variant->locker, variant); |
| 442 | disk_cache.SaveUsage(GetUsage(variant, *curr_locker_variant->locker)); | 414 | disk_cache.SaveUsage(GetUsage(variant, *curr_locker_variant->locker)); |
| 443 | 415 | ||
| @@ -469,7 +441,7 @@ bool CachedShader::EnsureValidLockerVariant() { | |||
| 469 | if (!curr_locker_variant) { | 441 | if (!curr_locker_variant) { |
| 470 | auto& new_variant = locker_variants.emplace_back(); | 442 | auto& new_variant = locker_variants.emplace_back(); |
| 471 | new_variant = std::make_unique<LockerVariant>(); | 443 | new_variant = std::make_unique<LockerVariant>(); |
| 472 | new_variant->locker = MakeLocker(system, program_type); | 444 | new_variant->locker = MakeLocker(system, shader_type); |
| 473 | curr_locker_variant = new_variant.get(); | 445 | curr_locker_variant = new_variant.get(); |
| 474 | } | 446 | } |
| 475 | return previous_variant == curr_locker_variant; | 447 | return previous_variant == curr_locker_variant; |
| @@ -537,10 +509,10 @@ void ShaderCacheOpenGL::LoadDiskCache(const std::atomic_bool& stop_loading, | |||
| 537 | } | 509 | } |
| 538 | } | 510 | } |
| 539 | if (!shader) { | 511 | if (!shader) { |
| 540 | auto locker{MakeLocker(system, unspecialized.program_type)}; | 512 | auto locker{MakeLocker(system, unspecialized.type)}; |
| 541 | FillLocker(*locker, usage); | 513 | FillLocker(*locker, usage); |
| 542 | 514 | ||
| 543 | shader = BuildShader(device, usage.unique_identifier, unspecialized.program_type, | 515 | shader = BuildShader(device, usage.unique_identifier, unspecialized.type, |
| 544 | unspecialized.code, unspecialized.code_b, *locker, | 516 | unspecialized.code, unspecialized.code_b, *locker, |
| 545 | usage.variant, true); | 517 | usage.variant, true); |
| 546 | } | 518 | } |
| @@ -645,7 +617,7 @@ bool ShaderCacheOpenGL::GenerateUnspecializedShaders( | |||
| 645 | const auto& raw{raws[i]}; | 617 | const auto& raw{raws[i]}; |
| 646 | const u64 unique_identifier{raw.GetUniqueIdentifier()}; | 618 | const u64 unique_identifier{raw.GetUniqueIdentifier()}; |
| 647 | const u64 calculated_hash{ | 619 | const u64 calculated_hash{ |
| 648 | GetUniqueIdentifier(raw.GetProgramType(), raw.GetProgramCode(), raw.GetProgramCodeB())}; | 620 | GetUniqueIdentifier(raw.GetType(), raw.HasProgramA(), raw.GetCode(), raw.GetCodeB())}; |
| 649 | if (unique_identifier != calculated_hash) { | 621 | if (unique_identifier != calculated_hash) { |
| 650 | LOG_ERROR(Render_OpenGL, | 622 | LOG_ERROR(Render_OpenGL, |
| 651 | "Invalid hash in entry={:016x} (obtained hash={:016x}) - " | 623 | "Invalid hash in entry={:016x} (obtained hash={:016x}) - " |
| @@ -656,9 +628,9 @@ bool ShaderCacheOpenGL::GenerateUnspecializedShaders( | |||
| 656 | } | 628 | } |
| 657 | 629 | ||
| 658 | const u32 main_offset = | 630 | const u32 main_offset = |
| 659 | raw.GetProgramType() == ProgramType::Compute ? KERNEL_MAIN_OFFSET : STAGE_MAIN_OFFSET; | 631 | raw.GetType() == ShaderType::Compute ? KERNEL_MAIN_OFFSET : STAGE_MAIN_OFFSET; |
| 660 | ConstBufferLocker locker(GetEnginesShaderType(raw.GetProgramType())); | 632 | ConstBufferLocker locker(raw.GetType()); |
| 661 | const ShaderIR ir(raw.GetProgramCode(), main_offset, COMPILER_SETTINGS, locker); | 633 | const ShaderIR ir(raw.GetCode(), main_offset, COMPILER_SETTINGS, locker); |
| 662 | // TODO(Rodrigo): Handle VertexA shaders | 634 | // TODO(Rodrigo): Handle VertexA shaders |
| 663 | // std::optional<ShaderIR> ir_b; | 635 | // std::optional<ShaderIR> ir_b; |
| 664 | // if (raw.HasProgramA()) { | 636 | // if (raw.HasProgramA()) { |
| @@ -667,9 +639,9 @@ bool ShaderCacheOpenGL::GenerateUnspecializedShaders( | |||
| 667 | 639 | ||
| 668 | UnspecializedShader unspecialized; | 640 | UnspecializedShader unspecialized; |
| 669 | unspecialized.entries = GLShader::GetEntries(ir); | 641 | unspecialized.entries = GLShader::GetEntries(ir); |
| 670 | unspecialized.program_type = raw.GetProgramType(); | 642 | unspecialized.type = raw.GetType(); |
| 671 | unspecialized.code = raw.GetProgramCode(); | 643 | unspecialized.code = raw.GetCode(); |
| 672 | unspecialized.code_b = raw.GetProgramCodeB(); | 644 | unspecialized.code_b = raw.GetCodeB(); |
| 673 | unspecialized_shaders.emplace(raw.GetUniqueIdentifier(), unspecialized); | 645 | unspecialized_shaders.emplace(raw.GetUniqueIdentifier(), unspecialized); |
| 674 | 646 | ||
| 675 | if (callback) { | 647 | if (callback) { |
| @@ -702,7 +674,8 @@ Shader ShaderCacheOpenGL::GetStageProgram(Maxwell::ShaderProgram program) { | |||
| 702 | code_b = GetShaderCode(memory_manager, address_b, memory_manager.GetPointer(address_b)); | 674 | code_b = GetShaderCode(memory_manager, address_b, memory_manager.GetPointer(address_b)); |
| 703 | } | 675 | } |
| 704 | 676 | ||
| 705 | const auto unique_identifier = GetUniqueIdentifier(GetProgramType(program), code, code_b); | 677 | const auto unique_identifier = GetUniqueIdentifier( |
| 678 | GetShaderType(program), program == Maxwell::ShaderProgram::VertexA, code, code_b); | ||
| 706 | const auto precompiled_variants = GetPrecompiledVariants(unique_identifier); | 679 | const auto precompiled_variants = GetPrecompiledVariants(unique_identifier); |
| 707 | const auto cpu_addr{*memory_manager.GpuToCpuAddress(address)}; | 680 | const auto cpu_addr{*memory_manager.GpuToCpuAddress(address)}; |
| 708 | const ShaderParameters params{system, disk_cache, precompiled_variants, device, | 681 | const ShaderParameters params{system, disk_cache, precompiled_variants, device, |
| @@ -730,7 +703,7 @@ Shader ShaderCacheOpenGL::GetComputeKernel(GPUVAddr code_addr) { | |||
| 730 | 703 | ||
| 731 | // No kernel found - create a new one | 704 | // No kernel found - create a new one |
| 732 | auto code{GetShaderCode(memory_manager, code_addr, host_ptr)}; | 705 | auto code{GetShaderCode(memory_manager, code_addr, host_ptr)}; |
| 733 | const auto unique_identifier{GetUniqueIdentifier(ProgramType::Compute, code, {})}; | 706 | const auto unique_identifier{GetUniqueIdentifier(ShaderType::Compute, false, code, {})}; |
| 734 | const auto precompiled_variants = GetPrecompiledVariants(unique_identifier); | 707 | const auto precompiled_variants = GetPrecompiledVariants(unique_identifier); |
| 735 | const auto cpu_addr{*memory_manager.GpuToCpuAddress(code_addr)}; | 708 | const auto cpu_addr{*memory_manager.GpuToCpuAddress(code_addr)}; |
| 736 | const ShaderParameters params{system, disk_cache, precompiled_variants, device, | 709 | const ShaderParameters params{system, disk_cache, precompiled_variants, device, |
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.h b/src/video_core/renderer_opengl/gl_shader_cache.h index 795b05a19..d23c8d6d4 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.h +++ b/src/video_core/renderer_opengl/gl_shader_cache.h | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <glad/glad.h> | 17 | #include <glad/glad.h> |
| 18 | 18 | ||
| 19 | #include "common/common_types.h" | 19 | #include "common/common_types.h" |
| 20 | #include "video_core/engines/shader_type.h" | ||
| 20 | #include "video_core/rasterizer_cache.h" | 21 | #include "video_core/rasterizer_cache.h" |
| 21 | #include "video_core/renderer_opengl/gl_resource_manager.h" | 22 | #include "video_core/renderer_opengl/gl_resource_manager.h" |
| 22 | #include "video_core/renderer_opengl/gl_shader_decompiler.h" | 23 | #include "video_core/renderer_opengl/gl_shader_decompiler.h" |
| @@ -47,7 +48,7 @@ using PrecompiledVariants = std::vector<PrecompiledPrograms::iterator>; | |||
| 47 | 48 | ||
| 48 | struct UnspecializedShader { | 49 | struct UnspecializedShader { |
| 49 | GLShader::ShaderEntries entries; | 50 | GLShader::ShaderEntries entries; |
| 50 | ProgramType program_type; | 51 | Tegra::Engines::ShaderType type; |
| 51 | ProgramCode code; | 52 | ProgramCode code; |
| 52 | ProgramCode code_b; | 53 | ProgramCode code_b; |
| 53 | }; | 54 | }; |
| @@ -77,7 +78,7 @@ public: | |||
| 77 | } | 78 | } |
| 78 | 79 | ||
| 79 | std::size_t GetSizeInBytes() const override { | 80 | std::size_t GetSizeInBytes() const override { |
| 80 | return program_code.size() * sizeof(u64); | 81 | return code.size() * sizeof(u64); |
| 81 | } | 82 | } |
| 82 | 83 | ||
| 83 | /// Gets the shader entries for the shader | 84 | /// Gets the shader entries for the shader |
| @@ -94,7 +95,7 @@ private: | |||
| 94 | std::unordered_map<ProgramVariant, CachedProgram> programs; | 95 | std::unordered_map<ProgramVariant, CachedProgram> programs; |
| 95 | }; | 96 | }; |
| 96 | 97 | ||
| 97 | explicit CachedShader(const ShaderParameters& params, ProgramType program_type, | 98 | explicit CachedShader(const ShaderParameters& params, Tegra::Engines::ShaderType shader_type, |
| 98 | GLShader::ShaderEntries entries, ProgramCode program_code, | 99 | GLShader::ShaderEntries entries, ProgramCode program_code, |
| 99 | ProgramCode program_code_b); | 100 | ProgramCode program_code_b); |
| 100 | 101 | ||
| @@ -110,12 +111,12 @@ private: | |||
| 110 | VAddr cpu_addr{}; | 111 | VAddr cpu_addr{}; |
| 111 | 112 | ||
| 112 | u64 unique_identifier{}; | 113 | u64 unique_identifier{}; |
| 113 | ProgramType program_type{}; | 114 | Tegra::Engines::ShaderType shader_type{}; |
| 114 | 115 | ||
| 115 | GLShader::ShaderEntries entries; | 116 | GLShader::ShaderEntries entries; |
| 116 | 117 | ||
| 117 | ProgramCode program_code; | 118 | ProgramCode code; |
| 118 | ProgramCode program_code_b; | 119 | ProgramCode code_b; |
| 119 | 120 | ||
| 120 | LockerVariant* curr_locker_variant = nullptr; | 121 | LockerVariant* curr_locker_variant = nullptr; |
| 121 | std::vector<std::unique_ptr<LockerVariant>> locker_variants; | 122 | std::vector<std::unique_ptr<LockerVariant>> locker_variants; |
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index fe016c05c..caec565d1 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include "common/common_types.h" | 16 | #include "common/common_types.h" |
| 17 | #include "common/logging/log.h" | 17 | #include "common/logging/log.h" |
| 18 | #include "video_core/engines/maxwell_3d.h" | 18 | #include "video_core/engines/maxwell_3d.h" |
| 19 | #include "video_core/engines/shader_type.h" | ||
| 19 | #include "video_core/renderer_opengl/gl_device.h" | 20 | #include "video_core/renderer_opengl/gl_device.h" |
| 20 | #include "video_core/renderer_opengl/gl_rasterizer.h" | 21 | #include "video_core/renderer_opengl/gl_rasterizer.h" |
| 21 | #include "video_core/renderer_opengl/gl_shader_decompiler.h" | 22 | #include "video_core/renderer_opengl/gl_shader_decompiler.h" |
| @@ -27,6 +28,7 @@ namespace OpenGL::GLShader { | |||
| 27 | 28 | ||
| 28 | namespace { | 29 | namespace { |
| 29 | 30 | ||
| 31 | using Tegra::Engines::ShaderType; | ||
| 30 | using Tegra::Shader::Attribute; | 32 | using Tegra::Shader::Attribute; |
| 31 | using Tegra::Shader::AttributeUse; | 33 | using Tegra::Shader::AttributeUse; |
| 32 | using Tegra::Shader::Header; | 34 | using Tegra::Shader::Header; |
| @@ -331,8 +333,8 @@ std::string FlowStackTopName(MetaStackClass stack) { | |||
| 331 | return fmt::format("{}_flow_stack_top", GetFlowStackPrefix(stack)); | 333 | return fmt::format("{}_flow_stack_top", GetFlowStackPrefix(stack)); |
| 332 | } | 334 | } |
| 333 | 335 | ||
| 334 | constexpr bool IsVertexShader(ProgramType stage) { | 336 | [[deprecated]] constexpr bool IsVertexShader(ShaderType stage) { |
| 335 | return stage == ProgramType::VertexA || stage == ProgramType::VertexB; | 337 | return stage == ShaderType::Vertex; |
| 336 | } | 338 | } |
| 337 | 339 | ||
| 338 | class ASTDecompiler; | 340 | class ASTDecompiler; |
| @@ -340,7 +342,7 @@ class ExprDecompiler; | |||
| 340 | 342 | ||
| 341 | class GLSLDecompiler final { | 343 | class GLSLDecompiler final { |
| 342 | public: | 344 | public: |
| 343 | explicit GLSLDecompiler(const Device& device, const ShaderIR& ir, ProgramType stage, | 345 | explicit GLSLDecompiler(const Device& device, const ShaderIR& ir, ShaderType stage, |
| 344 | std::string suffix) | 346 | std::string suffix) |
| 345 | : device{device}, ir{ir}, stage{stage}, suffix{suffix}, header{ir.GetHeader()} {} | 347 | : device{device}, ir{ir}, stage{stage}, suffix{suffix}, header{ir.GetHeader()} {} |
| 346 | 348 | ||
| @@ -427,7 +429,7 @@ private: | |||
| 427 | } | 429 | } |
| 428 | 430 | ||
| 429 | void DeclareGeometry() { | 431 | void DeclareGeometry() { |
| 430 | if (stage != ProgramType::Geometry) { | 432 | if (stage != ShaderType::Geometry) { |
| 431 | return; | 433 | return; |
| 432 | } | 434 | } |
| 433 | 435 | ||
| @@ -510,7 +512,7 @@ private: | |||
| 510 | } | 512 | } |
| 511 | 513 | ||
| 512 | void DeclareLocalMemory() { | 514 | void DeclareLocalMemory() { |
| 513 | if (stage == ProgramType::Compute) { | 515 | if (stage == ShaderType::Compute) { |
| 514 | code.AddLine("#ifdef LOCAL_MEMORY_SIZE"); | 516 | code.AddLine("#ifdef LOCAL_MEMORY_SIZE"); |
| 515 | code.AddLine("uint {}[LOCAL_MEMORY_SIZE];", GetLocalMemory()); | 517 | code.AddLine("uint {}[LOCAL_MEMORY_SIZE];", GetLocalMemory()); |
| 516 | code.AddLine("#endif"); | 518 | code.AddLine("#endif"); |
| @@ -575,12 +577,12 @@ private: | |||
| 575 | const u32 location{GetGenericAttributeIndex(index)}; | 577 | const u32 location{GetGenericAttributeIndex(index)}; |
| 576 | 578 | ||
| 577 | std::string name{GetInputAttribute(index)}; | 579 | std::string name{GetInputAttribute(index)}; |
| 578 | if (stage == ProgramType::Geometry) { | 580 | if (stage == ShaderType::Geometry) { |
| 579 | name = "gs_" + name + "[]"; | 581 | name = "gs_" + name + "[]"; |
| 580 | } | 582 | } |
| 581 | 583 | ||
| 582 | std::string suffix; | 584 | std::string suffix; |
| 583 | if (stage == ProgramType::Fragment) { | 585 | if (stage == ShaderType::Fragment) { |
| 584 | const auto input_mode{header.ps.GetAttributeUse(location)}; | 586 | const auto input_mode{header.ps.GetAttributeUse(location)}; |
| 585 | if (skip_unused && input_mode == AttributeUse::Unused) { | 587 | if (skip_unused && input_mode == AttributeUse::Unused) { |
| 586 | return; | 588 | return; |
| @@ -592,7 +594,7 @@ private: | |||
| 592 | } | 594 | } |
| 593 | 595 | ||
| 594 | void DeclareOutputAttributes() { | 596 | void DeclareOutputAttributes() { |
| 595 | if (ir.HasPhysicalAttributes() && stage != ProgramType::Fragment) { | 597 | if (ir.HasPhysicalAttributes() && stage != ShaderType::Fragment) { |
| 596 | for (u32 i = 0; i < GetNumPhysicalVaryings(); ++i) { | 598 | for (u32 i = 0; i < GetNumPhysicalVaryings(); ++i) { |
| 597 | DeclareOutputAttribute(ToGenericAttribute(i)); | 599 | DeclareOutputAttribute(ToGenericAttribute(i)); |
| 598 | } | 600 | } |
| @@ -704,7 +706,7 @@ private: | |||
| 704 | constexpr u32 element_stride = 4; | 706 | constexpr u32 element_stride = 4; |
| 705 | const u32 address{generic_base + index * generic_stride + element * element_stride}; | 707 | const u32 address{generic_base + index * generic_stride + element * element_stride}; |
| 706 | 708 | ||
| 707 | const bool declared = stage != ProgramType::Fragment || | 709 | const bool declared = stage != ShaderType::Fragment || |
| 708 | header.ps.GetAttributeUse(index) != AttributeUse::Unused; | 710 | header.ps.GetAttributeUse(index) != AttributeUse::Unused; |
| 709 | const std::string value = | 711 | const std::string value = |
| 710 | declared ? ReadAttribute(attribute, element).AsFloat() : "0.0f"; | 712 | declared ? ReadAttribute(attribute, element).AsFloat() : "0.0f"; |
| @@ -796,7 +798,7 @@ private: | |||
| 796 | } | 798 | } |
| 797 | 799 | ||
| 798 | if (const auto abuf = std::get_if<AbufNode>(&*node)) { | 800 | if (const auto abuf = std::get_if<AbufNode>(&*node)) { |
| 799 | UNIMPLEMENTED_IF_MSG(abuf->IsPhysicalBuffer() && stage == ProgramType::Geometry, | 801 | UNIMPLEMENTED_IF_MSG(abuf->IsPhysicalBuffer() && stage == ShaderType::Geometry, |
| 800 | "Physical attributes in geometry shaders are not implemented"); | 802 | "Physical attributes in geometry shaders are not implemented"); |
| 801 | if (abuf->IsPhysicalBuffer()) { | 803 | if (abuf->IsPhysicalBuffer()) { |
| 802 | return {fmt::format("ReadPhysicalAttribute({})", | 804 | return {fmt::format("ReadPhysicalAttribute({})", |
| @@ -891,7 +893,7 @@ private: | |||
| 891 | 893 | ||
| 892 | Expression ReadAttribute(Attribute::Index attribute, u32 element, const Node& buffer = {}) { | 894 | Expression ReadAttribute(Attribute::Index attribute, u32 element, const Node& buffer = {}) { |
| 893 | const auto GeometryPass = [&](std::string_view name) { | 895 | const auto GeometryPass = [&](std::string_view name) { |
| 894 | if (stage == ProgramType::Geometry && buffer) { | 896 | if (stage == ShaderType::Geometry && buffer) { |
| 895 | // TODO(Rodrigo): Guard geometry inputs against out of bound reads. Some games | 897 | // TODO(Rodrigo): Guard geometry inputs against out of bound reads. Some games |
| 896 | // set an 0x80000000 index for those and the shader fails to build. Find out why | 898 | // set an 0x80000000 index for those and the shader fails to build. Find out why |
| 897 | // this happens and what's its intent. | 899 | // this happens and what's its intent. |
| @@ -903,11 +905,11 @@ private: | |||
| 903 | switch (attribute) { | 905 | switch (attribute) { |
| 904 | case Attribute::Index::Position: | 906 | case Attribute::Index::Position: |
| 905 | switch (stage) { | 907 | switch (stage) { |
| 906 | case ProgramType::Geometry: | 908 | case ShaderType::Geometry: |
| 907 | return {fmt::format("gl_in[{}].gl_Position{}", Visit(buffer).AsUint(), | 909 | return {fmt::format("gl_in[{}].gl_Position{}", Visit(buffer).AsUint(), |
| 908 | GetSwizzle(element)), | 910 | GetSwizzle(element)), |
| 909 | Type::Float}; | 911 | Type::Float}; |
| 910 | case ProgramType::Fragment: | 912 | case ShaderType::Fragment: |
| 911 | return {element == 3 ? "1.0f" : ("gl_FragCoord"s + GetSwizzle(element)), | 913 | return {element == 3 ? "1.0f" : ("gl_FragCoord"s + GetSwizzle(element)), |
| 912 | Type::Float}; | 914 | Type::Float}; |
| 913 | default: | 915 | default: |
| @@ -941,7 +943,7 @@ private: | |||
| 941 | return {"0", Type::Int}; | 943 | return {"0", Type::Int}; |
| 942 | case Attribute::Index::FrontFacing: | 944 | case Attribute::Index::FrontFacing: |
| 943 | // TODO(Subv): Find out what the values are for the other elements. | 945 | // TODO(Subv): Find out what the values are for the other elements. |
| 944 | ASSERT(stage == ProgramType::Fragment); | 946 | ASSERT(stage == ShaderType::Fragment); |
| 945 | switch (element) { | 947 | switch (element) { |
| 946 | case 3: | 948 | case 3: |
| 947 | return {"(gl_FrontFacing ? -1 : 0)", Type::Int}; | 949 | return {"(gl_FrontFacing ? -1 : 0)", Type::Int}; |
| @@ -967,7 +969,7 @@ private: | |||
| 967 | // be found in fragment shaders, so we disable precise there. There are vertex shaders that | 969 | // be found in fragment shaders, so we disable precise there. There are vertex shaders that |
| 968 | // also fail to build but nobody seems to care about those. | 970 | // also fail to build but nobody seems to care about those. |
| 969 | // Note: Only bugged drivers will skip precise. | 971 | // Note: Only bugged drivers will skip precise. |
| 970 | const bool disable_precise = device.HasPreciseBug() && stage == ProgramType::Fragment; | 972 | const bool disable_precise = device.HasPreciseBug() && stage == ShaderType::Fragment; |
| 971 | 973 | ||
| 972 | std::string temporary = code.GenerateTemporary(); | 974 | std::string temporary = code.GenerateTemporary(); |
| 973 | code.AddLine("{}{} {} = {};", disable_precise ? "" : "precise ", GetTypeString(type), | 975 | code.AddLine("{}{} {} = {};", disable_precise ? "" : "precise ", GetTypeString(type), |
| @@ -1233,7 +1235,7 @@ private: | |||
| 1233 | fmt::format("{}[{} >> 2]", GetLocalMemory(), Visit(lmem->GetAddress()).AsUint()), | 1235 | fmt::format("{}[{} >> 2]", GetLocalMemory(), Visit(lmem->GetAddress()).AsUint()), |
| 1234 | Type::Uint}; | 1236 | Type::Uint}; |
| 1235 | } else if (const auto smem = std::get_if<SmemNode>(&*dest)) { | 1237 | } else if (const auto smem = std::get_if<SmemNode>(&*dest)) { |
| 1236 | ASSERT(stage == ProgramType::Compute); | 1238 | ASSERT(stage == ShaderType::Compute); |
| 1237 | target = {fmt::format("smem[{} >> 2]", Visit(smem->GetAddress()).AsUint()), Type::Uint}; | 1239 | target = {fmt::format("smem[{} >> 2]", Visit(smem->GetAddress()).AsUint()), Type::Uint}; |
| 1238 | } else if (const auto gmem = std::get_if<GmemNode>(&*dest)) { | 1240 | } else if (const auto gmem = std::get_if<GmemNode>(&*dest)) { |
| 1239 | const std::string real = Visit(gmem->GetRealAddress()).AsUint(); | 1241 | const std::string real = Visit(gmem->GetRealAddress()).AsUint(); |
| @@ -1801,7 +1803,7 @@ private: | |||
| 1801 | } | 1803 | } |
| 1802 | 1804 | ||
| 1803 | void PreExit() { | 1805 | void PreExit() { |
| 1804 | if (stage != ProgramType::Fragment) { | 1806 | if (stage != ShaderType::Fragment) { |
| 1805 | return; | 1807 | return; |
| 1806 | } | 1808 | } |
| 1807 | const auto& used_registers = ir.GetRegisters(); | 1809 | const auto& used_registers = ir.GetRegisters(); |
| @@ -1854,14 +1856,14 @@ private: | |||
| 1854 | } | 1856 | } |
| 1855 | 1857 | ||
| 1856 | Expression EmitVertex(Operation operation) { | 1858 | Expression EmitVertex(Operation operation) { |
| 1857 | ASSERT_MSG(stage == ProgramType::Geometry, | 1859 | ASSERT_MSG(stage == ShaderType::Geometry, |
| 1858 | "EmitVertex is expected to be used in a geometry shader."); | 1860 | "EmitVertex is expected to be used in a geometry shader."); |
| 1859 | code.AddLine("EmitVertex();"); | 1861 | code.AddLine("EmitVertex();"); |
| 1860 | return {}; | 1862 | return {}; |
| 1861 | } | 1863 | } |
| 1862 | 1864 | ||
| 1863 | Expression EndPrimitive(Operation operation) { | 1865 | Expression EndPrimitive(Operation operation) { |
| 1864 | ASSERT_MSG(stage == ProgramType::Geometry, | 1866 | ASSERT_MSG(stage == ShaderType::Geometry, |
| 1865 | "EndPrimitive is expected to be used in a geometry shader."); | 1867 | "EndPrimitive is expected to be used in a geometry shader."); |
| 1866 | code.AddLine("EndPrimitive();"); | 1868 | code.AddLine("EndPrimitive();"); |
| 1867 | return {}; | 1869 | return {}; |
| @@ -2192,7 +2194,7 @@ private: | |||
| 2192 | 2194 | ||
| 2193 | const Device& device; | 2195 | const Device& device; |
| 2194 | const ShaderIR& ir; | 2196 | const ShaderIR& ir; |
| 2195 | const ProgramType stage; | 2197 | const ShaderType stage; |
| 2196 | const std::string suffix; | 2198 | const std::string suffix; |
| 2197 | const Header header; | 2199 | const Header header; |
| 2198 | 2200 | ||
| @@ -2447,7 +2449,7 @@ const float fswzadd_modifiers_b[] = float[4](-1.0f, -1.0f, 1.0f, -1.0f ); | |||
| 2447 | )"; | 2449 | )"; |
| 2448 | } | 2450 | } |
| 2449 | 2451 | ||
| 2450 | std::string Decompile(const Device& device, const ShaderIR& ir, ProgramType stage, | 2452 | std::string Decompile(const Device& device, const ShaderIR& ir, ShaderType stage, |
| 2451 | const std::string& suffix) { | 2453 | const std::string& suffix) { |
| 2452 | GLSLDecompiler decompiler(device, ir, stage, suffix); | 2454 | GLSLDecompiler decompiler(device, ir, stage, suffix); |
| 2453 | decompiler.Decompile(); | 2455 | decompiler.Decompile(); |
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.h b/src/video_core/renderer_opengl/gl_shader_decompiler.h index b1e75e6cc..7876f48d6 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.h +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <vector> | 10 | #include <vector> |
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "video_core/engines/maxwell_3d.h" | 12 | #include "video_core/engines/maxwell_3d.h" |
| 13 | #include "video_core/engines/shader_type.h" | ||
| 13 | #include "video_core/shader/shader_ir.h" | 14 | #include "video_core/shader/shader_ir.h" |
| 14 | 15 | ||
| 15 | namespace VideoCommon::Shader { | 16 | namespace VideoCommon::Shader { |
| @@ -17,20 +18,8 @@ class ShaderIR; | |||
| 17 | } | 18 | } |
| 18 | 19 | ||
| 19 | namespace OpenGL { | 20 | namespace OpenGL { |
| 20 | |||
| 21 | class Device; | 21 | class Device; |
| 22 | 22 | } | |
| 23 | enum class ProgramType : u32 { | ||
| 24 | VertexA = 0, | ||
| 25 | VertexB = 1, | ||
| 26 | TessellationControl = 2, | ||
| 27 | TessellationEval = 3, | ||
| 28 | Geometry = 4, | ||
| 29 | Fragment = 5, | ||
| 30 | Compute = 6 | ||
| 31 | }; | ||
| 32 | |||
| 33 | } // namespace OpenGL | ||
| 34 | 23 | ||
| 35 | namespace OpenGL::GLShader { | 24 | namespace OpenGL::GLShader { |
| 36 | 25 | ||
| @@ -94,6 +83,6 @@ ShaderEntries GetEntries(const VideoCommon::Shader::ShaderIR& ir); | |||
| 94 | std::string GetCommonDeclarations(); | 83 | std::string GetCommonDeclarations(); |
| 95 | 84 | ||
| 96 | std::string Decompile(const Device& device, const VideoCommon::Shader::ShaderIR& ir, | 85 | std::string Decompile(const Device& device, const VideoCommon::Shader::ShaderIR& ir, |
| 97 | ProgramType stage, const std::string& suffix); | 86 | Tegra::Engines::ShaderType stage, const std::string& suffix); |
| 98 | 87 | ||
| 99 | } // namespace OpenGL::GLShader | 88 | } // namespace OpenGL::GLShader |
diff --git a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp index ccf530367..09f62c8c4 100644 --- a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <cstring> | 5 | #include <cstring> |
| 6 | |||
| 6 | #include <fmt/format.h> | 7 | #include <fmt/format.h> |
| 7 | 8 | ||
| 8 | #include "common/assert.h" | 9 | #include "common/assert.h" |
| @@ -12,16 +13,16 @@ | |||
| 12 | #include "common/logging/log.h" | 13 | #include "common/logging/log.h" |
| 13 | #include "common/scm_rev.h" | 14 | #include "common/scm_rev.h" |
| 14 | #include "common/zstd_compression.h" | 15 | #include "common/zstd_compression.h" |
| 15 | |||
| 16 | #include "core/core.h" | 16 | #include "core/core.h" |
| 17 | #include "core/hle/kernel/process.h" | 17 | #include "core/hle/kernel/process.h" |
| 18 | #include "core/settings.h" | 18 | #include "core/settings.h" |
| 19 | 19 | #include "video_core/engines/shader_type.h" | |
| 20 | #include "video_core/renderer_opengl/gl_shader_cache.h" | 20 | #include "video_core/renderer_opengl/gl_shader_cache.h" |
| 21 | #include "video_core/renderer_opengl/gl_shader_disk_cache.h" | 21 | #include "video_core/renderer_opengl/gl_shader_disk_cache.h" |
| 22 | 22 | ||
| 23 | namespace OpenGL { | 23 | namespace OpenGL { |
| 24 | 24 | ||
| 25 | using Tegra::Engines::ShaderType; | ||
| 25 | using VideoCommon::Shader::BindlessSamplerMap; | 26 | using VideoCommon::Shader::BindlessSamplerMap; |
| 26 | using VideoCommon::Shader::BoundSamplerMap; | 27 | using VideoCommon::Shader::BoundSamplerMap; |
| 27 | using VideoCommon::Shader::KeyMap; | 28 | using VideoCommon::Shader::KeyMap; |
| @@ -67,10 +68,10 @@ ShaderCacheVersionHash GetShaderCacheVersionHash() { | |||
| 67 | 68 | ||
| 68 | } // Anonymous namespace | 69 | } // Anonymous namespace |
| 69 | 70 | ||
| 70 | ShaderDiskCacheRaw::ShaderDiskCacheRaw(u64 unique_identifier, ProgramType program_type, | 71 | ShaderDiskCacheRaw::ShaderDiskCacheRaw(u64 unique_identifier, ShaderType type, ProgramCode code, |
| 71 | ProgramCode program_code, ProgramCode program_code_b) | 72 | ProgramCode code_b) |
| 72 | : unique_identifier{unique_identifier}, program_type{program_type}, | 73 | : unique_identifier{unique_identifier}, type{type}, code{std::move(code)}, code_b{std::move( |
| 73 | program_code{std::move(program_code)}, program_code_b{std::move(program_code_b)} {} | 74 | code_b)} {} |
| 74 | 75 | ||
| 75 | ShaderDiskCacheRaw::ShaderDiskCacheRaw() = default; | 76 | ShaderDiskCacheRaw::ShaderDiskCacheRaw() = default; |
| 76 | 77 | ||
| @@ -78,42 +79,39 @@ ShaderDiskCacheRaw::~ShaderDiskCacheRaw() = default; | |||
| 78 | 79 | ||
| 79 | bool ShaderDiskCacheRaw::Load(FileUtil::IOFile& file) { | 80 | bool ShaderDiskCacheRaw::Load(FileUtil::IOFile& file) { |
| 80 | if (file.ReadBytes(&unique_identifier, sizeof(u64)) != sizeof(u64) || | 81 | if (file.ReadBytes(&unique_identifier, sizeof(u64)) != sizeof(u64) || |
| 81 | file.ReadBytes(&program_type, sizeof(u32)) != sizeof(u32)) { | 82 | file.ReadBytes(&type, sizeof(u32)) != sizeof(u32)) { |
| 82 | return false; | 83 | return false; |
| 83 | } | 84 | } |
| 84 | u32 program_code_size{}; | 85 | u32 code_size{}; |
| 85 | u32 program_code_size_b{}; | 86 | u32 code_size_b{}; |
| 86 | if (file.ReadBytes(&program_code_size, sizeof(u32)) != sizeof(u32) || | 87 | if (file.ReadBytes(&code_size, sizeof(u32)) != sizeof(u32) || |
| 87 | file.ReadBytes(&program_code_size_b, sizeof(u32)) != sizeof(u32)) { | 88 | file.ReadBytes(&code_size_b, sizeof(u32)) != sizeof(u32)) { |
| 88 | return false; | 89 | return false; |
| 89 | } | 90 | } |
| 90 | 91 | ||
| 91 | program_code.resize(program_code_size); | 92 | code.resize(code_size); |
| 92 | program_code_b.resize(program_code_size_b); | 93 | code_b.resize(code_size_b); |
| 93 | 94 | ||
| 94 | if (file.ReadArray(program_code.data(), program_code_size) != program_code_size) | 95 | if (file.ReadArray(code.data(), code_size) != code_size) |
| 95 | return false; | 96 | return false; |
| 96 | 97 | ||
| 97 | if (HasProgramA() && | 98 | if (HasProgramA() && file.ReadArray(code_b.data(), code_size_b) != code_size_b) { |
| 98 | file.ReadArray(program_code_b.data(), program_code_size_b) != program_code_size_b) { | ||
| 99 | return false; | 99 | return false; |
| 100 | } | 100 | } |
| 101 | return true; | 101 | return true; |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | bool ShaderDiskCacheRaw::Save(FileUtil::IOFile& file) const { | 104 | bool ShaderDiskCacheRaw::Save(FileUtil::IOFile& file) const { |
| 105 | if (file.WriteObject(unique_identifier) != 1 || | 105 | if (file.WriteObject(unique_identifier) != 1 || file.WriteObject(static_cast<u32>(type)) != 1 || |
| 106 | file.WriteObject(static_cast<u32>(program_type)) != 1 || | 106 | file.WriteObject(static_cast<u32>(code.size())) != 1 || |
| 107 | file.WriteObject(static_cast<u32>(program_code.size())) != 1 || | 107 | file.WriteObject(static_cast<u32>(code_b.size())) != 1) { |
| 108 | file.WriteObject(static_cast<u32>(program_code_b.size())) != 1) { | ||
| 109 | return false; | 108 | return false; |
| 110 | } | 109 | } |
| 111 | 110 | ||
| 112 | if (file.WriteArray(program_code.data(), program_code.size()) != program_code.size()) | 111 | if (file.WriteArray(code.data(), code.size()) != code.size()) |
| 113 | return false; | 112 | return false; |
| 114 | 113 | ||
| 115 | if (HasProgramA() && | 114 | if (HasProgramA() && file.WriteArray(code_b.data(), code_b.size()) != code_b.size()) { |
| 116 | file.WriteArray(program_code_b.data(), program_code_b.size()) != program_code_b.size()) { | ||
| 117 | return false; | 115 | return false; |
| 118 | } | 116 | } |
| 119 | return true; | 117 | return true; |
diff --git a/src/video_core/renderer_opengl/gl_shader_disk_cache.h b/src/video_core/renderer_opengl/gl_shader_disk_cache.h index 28689f6c7..917dbccdd 100644 --- a/src/video_core/renderer_opengl/gl_shader_disk_cache.h +++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.h | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #include "common/assert.h" | 18 | #include "common/assert.h" |
| 19 | #include "common/common_types.h" | 19 | #include "common/common_types.h" |
| 20 | #include "core/file_sys/vfs_vector.h" | 20 | #include "core/file_sys/vfs_vector.h" |
| 21 | #include "video_core/engines/shader_type.h" | ||
| 21 | #include "video_core/renderer_opengl/gl_shader_gen.h" | 22 | #include "video_core/renderer_opengl/gl_shader_gen.h" |
| 22 | #include "video_core/shader/const_buffer_locker.h" | 23 | #include "video_core/shader/const_buffer_locker.h" |
| 23 | 24 | ||
| @@ -154,8 +155,8 @@ namespace OpenGL { | |||
| 154 | /// Describes a shader how it's used by the guest GPU | 155 | /// Describes a shader how it's used by the guest GPU |
| 155 | class ShaderDiskCacheRaw { | 156 | class ShaderDiskCacheRaw { |
| 156 | public: | 157 | public: |
| 157 | explicit ShaderDiskCacheRaw(u64 unique_identifier, ProgramType program_type, | 158 | explicit ShaderDiskCacheRaw(u64 unique_identifier, Tegra::Engines::ShaderType type, |
| 158 | ProgramCode program_code, ProgramCode program_code_b = {}); | 159 | ProgramCode code, ProgramCode code_b = {}); |
| 159 | ShaderDiskCacheRaw(); | 160 | ShaderDiskCacheRaw(); |
| 160 | ~ShaderDiskCacheRaw(); | 161 | ~ShaderDiskCacheRaw(); |
| 161 | 162 | ||
| @@ -168,27 +169,26 @@ public: | |||
| 168 | } | 169 | } |
| 169 | 170 | ||
| 170 | bool HasProgramA() const { | 171 | bool HasProgramA() const { |
| 171 | return program_type == ProgramType::VertexA; | 172 | return !code.empty() && !code_b.empty(); |
| 172 | } | 173 | } |
| 173 | 174 | ||
| 174 | ProgramType GetProgramType() const { | 175 | Tegra::Engines::ShaderType GetType() const { |
| 175 | return program_type; | 176 | return type; |
| 176 | } | 177 | } |
| 177 | 178 | ||
| 178 | const ProgramCode& GetProgramCode() const { | 179 | const ProgramCode& GetCode() const { |
| 179 | return program_code; | 180 | return code; |
| 180 | } | 181 | } |
| 181 | 182 | ||
| 182 | const ProgramCode& GetProgramCodeB() const { | 183 | const ProgramCode& GetCodeB() const { |
| 183 | return program_code_b; | 184 | return code_b; |
| 184 | } | 185 | } |
| 185 | 186 | ||
| 186 | private: | 187 | private: |
| 187 | u64 unique_identifier{}; | 188 | u64 unique_identifier{}; |
| 188 | ProgramType program_type{}; | 189 | Tegra::Engines::ShaderType type{}; |
| 189 | 190 | ProgramCode code; | |
| 190 | ProgramCode program_code; | 191 | ProgramCode code_b; |
| 191 | ProgramCode program_code_b; | ||
| 192 | }; | 192 | }; |
| 193 | 193 | ||
| 194 | /// Contains an OpenGL dumped binary program | 194 | /// Contains an OpenGL dumped binary program |
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index af17216bd..2f601d550 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #include <fmt/format.h> | 5 | #include <fmt/format.h> |
| 6 | #include "video_core/engines/maxwell_3d.h" | 6 | #include "video_core/engines/maxwell_3d.h" |
| 7 | #include "video_core/engines/shader_type.h" | ||
| 7 | #include "video_core/renderer_opengl/gl_shader_decompiler.h" | 8 | #include "video_core/renderer_opengl/gl_shader_decompiler.h" |
| 8 | #include "video_core/renderer_opengl/gl_shader_gen.h" | 9 | #include "video_core/renderer_opengl/gl_shader_gen.h" |
| 9 | #include "video_core/shader/shader_ir.h" | 10 | #include "video_core/shader/shader_ir.h" |
| @@ -11,6 +12,7 @@ | |||
| 11 | namespace OpenGL::GLShader { | 12 | namespace OpenGL::GLShader { |
| 12 | 13 | ||
| 13 | using Tegra::Engines::Maxwell3D; | 14 | using Tegra::Engines::Maxwell3D; |
| 15 | using Tegra::Engines::ShaderType; | ||
| 14 | using VideoCommon::Shader::CompileDepth; | 16 | using VideoCommon::Shader::CompileDepth; |
| 15 | using VideoCommon::Shader::CompilerSettings; | 17 | using VideoCommon::Shader::CompilerSettings; |
| 16 | using VideoCommon::Shader::ProgramCode; | 18 | using VideoCommon::Shader::ProgramCode; |
| @@ -24,10 +26,9 @@ layout (std140, binding = EMULATION_UBO_BINDING) uniform vs_config { | |||
| 24 | }; | 26 | }; |
| 25 | 27 | ||
| 26 | )"; | 28 | )"; |
| 27 | const auto stage = ir_b ? ProgramType::VertexA : ProgramType::VertexB; | 29 | out += Decompile(device, ir, ShaderType::Vertex, "vertex"); |
| 28 | out += Decompile(device, ir, stage, "vertex"); | ||
| 29 | if (ir_b) { | 30 | if (ir_b) { |
| 30 | out += Decompile(device, *ir_b, ProgramType::VertexB, "vertex_b"); | 31 | out += Decompile(device, *ir_b, ShaderType::Vertex, "vertex_b"); |
| 31 | } | 32 | } |
| 32 | 33 | ||
| 33 | out += R"( | 34 | out += R"( |
| @@ -49,7 +50,7 @@ layout (std140, binding = EMULATION_UBO_BINDING) uniform gs_config { | |||
| 49 | }; | 50 | }; |
| 50 | 51 | ||
| 51 | )"; | 52 | )"; |
| 52 | out += Decompile(device, ir, ProgramType::Geometry, "geometry"); | 53 | out += Decompile(device, ir, ShaderType::Geometry, "geometry"); |
| 53 | 54 | ||
| 54 | out += R"( | 55 | out += R"( |
| 55 | void main() { | 56 | void main() { |
| @@ -76,7 +77,7 @@ layout (std140, binding = EMULATION_UBO_BINDING) uniform fs_config { | |||
| 76 | }; | 77 | }; |
| 77 | 78 | ||
| 78 | )"; | 79 | )"; |
| 79 | out += Decompile(device, ir, ProgramType::Fragment, "fragment"); | 80 | out += Decompile(device, ir, ShaderType::Fragment, "fragment"); |
| 80 | 81 | ||
| 81 | out += R"( | 82 | out += R"( |
| 82 | void main() { | 83 | void main() { |
| @@ -88,7 +89,7 @@ void main() { | |||
| 88 | 89 | ||
| 89 | std::string GenerateComputeShader(const Device& device, const ShaderIR& ir) { | 90 | std::string GenerateComputeShader(const Device& device, const ShaderIR& ir) { |
| 90 | std::string out = GetCommonDeclarations(); | 91 | std::string out = GetCommonDeclarations(); |
| 91 | out += Decompile(device, ir, ProgramType::Compute, "compute"); | 92 | out += Decompile(device, ir, ShaderType::Compute, "compute"); |
| 92 | out += R"( | 93 | out += R"( |
| 93 | void main() { | 94 | void main() { |
| 94 | execute_compute(); | 95 | execute_compute(); |
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 |
diff --git a/src/video_core/shader/const_buffer_locker.cpp b/src/video_core/shader/const_buffer_locker.cpp index fe467608e..b65399f91 100644 --- a/src/video_core/shader/const_buffer_locker.cpp +++ b/src/video_core/shader/const_buffer_locker.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "common/assert.h" | 9 | #include "common/assert.h" |
| 10 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "video_core/engines/maxwell_3d.h" | 11 | #include "video_core/engines/maxwell_3d.h" |
| 12 | #include "video_core/engines/shader_type.h" | ||
| 12 | #include "video_core/shader/const_buffer_locker.h" | 13 | #include "video_core/shader/const_buffer_locker.h" |
| 13 | 14 | ||
| 14 | namespace VideoCommon::Shader { | 15 | namespace VideoCommon::Shader { |
diff --git a/src/video_core/shader/const_buffer_locker.h b/src/video_core/shader/const_buffer_locker.h index 600e2f3c3..50a8ce42a 100644 --- a/src/video_core/shader/const_buffer_locker.h +++ b/src/video_core/shader/const_buffer_locker.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 9 | #include "common/hash.h" | 9 | #include "common/hash.h" |
| 10 | #include "video_core/engines/const_buffer_engine_interface.h" | 10 | #include "video_core/engines/const_buffer_engine_interface.h" |
| 11 | #include "video_core/engines/shader_type.h" | ||
| 11 | 12 | ||
| 12 | namespace VideoCommon::Shader { | 13 | namespace VideoCommon::Shader { |
| 13 | 14 | ||
| @@ -20,7 +21,7 @@ using BindlessSamplerMap = | |||
| 20 | * The ConstBufferLocker is a class use to interface the 3D and compute engines with the shader | 21 | * The ConstBufferLocker is a class use to interface the 3D and compute engines with the shader |
| 21 | * compiler. with it, the shader can obtain required data from GPU state and store it for disk | 22 | * compiler. with it, the shader can obtain required data from GPU state and store it for disk |
| 22 | * shader compilation. | 23 | * shader compilation. |
| 23 | **/ | 24 | */ |
| 24 | class ConstBufferLocker { | 25 | class ConstBufferLocker { |
| 25 | public: | 26 | public: |
| 26 | explicit ConstBufferLocker(Tegra::Engines::ShaderType shader_stage); | 27 | explicit ConstBufferLocker(Tegra::Engines::ShaderType shader_stage); |