diff options
author | Ilia Mirkin <[email protected]> | 2016-06-12 00:46:18 -0400 |
---|---|---|
committer | Ilia Mirkin <[email protected]> | 2016-06-18 13:38:30 -0400 |
commit | b21a00d1295d721275946e045e92920acdcb1a85 (patch) | |
tree | 737ab6c6b8be2cdc991426406936a58b3ca7dca5 /src/gallium/drivers | |
parent | d1bdc1238a39469e6760758876e8832019795a54 (diff) |
nvc0: add support for GL_EXT_window_rectangles
Signed-off-by: Ilia Mirkin <[email protected]>
Reviewed-by: Samuel Pitoiset <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/nouveau/nvc0/nvc0_context.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nvc0/nvc0_screen.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nvc0/nvc0_state.c | 17 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c | 25 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nvc0/nvc0_stateobj.h | 6 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nvc0/nvc0_surface.c | 22 |
7 files changed, 72 insertions, 5 deletions
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h index 1b3f88becdd..fe9f9f56e0a 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h @@ -58,6 +58,7 @@ #define NVC0_NEW_3D_TESSFACTOR (1 << 25) #define NVC0_NEW_3D_BUFFERS (1 << 26) #define NVC0_NEW_3D_DRIVERCONST (1 << 27) +#define NVC0_NEW_3D_WINDOW_RECTS (1 << 28) #define NVC0_NEW_CP_PROGRAM (1 << 0) #define NVC0_NEW_CP_SURFACES (1 << 1) @@ -214,6 +215,7 @@ struct nvc0_context { struct pipe_viewport_state viewports[NVC0_MAX_VIEWPORTS]; unsigned viewports_dirty; struct pipe_clip_state clip; + struct nvc0_window_rect_stateobj window_rect; unsigned sample_mask; unsigned min_samples; diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c index 1afa43a0b5c..08ec4136880 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c @@ -157,6 +157,8 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) return PIPE_ENDIAN_LITTLE; case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS: return 30; + case PIPE_CAP_MAX_WINDOW_RECTANGLES: + return NVC0_MAX_WINDOW_RECTANGLES; /* supported caps */ case PIPE_CAP_TEXTURE_MIRROR_CLAMP: @@ -261,7 +263,6 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_PCI_BUS: case PIPE_CAP_PCI_DEVICE: case PIPE_CAP_PCI_FUNCTION: - case PIPE_CAP_MAX_WINDOW_RECTANGLES: return 0; case PIPE_CAP_VENDOR_ID: diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h index b6edc33993d..4a89794853f 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h @@ -25,6 +25,8 @@ #define NVC0_MAX_IMAGES 8 +#define NVC0_MAX_WINDOW_RECTANGLES 8 + struct nvc0_context; struct nvc0_blitter; diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c index 92161ec9e65..7e42be76bf1 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c @@ -1000,6 +1000,22 @@ nvc0_set_viewport_states(struct pipe_context *pipe, } static void +nvc0_set_window_rectangles(struct pipe_context *pipe, + boolean include, + unsigned num_rectangles, + const struct pipe_scissor_state *rectangles) +{ + struct nvc0_context *nvc0 = nvc0_context(pipe); + + nvc0->window_rect.inclusive = include; + nvc0->window_rect.rects = MIN2(num_rectangles, NVC0_MAX_WINDOW_RECTANGLES); + memcpy(nvc0->window_rect.rect, rectangles, + sizeof(struct pipe_scissor_state) * nvc0->window_rect.rects); + + nvc0->dirty_3d |= NVC0_NEW_3D_WINDOW_RECTS; +} + +static void nvc0_set_tess_state(struct pipe_context *pipe, const float default_tess_outer[4], const float default_tess_inner[2]) @@ -1490,6 +1506,7 @@ nvc0_init_state_functions(struct nvc0_context *nvc0) pipe->set_polygon_stipple = nvc0_set_polygon_stipple; pipe->set_scissor_states = nvc0_set_scissor_states; pipe->set_viewport_states = nvc0_set_viewport_states; + pipe->set_window_rectangles = nvc0_set_window_rectangles; pipe->set_tess_state = nvc0_set_tess_state; pipe->create_vertex_elements_state = nvc0_vertex_state_create; diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c index ad44e859a7c..05c15ce070a 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c @@ -326,6 +326,30 @@ nvc0_validate_viewport(struct nvc0_context *nvc0) nvc0->viewports_dirty = 0; } +static void +nvc0_validate_window_rects(struct nvc0_context *nvc0) +{ + struct nouveau_pushbuf *push = nvc0->base.pushbuf; + bool enable = nvc0->window_rect.rects > 0 || nvc0->window_rect.inclusive; + int i; + + IMMED_NVC0(push, NVC0_3D(CLIP_RECTS_EN), enable); + if (!enable) + return; + + IMMED_NVC0(push, NVC0_3D(CLIP_RECTS_MODE), !nvc0->window_rect.inclusive); + BEGIN_NVC0(push, NVC0_3D(CLIP_RECT_HORIZ(0)), NVC0_MAX_WINDOW_RECTANGLES * 2); + for (i = 0; i < nvc0->window_rect.rects; i++) { + struct pipe_scissor_state *s = &nvc0->window_rect.rect[i]; + PUSH_DATA(push, (s->maxx << 16) | s->minx); + PUSH_DATA(push, (s->maxy << 16) | s->miny); + } + for (; i < NVC0_MAX_WINDOW_RECTANGLES; i++) { + PUSH_DATA(push, 0); + PUSH_DATA(push, 0); + } +} + static inline void nvc0_upload_uclip_planes(struct nvc0_context *nvc0, unsigned s) { @@ -716,6 +740,7 @@ validate_list_3d[] = { { nvc0_validate_stipple, NVC0_NEW_3D_STIPPLE }, { nvc0_validate_scissor, NVC0_NEW_3D_SCISSOR | NVC0_NEW_3D_RASTERIZER }, { nvc0_validate_viewport, NVC0_NEW_3D_VIEWPORT }, + { nvc0_validate_window_rects, NVC0_NEW_3D_WINDOW_RECTS }, { nvc0_vertprog_validate, NVC0_NEW_3D_VERTPROG }, { nvc0_tctlprog_validate, NVC0_NEW_3D_TCTLPROG }, { nvc0_tevlprog_validate, NVC0_NEW_3D_TEVLPROG }, diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_stateobj.h b/src/gallium/drivers/nouveau/nvc0/nvc0_stateobj.h index f9680f5a90f..c900fcadcb7 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_stateobj.h +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_stateobj.h @@ -61,6 +61,12 @@ struct nvc0_vertex_stateobj { struct nvc0_vertex_element element[0]; }; +struct nvc0_window_rect_stateobj { + bool inclusive; + unsigned rects; + struct pipe_scissor_state rect[PIPE_MAX_WINDOW_RECTANGLES]; +}; + struct nvc0_so_target { struct pipe_stream_output_target pipe; struct pipe_query *pq; diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c index a1775698a3d..7556e7133fc 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c @@ -782,6 +782,7 @@ struct nvc0_blitctx enum pipe_texture_target target; struct { struct pipe_framebuffer_state fb; + struct nvc0_window_rect_stateobj window_rect; struct nvc0_rasterizer_stateobj *rast; struct nvc0_program *vp; struct nvc0_program *tcp; @@ -1035,7 +1036,8 @@ nvc0_blitctx_prepare_state(struct nvc0_blitctx *blit) } static void -nvc0_blitctx_pre_blit(struct nvc0_blitctx *ctx) +nvc0_blitctx_pre_blit(struct nvc0_blitctx *ctx, + const struct pipe_blit_info *info) { struct nvc0_context *nvc0 = ctx->nvc0; struct nvc0_blitter *blitter = nvc0->screen->blitter; @@ -1058,6 +1060,7 @@ nvc0_blitctx_pre_blit(struct nvc0_blitctx *ctx) ctx->saved.fp = nvc0->fragprog; ctx->saved.min_samples = nvc0->min_samples; + ctx->saved.window_rect = nvc0->window_rect; nvc0->rast = &ctx->rast; @@ -1067,6 +1070,13 @@ nvc0_blitctx_pre_blit(struct nvc0_blitctx *ctx) nvc0->gmtyprog = NULL; nvc0->fragprog = ctx->fp; + nvc0->window_rect.rects = + MIN2(info->num_window_rectangles, NVC0_MAX_WINDOW_RECTANGLES); + nvc0->window_rect.inclusive = info->window_rectangle_include; + if (nvc0->window_rect.rects) + memcpy(nvc0->window_rect.rect, info->window_rectangles, + sizeof(struct pipe_scissor_state) * nvc0->window_rect.rects); + for (s = 0; s <= 4; ++s) { ctx->saved.num_textures[s] = nvc0->num_textures[s]; ctx->saved.num_samplers[s] = nvc0->num_samplers[s]; @@ -1099,7 +1109,7 @@ nvc0_blitctx_pre_blit(struct nvc0_blitctx *ctx) nvc0->dirty_3d = NVC0_NEW_3D_FRAMEBUFFER | NVC0_NEW_3D_MIN_SAMPLES | NVC0_NEW_3D_VERTPROG | NVC0_NEW_3D_FRAGPROG | NVC0_NEW_3D_TCTLPROG | NVC0_NEW_3D_TEVLPROG | NVC0_NEW_3D_GMTYPROG | - NVC0_NEW_3D_TEXTURES | NVC0_NEW_3D_SAMPLERS; + NVC0_NEW_3D_TEXTURES | NVC0_NEW_3D_SAMPLERS | NVC0_NEW_3D_WINDOW_RECTS; } static void @@ -1127,6 +1137,7 @@ nvc0_blitctx_post_blit(struct nvc0_blitctx *blit) nvc0->fragprog = blit->saved.fp; nvc0->min_samples = blit->saved.min_samples; + nvc0->window_rect = blit->saved.window_rect; pipe_sampler_view_reference(&nvc0->textures[4][0], NULL); pipe_sampler_view_reference(&nvc0->textures[4][1], NULL); @@ -1158,7 +1169,7 @@ nvc0_blitctx_post_blit(struct nvc0_blitctx *blit) nvc0->dirty_3d = blit->saved.dirty_3d | (NVC0_NEW_3D_FRAMEBUFFER | NVC0_NEW_3D_SCISSOR | NVC0_NEW_3D_SAMPLE_MASK | NVC0_NEW_3D_RASTERIZER | NVC0_NEW_3D_ZSA | NVC0_NEW_3D_BLEND | - NVC0_NEW_3D_VIEWPORT | + NVC0_NEW_3D_VIEWPORT | NVC0_NEW_3D_WINDOW_RECTS | NVC0_NEW_3D_TEXTURES | NVC0_NEW_3D_SAMPLERS | NVC0_NEW_3D_VERTPROG | NVC0_NEW_3D_FRAGPROG | NVC0_NEW_3D_TCTLPROG | NVC0_NEW_3D_TEVLPROG | NVC0_NEW_3D_GMTYPROG | @@ -1191,7 +1202,7 @@ nvc0_blit_3d(struct nvc0_context *nvc0, const struct pipe_blit_info *info) blit->render_condition_enable = info->render_condition_enable; nvc0_blit_select_fp(blit, info); - nvc0_blitctx_pre_blit(blit); + nvc0_blitctx_pre_blit(blit, info); nvc0_blit_set_dst(blit, dst, info->dst.level, -1, info->dst.format); nvc0_blit_set_src(blit, src, info->src.level, -1, info->src.format, @@ -1606,6 +1617,9 @@ nvc0_blit(struct pipe_context *pipe, const struct pipe_blit_info *info) info->src.box.height != -info->dst.box.height)) eng3d = true; + if (info->num_window_rectangles > 0 || info->window_rectangle_include) + eng3d = true; + if (nvc0->screen->num_occlusion_queries_active) IMMED_NVC0(push, NVC0_3D(SAMPLECNT_ENABLE), 0); |