X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fgallium%2Fdrivers%2Fsvga%2Fsvga_state_constants.c;h=8d6b46a1cae8545a98f6d69034bee2ed7eddd8d1;hb=8dee325752daf1850a1f497c82b30d0574a5b612;hp=8784f47413f12c254e80ce883907831cb8558e41;hpb=c4cb879f00de89c300462e7b2d0f221d920c396f;p=mesa.git diff --git a/src/gallium/drivers/svga/svga_state_constants.c b/src/gallium/drivers/svga/svga_state_constants.c index 8784f47413f..8d6b46a1cae 100644 --- a/src/gallium/drivers/svga/svga_state_constants.c +++ b/src/gallium/drivers/svga/svga_state_constants.c @@ -65,7 +65,7 @@ static unsigned svga_get_extra_constants_common(struct svga_context *svga, const struct svga_shader_variant *variant, - unsigned shader, float *dest) + enum pipe_shader_type shader, float *dest) { uint32_t *dest_u = (uint32_t *) dest; // uint version of dest unsigned i; @@ -271,7 +271,7 @@ svga_get_extra_gs_constants(struct svga_context *svga, float *dest) * \param value the new float[4] value */ static enum pipe_error -emit_const(struct svga_context *svga, unsigned shader, unsigned i, +emit_const(struct svga_context *svga, enum pipe_shader_type shader, unsigned i, const float *value) { enum pipe_error ret = PIPE_OK; @@ -316,7 +316,7 @@ emit_const(struct svga_context *svga, unsigned shader, unsigned i, */ static enum pipe_error emit_const_range(struct svga_context *svga, - unsigned shader, + enum pipe_shader_type shader, unsigned offset, unsigned count, const float (*values)[4]) @@ -439,7 +439,7 @@ emit_const_range(struct svga_context *svga, * On VGPU10, emit_consts_vgpu10 is used instead. */ static enum pipe_error -emit_consts_vgpu9(struct svga_context *svga, unsigned shader) +emit_consts_vgpu9(struct svga_context *svga, enum pipe_shader_type shader) { const struct pipe_constant_buffer *cbuf; struct svga_screen *ss = svga_screen(svga->pipe.screen); @@ -541,7 +541,7 @@ emit_consts_vgpu9(struct svga_context *svga, unsigned shader) static enum pipe_error -emit_constbuf_vgpu10(struct svga_context *svga, unsigned shader) +emit_constbuf_vgpu10(struct svga_context *svga, enum pipe_shader_type shader) { const struct pipe_constant_buffer *cbuf; struct pipe_resource *dst_buffer = NULL; @@ -646,15 +646,29 @@ emit_constbuf_vgpu10(struct svga_context *svga, unsigned shader) assert(extra_offset + extra_size <= new_buf_size); memcpy((char *) dst_map + extra_offset, extras, extra_size); } - u_upload_unmap(svga->const0_upload); - /* Issue the SetSingleConstantBuffer command */ - dst_handle = svga_buffer_handle(svga, dst_buffer); - if (!dst_handle) { - pipe_resource_reference(&dst_buffer, NULL); - return PIPE_ERROR_OUT_OF_MEMORY; + /* Get winsys handle for the constant buffer */ + if (svga->state.hw_draw.const0_buffer == dst_buffer && + svga->state.hw_draw.const0_handle) { + /* re-reference already mapped buffer */ + dst_handle = svga->state.hw_draw.const0_handle; + } + else { + /* we must unmap the buffer before getting the winsys handle */ + u_upload_unmap(svga->const0_upload); + + dst_handle = svga_buffer_handle(svga, dst_buffer); + if (!dst_handle) { + pipe_resource_reference(&dst_buffer, NULL); + return PIPE_ERROR_OUT_OF_MEMORY; + } + + /* save the buffer / handle for next time */ + pipe_resource_reference(&svga->state.hw_draw.const0_buffer, dst_buffer); + svga->state.hw_draw.const0_handle = dst_handle; } + /* Issue the SetSingleConstantBuffer command */ assert(new_buf_size % 16 == 0); ret = SVGA3D_vgpu10_SetSingleConstantBuffer(svga->swc, 0, /* index */ @@ -686,7 +700,7 @@ emit_constbuf_vgpu10(struct svga_context *svga, unsigned shader) static enum pipe_error -emit_consts_vgpu10(struct svga_context *svga, unsigned shader) +emit_consts_vgpu10(struct svga_context *svga, enum pipe_shader_type shader) { enum pipe_error ret; unsigned dirty_constbufs;