summaryrefslogtreecommitdiff
path: root/src/video_core/shader/registry.cpp
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2020-02-29 03:49:51 -0300
committerGravatar ReinUsesLisp2020-03-09 18:40:07 -0300
commit0528be5c92db67b608dc64322c55e57629c80619 (patch)
tree6705b628f5b7db52300f967f5101d172384eb101 /src/video_core/shader/registry.cpp
parentvideo_core: Rename "const buffer locker" to "registry" (diff)
downloadyuzu-0528be5c92db67b608dc64322c55e57629c80619.tar.gz
yuzu-0528be5c92db67b608dc64322c55e57629c80619.tar.xz
yuzu-0528be5c92db67b608dc64322c55e57629c80619.zip
shader/registry: Store graphics and compute metadata
Store information GLSL forces us to provide but it's dynamic state in hardware (workgroup sizes, primitive topology, shared memory size).
Diffstat (limited to 'src/video_core/shader/registry.cpp')
-rw-r--r--src/video_core/shader/registry.cpp59
1 files changed, 38 insertions, 21 deletions
diff --git a/src/video_core/shader/registry.cpp b/src/video_core/shader/registry.cpp
index 7126caf98..dc2d3dce3 100644
--- a/src/video_core/shader/registry.cpp
+++ b/src/video_core/shader/registry.cpp
@@ -6,21 +6,55 @@
6#include <tuple> 6#include <tuple>
7 7
8#include "common/common_types.h" 8#include "common/common_types.h"
9#include "video_core/engines/kepler_compute.h"
9#include "video_core/engines/maxwell_3d.h" 10#include "video_core/engines/maxwell_3d.h"
10#include "video_core/engines/shader_type.h" 11#include "video_core/engines/shader_type.h"
11#include "video_core/shader/registry.h" 12#include "video_core/shader/registry.h"
12 13
13namespace VideoCommon::Shader { 14namespace VideoCommon::Shader {
14 15
16using Tegra::Engines::ConstBufferEngineInterface;
15using Tegra::Engines::SamplerDescriptor; 17using Tegra::Engines::SamplerDescriptor;
18using Tegra::Engines::ShaderType;
16 19
17Registry::Registry(Tegra::Engines::ShaderType shader_stage, 20namespace {
18 VideoCore::GuestDriverProfile stored_guest_driver_profile) 21
19 : stage{shader_stage}, stored_guest_driver_profile{stored_guest_driver_profile} {} 22GraphicsInfo MakeGraphicsInfo(ShaderType shader_stage, ConstBufferEngineInterface& engine) {
23 if (shader_stage == ShaderType::Compute) {
24 return {};
25 }
26 auto& graphics = static_cast<Tegra::Engines::Maxwell3D&>(engine);
27
28 GraphicsInfo info;
29 info.primitive_topology = graphics.regs.draw.topology;
30 return info;
31}
32
33ComputeInfo MakeComputeInfo(ShaderType shader_stage, ConstBufferEngineInterface& engine) {
34 if (shader_stage != ShaderType::Compute) {
35 return {};
36 }
37 auto& compute = static_cast<Tegra::Engines::KeplerCompute&>(engine);
38 const auto& launch = compute.launch_description;
39
40 ComputeInfo info;
41 info.workgroup_size = {launch.block_dim_x, launch.block_dim_y, launch.block_dim_z};
42 info.local_memory_size_in_words = launch.local_pos_alloc;
43 info.shared_memory_size_in_words = launch.shared_alloc;
44 return info;
45}
46
47} // Anonymous namespace
48
49Registry::Registry(Tegra::Engines::ShaderType shader_stage, const SerializedRegistryInfo& info)
50 : stage{shader_stage}, stored_guest_driver_profile{info.guest_driver_profile},
51 bound_buffer{info.bound_buffer}, graphics_info{info.graphics}, compute_info{info.compute} {}
20 52
21Registry::Registry(Tegra::Engines::ShaderType shader_stage, 53Registry::Registry(Tegra::Engines::ShaderType shader_stage,
22 Tegra::Engines::ConstBufferEngineInterface& engine) 54 Tegra::Engines::ConstBufferEngineInterface& engine)
23 : stage{shader_stage}, engine{&engine} {} 55 : stage{shader_stage}, engine{&engine}, bound_buffer{engine.GetBoundBuffer()},
56 graphics_info{MakeGraphicsInfo(shader_stage, engine)}, compute_info{MakeComputeInfo(
57 shader_stage, engine)} {}
24 58
25Registry::~Registry() = default; 59Registry::~Registry() = default;
26 60
@@ -67,18 +101,6 @@ std::optional<Tegra::Engines::SamplerDescriptor> Registry::ObtainBindlessSampler
67 return value; 101 return value;
68} 102}
69 103
70std::optional<u32> Registry::ObtainBoundBuffer() {
71 if (bound_buffer_saved) {
72 return bound_buffer;
73 }
74 if (!engine) {
75 return std::nullopt;
76 }
77 bound_buffer_saved = true;
78 bound_buffer = engine->GetBoundBuffer();
79 return bound_buffer;
80}
81
82void Registry::InsertKey(u32 buffer, u32 offset, u32 value) { 104void Registry::InsertKey(u32 buffer, u32 offset, u32 value) {
83 keys.insert_or_assign({buffer, offset}, value); 105 keys.insert_or_assign({buffer, offset}, value);
84} 106}
@@ -91,11 +113,6 @@ void Registry::InsertBindlessSampler(u32 buffer, u32 offset, SamplerDescriptor s
91 bindless_samplers.insert_or_assign({buffer, offset}, sampler); 113 bindless_samplers.insert_or_assign({buffer, offset}, sampler);
92} 114}
93 115
94void Registry::SetBoundBuffer(u32 buffer) {
95 bound_buffer_saved = true;
96 bound_buffer = buffer;
97}
98
99bool Registry::IsConsistent() const { 116bool Registry::IsConsistent() const {
100 if (!engine) { 117 if (!engine) {
101 return true; 118 return true;