diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2015-11-22 02:45:43 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2015-11-22 02:45:43 +0000 |
commit | 2ba37c52131b39d6d0ec2452a95ea7a9d7ea6b8f (patch) | |
tree | 2da543a02115219d34deffe911226f3f85f443ac /lib/mesa/src/gallium/drivers/llvmpipe | |
parent | e7a2786346bc6e40b27248cf122036d8c701fa22 (diff) |
import Mesa 11.0.6
Diffstat (limited to 'lib/mesa/src/gallium/drivers/llvmpipe')
8 files changed, 157 insertions, 205 deletions
diff --git a/lib/mesa/src/gallium/drivers/llvmpipe/SConscript b/lib/mesa/src/gallium/drivers/llvmpipe/SConscript index 74d7a9e16..3a51efcd5 100644 --- a/lib/mesa/src/gallium/drivers/llvmpipe/SConscript +++ b/lib/mesa/src/gallium/drivers/llvmpipe/SConscript @@ -4,12 +4,12 @@ import distutils.version Import('*') if not env['llvm']: - print('warning: LLVM disabled: not building llvmpipe') + print 'warning: LLVM disabled: not building llvmpipe' Return() env = env.Clone() -env.MSVC2013Compat() +env.MSVC2008Compat() llvmpipe = env.ConvenienceLibrary( target = 'llvmpipe', @@ -25,19 +25,25 @@ if not env['embedded']: env.Prepend(LIBS = [llvmpipe, gallium, mesautil]) tests = [ - 'arit', 'format', 'blend', 'conv', 'printf', ] + if not env['msvc']: + tests.append('arit') + for test in tests: testname = 'lp_test_' + test target = env.Program( target = testname, source = [testname + '.c', 'lp_test_main.c'], ) - env.UnitTest(testname, target) + env.InstallProgram(target) + + # http://www.scons.org/wiki/UnitTests + alias = env.Alias(testname, [target], target[0].abspath) + AlwaysBuild(alias) Export('llvmpipe') diff --git a/lib/mesa/src/gallium/drivers/llvmpipe/lp_context.h b/lib/mesa/src/gallium/drivers/llvmpipe/lp_context.h index 54d98fdbf..c273b25f0 100644 --- a/lib/mesa/src/gallium/drivers/llvmpipe/lp_context.h +++ b/lib/mesa/src/gallium/drivers/llvmpipe/lp_context.h @@ -81,6 +81,9 @@ struct llvmpipe_context { struct pipe_viewport_state viewports[PIPE_MAX_VIEWPORTS]; struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; + struct pipe_index_buffer index_buffer; + struct pipe_resource *mapped_vs_tex[PIPE_MAX_SHADER_SAMPLER_VIEWS]; + struct pipe_resource *mapped_gs_tex[PIPE_MAX_SHADER_SAMPLER_VIEWS]; unsigned num_samplers[PIPE_SHADER_TYPES]; unsigned num_sampler_views[PIPE_SHADER_TYPES]; @@ -105,22 +108,22 @@ struct llvmpipe_context { struct vertex_info vertex_info; /** Which vertex shader output slot contains color */ - int8_t color_slot[2]; + int color_slot[2]; /** Which vertex shader output slot contains bcolor */ - int8_t bcolor_slot[2]; + int bcolor_slot[2]; /** Which vertex shader output slot contains point size */ - int8_t psize_slot; + int psize_slot; /** Which vertex shader output slot contains viewport index */ - int8_t viewport_index_slot; + int viewport_index_slot; /** Which geometry shader output slot contains layer */ - int8_t layer_slot; + int layer_slot; /** A fake frontface output for unfilled primitives */ - int8_t face_slot; + int face_slot; /** Depth format and bias settings. */ boolean floating_point_depth; @@ -148,7 +151,7 @@ struct llvmpipe_context { /** Conditional query object and mode */ struct pipe_query *render_cond_query; - enum pipe_render_cond_flag render_cond_mode; + uint render_cond_mode; boolean render_cond_cond; /** The LLVMContext to use for LLVM related work */ @@ -157,8 +160,7 @@ struct llvmpipe_context { struct pipe_context * -llvmpipe_create_context(struct pipe_screen *screen, void *priv, - unsigned flags); +llvmpipe_create_context( struct pipe_screen *screen, void *priv ); struct pipe_resource * llvmpipe_user_buffer_create(struct pipe_screen *screen, diff --git a/lib/mesa/src/gallium/drivers/llvmpipe/lp_draw_arrays.c b/lib/mesa/src/gallium/drivers/llvmpipe/lp_draw_arrays.c index 2efe3ef5b..edfb20409 100644 --- a/lib/mesa/src/gallium/drivers/llvmpipe/lp_draw_arrays.c +++ b/lib/mesa/src/gallium/drivers/llvmpipe/lp_draw_arrays.c @@ -73,30 +73,33 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) * Map vertex buffers */ for (i = 0; i < lp->num_vertex_buffers; i++) { - const void *buf = lp->vertex_buffer[i].is_user_buffer ? - lp->vertex_buffer[i].buffer.user : NULL; + const void *buf = lp->vertex_buffer[i].user_buffer; size_t size = ~0; if (!buf) { - if (!lp->vertex_buffer[i].buffer.resource) { + if (!lp->vertex_buffer[i].buffer) { continue; } - buf = llvmpipe_resource_data(lp->vertex_buffer[i].buffer.resource); - size = lp->vertex_buffer[i].buffer.resource->width0; + buf = llvmpipe_resource_data(lp->vertex_buffer[i].buffer); + size = lp->vertex_buffer[i].buffer->width0; } draw_set_mapped_vertex_buffer(draw, i, buf, size); } /* Map index buffer, if present */ - if (info->index_size) { + if (info->indexed) { unsigned available_space = ~0; - mapped_indices = info->has_user_indices ? info->index.user : NULL; + mapped_indices = lp->index_buffer.user_buffer; if (!mapped_indices) { - mapped_indices = llvmpipe_resource_data(info->index.resource); - available_space = info->index.resource->width0; + mapped_indices = llvmpipe_resource_data(lp->index_buffer.buffer); + if (lp->index_buffer.buffer->width0 > lp->index_buffer.offset) + available_space = + (lp->index_buffer.buffer->width0 - lp->index_buffer.offset); + else + available_space = 0; } draw_set_indexes(draw, - (ubyte *) mapped_indices, - info->index_size, available_space); + (ubyte *) mapped_indices + lp->index_buffer.offset, + lp->index_buffer.index_size, available_space); } for (i = 0; i < lp->num_so_targets; i++) { @@ -146,6 +149,9 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) draw_vs_reset_so(lp->vs); } } + + llvmpipe_cleanup_vertex_sampling(lp); + llvmpipe_cleanup_geometry_sampling(lp); /* * TODO: Flush only when a user vertex/index buffer is present diff --git a/lib/mesa/src/gallium/drivers/llvmpipe/lp_setup_context.h b/lib/mesa/src/gallium/drivers/llvmpipe/lp_setup_context.h index 4b55fd922..2410e2384 100644 --- a/lib/mesa/src/gallium/drivers/llvmpipe/lp_setup_context.h +++ b/lib/mesa/src/gallium/drivers/llvmpipe/lp_setup_context.h @@ -105,10 +105,10 @@ struct lp_setup_context float pixel_offset; float line_width; float point_size; - int8_t psize_slot; - int8_t viewport_index_slot; - int8_t layer_slot; - int8_t face_slot; + float psize; + unsigned viewport_index_slot; + unsigned layer_slot; + int face_slot; struct pipe_framebuffer_state fb; struct u_rect framebuffer; @@ -133,7 +133,6 @@ struct lp_setup_context const struct lp_rast_state *stored; /**< what's in the scene */ struct lp_rast_state current; /**< currently set state */ struct pipe_resource *current_tex[PIPE_MAX_SHADER_SAMPLER_VIEWS]; - unsigned current_tex_num; } fs; /** fragment shader constants */ @@ -168,21 +167,6 @@ struct lp_setup_context const float (*v2)[4]); }; -static inline void -scissor_planes_needed(boolean scis_planes[4], const struct u_rect *bbox, - const struct u_rect *scissor) -{ - /* left */ - scis_planes[0] = (bbox->x0 < scissor->x0); - /* right */ - scis_planes[1] = (bbox->x1 > scissor->x1); - /* top */ - scis_planes[2] = (bbox->y0 < scissor->y0); - /* bottom */ - scis_planes[3] = (bbox->y1 > scissor->y1); -} - - void lp_setup_choose_triangle( struct lp_setup_context *setup ); void lp_setup_choose_line( struct lp_setup_context *setup ); void lp_setup_choose_point( struct lp_setup_context *setup ); @@ -215,11 +199,10 @@ lp_setup_alloc_triangle(struct lp_scene *scene, unsigned *tri_size); boolean -lp_setup_bin_triangle(struct lp_setup_context *setup, - struct lp_rast_triangle *tri, - const struct u_rect *bboxorig, - const struct u_rect *bbox, - int nr_planes, - unsigned scissor_index); +lp_setup_bin_triangle( struct lp_setup_context *setup, + struct lp_rast_triangle *tri, + const struct u_rect *bbox, + int nr_planes, + unsigned scissor_index ); #endif diff --git a/lib/mesa/src/gallium/drivers/llvmpipe/lp_setup_line.c b/lib/mesa/src/gallium/drivers/llvmpipe/lp_setup_line.c index d0bac5efb..a190254d9 100644 --- a/lib/mesa/src/gallium/drivers/llvmpipe/lp_setup_line.c +++ b/lib/mesa/src/gallium/drivers/llvmpipe/lp_setup_line.c @@ -288,9 +288,7 @@ try_setup_line( struct lp_setup_context *setup, struct lp_rast_plane *plane; struct lp_line_info info; float width = MAX2(1.0, setup->line_width); - const struct u_rect *scissor; - struct u_rect bbox, bboxpos; - boolean s_planes[4]; + struct u_rect bbox; unsigned tri_bytes; int x[4]; int y[4]; @@ -313,7 +311,6 @@ try_setup_line( struct lp_setup_context *setup, float y2diff; float dx, dy; float area; - const float (*pv)[4]; boolean draw_start; boolean draw_end; @@ -323,18 +320,19 @@ try_setup_line( struct lp_setup_context *setup, if (0) print_line(setup, v1, v2); - if (setup->flatshade_first) { - pv = v1; + if (setup->scissor_test) { + nr_planes = 8; + if (setup->viewport_index_slot > 0) { + unsigned *udata = (unsigned*)v1[setup->viewport_index_slot]; + viewport_index = lp_clamp_viewport_idx(*udata); + } } else { - pv = v2; - } - if (setup->viewport_index_slot > 0) { - unsigned *udata = (unsigned*)pv[setup->viewport_index_slot]; - viewport_index = lp_clamp_viewport_idx(*udata); + nr_planes = 4; } + if (setup->layer_slot > 0) { - layer = *(unsigned*)pv[setup->layer_slot]; + layer = *(unsigned*)v1[setup->layer_slot]; layer = MIN2(layer, scene->fb_max_layer); } @@ -581,24 +579,10 @@ try_setup_line( struct lp_setup_context *setup, return TRUE; } - bboxpos = bbox; - /* Can safely discard negative regions: */ - bboxpos.x0 = MAX2(bboxpos.x0, 0); - bboxpos.y0 = MAX2(bboxpos.y0, 0); - - nr_planes = 4; - /* - * Determine how many scissor planes we need, that is drop scissor - * edges if the bounding box of the tri is fully inside that edge. - */ - if (setup->scissor_test) { - /* why not just use draw_regions */ - scissor = &setup->scissors[viewport_index]; - scissor_planes_needed(s_planes, &bboxpos, scissor); - nr_planes += s_planes[0] + s_planes[1] + s_planes[2] + s_planes[3]; - } + bbox.x0 = MAX2(bbox.x0, 0); + bbox.y0 = MAX2(bbox.y0, 0); line = lp_setup_alloc_triangle(scene, key->num_inputs, @@ -653,25 +637,19 @@ try_setup_line( struct lp_setup_context *setup, line->inputs.layer = layer; line->inputs.viewport_index = viewport_index; - /* - * XXX: this code is mostly identical to the one in lp_setup_tri, except it - * uses 4 planes instead of 3. Could share the code (including the sse - * assembly, in fact we'd get the 4th plane for free). - * The only difference apart from storing the 4th plane would be some - * different shuffle for calculating dcdx/dcdy. - */ for (i = 0; i < 4; i++) { - /* half-edge constants, will be iterated over the whole render + /* half-edge constants, will be interated over the whole render * target. */ plane[i].c = IMUL64(plane[i].dcdx, x[i]) - IMUL64(plane[i].dcdy, y[i]); - /* correct for top-left vs. bottom-left fill convention. - */ + + /* correct for top-left vs. bottom-left fill convention. + */ if (plane[i].dcdx < 0) { /* both fill conventions want this - adjust for left edges */ - plane[i].c++; + plane[i].c++; } else if (plane[i].dcdx == 0) { if (setup->pixel_offset == 0) { @@ -717,45 +695,33 @@ try_setup_line( struct lp_setup_context *setup, * Note that otherwise, the scissor planes only vary in 'C' value, * and even then only on state-changes. Could alternatively store * these planes elsewhere. - * (Or only store the c value together with a bit indicating which - * scissor edge this is, so rasterization would treat them differently - * (easier to evaluate) to ordinary planes.) */ - if (nr_planes > 4) { - struct lp_rast_plane *plane_s = &plane[4]; - - if (s_planes[0]) { - plane_s->dcdx = -1 << 8; - plane_s->dcdy = 0; - plane_s->c = (1-scissor->x0) << 8; - plane_s->eo = 1 << 8; - plane_s++; - } - if (s_planes[1]) { - plane_s->dcdx = 1 << 8; - plane_s->dcdy = 0; - plane_s->c = (scissor->x1+1) << 8; - plane_s->eo = 0 << 8; - plane_s++; - } - if (s_planes[2]) { - plane_s->dcdx = 0; - plane_s->dcdy = 1 << 8; - plane_s->c = (1-scissor->y0) << 8; - plane_s->eo = 1 << 8; - plane_s++; - } - if (s_planes[3]) { - plane_s->dcdx = 0; - plane_s->dcdy = -1 << 8; - plane_s->c = (scissor->y1+1) << 8; - plane_s->eo = 0; - plane_s++; - } - assert(plane_s == &plane[nr_planes]); + if (nr_planes == 8) { + const struct u_rect *scissor = + &setup->scissors[viewport_index]; + + plane[4].dcdx = -1; + plane[4].dcdy = 0; + plane[4].c = 1-scissor->x0; + plane[4].eo = 1; + + plane[5].dcdx = 1; + plane[5].dcdy = 0; + plane[5].c = scissor->x1+1; + plane[5].eo = 0; + + plane[6].dcdx = 0; + plane[6].dcdy = 1; + plane[6].c = 1-scissor->y0; + plane[6].eo = 1; + + plane[7].dcdx = 0; + plane[7].dcdy = -1; + plane[7].c = scissor->y1+1; + plane[7].eo = 0; } - return lp_setup_bin_triangle(setup, line, &bbox, &bboxpos, nr_planes, viewport_index); + return lp_setup_bin_triangle(setup, line, &bbox, nr_planes, viewport_index); } diff --git a/lib/mesa/src/gallium/drivers/llvmpipe/lp_setup_point.c b/lib/mesa/src/gallium/drivers/llvmpipe/lp_setup_point.c index 8cb6b83f9..75544b524 100644 --- a/lib/mesa/src/gallium/drivers/llvmpipe/lp_setup_point.c +++ b/lib/mesa/src/gallium/drivers/llvmpipe/lp_setup_point.c @@ -328,7 +328,7 @@ try_setup_point( struct lp_setup_context *setup, struct llvmpipe_context *lp_context = (struct llvmpipe_context *)setup->pipe; /* x/y positions in fixed point */ const struct lp_setup_variant_key *key = &setup->setup.variant->key; - const int sizeAttr = setup->psize_slot; + const int sizeAttr = setup->psize; const float size = (setup->point_size_per_vertex && sizeAttr > 0) ? v0[sizeAttr][0] : setup->point_size; @@ -492,28 +492,28 @@ try_setup_point( struct lp_setup_context *setup, { struct lp_rast_plane *plane = GET_PLANES(point); - plane[0].dcdx = -1 << 8; + plane[0].dcdx = -1; plane[0].dcdy = 0; - plane[0].c = (1-bbox.x0) << 8; - plane[0].eo = 1 << 8; + plane[0].c = 1-bbox.x0; + plane[0].eo = 1; - plane[1].dcdx = 1 << 8; + plane[1].dcdx = 1; plane[1].dcdy = 0; - plane[1].c = (bbox.x1+1) << 8; + plane[1].c = bbox.x1+1; plane[1].eo = 0; plane[2].dcdx = 0; - plane[2].dcdy = 1 << 8; - plane[2].c = (1-bbox.y0) << 8; - plane[2].eo = 1 << 8; + plane[2].dcdy = 1; + plane[2].c = 1-bbox.y0; + plane[2].eo = 1; plane[3].dcdx = 0; - plane[3].dcdy = -1 << 8; - plane[3].c = (bbox.y1+1) << 8; + plane[3].dcdy = -1; + plane[3].c = bbox.y1+1; plane[3].eo = 0; } - return lp_setup_bin_triangle(setup, point, &bbox, &bbox, nr_planes, viewport_index); + return lp_setup_bin_triangle(setup, point, &bbox, nr_planes, viewport_index); } diff --git a/lib/mesa/src/gallium/drivers/llvmpipe/lp_state_derived.c b/lib/mesa/src/gallium/drivers/llvmpipe/lp_state_derived.c index 3e75d44da..a25e83261 100644 --- a/lib/mesa/src/gallium/drivers/llvmpipe/lp_state_derived.c +++ b/lib/mesa/src/gallium/drivers/llvmpipe/lp_state_derived.c @@ -48,26 +48,17 @@ static void compute_vertex_info(struct llvmpipe_context *llvmpipe) { - const struct tgsi_shader_info *fsInfo = &llvmpipe->fs->info.base; + const struct lp_fragment_shader *lpfs = llvmpipe->fs; struct vertex_info *vinfo = &llvmpipe->vertex_info; int vs_index; uint i; draw_prepare_shader_outputs(llvmpipe->draw); - /* - * Those can't actually be 0 (because pos is always at 0). - * But use ints anyway to avoid confusion (in vs outputs, they - * can very well be at pos 0). - */ llvmpipe->color_slot[0] = -1; llvmpipe->color_slot[1] = -1; llvmpipe->bcolor_slot[0] = -1; llvmpipe->bcolor_slot[1] = -1; - llvmpipe->viewport_index_slot = -1; - llvmpipe->layer_slot = -1; - llvmpipe->face_slot = -1; - llvmpipe->psize_slot = -1; /* * Match FS inputs against VS outputs, emitting the necessary @@ -78,52 +69,38 @@ compute_vertex_info(struct llvmpipe_context *llvmpipe) vinfo->num_attribs = 0; vs_index = draw_find_shader_output(llvmpipe->draw, - TGSI_SEMANTIC_POSITION, 0); + TGSI_SEMANTIC_POSITION, + 0); - draw_emit_vertex_attr(vinfo, EMIT_4F, vs_index); + draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, vs_index); - for (i = 0; i < fsInfo->num_inputs; i++) { + for (i = 0; i < lpfs->info.base.num_inputs; i++) { /* * Search for each input in current vs output: */ + vs_index = draw_find_shader_output(llvmpipe->draw, - fsInfo->input_semantic_name[i], - fsInfo->input_semantic_index[i]); + lpfs->info.base.input_semantic_name[i], + lpfs->info.base.input_semantic_index[i]); - if (fsInfo->input_semantic_name[i] == TGSI_SEMANTIC_COLOR && - fsInfo->input_semantic_index[i] < 2) { - int idx = fsInfo->input_semantic_index[i]; + if (lpfs->info.base.input_semantic_name[i] == TGSI_SEMANTIC_COLOR && + lpfs->info.base.input_semantic_index[i] < 2) { + int idx = lpfs->info.base.input_semantic_index[i]; llvmpipe->color_slot[idx] = (int)vinfo->num_attribs; } - if (fsInfo->input_semantic_name[i] == TGSI_SEMANTIC_FACE) { - llvmpipe->face_slot = (int)vinfo->num_attribs; - draw_emit_vertex_attr(vinfo, EMIT_4F, vs_index); - /* - * For vp index and layer, if the fs requires them but the vs doesn't - * provide them, draw (vbuf) will give us the required 0 (slot -1). - * (This means in this case we'll also use those slots in setup, which - * isn't necessary but they'll contain the correct (0) value.) - */ - } else if (fsInfo->input_semantic_name[i] == - TGSI_SEMANTIC_VIEWPORT_INDEX) { - llvmpipe->viewport_index_slot = (int)vinfo->num_attribs; - draw_emit_vertex_attr(vinfo, EMIT_4F, vs_index); - } else if (fsInfo->input_semantic_name[i] == TGSI_SEMANTIC_LAYER) { - llvmpipe->layer_slot = (int)vinfo->num_attribs; - draw_emit_vertex_attr(vinfo, EMIT_4F, vs_index); + if (lpfs->info.base.input_semantic_name[i] == TGSI_SEMANTIC_FACE) { + llvmpipe->face_slot = vinfo->num_attribs; + draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT, vs_index); + } else if (lpfs->info.base.input_semantic_name[i] == TGSI_SEMANTIC_PRIMID) { + draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT, vs_index); } else { /* - * Note that we'd actually want to skip position (as we won't use - * the attribute in the fs) but can't. The reason is that we don't - * actually have an input/output map for setup (even though it looks - * like we do...). Could adjust for this though even without a map - * (in llvmpipe_create_fs_state()). + * Emit the requested fs attribute for all but position. */ - draw_emit_vertex_attr(vinfo, EMIT_4F, vs_index); + draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, vs_index); } } - /* Figure out if we need bcolor as well. */ for (i = 0; i < 2; i++) { @@ -132,40 +109,41 @@ compute_vertex_info(struct llvmpipe_context *llvmpipe) if (vs_index >= 0) { llvmpipe->bcolor_slot[i] = (int)vinfo->num_attribs; - draw_emit_vertex_attr(vinfo, EMIT_4F, vs_index); + draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, vs_index); } } + /* Figure out if we need pointsize as well. */ vs_index = draw_find_shader_output(llvmpipe->draw, TGSI_SEMANTIC_PSIZE, 0); if (vs_index >= 0) { - llvmpipe->psize_slot = (int)vinfo->num_attribs; - draw_emit_vertex_attr(vinfo, EMIT_4F, vs_index); + llvmpipe->psize_slot = vinfo->num_attribs; + draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT, vs_index); } - /* Figure out if we need viewport index (if it wasn't already in fs input) */ - if (llvmpipe->viewport_index_slot < 0) { - vs_index = draw_find_shader_output(llvmpipe->draw, - TGSI_SEMANTIC_VIEWPORT_INDEX, - 0); - if (vs_index >= 0) { - llvmpipe->viewport_index_slot =(int)vinfo->num_attribs; - draw_emit_vertex_attr(vinfo, EMIT_4F, vs_index); - } + /* Figure out if we need viewport index */ + vs_index = draw_find_shader_output(llvmpipe->draw, + TGSI_SEMANTIC_VIEWPORT_INDEX, + 0); + if (vs_index >= 0) { + llvmpipe->viewport_index_slot = vinfo->num_attribs; + draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT, vs_index); + } else { + llvmpipe->viewport_index_slot = 0; } - /* Figure out if we need layer (if it wasn't already in fs input) */ - if (llvmpipe->layer_slot < 0) { - vs_index = draw_find_shader_output(llvmpipe->draw, - TGSI_SEMANTIC_LAYER, - 0); - if (vs_index >= 0) { - llvmpipe->layer_slot = (int)vinfo->num_attribs; - draw_emit_vertex_attr(vinfo, EMIT_4F, vs_index); - } + /* Figure out if we need layer */ + vs_index = draw_find_shader_output(llvmpipe->draw, + TGSI_SEMANTIC_LAYER, + 0); + if (vs_index >= 0) { + llvmpipe->layer_slot = vinfo->num_attribs; + draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT, vs_index); + } else { + llvmpipe->layer_slot = 0; } draw_compute_vertex_size(vinfo); @@ -190,13 +168,11 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe ) llvmpipe->tex_timestamp = lp_screen->timestamp; llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW; } - - /* This needs LP_NEW_RASTERIZER because of draw_prepare_shader_outputs(). */ + if (llvmpipe->dirty & (LP_NEW_RASTERIZER | LP_NEW_FS | - LP_NEW_GS | LP_NEW_VS)) - compute_vertex_info(llvmpipe); + compute_vertex_info( llvmpipe ); if (llvmpipe->dirty & (LP_NEW_FS | LP_NEW_FRAMEBUFFER | @@ -236,9 +212,9 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe ) llvmpipe->stencil_ref.ref_value); } - if (llvmpipe->dirty & LP_NEW_FS_CONSTANTS) + if (llvmpipe->dirty & LP_NEW_CONSTANTS) lp_setup_set_fs_constants(llvmpipe->setup, - ARRAY_SIZE(llvmpipe->constants[PIPE_SHADER_FRAGMENT]), + Elements(llvmpipe->constants[PIPE_SHADER_FRAGMENT]), llvmpipe->constants[PIPE_SHADER_FRAGMENT]); if (llvmpipe->dirty & (LP_NEW_SAMPLER_VIEW)) diff --git a/lib/mesa/src/gallium/drivers/llvmpipe/lp_state_vertex.c b/lib/mesa/src/gallium/drivers/llvmpipe/lp_state_vertex.c index 702ecf96a..1e93fd867 100644 --- a/lib/mesa/src/gallium/drivers/llvmpipe/lp_state_vertex.c +++ b/lib/mesa/src/gallium/drivers/llvmpipe/lp_state_vertex.c @@ -93,6 +93,18 @@ llvmpipe_set_vertex_buffers(struct pipe_context *pipe, } +static void +llvmpipe_set_index_buffer(struct pipe_context *pipe, + const struct pipe_index_buffer *ib) +{ + struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); + + if (ib) + memcpy(&llvmpipe->index_buffer, ib, sizeof(llvmpipe->index_buffer)); + else + memset(&llvmpipe->index_buffer, 0, sizeof(llvmpipe->index_buffer)); +} + void llvmpipe_init_vertex_funcs(struct llvmpipe_context *llvmpipe) { @@ -101,4 +113,5 @@ llvmpipe_init_vertex_funcs(struct llvmpipe_context *llvmpipe) llvmpipe->pipe.delete_vertex_elements_state = llvmpipe_delete_vertex_elements_state; llvmpipe->pipe.set_vertex_buffers = llvmpipe_set_vertex_buffers; + llvmpipe->pipe.set_index_buffer = llvmpipe_set_index_buffer; } |