mirror of https://github.com/xemu-project/xemu.git
nv2a: Match HW behavior when setting window clip
This commit is contained in:
parent
6f3470acc8
commit
989dbcc76d
|
@ -1507,13 +1507,17 @@ DEF_METHOD(NV097, SET_WINDOW_CLIP_TYPE)
|
||||||
DEF_METHOD_INC(NV097, SET_WINDOW_CLIP_HORIZONTAL)
|
DEF_METHOD_INC(NV097, SET_WINDOW_CLIP_HORIZONTAL)
|
||||||
{
|
{
|
||||||
int slot = (method - NV097_SET_WINDOW_CLIP_HORIZONTAL) / 4;
|
int slot = (method - NV097_SET_WINDOW_CLIP_HORIZONTAL) / 4;
|
||||||
pg->regs[NV_PGRAPH_WINDOWCLIPX0 + slot * 4] = parameter;
|
for (; slot < 8; ++slot) {
|
||||||
|
pg->regs[NV_PGRAPH_WINDOWCLIPX0 + slot * 4] = parameter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_METHOD_INC(NV097, SET_WINDOW_CLIP_VERTICAL)
|
DEF_METHOD_INC(NV097, SET_WINDOW_CLIP_VERTICAL)
|
||||||
{
|
{
|
||||||
int slot = (method - NV097_SET_WINDOW_CLIP_VERTICAL) / 4;
|
int slot = (method - NV097_SET_WINDOW_CLIP_VERTICAL) / 4;
|
||||||
pg->regs[NV_PGRAPH_WINDOWCLIPY0 + slot * 4] = parameter;
|
for (; slot < 8; ++slot) {
|
||||||
|
pg->regs[NV_PGRAPH_WINDOWCLIPY0 + slot * 4] = parameter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_METHOD(NV097, SET_ALPHA_TEST_ENABLE)
|
DEF_METHOD(NV097, SET_ALPHA_TEST_ENABLE)
|
||||||
|
@ -4075,6 +4079,7 @@ static void pgraph_shader_update_constants(PGRAPHState *pg,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clipping regions */
|
/* Clipping regions */
|
||||||
|
int max_gl_height = pg->surface_binding_dim.height - 1;
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
uint32_t x = pg->regs[NV_PGRAPH_WINDOWCLIPX0 + i * 4];
|
uint32_t x = pg->regs[NV_PGRAPH_WINDOWCLIPX0 + i * 4];
|
||||||
unsigned int x_min = GET_MASK(x, NV_PGRAPH_WINDOWCLIPX0_XMIN);
|
unsigned int x_min = GET_MASK(x, NV_PGRAPH_WINDOWCLIPX0_XMIN);
|
||||||
|
@ -4086,9 +4091,9 @@ static void pgraph_shader_update_constants(PGRAPHState *pg,
|
||||||
pgraph_apply_anti_aliasing_factor(pg, &x_max, &y_max);
|
pgraph_apply_anti_aliasing_factor(pg, &x_max, &y_max);
|
||||||
|
|
||||||
/* Translate for the GL viewport origin */
|
/* Translate for the GL viewport origin */
|
||||||
unsigned int y_min_xlat = MAX(pg->surface_binding_dim.height - y_max - 1, 0);
|
unsigned int y_min_xlat = MAX(max_gl_height - (int)y_max, 0);
|
||||||
unsigned int y_max_xlat = MIN(pg->surface_binding_dim.height - y_min - 1,
|
unsigned int y_max_xlat = MIN(max_gl_height - (int)y_min, max_gl_height);
|
||||||
pg->surface_binding_dim.height);
|
|
||||||
pgraph_apply_scaling_factor(pg, &x_min, &y_min_xlat);
|
pgraph_apply_scaling_factor(pg, &x_min, &y_min_xlat);
|
||||||
pgraph_apply_scaling_factor(pg, &x_max, &y_max_xlat);
|
pgraph_apply_scaling_factor(pg, &x_max, &y_max_xlat);
|
||||||
|
|
||||||
|
|
|
@ -652,10 +652,12 @@ static MString* psh_convert(struct PixelShader *ps)
|
||||||
if (!ps->state.window_clip_exclusive) {
|
if (!ps->state.window_clip_exclusive) {
|
||||||
mstring_append(clip, "bool clipContained = false;\n");
|
mstring_append(clip, "bool clipContained = false;\n");
|
||||||
}
|
}
|
||||||
mstring_append(clip, "for (int i = 0; i < 8; i++) {\n"
|
mstring_append(clip, "vec2 coord = gl_FragCoord.xy - 0.5;\n"
|
||||||
" bvec4 clipTest = bvec4(lessThan(gl_FragCoord.xy-0.5, vec2(clipRegion[i].xy)),\n"
|
"for (int i = 0; i < 8; i++) {\n"
|
||||||
" greaterThan(gl_FragCoord.xy-0.5, vec2(clipRegion[i].zw)));\n"
|
" bool outside = any(bvec4(\n"
|
||||||
" if (!any(clipTest)) {\n");
|
" lessThan(coord, vec2(clipRegion[i].xy)),\n"
|
||||||
|
" greaterThan(coord, vec2(clipRegion[i].zw))));\n"
|
||||||
|
" if (!outside) {\n");
|
||||||
if (ps->state.window_clip_exclusive) {
|
if (ps->state.window_clip_exclusive) {
|
||||||
mstring_append(clip, " discard;\n");
|
mstring_append(clip, " discard;\n");
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue