Skip to content

Commit 7944150

Browse files
authored
nv2a: Check supported line width
* Added logic to check for the supported line width range before setting the line width to avoid errors. I also moved the glLineWidth call so that it could be after the call to get the supported line width range for the desired line type. * Moved the glLineWidth call outside the if/else * Moved the code to query line GL_SMOOTH_LINE_WIDTH_RANGE and GL_ALIASED_LINE_WIDTH_RANGE to nv2a_gl_context_init(void) so that it's just called while OpenGL is being initialized. * Removed the lineWidth local variable. It's simpler to just call glLineWidth in the if and else blocks
1 parent 7f5176b commit 7944150

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

hw/xbox/nv2a/pgraph.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,8 @@ static const SurfaceFormatInfo kelvin_surface_zeta_fixed_format_map[] = {
381381
{4, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_DEPTH_STENCIL_ATTACHMENT},
382382
};
383383

384+
static GLfloat supportedAliasedLineWidthRange[2] = { 0.0f, 0.0f };
385+
static GLfloat supportedSmoothLineWidthRange[2] = { 0.0f, 0.0f };
384386

385387
// static void pgraph_set_context_user(NV2AState *d, uint32_t val);
386388
static void pgraph_gl_fence(void);
@@ -3053,7 +3055,6 @@ DEF_METHOD(NV097, SET_BEGIN_END)
30533055
glDisable(GL_DITHER);
30543056
}
30553057

3056-
glLineWidth(pg->surface_scale_factor);
30573058
glEnable(GL_PROGRAM_POINT_SIZE);
30583059

30593060
bool anti_aliasing = GET_MASK(pg->regs[NV_PGRAPH_ANTIALIASING], NV_PGRAPH_ANTIALIASING_ENABLE);
@@ -3062,8 +3063,10 @@ DEF_METHOD(NV097, SET_BEGIN_END)
30623063
if (!anti_aliasing && pg->regs[NV_PGRAPH_SETUPRASTER] &
30633064
NV_PGRAPH_SETUPRASTER_LINESMOOTHENABLE) {
30643065
glEnable(GL_LINE_SMOOTH);
3066+
glLineWidth(MIN(supportedSmoothLineWidthRange[1], pg->surface_scale_factor));
30653067
} else {
30663068
glDisable(GL_LINE_SMOOTH);
3069+
glLineWidth(MIN(supportedAliasedLineWidthRange[1], pg->surface_scale_factor));
30673070
}
30683071
if (!anti_aliasing && pg->regs[NV_PGRAPH_SETUPRASTER] &
30693072
NV_PGRAPH_SETUPRASTER_POLYSMOOTHENABLE) {
@@ -3910,6 +3913,9 @@ void nv2a_gl_context_init(void)
39103913
{
39113914
g_nv2a_context_render = glo_context_create();
39123915
g_nv2a_context_display = glo_context_create();
3916+
3917+
glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, supportedSmoothLineWidthRange);
3918+
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, supportedAliasedLineWidthRange);
39133919
}
39143920

39153921
void nv2a_set_surface_scale_factor(unsigned int scale)

0 commit comments

Comments
 (0)