diff options
| author | 2020-04-19 01:25:52 -0300 | |
|---|---|---|
| committer | 2020-04-21 19:55:44 -0300 | |
| commit | 0bbae63300fc83505d34f5ca3f9a5be10e42d7c7 (patch) | |
| tree | a7a1b11034b64ca73adea93260efe0d98bc30707 /src | |
| parent | Merge pull request #3718 from ReinUsesLisp/better-pipeline-state (diff) | |
| download | yuzu-0bbae63300fc83505d34f5ca3f9a5be10e42d7c7.tar.gz yuzu-0bbae63300fc83505d34f5ca3f9a5be10e42d7c7.tar.xz yuzu-0bbae63300fc83505d34f5ca3f9a5be10e42d7c7.zip | |
gl_rasterizer: Fix buffers without size
On NVN buffers can be enabled but have no size. According to deko3d and
the behavior we see in Animal Crossing: New Horizons these buffers get
the special address of 0x1000 and limit themselves to 0xfff.
Implement buffers without a size by binding a null buffer to OpenGL
without a side.
https://github.com/devkitPro/deko3d/blob/1d1930beea093b5a663419e93b0649719a3ca5da/source/maxwell/gpu_3d_vbo.cpp#L62-L63
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 3 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 12 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 6 |
3 files changed, 13 insertions, 8 deletions
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 59d5752d2..7bbc6600b 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -1259,7 +1259,8 @@ public: | |||
| 1259 | 1259 | ||
| 1260 | GPUVAddr LimitAddress() const { | 1260 | GPUVAddr LimitAddress() const { |
| 1261 | return static_cast<GPUVAddr>((static_cast<GPUVAddr>(limit_high) << 32) | | 1261 | return static_cast<GPUVAddr>((static_cast<GPUVAddr>(limit_high) << 32) | |
| 1262 | limit_low); | 1262 | limit_low) + |
| 1263 | 1; | ||
| 1263 | } | 1264 | } |
| 1264 | } vertex_array_limit[NumVertexArrays]; | 1265 | } vertex_array_limit[NumVertexArrays]; |
| 1265 | 1266 | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 175374f0d..1c3b3b644 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -185,8 +185,12 @@ void RasterizerOpenGL::SetupVertexBuffer() { | |||
| 185 | const GPUVAddr start = vertex_array.StartAddress(); | 185 | const GPUVAddr start = vertex_array.StartAddress(); |
| 186 | const GPUVAddr end = regs.vertex_array_limit[index].LimitAddress(); | 186 | const GPUVAddr end = regs.vertex_array_limit[index].LimitAddress(); |
| 187 | 187 | ||
| 188 | ASSERT(end > start); | 188 | ASSERT(end >= start); |
| 189 | const u64 size = end - start + 1; | 189 | const u64 size = end - start; |
| 190 | if (size == 0) { | ||
| 191 | glBindVertexBuffer(static_cast<GLuint>(index), 0, 0, vertex_array.stride); | ||
| 192 | continue; | ||
| 193 | } | ||
| 190 | const auto [vertex_buffer, vertex_buffer_offset] = buffer_cache.UploadMemory(start, size); | 194 | const auto [vertex_buffer, vertex_buffer_offset] = buffer_cache.UploadMemory(start, size); |
| 191 | glBindVertexBuffer(static_cast<GLuint>(index), vertex_buffer, vertex_buffer_offset, | 195 | glBindVertexBuffer(static_cast<GLuint>(index), vertex_buffer, vertex_buffer_offset, |
| 192 | vertex_array.stride); | 196 | vertex_array.stride); |
| @@ -310,8 +314,8 @@ std::size_t RasterizerOpenGL::CalculateVertexArraysSize() const { | |||
| 310 | const GPUVAddr start = regs.vertex_array[index].StartAddress(); | 314 | const GPUVAddr start = regs.vertex_array[index].StartAddress(); |
| 311 | const GPUVAddr end = regs.vertex_array_limit[index].LimitAddress(); | 315 | const GPUVAddr end = regs.vertex_array_limit[index].LimitAddress(); |
| 312 | 316 | ||
| 313 | ASSERT(end > start); | 317 | size += end - start; |
| 314 | size += end - start + 1; | 318 | ASSERT(end >= start); |
| 315 | } | 319 | } |
| 316 | 320 | ||
| 317 | return size; | 321 | return size; |
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 71007bbe8..2ebf34fc4 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp | |||
| @@ -834,8 +834,8 @@ void RasterizerVulkan::SetupVertexArrays(FixedPipelineState::VertexInput& vertex | |||
| 834 | const GPUVAddr start{vertex_array.StartAddress()}; | 834 | const GPUVAddr start{vertex_array.StartAddress()}; |
| 835 | const GPUVAddr end{regs.vertex_array_limit[index].LimitAddress()}; | 835 | const GPUVAddr end{regs.vertex_array_limit[index].LimitAddress()}; |
| 836 | 836 | ||
| 837 | ASSERT(end > start); | 837 | ASSERT(end >= start); |
| 838 | const std::size_t size{end - start + 1}; | 838 | const std::size_t size{end - start}; |
| 839 | const auto [buffer, offset] = buffer_cache.UploadMemory(start, size); | 839 | const auto [buffer, offset] = buffer_cache.UploadMemory(start, size); |
| 840 | buffer_bindings.AddVertexBinding(buffer, offset); | 840 | buffer_bindings.AddVertexBinding(buffer, offset); |
| 841 | } | 841 | } |
| @@ -1179,7 +1179,7 @@ std::size_t RasterizerVulkan::CalculateVertexArraysSize() const { | |||
| 1179 | const GPUVAddr end{regs.vertex_array_limit[index].LimitAddress()}; | 1179 | const GPUVAddr end{regs.vertex_array_limit[index].LimitAddress()}; |
| 1180 | DEBUG_ASSERT(end >= start); | 1180 | DEBUG_ASSERT(end >= start); |
| 1181 | 1181 | ||
| 1182 | size += (end - start + 1) * regs.vertex_array[index].enable; | 1182 | size += (end - start) * regs.vertex_array[index].enable; |
| 1183 | } | 1183 | } |
| 1184 | return size; | 1184 | return size; |
| 1185 | } | 1185 | } |