diff options
author | Kenneth Graunke <[email protected]> | 2018-01-09 23:13:16 -0800 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2019-02-21 10:26:04 -0800 |
commit | 3eadb1b3a1be98cd2f1d4787a4921d2e39f9901f (patch) | |
tree | c64d91c9a907ac8a3a2e7a9eed3043ed9ded3a36 /src/gallium | |
parent | e7c9bddda73d131887eb848b267b8bac74a8389e (diff) |
iris: framebuffers
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/iris/iris_context.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/iris/iris_state.c | 63 |
2 files changed, 40 insertions, 25 deletions
diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h index eed17bf2ee0..5a6ee906ab7 100644 --- a/src/gallium/drivers/iris/iris_context.h +++ b/src/gallium/drivers/iris/iris_context.h @@ -49,6 +49,7 @@ enum iris_dirty { IRIS_DIRTY_SCISSOR = (1ull << 10), IRIS_DIRTY_LINE_STIPPLE = (1ull << 11), IRIS_DIRTY_VERTEX_ELEMENTS = (1ull << 12), + IRIS_DIRTY_MULTISAMPLE = (1ull << 13), }; struct iris_depth_stencil_alpha_state; @@ -71,6 +72,7 @@ struct iris_context { struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissors[IRIS_MAX_VIEWPORTS]; struct pipe_stencil_ref stencil_ref; + struct pipe_framebuffer_state framebuffer; } state; }; diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index 00da80b4326..66f33fc242b 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -413,6 +413,7 @@ struct iris_rasterizer_state { bool flatshade; /* for shader state */ bool light_twoside; /* for shader state */ bool rasterizer_discard; /* for 3DSTATE_STREAMOUT */ + bool half_pixel_center; /* for 3DSTATE_MULTISAMPLE */ enum pipe_sprite_coord_mode sprite_coord_mode; /* PIPE_SPRITE_* */ uint8_t line_stipple_factor; @@ -450,7 +451,7 @@ iris_create_rasterizer_state(struct pipe_context *ctx, cso->line_stipple_factor = state->line_stipple_factor; cso->line_stipple_pattern = state->line_stipple_pattern; // for 3DSTATE_MULTISAMPLE, if we want it. - //cso->half_pixel_center = state->half_pixel_center; + cso->half_pixel_center = state->half_pixel_center; iris_pack_command(GENX(3DSTATE_SF), cso->sf, sf) { sf.StatisticsEnable = true; @@ -545,6 +546,10 @@ iris_bind_rasterizer_state(struct pipe_context *ctx, void *state) ice->state.dirty |= IRIS_DIRTY_LINE_STIPPLE; } + if (old_cso->half_pixel_center != new_cso->half_pixel_center) { + ice->state.dirty |= IRIS_DIRTY_MULTISAMPLE; + } + ice->state.cso_rast = new_cso; ice->state.dirty |= IRIS_DIRTY_RASTER; } @@ -985,34 +990,32 @@ iris_set_viewport_states(struct pipe_context *ctx, ice->state.dirty |= IRIS_DIRTY_SF_CL_VIEWPORT; } -struct iris_framebuffer_state { - struct pipe_framebuffer_state pipe; -}; - static void iris_set_framebuffer_state(struct pipe_context *ctx, const struct pipe_framebuffer_state *state) { -#if 0 struct iris_context *ice = (struct iris_context *) ctx; - struct iris_framebuffer_state *cso = - malloc(sizeof(struct iris_framebuffer_state)); + struct pipe_framebuffer_state *cso = &ice->state.framebuffer; - unsigned i; - for (i = 0; i < framebuffer->nr_cbufs; i++) - pipe_surface_reference(&cso->pipe.cbufs[i], framebuffer->cbufs[i]); - for (; i < vc5->framebuffer.nr_cbufs; i++) - pipe_surface_reference(&cso->pipe.cbufs[i], NULL); + if (cso->samples != state->samples) { + ice->state.dirty |= IRIS_DIRTY_MULTISAMPLE; + } - cso->pipe.nr_cbufs = state->nr_cbufs; + cso->width = state->width; + cso->height = state->height; + cso->layers = state->layers; + cso->samples = state->samples; - pipe_surface_reference(&cso->pipe.zsbuf, framebuffer->zsbuf); + unsigned i; + for (i = 0; i < state->nr_cbufs; i++) + pipe_surface_reference(&cso->cbufs[i], state->cbufs[i]); + for (; i < cso->nr_cbufs; i++) + pipe_surface_reference(&cso->cbufs[i], NULL); - // ice->state.cso_fb = cso; - // ice->state.dirty |= IRIS_DIRTY_FRAMEBUFFER; + cso->nr_cbufs = state->nr_cbufs; + + pipe_surface_reference(&cso->zsbuf, state->zsbuf); - // XXX: unreference them when destroying context -#endif } static void @@ -1286,6 +1289,18 @@ iris_upload_render_state(struct iris_context *ice, struct iris_batch *batch) iris_batch_emit(batch, cso->vf_instancing[i], sizeof(cso->vf_instancing[0])); } + for (int i = 0; i < cso->count; i++) { + /* TODO: vertexid, instanceid support */ + iris_emit_cmd(batch, GENX(3DSTATE_VF_SGVS), sgvs); + } + } + + if (dirty & IRIS_DIRTY_MULTISAMPLE) { + iris_emit_cmd(batch, GENX(3DSTATE_MULTISAMPLE), ms) { + ms.PixelLocation = + ice->state.cso_rast->half_pixel_center ? CENTER : UL_CORNER; + ms.NumberofMultisamples = ffs(ice->state.framebuffer.samples) - 1; + } } #if 0 @@ -1351,12 +1366,6 @@ iris_upload_render_state(struct iris_context *ice, struct iris_batch *batch) -> pipe_draw_info (index) 3DSTATE_VERTEX_BUFFERS -> pipe_vertex_buffer (set_vertex_buffer hook) - 3DSTATE_VERTEX_ELEMENTS - -> iris_vertex_element - 3DSTATE_VF_INSTANCING - -> iris_vertex_element - 3DSTATE_VF_SGVS - -> TODO ??? 3DSTATE_VF_COMPONENT_PACKING -> TODO ??? @@ -1374,6 +1383,10 @@ void iris_destroy_state(struct iris_context *ice) { // XXX: unreference resources/surfaces. + for (unsigned i = 0; i < ice->state.framebuffer.nr_cbufs; i++) { + pipe_surface_reference(&ice->state.framebuffer.cbufs[i], NULL); + } + pipe_surface_reference(&ice->state.framebuffer.zsbuf, NULL); } void |