Skip to content

Commit 99bb82f

Browse files
committed
[GPU] Separate GetHostViewportInfo X and Y bounds
1 parent 49dc0e9 commit 99bb82f

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/xenia/gpu/d3d12/d3d12_command_processor.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,8 @@ bool D3D12CommandProcessor::IssueDraw(xenos::PrimitiveType primitive_type,
20162016
}
20172017
draw_util::ViewportInfo viewport_info;
20182018
draw_util::GetHostViewportInfo(regs, float(pixel_size_x), float(pixel_size_y),
2019-
true, float(D3D12_VIEWPORT_BOUNDS_MAX), false,
2019+
true, float(D3D12_VIEWPORT_BOUNDS_MAX),
2020+
float(D3D12_VIEWPORT_BOUNDS_MAX), false,
20202021
viewport_info);
20212022
draw_util::Scissor scissor;
20222023
draw_util::GetScissor(regs, scissor);

src/xenia/gpu/draw_util.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,12 @@ int32_t FloatToD3D11Fixed16p8(float f32) {
113113

114114
void GetHostViewportInfo(const RegisterFile& regs, float pixel_size_x,
115115
float pixel_size_y, bool origin_bottom_left,
116-
float xy_max, bool allow_reverse_z,
116+
float x_max, float y_max, bool allow_reverse_z,
117117
ViewportInfo& viewport_info_out) {
118118
assert_true(pixel_size_x >= 1.0f);
119119
assert_true(pixel_size_y >= 1.0f);
120-
assert_true(xy_max >= 1.0f);
120+
assert_true(x_max >= 1.0f);
121+
assert_true(y_max >= 1.0f);
121122

122123
// PA_CL_VTE_CNTL contains whether offsets and scales are enabled.
123124
// http://www.x.org/docs/AMD/old/evergreen_3D_registers_v2.pdf
@@ -167,9 +168,9 @@ void GetHostViewportInfo(const RegisterFile& regs, float pixel_size_x,
167168
// Keep the viewport in the positive quarter-plane for simplicity of
168169
// clamping to the maximum supported bounds.
169170
float cutoff_left = std::fmax(-viewport_left, 0.0f);
170-
float cutoff_right = std::fmax(viewport_right - xy_max, 0.0f);
171+
float cutoff_right = std::fmax(viewport_right - x_max, 0.0f);
171172
viewport_left = std::fmax(viewport_left, 0.0f);
172-
viewport_right = std::fmin(viewport_right, xy_max);
173+
viewport_right = std::fmin(viewport_right, x_max);
173174
viewport_width = viewport_right - viewport_left;
174175
if (viewport_width > size_min) {
175176
ndc_scale_x =
@@ -194,7 +195,7 @@ void GetHostViewportInfo(const RegisterFile& regs, float pixel_size_x,
194195
// enabled, via the shader.
195196
viewport_left = 0.0f;
196197
viewport_width = std::min(
197-
float(xenos::kTexture2DCubeMaxWidthHeight) * pixel_size_x, xy_max);
198+
float(xenos::kTexture2DCubeMaxWidthHeight) * pixel_size_x, x_max);
198199
ndc_scale_x = (2.0f * pixel_size_x) / viewport_width;
199200
ndc_offset_x = viewport_offset_x * ndc_scale_x - 1.0f;
200201
}
@@ -205,9 +206,9 @@ void GetHostViewportInfo(const RegisterFile& regs, float pixel_size_x,
205206
viewport_top = viewport_offset_y * pixel_size_y - viewport_scale_y_abs;
206207
float viewport_bottom = viewport_top + viewport_scale_y_abs * 2.0f;
207208
float cutoff_top = std::fmax(-viewport_top, 0.0f);
208-
float cutoff_bottom = std::fmax(viewport_bottom - xy_max, 0.0f);
209+
float cutoff_bottom = std::fmax(viewport_bottom - y_max, 0.0f);
209210
viewport_top = std::fmax(viewport_top, 0.0f);
210-
viewport_bottom = std::fmin(viewport_bottom, xy_max);
211+
viewport_bottom = std::fmin(viewport_bottom, y_max);
211212
viewport_height = viewport_bottom - viewport_top;
212213
if (viewport_height > size_min) {
213214
ndc_scale_y =
@@ -227,7 +228,7 @@ void GetHostViewportInfo(const RegisterFile& regs, float pixel_size_x,
227228
}
228229
} else {
229230
viewport_height = std::min(
230-
float(xenos::kTexture2DCubeMaxWidthHeight) * pixel_size_y, xy_max);
231+
float(xenos::kTexture2DCubeMaxWidthHeight) * pixel_size_y, y_max);
231232
ndc_scale_y = (2.0f * pixel_size_y) / viewport_height;
232233
ndc_offset_y = viewport_offset_y * ndc_scale_y - 1.0f;
233234
}

src/xenia/gpu/draw_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct ViewportInfo {
5252
// Direct3D clip space with 0...W Z rather than -W...W.
5353
void GetHostViewportInfo(const RegisterFile& regs, float pixel_size_x,
5454
float pixel_size_y, bool origin_bottom_left,
55-
float xy_max, bool allow_reverse_z,
55+
float x_max, float y_max, bool allow_reverse_z,
5656
ViewportInfo& viewport_info_out);
5757

5858
struct Scissor {

0 commit comments

Comments
 (0)