summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/shader_recompiler/stage.h11
-rw-r--r--src/video_core/engines/kepler_compute.cpp1
-rw-r--r--src/video_core/engines/maxwell_3d.cpp1
-rw-r--r--src/video_core/engines/maxwell_3d.h1
-rw-r--r--src/video_core/engines/shader_type.h21
-rw-r--r--src/video_core/renderer_opengl/gl_device.cpp18
-rw-r--r--src/video_core/renderer_opengl/gl_device.h11
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp2
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.cpp1
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.h1
-rw-r--r--src/video_core/renderer_vulkan/maxwell_to_vk.cpp15
-rw-r--r--src/video_core/renderer_vulkan/maxwell_to_vk.h3
-rw-r--r--src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp2
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.cpp2
-rw-r--r--src/video_core/shader_environment.cpp2
15 files changed, 37 insertions, 55 deletions
diff --git a/src/shader_recompiler/stage.h b/src/shader_recompiler/stage.h
index 7d4f2c0bb..5c1c8d8fc 100644
--- a/src/shader_recompiler/stage.h
+++ b/src/shader_recompiler/stage.h
@@ -9,13 +9,20 @@
9namespace Shader { 9namespace Shader {
10 10
11enum class Stage : u32 { 11enum class Stage : u32 {
12 Compute,
13 VertexA,
14 VertexB, 12 VertexB,
15 TessellationControl, 13 TessellationControl,
16 TessellationEval, 14 TessellationEval,
17 Geometry, 15 Geometry,
18 Fragment, 16 Fragment,
17
18 Compute,
19
20 VertexA,
19}; 21};
22constexpr u32 MaxStageTypes = 6;
23
24[[nodiscard]] constexpr Stage StageFromIndex(size_t index) noexcept {
25 return static_cast<Stage>(static_cast<size_t>(Stage::VertexB) + index);
26}
20 27
21} // namespace Shader 28} // namespace Shader
diff --git a/src/video_core/engines/kepler_compute.cpp b/src/video_core/engines/kepler_compute.cpp
index cae93c470..492b4c5a3 100644
--- a/src/video_core/engines/kepler_compute.cpp
+++ b/src/video_core/engines/kepler_compute.cpp
@@ -8,7 +8,6 @@
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"
12#include "video_core/memory_manager.h" 11#include "video_core/memory_manager.h"
13#include "video_core/rasterizer_interface.h" 12#include "video_core/rasterizer_interface.h"
14#include "video_core/renderer_base.h" 13#include "video_core/renderer_base.h"
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index 103a51fd0..b18b8a02a 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -8,7 +8,6 @@
8#include "core/core.h" 8#include "core/core.h"
9#include "core/core_timing.h" 9#include "core/core_timing.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"
12#include "video_core/gpu.h" 11#include "video_core/gpu.h"
13#include "video_core/memory_manager.h" 12#include "video_core/memory_manager.h"
14#include "video_core/rasterizer_interface.h" 13#include "video_core/rasterizer_interface.h"
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 04d5790f6..fc2c36c6b 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -20,7 +20,6 @@
20#include "video_core/engines/const_buffer_info.h" 20#include "video_core/engines/const_buffer_info.h"
21#include "video_core/engines/engine_interface.h" 21#include "video_core/engines/engine_interface.h"
22#include "video_core/engines/engine_upload.h" 22#include "video_core/engines/engine_upload.h"
23#include "video_core/engines/shader_type.h"
24#include "video_core/gpu.h" 23#include "video_core/gpu.h"
25#include "video_core/macro/macro.h" 24#include "video_core/macro/macro.h"
26#include "video_core/textures/texture.h" 25#include "video_core/textures/texture.h"
diff --git a/src/video_core/engines/shader_type.h b/src/video_core/engines/shader_type.h
deleted file mode 100644
index 49ce5cde5..000000000
--- a/src/video_core/engines/shader_type.h
+++ /dev/null
@@ -1,21 +0,0 @@
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
9namespace Tegra::Engines {
10
11enum class ShaderType : u32 {
12 Vertex = 0,
13 TesselationControl = 1,
14 TesselationEval = 2,
15 Geometry = 3,
16 Fragment = 4,
17 Compute = 5,
18};
19static constexpr std::size_t MaxShaderTypes = 6;
20
21} // namespace Tegra::Engines
diff --git a/src/video_core/renderer_opengl/gl_device.cpp b/src/video_core/renderer_opengl/gl_device.cpp
index b1b5ba1ab..27be347e6 100644
--- a/src/video_core/renderer_opengl/gl_device.cpp
+++ b/src/video_core/renderer_opengl/gl_device.cpp
@@ -17,6 +17,7 @@
17#include "common/logging/log.h" 17#include "common/logging/log.h"
18#include "common/scope_exit.h" 18#include "common/scope_exit.h"
19#include "common/settings.h" 19#include "common/settings.h"
20#include "shader_recompiler/stage.h"
20#include "video_core/renderer_opengl/gl_device.h" 21#include "video_core/renderer_opengl/gl_device.h"
21#include "video_core/renderer_opengl/gl_resource_manager.h" 22#include "video_core/renderer_opengl/gl_resource_manager.h"
22 23
@@ -59,16 +60,18 @@ bool HasExtension(std::span<const std::string_view> extensions, std::string_view
59 return std::ranges::find(extensions, extension) != extensions.end(); 60 return std::ranges::find(extensions, extension) != extensions.end();
60} 61}
61 62
62std::array<u32, Tegra::Engines::MaxShaderTypes> BuildMaxUniformBuffers() noexcept { 63std::array<u32, Shader::MaxStageTypes> BuildMaxUniformBuffers() noexcept {
63 std::array<u32, Tegra::Engines::MaxShaderTypes> max; 64 std::array<u32, Shader::MaxStageTypes> max;
64 std::ranges::transform(LIMIT_UBOS, max.begin(), 65 std::ranges::transform(LIMIT_UBOS, max.begin(), &GetInteger<u32>);
65 [](GLenum pname) { return GetInteger<u32>(pname); });
66 return max; 66 return max;
67} 67}
68 68
69bool IsASTCSupported() { 69bool IsASTCSupported() {
70 static constexpr std::array targets = {GL_TEXTURE_2D, GL_TEXTURE_2D_ARRAY}; 70 static constexpr std::array targets{
71 static constexpr std::array formats = { 71 GL_TEXTURE_2D,
72 GL_TEXTURE_2D_ARRAY,
73 };
74 static constexpr std::array formats{
72 GL_COMPRESSED_RGBA_ASTC_4x4_KHR, GL_COMPRESSED_RGBA_ASTC_5x4_KHR, 75 GL_COMPRESSED_RGBA_ASTC_4x4_KHR, GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
73 GL_COMPRESSED_RGBA_ASTC_5x5_KHR, GL_COMPRESSED_RGBA_ASTC_6x5_KHR, 76 GL_COMPRESSED_RGBA_ASTC_5x5_KHR, GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
74 GL_COMPRESSED_RGBA_ASTC_6x6_KHR, GL_COMPRESSED_RGBA_ASTC_8x5_KHR, 77 GL_COMPRESSED_RGBA_ASTC_6x6_KHR, GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
@@ -84,11 +87,10 @@ bool IsASTCSupported() {
84 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, 87 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
85 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, 88 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
86 }; 89 };
87 static constexpr std::array required_support = { 90 static constexpr std::array required_support{
88 GL_VERTEX_TEXTURE, GL_TESS_CONTROL_TEXTURE, GL_TESS_EVALUATION_TEXTURE, 91 GL_VERTEX_TEXTURE, GL_TESS_CONTROL_TEXTURE, GL_TESS_EVALUATION_TEXTURE,
89 GL_GEOMETRY_TEXTURE, GL_FRAGMENT_TEXTURE, GL_COMPUTE_TEXTURE, 92 GL_GEOMETRY_TEXTURE, GL_FRAGMENT_TEXTURE, GL_COMPUTE_TEXTURE,
90 }; 93 };
91
92 for (const GLenum target : targets) { 94 for (const GLenum target : targets) {
93 for (const GLenum format : formats) { 95 for (const GLenum format : formats) {
94 for (const GLenum support : required_support) { 96 for (const GLenum support : required_support) {
diff --git a/src/video_core/renderer_opengl/gl_device.h b/src/video_core/renderer_opengl/gl_device.h
index 0bd277d38..ad7b01b06 100644
--- a/src/video_core/renderer_opengl/gl_device.h
+++ b/src/video_core/renderer_opengl/gl_device.h
@@ -6,7 +6,7 @@
6 6
7#include <cstddef> 7#include <cstddef>
8#include "common/common_types.h" 8#include "common/common_types.h"
9#include "video_core/engines/shader_type.h" 9#include "shader_recompiler/stage.h"
10 10
11namespace OpenGL { 11namespace OpenGL {
12 12
@@ -16,8 +16,8 @@ public:
16 16
17 [[nodiscard]] std::string GetVendorName() const; 17 [[nodiscard]] std::string GetVendorName() const;
18 18
19 u32 GetMaxUniformBuffers(Tegra::Engines::ShaderType shader_type) const noexcept { 19 u32 GetMaxUniformBuffers(Shader::Stage stage) const noexcept {
20 return max_uniform_buffers[static_cast<std::size_t>(shader_type)]; 20 return max_uniform_buffers[static_cast<size_t>(stage)];
21 } 21 }
22 22
23 size_t GetUniformBufferAlignment() const { 23 size_t GetUniformBufferAlignment() const {
@@ -148,8 +148,7 @@ private:
148 static bool TestVariableAoffi(); 148 static bool TestVariableAoffi();
149 static bool TestPreciseBug(); 149 static bool TestPreciseBug();
150 150
151 std::string vendor_name; 151 std::array<u32, Shader::MaxStageTypes> max_uniform_buffers{};
152 std::array<u32, Tegra::Engines::MaxShaderTypes> max_uniform_buffers{};
153 size_t uniform_buffer_alignment{}; 152 size_t uniform_buffer_alignment{};
154 size_t shader_storage_alignment{}; 153 size_t shader_storage_alignment{};
155 u32 max_vertex_attributes{}; 154 u32 max_vertex_attributes{};
@@ -181,6 +180,8 @@ private:
181 bool has_sparse_texture_2{}; 180 bool has_sparse_texture_2{};
182 bool warp_size_potentially_larger_than_guest{}; 181 bool warp_size_potentially_larger_than_guest{};
183 bool need_fastmath_off{}; 182 bool need_fastmath_off{};
183
184 std::string vendor_name;
184}; 185};
185 186
186} // namespace OpenGL 187} // namespace OpenGL
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index e3d336f86..0f0d780b5 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -23,7 +23,6 @@
23#include "core/memory.h" 23#include "core/memory.h"
24#include "video_core/engines/kepler_compute.h" 24#include "video_core/engines/kepler_compute.h"
25#include "video_core/engines/maxwell_3d.h" 25#include "video_core/engines/maxwell_3d.h"
26#include "video_core/engines/shader_type.h"
27#include "video_core/memory_manager.h" 26#include "video_core/memory_manager.h"
28#include "video_core/renderer_opengl/gl_device.h" 27#include "video_core/renderer_opengl/gl_device.h"
29#include "video_core/renderer_opengl/gl_query_cache.h" 28#include "video_core/renderer_opengl/gl_query_cache.h"
@@ -40,7 +39,6 @@ namespace OpenGL {
40using Maxwell = Tegra::Engines::Maxwell3D::Regs; 39using Maxwell = Tegra::Engines::Maxwell3D::Regs;
41using GLvec4 = std::array<GLfloat, 4>; 40using GLvec4 = std::array<GLfloat, 4>;
42 41
43using Tegra::Engines::ShaderType;
44using VideoCore::Surface::PixelFormat; 42using VideoCore::Surface::PixelFormat;
45using VideoCore::Surface::SurfaceTarget; 43using VideoCore::Surface::SurfaceTarget;
46using VideoCore::Surface::SurfaceType; 44using VideoCore::Surface::SurfaceType;
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp
index f2f18b18a..5af9b7745 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp
@@ -26,7 +26,6 @@
26#include "shader_recompiler/profile.h" 26#include "shader_recompiler/profile.h"
27#include "video_core/engines/kepler_compute.h" 27#include "video_core/engines/kepler_compute.h"
28#include "video_core/engines/maxwell_3d.h" 28#include "video_core/engines/maxwell_3d.h"
29#include "video_core/engines/shader_type.h"
30#include "video_core/memory_manager.h" 29#include "video_core/memory_manager.h"
31#include "video_core/renderer_opengl/gl_rasterizer.h" 30#include "video_core/renderer_opengl/gl_rasterizer.h"
32#include "video_core/renderer_opengl/gl_resource_manager.h" 31#include "video_core/renderer_opengl/gl_resource_manager.h"
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.h b/src/video_core/renderer_opengl/gl_shader_cache.h
index 16873fcec..9d5306293 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.h
+++ b/src/video_core/renderer_opengl/gl_shader_cache.h
@@ -17,7 +17,6 @@
17#include "shader_recompiler/host_translate_info.h" 17#include "shader_recompiler/host_translate_info.h"
18#include "shader_recompiler/object_pool.h" 18#include "shader_recompiler/object_pool.h"
19#include "shader_recompiler/profile.h" 19#include "shader_recompiler/profile.h"
20#include "video_core/engines/shader_type.h"
21#include "video_core/renderer_opengl/gl_compute_pipeline.h" 20#include "video_core/renderer_opengl/gl_compute_pipeline.h"
22#include "video_core/renderer_opengl/gl_graphics_pipeline.h" 21#include "video_core/renderer_opengl/gl_graphics_pipeline.h"
23#include "video_core/renderer_opengl/gl_shader_context.h" 22#include "video_core/renderer_opengl/gl_shader_context.h"
diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp
index 8f0b0b8ec..8f9b9a11a 100644
--- a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp
+++ b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp
@@ -266,19 +266,20 @@ FormatInfo SurfaceFormat(const Device& device, FormatType format_type, bool with
266 return {device.GetSupportedFormat(tuple.format, usage, format_type), attachable, storage}; 266 return {device.GetSupportedFormat(tuple.format, usage, format_type), attachable, storage};
267} 267}
268 268
269VkShaderStageFlagBits ShaderStage(Tegra::Engines::ShaderType stage) { 269VkShaderStageFlagBits ShaderStage(Shader::Stage stage) {
270 switch (stage) { 270 switch (stage) {
271 case Tegra::Engines::ShaderType::Vertex: 271 case Shader::Stage::VertexA:
272 case Shader::Stage::VertexB:
272 return VK_SHADER_STAGE_VERTEX_BIT; 273 return VK_SHADER_STAGE_VERTEX_BIT;
273 case Tegra::Engines::ShaderType::TesselationControl: 274 case Shader::Stage::TessellationControl:
274 return VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; 275 return VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT;
275 case Tegra::Engines::ShaderType::TesselationEval: 276 case Shader::Stage::TessellationEval:
276 return VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; 277 return VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT;
277 case Tegra::Engines::ShaderType::Geometry: 278 case Shader::Stage::Geometry:
278 return VK_SHADER_STAGE_GEOMETRY_BIT; 279 return VK_SHADER_STAGE_GEOMETRY_BIT;
279 case Tegra::Engines::ShaderType::Fragment: 280 case Shader::Stage::Fragment:
280 return VK_SHADER_STAGE_FRAGMENT_BIT; 281 return VK_SHADER_STAGE_FRAGMENT_BIT;
281 case Tegra::Engines::ShaderType::Compute: 282 case Shader::Stage::Compute:
282 return VK_SHADER_STAGE_COMPUTE_BIT; 283 return VK_SHADER_STAGE_COMPUTE_BIT;
283 } 284 }
284 UNIMPLEMENTED_MSG("Unimplemented shader stage={}", stage); 285 UNIMPLEMENTED_MSG("Unimplemented shader stage={}", stage);
diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.h b/src/video_core/renderer_vulkan/maxwell_to_vk.h
index 50a599c11..8a9616039 100644
--- a/src/video_core/renderer_vulkan/maxwell_to_vk.h
+++ b/src/video_core/renderer_vulkan/maxwell_to_vk.h
@@ -5,6 +5,7 @@
5#pragma once 5#pragma once
6 6
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "shader_recompiler/stage.h"
8#include "video_core/engines/maxwell_3d.h" 9#include "video_core/engines/maxwell_3d.h"
9#include "video_core/surface.h" 10#include "video_core/surface.h"
10#include "video_core/textures/texture.h" 11#include "video_core/textures/texture.h"
@@ -45,7 +46,7 @@ struct FormatInfo {
45[[nodiscard]] FormatInfo SurfaceFormat(const Device& device, FormatType format_type, bool with_srgb, 46[[nodiscard]] FormatInfo SurfaceFormat(const Device& device, FormatType format_type, bool with_srgb,
46 PixelFormat pixel_format); 47 PixelFormat pixel_format);
47 48
48VkShaderStageFlagBits ShaderStage(Tegra::Engines::ShaderType stage); 49VkShaderStageFlagBits ShaderStage(Shader::Stage stage);
49 50
50VkPrimitiveTopology PrimitiveTopology(const Device& device, Maxwell::PrimitiveTopology topology); 51VkPrimitiveTopology PrimitiveTopology(const Device& device, Maxwell::PrimitiveTopology topology);
51 52
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
index 2b59a9d88..9eb353a88 100644
--- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
+++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
@@ -737,7 +737,7 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {
737 .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, 737 .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
738 .pNext = nullptr, 738 .pNext = nullptr,
739 .flags = 0, 739 .flags = 0,
740 .stage = MaxwellToVK::ShaderStage(static_cast<Tegra::Engines::ShaderType>(stage)), 740 .stage = MaxwellToVK::ShaderStage(Shader::StageFromIndex(stage)),
741 .module = *spv_modules[stage], 741 .module = *spv_modules[stage],
742 .pName = "main", 742 .pName = "main",
743 .pSpecializationInfo = nullptr, 743 .pSpecializationInfo = nullptr,
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
index c57e16c50..f04c3394c 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
@@ -58,8 +58,6 @@ struct DrawParams {
58 bool is_indexed; 58 bool is_indexed;
59}; 59};
60 60
61constexpr auto COMPUTE_SHADER_INDEX = static_cast<size_t>(Tegra::Engines::ShaderType::Compute);
62
63VkViewport GetViewportState(const Device& device, const Maxwell& regs, size_t index) { 61VkViewport GetViewportState(const Device& device, const Maxwell& regs, size_t index) {
64 const auto& src = regs.viewport_transform[index]; 62 const auto& src = regs.viewport_transform[index];
65 const float width = src.scale_x * 2.0f; 63 const float width = src.scale_x * 2.0f;
diff --git a/src/video_core/shader_environment.cpp b/src/video_core/shader_environment.cpp
index 6243cd176..d463e2b56 100644
--- a/src/video_core/shader_environment.cpp
+++ b/src/video_core/shader_environment.cpp
@@ -22,7 +22,7 @@
22namespace VideoCommon { 22namespace VideoCommon {
23 23
24constexpr std::array<char, 8> MAGIC_NUMBER{'y', 'u', 'z', 'u', 'c', 'a', 'c', 'h'}; 24constexpr std::array<char, 8> MAGIC_NUMBER{'y', 'u', 'z', 'u', 'c', 'a', 'c', 'h'};
25constexpr u32 CACHE_VERSION = 3; 25constexpr u32 CACHE_VERSION = 4;
26 26
27constexpr size_t INST_SIZE = sizeof(u64); 27constexpr size_t INST_SIZE = sizeof(u64);
28 28