diff options
Diffstat (limited to 'lib/mesa/src')
-rw-r--r-- | lib/mesa/src/gallium/drivers/svga/svga_link.c | 15 | ||||
-rw-r--r-- | lib/mesa/src/gallium/drivers/svga/svga_pipe_streamout.c | 44 | ||||
-rw-r--r-- | lib/mesa/src/gallium/drivers/svga/svga_state_sampler.c | 178 | ||||
-rw-r--r-- | lib/mesa/src/gallium/drivers/virgl/virgl_context.h | 5 | ||||
-rw-r--r-- | lib/mesa/src/gallium/drivers/virgl/virgl_tgsi.c | 11 |
5 files changed, 74 insertions, 179 deletions
diff --git a/lib/mesa/src/gallium/drivers/svga/svga_link.c b/lib/mesa/src/gallium/drivers/svga/svga_link.c index 9c1df0c7f..f3e524d38 100644 --- a/lib/mesa/src/gallium/drivers/svga/svga_link.c +++ b/lib/mesa/src/gallium/drivers/svga/svga_link.c @@ -25,7 +25,6 @@ #include "svga_context.h" #include "svga_link.h" -#include "svga_debug.h" #include "tgsi/tgsi_strings.h" @@ -46,7 +45,7 @@ svga_link_shaders(const struct tgsi_shader_info *outshader_info, { unsigned i, free_slot; - for (i = 0; i < ARRAY_SIZE(linkage->input_map); i++) { + for (i = 0; i < Elements(linkage->input_map); i++) { linkage->input_map[i] = INVALID_INDEX; } @@ -56,13 +55,13 @@ svga_link_shaders(const struct tgsi_shader_info *outshader_info, * We'll modify the input shader's inputs to match the output shader. */ assert(inshader_info->num_inputs <= - ARRAY_SIZE(inshader_info->input_semantic_name)); + Elements(inshader_info->input_semantic_name)); /* free register index that can be used for built-in varyings */ free_slot = outshader_info->num_outputs + 1; for (i = 0; i < inshader_info->num_inputs; i++) { - enum tgsi_semantic sem_name = inshader_info->input_semantic_name[i]; + unsigned sem_name = inshader_info->input_semantic_name[i]; unsigned sem_index = inshader_info->input_semantic_index[i]; unsigned j; /** @@ -77,7 +76,7 @@ svga_link_shaders(const struct tgsi_shader_info *outshader_info, else { /* search output shader outputs for same item */ for (j = 0; j < outshader_info->num_outputs; j++) { - assert(j < ARRAY_SIZE(outshader_info->output_semantic_name)); + assert(j < Elements(outshader_info->output_semantic_name)); if (outshader_info->output_semantic_name[j] == sem_name && outshader_info->output_semantic_index[j] == sem_index) { linkage->input_map[i] = j; @@ -98,15 +97,13 @@ svga_link_shaders(const struct tgsi_shader_info *outshader_info, } /* Debug */ - if (SVGA_DEBUG & DEBUG_TGSI) { + if (0) { unsigned reg = 0; - debug_printf("### linkage info:\n"); - for (i = 0; i < linkage->num_inputs; i++) { assert(linkage->input_map[i] != INVALID_INDEX); - debug_printf(" input[%d] slot %u %s %u %s\n", + debug_printf("input shader input[%d] slot %u %s %u %s\n", i, linkage->input_map[i], tgsi_semantic_names[inshader_info->input_semantic_name[i]], diff --git a/lib/mesa/src/gallium/drivers/svga/svga_pipe_streamout.c b/lib/mesa/src/gallium/drivers/svga/svga_pipe_streamout.c index 0c6c03475..3f443c44e 100644 --- a/lib/mesa/src/gallium/drivers/svga/svga_pipe_streamout.c +++ b/lib/mesa/src/gallium/drivers/svga/svga_pipe_streamout.c @@ -92,8 +92,7 @@ svga_create_stream_output(struct svga_context *svga, for (i = 0; i < info->num_outputs; i++) { unsigned reg_idx = info->output[i].register_index; unsigned buf_idx = info->output[i].output_buffer; - const enum tgsi_semantic sem_name = - shader->info.output_semantic_name[reg_idx]; + const unsigned sem_name = shader->info.output_semantic_name[reg_idx]; assert(buf_idx <= PIPE_MAX_SO_BUFFERS); @@ -158,6 +157,7 @@ enum pipe_error svga_set_stream_output(struct svga_context *svga, struct svga_stream_output *streamout) { + enum pipe_error ret = PIPE_OK; unsigned id = streamout ? streamout->id : SVGA3D_INVALID_ID; if (!svga_have_vgpu10(svga)) { @@ -168,15 +168,17 @@ svga_set_stream_output(struct svga_context *svga, streamout, id); if (svga->current_so != streamout) { - enum pipe_error ret = SVGA3D_vgpu10_SetStreamOutput(svga->swc, id); + /* Save current SO state */ + svga->current_so = streamout; + + ret = SVGA3D_vgpu10_SetStreamOutput(svga->swc, id); if (ret != PIPE_OK) { - return ret; + svga_context_flush(svga, NULL); + ret = SVGA3D_vgpu10_SetStreamOutput(svga->swc, id); } - - svga->current_so = streamout; } - return PIPE_OK; + return ret; } void @@ -274,14 +276,13 @@ svga_set_stream_output_targets(struct pipe_context *pipe, for (i = 0; i < num_targets; i++) { struct svga_stream_output_target *sot = svga_stream_output_target(targets[i]); + struct svga_buffer *sbuf = svga_buffer(sot->base.buffer); unsigned size; - svga->so_surfaces[i] = svga_buffer_handle(svga, sot->base.buffer, - PIPE_BIND_STREAM_OUTPUT); - - assert(svga_buffer(sot->base.buffer)->key.flags - & SVGA3D_SURFACE_BIND_STREAM_OUTPUT); + assert(sbuf->key.flags & SVGA3D_SURFACE_BIND_STREAM_OUTPUT); + (void) sbuf; + svga->so_surfaces[i] = svga_buffer_handle(svga, sot->base.buffer); svga->so_targets[i] = &sot->base; soBindings[i].offset = sot->base.buffer_offset; @@ -310,25 +311,6 @@ svga_set_stream_output_targets(struct pipe_context *pipe, svga->num_so_targets = num_targets; } -/** - * Rebind stream output target surfaces - */ -enum pipe_error -svga_rebind_stream_output_targets(struct svga_context *svga) -{ - struct svga_winsys_context *swc = svga->swc; - enum pipe_error ret; - unsigned i; - - for (i = 0; i < svga->num_so_targets; i++) { - ret = swc->resource_rebind(swc, svga->so_surfaces[i], NULL, SVGA_RELOC_WRITE); - if (ret != PIPE_OK) - return ret; - } - - return PIPE_OK; -} - void svga_init_stream_output_functions(struct svga_context *svga) { diff --git a/lib/mesa/src/gallium/drivers/svga/svga_state_sampler.c b/lib/mesa/src/gallium/drivers/svga/svga_state_sampler.c index c361dba67..e7b540cc7 100644 --- a/lib/mesa/src/gallium/drivers/svga/svga_state_sampler.c +++ b/lib/mesa/src/gallium/drivers/svga/svga_state_sampler.c @@ -30,7 +30,6 @@ #include "pipe/p_defines.h" #include "util/u_bitmask.h" -#include "util/u_format.h" #include "util/u_inlines.h" #include "util/u_math.h" #include "util/u_memory.h" @@ -40,11 +39,10 @@ #include "svga_format.h" #include "svga_resource_buffer.h" #include "svga_resource_texture.h" -#include "svga_sampler_view.h" #include "svga_shader.h" #include "svga_state.h" -#include "svga_surface.h" -#include "svga3d_surfacedefs.h" +#include "svga_sampler_view.h" + /** Get resource handle for a texture or buffer */ static inline struct svga_winsys_surface * @@ -64,9 +62,9 @@ svga_resource_handle(struct pipe_resource *res) * any of the resources bound to any of the currently bound sampler views. */ boolean -svga_check_sampler_view_resource_collision(const struct svga_context *svga, - const struct svga_winsys_surface *res, - enum pipe_shader_type shader) +svga_check_sampler_view_resource_collision(struct svga_context *svga, + struct svga_winsys_surface *res, + unsigned shader) { struct pipe_screen *screen = svga->pipe.screen; unsigned i; @@ -89,36 +87,6 @@ svga_check_sampler_view_resource_collision(const struct svga_context *svga, /** - * Check if there are any resources that are both bound to a render target - * and bound as a shader resource for the given type of shader. - */ -boolean -svga_check_sampler_framebuffer_resource_collision(struct svga_context *svga, - enum pipe_shader_type shader) -{ - struct svga_surface *surf; - unsigned i; - - for (i = 0; i < svga->curr.framebuffer.nr_cbufs; i++) { - surf = svga_surface(svga->curr.framebuffer.cbufs[i]); - if (surf && - svga_check_sampler_view_resource_collision(svga, surf->handle, - shader)) { - return TRUE; - } - } - - surf = svga_surface(svga->curr.framebuffer.zsbuf); - if (surf && - svga_check_sampler_view_resource_collision(svga, surf->handle, shader)) { - return TRUE; - } - - return FALSE; -} - - -/** * Create a DX ShaderResourceSamplerView for the given pipe_sampler_view, * if needed. */ @@ -135,21 +103,8 @@ svga_validate_pipe_sampler_view(struct svga_context *svga, SVGA3dSurfaceFormat format; SVGA3dResourceType resourceDim; SVGA3dShaderResourceViewDesc viewDesc; - enum pipe_format viewFormat = sv->base.format; - - /* vgpu10 cannot create a BGRX view for a BGRA resource, so force it to - * create a BGRA view (and vice versa). - */ - if (viewFormat == PIPE_FORMAT_B8G8R8X8_UNORM && - svga_texture_device_format_has_alpha(texture)) { - viewFormat = PIPE_FORMAT_B8G8R8A8_UNORM; - } - else if (viewFormat == PIPE_FORMAT_B8G8R8A8_UNORM && - !svga_texture_device_format_has_alpha(texture)) { - viewFormat = PIPE_FORMAT_B8G8R8X8_UNORM; - } - format = svga_translate_format(ss, viewFormat, + format = svga_translate_format(ss, sv->base.format, PIPE_BIND_SAMPLER_VIEW); assert(format != SVGA3D_FORMAT_INVALID); @@ -157,10 +112,9 @@ svga_validate_pipe_sampler_view(struct svga_context *svga, format = svga_sampler_format(format); if (texture->target == PIPE_BUFFER) { - unsigned elem_size = util_format_get_blocksize(sv->base.format); - - viewDesc.buffer.firstElement = sv->base.u.buf.offset / elem_size; - viewDesc.buffer.numElements = sv->base.u.buf.size / elem_size; + viewDesc.buffer.firstElement = sv->base.u.buf.first_element; + viewDesc.buffer.numElements = (sv->base.u.buf.last_element - + sv->base.u.buf.first_element + 1); } else { viewDesc.tex.mostDetailedMip = sv->base.u.tex.first_level; @@ -228,7 +182,7 @@ static enum pipe_error update_sampler_resources(struct svga_context *svga, unsigned dirty) { enum pipe_error ret = PIPE_OK; - enum pipe_shader_type shader; + unsigned shader; if (!svga_have_vgpu10(svga)) return PIPE_OK; @@ -236,7 +190,6 @@ update_sampler_resources(struct svga_context *svga, unsigned dirty) for (shader = PIPE_SHADER_VERTEX; shader <= PIPE_SHADER_GEOMETRY; shader++) { SVGA3dShaderResourceViewId ids[PIPE_MAX_SAMPLERS]; struct svga_winsys_surface *surfaces[PIPE_MAX_SAMPLERS]; - struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; unsigned count; unsigned nviews; unsigned i; @@ -245,9 +198,10 @@ update_sampler_resources(struct svga_context *svga, unsigned dirty) for (i = 0; i < count; i++) { struct svga_pipe_sampler_view *sv = svga_pipe_sampler_view(svga->curr.sampler_views[shader][i]); + struct svga_winsys_surface *surface; if (sv) { - surfaces[i] = svga_resource_handle(sv->base.texture); + surface = svga_resource_handle(sv->base.texture); ret = svga_validate_pipe_sampler_view(svga, sv); if (ret != PIPE_OK) @@ -255,19 +209,39 @@ update_sampler_resources(struct svga_context *svga, unsigned dirty) assert(sv->id != SVGA3D_INVALID_ID); ids[i] = sv->id; - sampler_views[i] = &sv->base; } else { - surfaces[i] = NULL; + surface = NULL; ids[i] = SVGA3D_INVALID_ID; - sampler_views[i] = NULL; } + surfaces[i] = surface; } - for (; i < svga->state.hw_draw.num_sampler_views[shader]; i++) { + for (; i < Elements(ids); i++) { ids[i] = SVGA3D_INVALID_ID; surfaces[i] = NULL; - sampler_views[i] = NULL; + } + + if (shader == PIPE_SHADER_FRAGMENT) { + /* Handle polygon stipple sampler view */ + if (svga->curr.rast->templ.poly_stipple_enable) { + const unsigned unit = svga->state.hw_draw.fs->pstipple_sampler_unit; + struct svga_pipe_sampler_view *sv = + svga->polygon_stipple.sampler_view; + + assert(sv); + if (!sv) { + return PIPE_OK; /* probably out of memory */ + } + + ret = svga_validate_pipe_sampler_view(svga, sv); + if (ret != PIPE_OK) + return ret; + + ids[unit] = sv->id; + surfaces[unit] = svga_resource_handle(sv->base.texture); + count = MAX2(count, unit+1); + } } /* Number of ShaderResources that need to be modified. This includes @@ -275,53 +249,20 @@ update_sampler_resources(struct svga_context *svga, unsigned dirty) */ nviews = MAX2(svga->state.hw_draw.num_sampler_views[shader], count); if (nviews > 0) { - if (count != svga->state.hw_draw.num_sampler_views[shader] || - memcmp(sampler_views, svga->state.hw_draw.sampler_views[shader], - count * sizeof(sampler_views[0])) != 0) { - ret = SVGA3D_vgpu10_SetShaderResources(svga->swc, + ret = SVGA3D_vgpu10_SetShaderResources(svga->swc, svga_shader_type(shader), 0, /* startView */ nviews, ids, surfaces); - if (ret != PIPE_OK) - return ret; - - /* Save referenced sampler views in the hw draw state. */ - svga->state.hw_draw.num_sampler_views[shader] = count; - for (i = 0; i < nviews; i++) { - pipe_sampler_view_reference( - &svga->state.hw_draw.sampler_views[shader][i], - sampler_views[i]); - } - } - } - } - - /* Handle polygon stipple sampler view */ - if (svga->curr.rast->templ.poly_stipple_enable) { - const unsigned unit = svga->state.hw_draw.fs->pstipple_sampler_unit; - struct svga_pipe_sampler_view *sv = svga->polygon_stipple.sampler_view; - struct svga_winsys_surface *surface; - - assert(sv); - if (!sv) { - return PIPE_OK; /* probably out of memory */ + if (ret != PIPE_OK) + return ret; } - ret = svga_validate_pipe_sampler_view(svga, sv); - if (ret != PIPE_OK) - return ret; - - surface = svga_resource_handle(sv->base.texture); - ret = SVGA3D_vgpu10_SetShaderResources( - svga->swc, - svga_shader_type(PIPE_SHADER_FRAGMENT), - unit, /* startView */ - 1, - &sv->id, - &surface); + /* Number of sampler views enabled in the device */ + svga->state.hw_draw.num_sampler_views[shader] = count; } + return ret; } @@ -339,7 +280,7 @@ static enum pipe_error update_samplers(struct svga_context *svga, unsigned dirty ) { enum pipe_error ret = PIPE_OK; - enum pipe_shader_type shader; + unsigned shader; if (!svga_have_vgpu10(svga)) return PIPE_OK; @@ -348,7 +289,6 @@ update_samplers(struct svga_context *svga, unsigned dirty ) const unsigned count = svga->curr.num_samplers[shader]; SVGA3dSamplerId ids[PIPE_MAX_SAMPLERS]; unsigned i; - unsigned nsamplers; for (i = 0; i < count; i++) { if (svga->curr.sampler[shader][i]) { @@ -360,25 +300,20 @@ update_samplers(struct svga_context *svga, unsigned dirty ) } } - for (; i < svga->state.hw_draw.num_samplers[shader]; i++) { - ids[i] = SVGA3D_INVALID_ID; - } - - nsamplers = MAX2(svga->state.hw_draw.num_samplers[shader], count); - if (nsamplers > 0) { + if (count > 0) { if (count != svga->state.hw_draw.num_samplers[shader] || memcmp(ids, svga->state.hw_draw.samplers[shader], count * sizeof(ids[0])) != 0) { /* HW state is really changing */ ret = SVGA3D_vgpu10_SetSamplers(svga->swc, - nsamplers, + count, 0, /* start */ svga_shader_type(shader), /* type */ ids); if (ret != PIPE_OK) return ret; memcpy(svga->state.hw_draw.samplers[shader], ids, - nsamplers * sizeof(ids[0])); + count * sizeof(ids[0])); svga->state.hw_draw.num_samplers[shader] = count; } } @@ -394,20 +329,11 @@ update_samplers(struct svga_context *svga, unsigned dirty ) return PIPE_OK; /* probably out of memory */ } - if (svga->state.hw_draw.samplers[PIPE_SHADER_FRAGMENT][unit] - != sampler->id) { - ret = SVGA3D_vgpu10_SetSamplers(svga->swc, - 1, /* count */ - unit, /* start */ - SVGA3D_SHADERTYPE_PS, - &sampler->id); - if (ret != PIPE_OK) - return ret; - - /* save the polygon stipple sampler in the hw draw state */ - svga->state.hw_draw.samplers[PIPE_SHADER_FRAGMENT][unit] = - sampler->id; - } + ret = SVGA3D_vgpu10_SetSamplers(svga->swc, + 1, /* count */ + unit, /* start */ + SVGA3D_SHADERTYPE_PS, + &sampler->id); } return ret; diff --git a/lib/mesa/src/gallium/drivers/virgl/virgl_context.h b/lib/mesa/src/gallium/drivers/virgl/virgl_context.h index d8d4ccbb3..adb8adef3 100644 --- a/lib/mesa/src/gallium/drivers/virgl/virgl_context.h +++ b/lib/mesa/src/gallium/drivers/virgl/virgl_context.h @@ -25,7 +25,7 @@ #include "pipe/p_state.h" #include "pipe/p_context.h" -#include "util/slab.h" +#include "util/u_slab.h" #include "util/list.h" struct pipe_screen; @@ -56,8 +56,9 @@ struct virgl_context { struct pipe_framebuffer_state framebuffer; - struct slab_child_pool texture_transfer_pool; + struct util_slab_mempool texture_transfer_pool; + struct pipe_index_buffer index_buffer; struct u_upload_mgr *uploader; struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; diff --git a/lib/mesa/src/gallium/drivers/virgl/virgl_tgsi.c b/lib/mesa/src/gallium/drivers/virgl/virgl_tgsi.c index 7ad1cbdb8..641b0b3e3 100644 --- a/lib/mesa/src/gallium/drivers/virgl/virgl_tgsi.c +++ b/lib/mesa/src/gallium/drivers/virgl/virgl_tgsi.c @@ -40,7 +40,6 @@ virgl_tgsi_transform_property(struct tgsi_transform_context *ctx, switch (prop->Property.PropertyName) { case TGSI_PROPERTY_NUM_CLIPDIST_ENABLED: case TGSI_PROPERTY_NUM_CULLDIST_ENABLED: - case TGSI_PROPERTY_NEXT_SHADER: break; default: ctx->emit_property(ctx, prop); @@ -48,15 +47,6 @@ virgl_tgsi_transform_property(struct tgsi_transform_context *ctx, } } -static void -virgl_tgsi_transform_instruction(struct tgsi_transform_context *ctx, - struct tgsi_full_instruction *inst) -{ - if (inst->Instruction.Precise) - inst->Instruction.Precise = 0; - ctx->emit_instruction(ctx, inst); -} - struct tgsi_token *virgl_tgsi_transform(const struct tgsi_token *tokens_in) { @@ -70,7 +60,6 @@ struct tgsi_token *virgl_tgsi_transform(const struct tgsi_token *tokens_in) memset(&transform, 0, sizeof(transform)); transform.base.transform_property = virgl_tgsi_transform_property; - transform.base.transform_instruction = virgl_tgsi_transform_instruction; tgsi_transform_shader(tokens_in, new_tokens, newLen, &transform.base); return new_tokens; |