mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 11:20:11 +01:00
st/mesa: add support for GL_ARB_viewport_array (v0.2)
this just ties the mesa code to the pre-existing gallium interface, I'm not sure what to do with the CSO stuff yet. 0.2: fix min/max bounds Acked-by: Ilia Mirkin <imirkin@alum.mit.edu> Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
parent
c116ee6042
commit
0705fa35cd
5 changed files with 73 additions and 56 deletions
|
|
@ -43,51 +43,56 @@
|
||||||
static void
|
static void
|
||||||
update_scissor( struct st_context *st )
|
update_scissor( struct st_context *st )
|
||||||
{
|
{
|
||||||
struct pipe_scissor_state scissor;
|
struct pipe_scissor_state scissor[PIPE_MAX_VIEWPORTS];
|
||||||
const struct gl_context *ctx = st->ctx;
|
const struct gl_context *ctx = st->ctx;
|
||||||
const struct gl_framebuffer *fb = ctx->DrawBuffer;
|
const struct gl_framebuffer *fb = ctx->DrawBuffer;
|
||||||
GLint miny, maxy;
|
GLint miny, maxy;
|
||||||
|
int i;
|
||||||
|
bool changed = false;
|
||||||
|
for (i = 0 ; i < ctx->Const.MaxViewports; i++) {
|
||||||
|
scissor[i].minx = 0;
|
||||||
|
scissor[i].miny = 0;
|
||||||
|
scissor[i].maxx = fb->Width;
|
||||||
|
scissor[i].maxy = fb->Height;
|
||||||
|
|
||||||
scissor.minx = 0;
|
if (ctx->Scissor.EnableFlags & (1 << i)) {
|
||||||
scissor.miny = 0;
|
/* need to be careful here with xmax or ymax < 0 */
|
||||||
scissor.maxx = fb->Width;
|
GLint xmax = MAX2(0, ctx->Scissor.ScissorArray[i].X + ctx->Scissor.ScissorArray[i].Width);
|
||||||
scissor.maxy = fb->Height;
|
GLint ymax = MAX2(0, ctx->Scissor.ScissorArray[i].Y + ctx->Scissor.ScissorArray[i].Height);
|
||||||
|
|
||||||
if (ctx->Scissor.EnableFlags & 1) {
|
if (ctx->Scissor.ScissorArray[i].X > (GLint)scissor[i].minx)
|
||||||
/* need to be careful here with xmax or ymax < 0 */
|
scissor[i].minx = ctx->Scissor.ScissorArray[i].X;
|
||||||
GLint xmax = MAX2(0, ctx->Scissor.ScissorArray[0].X + ctx->Scissor.ScissorArray[0].Width);
|
if (ctx->Scissor.ScissorArray[i].Y > (GLint)scissor[i].miny)
|
||||||
GLint ymax = MAX2(0, ctx->Scissor.ScissorArray[0].Y + ctx->Scissor.ScissorArray[0].Height);
|
scissor[i].miny = ctx->Scissor.ScissorArray[i].Y;
|
||||||
|
|
||||||
if (ctx->Scissor.ScissorArray[0].X > (GLint)scissor.minx)
|
if (xmax < (GLint) scissor[i].maxx)
|
||||||
scissor.minx = ctx->Scissor.ScissorArray[0].X;
|
scissor[i].maxx = xmax;
|
||||||
if (ctx->Scissor.ScissorArray[0].Y > (GLint)scissor.miny)
|
if (ymax < (GLint) scissor[i].maxy)
|
||||||
scissor.miny = ctx->Scissor.ScissorArray[0].Y;
|
scissor[i].maxy = ymax;
|
||||||
|
|
||||||
|
/* check for null space */
|
||||||
|
if (scissor[i].minx >= scissor[i].maxx || scissor[i].miny >= scissor[i].maxy)
|
||||||
|
scissor[i].minx = scissor[i].miny = scissor[i].maxx = scissor[i].maxy = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (xmax < (GLint) scissor.maxx)
|
/* Now invert Y if needed.
|
||||||
scissor.maxx = xmax;
|
* Gallium drivers use the convention Y=0=top for surfaces.
|
||||||
if (ymax < (GLint) scissor.maxy)
|
*/
|
||||||
scissor.maxy = ymax;
|
if (st_fb_orientation(fb) == Y_0_TOP) {
|
||||||
|
miny = fb->Height - scissor[i].maxy;
|
||||||
|
maxy = fb->Height - scissor[i].miny;
|
||||||
|
scissor[i].miny = miny;
|
||||||
|
scissor[i].maxy = maxy;
|
||||||
|
}
|
||||||
|
|
||||||
/* check for null space */
|
if (memcmp(&scissor[i], &st->state.scissor[i], sizeof(scissor)) != 0) {
|
||||||
if (scissor.minx >= scissor.maxx || scissor.miny >= scissor.maxy)
|
/* state has changed */
|
||||||
scissor.minx = scissor.miny = scissor.maxx = scissor.maxy = 0;
|
st->state.scissor[i] = scissor[i]; /* struct copy */
|
||||||
}
|
changed = true;
|
||||||
|
}
|
||||||
/* Now invert Y if needed.
|
|
||||||
* Gallium drivers use the convention Y=0=top for surfaces.
|
|
||||||
*/
|
|
||||||
if (st_fb_orientation(fb) == Y_0_TOP) {
|
|
||||||
miny = fb->Height - scissor.maxy;
|
|
||||||
maxy = fb->Height - scissor.miny;
|
|
||||||
scissor.miny = miny;
|
|
||||||
scissor.maxy = maxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (memcmp(&scissor, &st->state.scissor, sizeof(scissor)) != 0) {
|
|
||||||
/* state has changed */
|
|
||||||
st->state.scissor = scissor; /* struct copy */
|
|
||||||
st->pipe->set_scissor_states(st->pipe, 0, 1, &scissor); /* activate */
|
|
||||||
}
|
}
|
||||||
|
if (changed)
|
||||||
|
st->pipe->set_scissor_states(st->pipe, 0, ctx->Const.MaxViewports, scissor); /* activate */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ update_viewport( struct st_context *st )
|
||||||
{
|
{
|
||||||
struct gl_context *ctx = st->ctx;
|
struct gl_context *ctx = st->ctx;
|
||||||
GLfloat yScale, yBias;
|
GLfloat yScale, yBias;
|
||||||
|
int i;
|
||||||
/* _NEW_BUFFERS
|
/* _NEW_BUFFERS
|
||||||
*/
|
*/
|
||||||
if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
|
if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
|
||||||
|
|
@ -61,26 +61,29 @@ update_viewport( struct st_context *st )
|
||||||
|
|
||||||
/* _NEW_VIEWPORT
|
/* _NEW_VIEWPORT
|
||||||
*/
|
*/
|
||||||
|
for (i = 0; i < ctx->Const.MaxViewports; i++)
|
||||||
{
|
{
|
||||||
GLfloat x = ctx->ViewportArray[0].X;
|
GLfloat x = ctx->ViewportArray[i].X;
|
||||||
GLfloat y = ctx->ViewportArray[0].Y;
|
GLfloat y = ctx->ViewportArray[i].Y;
|
||||||
GLfloat z = ctx->ViewportArray[0].Near;
|
GLfloat z = ctx->ViewportArray[i].Near;
|
||||||
GLfloat half_width = ctx->ViewportArray[0].Width * 0.5f;
|
GLfloat half_width = ctx->ViewportArray[i].Width * 0.5f;
|
||||||
GLfloat half_height = ctx->ViewportArray[0].Height * 0.5f;
|
GLfloat half_height = ctx->ViewportArray[i].Height * 0.5f;
|
||||||
GLfloat half_depth = (GLfloat)(ctx->ViewportArray[0].Far - ctx->ViewportArray[0].Near) * 0.5f;
|
GLfloat half_depth = (GLfloat)(ctx->ViewportArray[i].Far - ctx->ViewportArray[i].Near) * 0.5f;
|
||||||
|
|
||||||
st->state.viewport.scale[0] = half_width;
|
st->state.viewport[i].scale[0] = half_width;
|
||||||
st->state.viewport.scale[1] = half_height * yScale;
|
st->state.viewport[i].scale[1] = half_height * yScale;
|
||||||
st->state.viewport.scale[2] = half_depth;
|
st->state.viewport[i].scale[2] = half_depth;
|
||||||
st->state.viewport.scale[3] = 1.0;
|
st->state.viewport[i].scale[3] = 1.0;
|
||||||
|
|
||||||
st->state.viewport.translate[0] = half_width + x;
|
st->state.viewport[i].translate[0] = half_width + x;
|
||||||
st->state.viewport.translate[1] = (half_height + y) * yScale + yBias;
|
st->state.viewport[i].translate[1] = (half_height + y) * yScale + yBias;
|
||||||
st->state.viewport.translate[2] = half_depth + z;
|
st->state.viewport[i].translate[2] = half_depth + z;
|
||||||
st->state.viewport.translate[3] = 0.0;
|
st->state.viewport[i].translate[3] = 0.0;
|
||||||
|
|
||||||
cso_set_viewport(st->cso_context, &st->state.viewport);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cso_set_viewport(st->cso_context, &st->state.viewport[0]);
|
||||||
|
if (ctx->Const.MaxViewports > 1)
|
||||||
|
st->pipe->set_viewport_states(st->pipe, 1, ctx->Const.MaxViewports - 1, &st->state.viewport[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,8 +115,8 @@ struct st_context
|
||||||
unsigned size;
|
unsigned size;
|
||||||
} constants[PIPE_SHADER_TYPES];
|
} constants[PIPE_SHADER_TYPES];
|
||||||
struct pipe_framebuffer_state framebuffer;
|
struct pipe_framebuffer_state framebuffer;
|
||||||
struct pipe_scissor_state scissor;
|
struct pipe_scissor_state scissor[PIPE_MAX_VIEWPORTS];
|
||||||
struct pipe_viewport_state viewport;
|
struct pipe_viewport_state viewport[PIPE_MAX_VIEWPORTS];
|
||||||
unsigned sample_mask;
|
unsigned sample_mask;
|
||||||
|
|
||||||
GLuint poly_stipple[32]; /**< In OpenGL's bottom-to-top order */
|
GLuint poly_stipple[32]; /**< In OpenGL's bottom-to-top order */
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
|
||||||
* code sends state updates to the pipe, not to our private draw module.
|
* code sends state updates to the pipe, not to our private draw module.
|
||||||
*/
|
*/
|
||||||
assert(draw);
|
assert(draw);
|
||||||
draw_set_viewport_states(draw, 0, 1, &st->state.viewport);
|
draw_set_viewport_states(draw, 0, 1, &st->state.viewport[0]);
|
||||||
draw_set_clip_state(draw, &st->state.clip);
|
draw_set_clip_state(draw, &st->state.clip);
|
||||||
draw_set_rasterizer_state(draw, &st->state.rasterizer, NULL);
|
draw_set_rasterizer_state(draw, &st->state.rasterizer, NULL);
|
||||||
draw_bind_vertex_shader(draw, st->vp_variant->draw_shader);
|
draw_bind_vertex_shader(draw, st->vp_variant->draw_shader);
|
||||||
|
|
|
||||||
|
|
@ -779,4 +779,13 @@ void st_init_extensions(struct st_context *st)
|
||||||
if (!ctx->Extensions.EXT_transform_feedback)
|
if (!ctx->Extensions.EXT_transform_feedback)
|
||||||
ctx->Const.DisableVaryingPacking = GL_TRUE;
|
ctx->Const.DisableVaryingPacking = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ctx->API == API_OPENGL_CORE) {
|
||||||
|
ctx->Const.MaxViewports = screen->get_param(screen, PIPE_CAP_MAX_VIEWPORTS);
|
||||||
|
if (ctx->Const.MaxViewports >= 16) {
|
||||||
|
ctx->Const.ViewportBounds.Min = -(float)ctx->Const.MaxViewportWidth;
|
||||||
|
ctx->Const.ViewportBounds.Max = ctx->Const.MaxViewportWidth;
|
||||||
|
ctx->Extensions.ARB_viewport_array = GL_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue