summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Fernando S2022-03-15 00:08:05 +0100
committerGravatar GitHub2022-03-15 00:08:05 +0100
commitf9e1f559b103fb6e716a070cebd2c075bd33de6e (patch)
tree37b027fce0744466d4b19464de1f8cf9009a402d
parentMerge pull request #8015 from FernandoS27/fix-global-mem (diff)
parentMaxwell3D: Link to override constant definition in nouveau (diff)
downloadyuzu-f9e1f559b103fb6e716a070cebd2c075bd33de6e.tar.gz
yuzu-f9e1f559b103fb6e716a070cebd2c075bd33de6e.tar.xz
yuzu-f9e1f559b103fb6e716a070cebd2c075bd33de6e.zip
Merge pull request #8000 from liamwhite/hagi
Initial support for Wii Hagi emulator
-rw-r--r--src/video_core/engines/maxwell_3d.cpp42
-rw-r--r--src/video_core/engines/maxwell_3d.h35
-rw-r--r--src/video_core/renderer_vulkan/vk_texture_cache.cpp3
3 files changed, 77 insertions, 3 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index 5d6d217bb..8f2fd28c2 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -7,6 +7,7 @@
7#include "common/assert.h" 7#include "common/assert.h"
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/dirty_flags.h"
10#include "video_core/engines/maxwell_3d.h" 11#include "video_core/engines/maxwell_3d.h"
11#include "video_core/gpu.h" 12#include "video_core/gpu.h"
12#include "video_core/memory_manager.h" 13#include "video_core/memory_manager.h"
@@ -208,6 +209,14 @@ void Maxwell3D::ProcessMethodCall(u32 method, u32 argument, u32 nonshadow_argume
208 return ProcessCBBind(4); 209 return ProcessCBBind(4);
209 case MAXWELL3D_REG_INDEX(draw.vertex_end_gl): 210 case MAXWELL3D_REG_INDEX(draw.vertex_end_gl):
210 return DrawArrays(); 211 return DrawArrays();
212 case MAXWELL3D_REG_INDEX(small_index):
213 regs.index_array.count = regs.small_index.count;
214 regs.index_array.first = regs.small_index.first;
215 dirty.flags[VideoCommon::Dirty::IndexBuffer] = true;
216 return DrawArrays();
217 case MAXWELL3D_REG_INDEX(topology_override):
218 use_topology_override = true;
219 return;
211 case MAXWELL3D_REG_INDEX(clear_buffers): 220 case MAXWELL3D_REG_INDEX(clear_buffers):
212 return ProcessClearBuffers(); 221 return ProcessClearBuffers();
213 case MAXWELL3D_REG_INDEX(query.query_get): 222 case MAXWELL3D_REG_INDEX(query.query_get):
@@ -360,6 +369,35 @@ void Maxwell3D::CallMethodFromMME(u32 method, u32 method_argument) {
360 } 369 }
361} 370}
362 371
372void Maxwell3D::ProcessTopologyOverride() {
373 using PrimitiveTopology = Maxwell3D::Regs::PrimitiveTopology;
374 using PrimitiveTopologyOverride = Maxwell3D::Regs::PrimitiveTopologyOverride;
375
376 PrimitiveTopology topology{};
377
378 switch (regs.topology_override) {
379 case PrimitiveTopologyOverride::None:
380 topology = regs.draw.topology;
381 break;
382 case PrimitiveTopologyOverride::Points:
383 topology = PrimitiveTopology::Points;
384 break;
385 case PrimitiveTopologyOverride::Lines:
386 topology = PrimitiveTopology::Lines;
387 break;
388 case PrimitiveTopologyOverride::LineStrip:
389 topology = PrimitiveTopology::LineStrip;
390 break;
391 default:
392 topology = static_cast<PrimitiveTopology>(regs.topology_override);
393 break;
394 }
395
396 if (use_topology_override) {
397 regs.draw.topology.Assign(topology);
398 }
399}
400
363void Maxwell3D::FlushMMEInlineDraw() { 401void Maxwell3D::FlushMMEInlineDraw() {
364 LOG_TRACE(HW_GPU, "called, topology={}, count={}", regs.draw.topology.Value(), 402 LOG_TRACE(HW_GPU, "called, topology={}, count={}", regs.draw.topology.Value(),
365 regs.vertex_buffer.count); 403 regs.vertex_buffer.count);
@@ -370,6 +408,8 @@ void Maxwell3D::FlushMMEInlineDraw() {
370 ASSERT_MSG(!regs.draw.instance_next || !regs.draw.instance_cont, 408 ASSERT_MSG(!regs.draw.instance_next || !regs.draw.instance_cont,
371 "Illegal combination of instancing parameters"); 409 "Illegal combination of instancing parameters");
372 410
411 ProcessTopologyOverride();
412
373 const bool is_indexed = mme_draw.current_mode == MMEDrawMode::Indexed; 413 const bool is_indexed = mme_draw.current_mode == MMEDrawMode::Indexed;
374 if (ShouldExecute()) { 414 if (ShouldExecute()) {
375 rasterizer->Draw(is_indexed, true); 415 rasterizer->Draw(is_indexed, true);
@@ -529,6 +569,8 @@ void Maxwell3D::DrawArrays() {
529 ASSERT_MSG(!regs.draw.instance_next || !regs.draw.instance_cont, 569 ASSERT_MSG(!regs.draw.instance_next || !regs.draw.instance_cont,
530 "Illegal combination of instancing parameters"); 570 "Illegal combination of instancing parameters");
531 571
572 ProcessTopologyOverride();
573
532 if (regs.draw.instance_next) { 574 if (regs.draw.instance_next) {
533 // Increment the current instance *before* drawing. 575 // Increment the current instance *before* drawing.
534 state.current_instance += 1; 576 state.current_instance += 1;
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index dc9df6c8b..6d34da046 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -367,6 +367,22 @@ public:
367 Patches = 0xe, 367 Patches = 0xe,
368 }; 368 };
369 369
370 // Constants as from NVC0_3D_UNK1970_D3D
371 // https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/gallium/drivers/nouveau/nvc0/nvc0_3d.xml.h#L1598
372 enum class PrimitiveTopologyOverride : u32 {
373 None = 0x0,
374 Points = 0x1,
375 Lines = 0x2,
376 LineStrip = 0x3,
377 Triangles = 0x4,
378 TriangleStrip = 0x5,
379 LinesAdjacency = 0xa,
380 LineStripAdjacency = 0xb,
381 TrianglesAdjacency = 0xc,
382 TriangleStripAdjacency = 0xd,
383 Patches = 0xe,
384 };
385
370 enum class IndexFormat : u32 { 386 enum class IndexFormat : u32 {
371 UnsignedByte = 0x0, 387 UnsignedByte = 0x0,
372 UnsignedShort = 0x1, 388 UnsignedShort = 0x1,
@@ -1200,7 +1216,12 @@ public:
1200 } 1216 }
1201 } index_array; 1217 } index_array;
1202 1218
1203 INSERT_PADDING_WORDS_NOINIT(0x7); 1219 union {
1220 BitField<0, 16, u32> first;
1221 BitField<16, 16, u32> count;
1222 } small_index;
1223
1224 INSERT_PADDING_WORDS_NOINIT(0x6);
1204 1225
1205 INSERT_PADDING_WORDS_NOINIT(0x1F); 1226 INSERT_PADDING_WORDS_NOINIT(0x1F);
1206 1227
@@ -1244,7 +1265,11 @@ public:
1244 BitField<11, 1, u32> depth_clamp_disabled; 1265 BitField<11, 1, u32> depth_clamp_disabled;
1245 } view_volume_clip_control; 1266 } view_volume_clip_control;
1246 1267
1247 INSERT_PADDING_WORDS_NOINIT(0x1F); 1268 INSERT_PADDING_WORDS_NOINIT(0xC);
1269
1270 PrimitiveTopologyOverride topology_override;
1271
1272 INSERT_PADDING_WORDS_NOINIT(0x12);
1248 1273
1249 u32 depth_bounds_enable; 1274 u32 depth_bounds_enable;
1250 1275
@@ -1531,6 +1556,9 @@ private:
1531 /// Handles a write to the VERTEX_END_GL register, triggering a draw. 1556 /// Handles a write to the VERTEX_END_GL register, triggering a draw.
1532 void DrawArrays(); 1557 void DrawArrays();
1533 1558
1559 /// Handles use of topology overrides (e.g., to avoid using a topology assigned from a macro)
1560 void ProcessTopologyOverride();
1561
1534 // Handles a instance drawcall from MME 1562 // Handles a instance drawcall from MME
1535 void StepInstance(MMEDrawMode expected_mode, u32 count); 1563 void StepInstance(MMEDrawMode expected_mode, u32 count);
1536 1564
@@ -1569,6 +1597,7 @@ private:
1569 Upload::State upload_state; 1597 Upload::State upload_state;
1570 1598
1571 bool execute_on{true}; 1599 bool execute_on{true};
1600 bool use_topology_override{false};
1572}; 1601};
1573 1602
1574#define ASSERT_REG_POSITION(field_name, position) \ 1603#define ASSERT_REG_POSITION(field_name, position) \
@@ -1685,6 +1714,7 @@ ASSERT_REG_POSITION(draw, 0x585);
1685ASSERT_REG_POSITION(primitive_restart, 0x591); 1714ASSERT_REG_POSITION(primitive_restart, 0x591);
1686ASSERT_REG_POSITION(provoking_vertex_last, 0x5A1); 1715ASSERT_REG_POSITION(provoking_vertex_last, 0x5A1);
1687ASSERT_REG_POSITION(index_array, 0x5F2); 1716ASSERT_REG_POSITION(index_array, 0x5F2);
1717ASSERT_REG_POSITION(small_index, 0x5F9);
1688ASSERT_REG_POSITION(polygon_offset_clamp, 0x61F); 1718ASSERT_REG_POSITION(polygon_offset_clamp, 0x61F);
1689ASSERT_REG_POSITION(instanced_arrays, 0x620); 1719ASSERT_REG_POSITION(instanced_arrays, 0x620);
1690ASSERT_REG_POSITION(vp_point_size, 0x644); 1720ASSERT_REG_POSITION(vp_point_size, 0x644);
@@ -1694,6 +1724,7 @@ ASSERT_REG_POSITION(cull_face, 0x648);
1694ASSERT_REG_POSITION(pixel_center_integer, 0x649); 1724ASSERT_REG_POSITION(pixel_center_integer, 0x649);
1695ASSERT_REG_POSITION(viewport_transform_enabled, 0x64B); 1725ASSERT_REG_POSITION(viewport_transform_enabled, 0x64B);
1696ASSERT_REG_POSITION(view_volume_clip_control, 0x64F); 1726ASSERT_REG_POSITION(view_volume_clip_control, 0x64F);
1727ASSERT_REG_POSITION(topology_override, 0x65C);
1697ASSERT_REG_POSITION(depth_bounds_enable, 0x66F); 1728ASSERT_REG_POSITION(depth_bounds_enable, 0x66F);
1698ASSERT_REG_POSITION(logic_op, 0x671); 1729ASSERT_REG_POSITION(logic_op, 0x671);
1699ASSERT_REG_POSITION(clear_buffers, 0x674); 1730ASSERT_REG_POSITION(clear_buffers, 0x674);
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp
index 0f62779de..ca6019a3a 100644
--- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp
@@ -1067,7 +1067,8 @@ void TextureCacheRuntime::ConvertImage(Framebuffer* dst, ImageView& dst_view, Im
1067 } 1067 }
1068 break; 1068 break;
1069 case PixelFormat::A8B8G8R8_UNORM: 1069 case PixelFormat::A8B8G8R8_UNORM:
1070 if (src_view.format == PixelFormat::S8_UINT_D24_UNORM) { 1070 if (src_view.format == PixelFormat::S8_UINT_D24_UNORM ||
1071 src_view.format == PixelFormat::D24_UNORM_S8_UINT) {
1071 return blit_image_helper.ConvertD24S8ToABGR8(dst, src_view); 1072 return blit_image_helper.ConvertD24S8ToABGR8(dst, src_view);
1072 } 1073 }
1073 break; 1074 break;