Skip to content

Commit 9248342

Browse files
committed
Revert "Use correct scissor rects (shadps4-emu#1146)"
This reverts commit 7d96c9d.
1 parent a12ec32 commit 9248342

File tree

2 files changed

+18
-89
lines changed

2 files changed

+18
-89
lines changed

src/video_core/amdgpu/liverpool.h

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,6 @@ struct Liverpool {
253253
}
254254
};
255255

256-
struct ModeControl {
257-
s32 msaa_enable : 1;
258-
s32 vport_scissor_enable : 1;
259-
s32 line_stripple_enable : 1;
260-
s32 send_unlit_stiles_to_pkr : 1;
261-
};
262-
263256
enum class ZOrder : u32 {
264257
LateZ = 0,
265258
EarlyZLateZ = 1,
@@ -571,39 +564,29 @@ struct Liverpool {
571564
s16 top_left_x;
572565
s16 top_left_y;
573566
};
574-
struct {
575-
s16 bottom_right_x;
576-
s16 bottom_right_y;
567+
union {
568+
BitField<0, 15, u32> bottom_right_x;
569+
BitField<16, 15, u32> bottom_right_y;
577570
};
578571

579-
// From AMD spec: 'Negative numbers clamped to 0'
580-
static s16 Clamp(s16 value) {
581-
return std::max(s16(0), value);
582-
}
583-
584572
u32 GetWidth() const {
585-
return static_cast<u32>(Clamp(bottom_right_x) - Clamp(top_left_x));
573+
return static_cast<u32>(bottom_right_x - top_left_x);
586574
}
587575

588576
u32 GetHeight() const {
589-
return static_cast<u32>(Clamp(bottom_right_y) - Clamp(top_left_y));
577+
return static_cast<u32>(bottom_right_y - top_left_y);
590578
}
591579
};
592580

593-
struct WindowOffset {
594-
s32 window_x_offset : 16;
595-
s32 window_y_offset : 16;
596-
};
597-
598581
struct ViewportScissor {
599582
union {
600583
BitField<0, 15, s32> top_left_x;
601-
BitField<16, 15, s32> top_left_y;
602-
BitField<31, 1, s32> window_offset_disable;
584+
BitField<15, 15, s32> top_left_y;
585+
BitField<30, 1, s32> window_offset_disable;
603586
};
604-
struct {
605-
s16 bottom_right_x;
606-
s16 bottom_right_y;
587+
union {
588+
BitField<0, 15, s32> bottom_right_x;
589+
BitField<15, 15, s32> bottom_right_y;
607590
};
608591

609592
u32 GetWidth() const {
@@ -1008,14 +991,10 @@ struct Liverpool {
1008991
Scissor screen_scissor;
1009992
INSERT_PADDING_WORDS(0xA010 - 0xA00C - 2);
1010993
DepthBuffer depth_buffer;
1011-
INSERT_PADDING_WORDS(0xA080 - 0xA018);
1012-
WindowOffset window_offset;
1013-
ViewportScissor window_scissor;
1014-
INSERT_PADDING_WORDS(0xA08E - 0xA081 - 2);
994+
INSERT_PADDING_WORDS(0xA08E - 0xA018);
1015995
ColorBufferMask color_target_mask;
1016996
ColorBufferMask color_shader_mask;
1017-
ViewportScissor generic_scissor;
1018-
INSERT_PADDING_WORDS(2);
997+
INSERT_PADDING_WORDS(0xA094 - 0xA08E - 2);
1019998
std::array<ViewportScissor, NumViewports> viewport_scissors;
1020999
std::array<ViewportDepth, NumViewports> viewport_depths;
10211000
INSERT_PADDING_WORDS(0xA103 - 0xA0D4);
@@ -1053,9 +1032,7 @@ struct Liverpool {
10531032
PolygonControl polygon_control;
10541033
ViewportControl viewport_control;
10551034
VsOutputControl vs_output_control;
1056-
INSERT_PADDING_WORDS(0xA292 - 0xA207 - 1);
1057-
ModeControl mode_control;
1058-
INSERT_PADDING_WORDS(0xA29D - 0xA292 - 1);
1035+
INSERT_PADDING_WORDS(0xA29E - 0xA207 - 2);
10591036
u32 index_size;
10601037
u32 max_index_size;
10611038
IndexBufferType index_buffer_type;
@@ -1267,11 +1244,8 @@ static_assert(GFX6_3D_REG_INDEX(depth_htile_data_base) == 0xA005);
12671244
static_assert(GFX6_3D_REG_INDEX(screen_scissor) == 0xA00C);
12681245
static_assert(GFX6_3D_REG_INDEX(depth_buffer.z_info) == 0xA010);
12691246
static_assert(GFX6_3D_REG_INDEX(depth_buffer.depth_slice) == 0xA017);
1270-
static_assert(GFX6_3D_REG_INDEX(window_offset) == 0xA080);
1271-
static_assert(GFX6_3D_REG_INDEX(window_scissor) == 0xA081);
12721247
static_assert(GFX6_3D_REG_INDEX(color_target_mask) == 0xA08E);
12731248
static_assert(GFX6_3D_REG_INDEX(color_shader_mask) == 0xA08F);
1274-
static_assert(GFX6_3D_REG_INDEX(generic_scissor) == 0xA090);
12751249
static_assert(GFX6_3D_REG_INDEX(viewport_scissors) == 0xA094);
12761250
static_assert(GFX6_3D_REG_INDEX(primitive_restart_index) == 0xA103);
12771251
static_assert(GFX6_3D_REG_INDEX(stencil_control) == 0xA10B);
@@ -1291,7 +1265,6 @@ static_assert(GFX6_3D_REG_INDEX(color_control) == 0xA202);
12911265
static_assert(GFX6_3D_REG_INDEX(clipper_control) == 0xA204);
12921266
static_assert(GFX6_3D_REG_INDEX(viewport_control) == 0xA206);
12931267
static_assert(GFX6_3D_REG_INDEX(vs_output_control) == 0xA207);
1294-
static_assert(GFX6_3D_REG_INDEX(mode_control) == 0xA292);
12951268
static_assert(GFX6_3D_REG_INDEX(index_size) == 0xA29D);
12961269
static_assert(GFX6_3D_REG_INDEX(index_buffer_type) == 0xA29F);
12971270
static_assert(GFX6_3D_REG_INDEX(enable_primitive_id) == 0xA2A1);

src/video_core/renderer_vulkan/vk_rasterizer.cpp

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -368,55 +368,11 @@ void Rasterizer::UpdateViewportScissorState() {
368368
.maxDepth = vp.zscale + vp.zoffset,
369369
});
370370
}
371-
372-
const bool enable_offset = !regs.window_scissor.window_offset_disable.Value();
373-
Liverpool::Scissor scsr{};
374-
const auto combined_scissor_value_tl = [](s16 scr, s16 win, s16 gen, s16 win_offset) {
375-
return std::max({scr, s16(win + win_offset), s16(gen + win_offset)});
376-
};
377-
378-
scsr.top_left_x = combined_scissor_value_tl(
379-
regs.screen_scissor.top_left_x, s16(regs.window_scissor.top_left_x.Value()),
380-
s16(regs.generic_scissor.top_left_x.Value()),
381-
enable_offset ? regs.window_offset.window_x_offset : 0);
382-
383-
scsr.top_left_y = combined_scissor_value_tl(
384-
regs.screen_scissor.top_left_y, s16(regs.window_scissor.top_left_y.Value()),
385-
s16(regs.generic_scissor.top_left_y.Value()),
386-
enable_offset ? regs.window_offset.window_y_offset : 0);
387-
388-
const auto combined_scissor_value_br = [](s16 scr, s16 win, s16 gen, s16 win_offset) {
389-
return std::min({scr, s16(win + win_offset), s16(gen + win_offset)});
390-
};
391-
392-
scsr.bottom_right_x = combined_scissor_value_br(
393-
regs.screen_scissor.bottom_right_x, regs.window_scissor.bottom_right_x,
394-
regs.generic_scissor.bottom_right_x,
395-
enable_offset ? regs.window_offset.window_x_offset : 0);
396-
397-
scsr.bottom_right_y = combined_scissor_value_br(
398-
regs.screen_scissor.bottom_right_y, regs.window_scissor.bottom_right_y,
399-
regs.generic_scissor.bottom_right_y,
400-
enable_offset ? regs.window_offset.window_y_offset : 0);
401-
402-
for (u32 idx = 0; idx < Liverpool::NumViewports; idx++) {
403-
auto vp_scsr = scsr;
404-
if (regs.mode_control.vport_scissor_enable) {
405-
vp_scsr.top_left_x =
406-
std::max(vp_scsr.top_left_x, s16(regs.viewport_scissors[idx].top_left_x.Value()));
407-
vp_scsr.top_left_y =
408-
std::max(vp_scsr.top_left_y, s16(regs.viewport_scissors[idx].top_left_y.Value()));
409-
vp_scsr.bottom_right_x =
410-
std::min(vp_scsr.bottom_right_x, regs.viewport_scissors[idx].bottom_right_x);
411-
vp_scsr.bottom_right_y =
412-
std::min(vp_scsr.bottom_right_y, regs.viewport_scissors[idx].bottom_right_y);
413-
}
414-
scissors.push_back({
415-
.offset = {vp_scsr.top_left_x, vp_scsr.top_left_y},
416-
.extent = {vp_scsr.GetWidth(), vp_scsr.GetHeight()},
417-
});
418-
}
419-
371+
const auto& sc = regs.screen_scissor;
372+
scissors.push_back({
373+
.offset = {sc.top_left_x, sc.top_left_y},
374+
.extent = {sc.GetWidth(), sc.GetHeight()},
375+
});
420376
const auto cmdbuf = scheduler.CommandBuffer();
421377
cmdbuf.setViewport(0, viewports);
422378
cmdbuf.setScissor(0, scissors);

0 commit comments

Comments
 (0)