diff options
| author | 2018-03-17 16:17:45 -0500 | |
|---|---|---|
| committer | 2018-03-17 18:32:55 -0500 | |
| commit | 1d9d9c16e8d05837e7f80c533190da27fb298d8b (patch) | |
| tree | 715af8134f8bc00b99708ef4f93cd04ee5fdfa43 /src | |
| parent | GPU: Corrected the parameter documentation for the SetShader macro call. (diff) | |
| download | yuzu-1d9d9c16e8d05837e7f80c533190da27fb298d8b.tar.gz yuzu-1d9d9c16e8d05837e7f80c533190da27fb298d8b.tar.xz yuzu-1d9d9c16e8d05837e7f80c533190da27fb298d8b.zip | |
GPU: Make the SetShader macro call do the same as the real macro's code.
It'll now set the CB_SIZE, CB_ADDRESS and CB_BIND registers when it's called.
Presumably this SetShader function is binding the constant shader uniforms to buffer 1 (c1[]).
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/engines/maxwell_3d.cpp | 20 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 27 |
2 files changed, 44 insertions, 3 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 9784ee069..4b15ed2f2 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -84,7 +84,7 @@ void Maxwell3D::SetShader(const std::vector<u32>& parameters) { | |||
| 84 | /** | 84 | /** |
| 85 | * Parameters description: | 85 | * Parameters description: |
| 86 | * [0] = Shader Program. | 86 | * [0] = Shader Program. |
| 87 | * [1] = Unknown. | 87 | * [1] = Unknown, presumably the shader id. |
| 88 | * [2] = Offset to the start of the shader, after the 0x30 bytes header. | 88 | * [2] = Offset to the start of the shader, after the 0x30 bytes header. |
| 89 | * [3] = Shader Type. | 89 | * [3] = Shader Type. |
| 90 | * [4] = Const Buffer Address >> 8. | 90 | * [4] = Const Buffer Address >> 8. |
| @@ -100,6 +100,24 @@ void Maxwell3D::SetShader(const std::vector<u32>& parameters) { | |||
| 100 | shader.type = shader_type; | 100 | shader.type = shader_type; |
| 101 | shader.address = address; | 101 | shader.address = address; |
| 102 | shader.cb_address = cb_address; | 102 | shader.cb_address = cb_address; |
| 103 | |||
| 104 | // Perform the same operations as the real macro code. | ||
| 105 | // TODO(Subv): Early exit if register 0xD1C + shader_program contains the same as params[1]. | ||
| 106 | auto& shader_regs = regs.shader_config[static_cast<size_t>(shader_program)]; | ||
| 107 | shader_regs.start_id = address; | ||
| 108 | // TODO(Subv): Write params[1] to register 0xD1C + shader_program. | ||
| 109 | // TODO(Subv): Write params[2] to register 0xD22 + shader_program. | ||
| 110 | |||
| 111 | // Note: This value is hardcoded in the macro's code. | ||
| 112 | static constexpr u32 DefaultCBSize = 0x10000; | ||
| 113 | regs.const_buffer.cb_size = DefaultCBSize; | ||
| 114 | regs.const_buffer.cb_address_high = cb_address >> 32; | ||
| 115 | regs.const_buffer.cb_address_low = cb_address & 0xFFFFFFFF; | ||
| 116 | |||
| 117 | // Write a hardcoded 0x11 to CB_BIND, this binds the current const buffer to buffer c1[] in the | ||
| 118 | // shader. It's likely that these are the constants for the shader. | ||
| 119 | regs.cb_bind[static_cast<size_t>(shader_type)].valid.Assign(1); | ||
| 120 | regs.cb_bind[static_cast<size_t>(shader_type)].index.Assign(1); | ||
| 103 | } | 121 | } |
| 104 | 122 | ||
| 105 | } // namespace Engines | 123 | } // namespace Engines |
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 47df43c97..6eb98080d 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -35,8 +35,10 @@ public: | |||
| 35 | struct Regs { | 35 | struct Regs { |
| 36 | static constexpr size_t NUM_REGS = 0xE36; | 36 | static constexpr size_t NUM_REGS = 0xE36; |
| 37 | 37 | ||
| 38 | static constexpr size_t NumCBData = 16; | ||
| 38 | static constexpr size_t NumVertexArrays = 32; | 39 | static constexpr size_t NumVertexArrays = 32; |
| 39 | static constexpr size_t MaxShaderProgram = 6; | 40 | static constexpr size_t MaxShaderProgram = 6; |
| 41 | static constexpr size_t MaxShaderType = 5; | ||
| 40 | 42 | ||
| 41 | enum class QueryMode : u32 { | 43 | enum class QueryMode : u32 { |
| 42 | Write = 0, | 44 | Write = 0, |
| @@ -136,7 +138,27 @@ public: | |||
| 136 | INSERT_PADDING_WORDS(9); | 138 | INSERT_PADDING_WORDS(9); |
| 137 | } shader_config[MaxShaderProgram]; | 139 | } shader_config[MaxShaderProgram]; |
| 138 | 140 | ||
| 139 | INSERT_PADDING_WORDS(0x5D0); | 141 | INSERT_PADDING_WORDS(0x8C); |
| 142 | |||
| 143 | struct { | ||
| 144 | u32 cb_size; | ||
| 145 | u32 cb_address_high; | ||
| 146 | u32 cb_address_low; | ||
| 147 | u32 cb_pos; | ||
| 148 | u32 cb_data[NumCBData]; | ||
| 149 | } const_buffer; | ||
| 150 | |||
| 151 | INSERT_PADDING_WORDS(0x74); | ||
| 152 | |||
| 153 | struct { | ||
| 154 | union { | ||
| 155 | BitField<0, 1, u32> valid; | ||
| 156 | BitField<4, 5, u32> index; | ||
| 157 | }; | ||
| 158 | INSERT_PADDING_WORDS(7); | ||
| 159 | } cb_bind[MaxShaderType]; | ||
| 160 | |||
| 161 | INSERT_PADDING_WORDS(0x494); | ||
| 140 | 162 | ||
| 141 | struct { | 163 | struct { |
| 142 | u32 set_shader_call; | 164 | u32 set_shader_call; |
| @@ -161,7 +183,7 @@ public: | |||
| 161 | std::array<ShaderInfo, Regs::MaxShaderProgram> shaders; | 183 | std::array<ShaderInfo, Regs::MaxShaderProgram> shaders; |
| 162 | }; | 184 | }; |
| 163 | 185 | ||
| 164 | State state; | 186 | State state{}; |
| 165 | 187 | ||
| 166 | private: | 188 | private: |
| 167 | MemoryManager& memory_manager; | 189 | MemoryManager& memory_manager; |
| @@ -194,6 +216,7 @@ ASSERT_REG_POSITION(query, 0x6C0); | |||
| 194 | ASSERT_REG_POSITION(vertex_array[0], 0x700); | 216 | ASSERT_REG_POSITION(vertex_array[0], 0x700); |
| 195 | ASSERT_REG_POSITION(vertex_array_limit[0], 0x7C0); | 217 | ASSERT_REG_POSITION(vertex_array_limit[0], 0x7C0); |
| 196 | ASSERT_REG_POSITION(shader_config[0], 0x800); | 218 | ASSERT_REG_POSITION(shader_config[0], 0x800); |
| 219 | ASSERT_REG_POSITION(const_buffer, 0x8E0); | ||
| 197 | ASSERT_REG_POSITION(set_shader, 0xE24); | 220 | ASSERT_REG_POSITION(set_shader, 0xE24); |
| 198 | 221 | ||
| 199 | #undef ASSERT_REG_POSITION | 222 | #undef ASSERT_REG_POSITION |