diff options
author | Brian Paul <[email protected]> | 2012-05-22 16:53:04 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2012-05-25 10:02:22 -0600 |
commit | 93ea5cd80b98219100782feb3fee9d7283059036 (patch) | |
tree | f8360883a7f031fbecc10abc36aa596563d1cae7 /src/gallium | |
parent | dcb4ec5ae1874d57cc668baac483654e0dfeb4aa (diff) |
svga: remove the special zero-stride vertex array code
This code actually hasn't been needed for some time now. We can just
treat a zero-stride vertex array like any other non-zero-stride array.
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/svga/svga_context.h | 6 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_pipe_draw.c | 9 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_state.c | 1 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_state.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_state_constants.c | 18 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_state_vs.c | 93 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_tgsi.c | 1 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_tgsi.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_tgsi_decl_sm30.c | 34 |
9 files changed, 12 insertions, 153 deletions
diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h index 067c791ec68..7567431ad49 100644 --- a/src/gallium/drivers/svga/svga_context.h +++ b/src/gallium/drivers/svga/svga_context.h @@ -237,11 +237,6 @@ struct svga_state } tex_flags; boolean any_user_vertex_buffers; - - unsigned zero_stride_vertex_elements; - unsigned num_zero_stride_vertex_elements; - /* ### maybe dynamically allocate this */ - float zero_stride_constants[PIPE_MAX_ATTRIBS*4]; }; struct svga_prescale { @@ -406,7 +401,6 @@ struct svga_context #define SVGA_NEW_NEED_SWTNL 0x400000 #define SVGA_NEW_FS_RESULT 0x800000 #define SVGA_NEW_VS_RESULT 0x1000000 -#define SVGA_NEW_ZERO_STRIDE 0x2000000 #define SVGA_NEW_TEXTURE_FLAGS 0x4000000 #define SVGA_NEW_STENCIL_REF 0x8000000 diff --git a/src/gallium/drivers/svga/svga_pipe_draw.c b/src/gallium/drivers/svga/svga_pipe_draw.c index 2cab5326592..8c5d274c89d 100644 --- a/src/gallium/drivers/svga/svga_pipe_draw.c +++ b/src/gallium/drivers/svga/svga_pipe_draw.c @@ -95,16 +95,9 @@ svga_user_buffer_range(struct svga_context *svga, first = ve[i].src_offset; count = (instance_count + instance_div - 1) / instance_div; size = vb->stride * (count - 1) + elemSize; - } else if (vb->stride) { + } else { first = vb->stride * start + ve[i].src_offset; size = vb->stride * (count - 1) + elemSize; - } else { - /* Only a single vertex! - * Upload with the largest vertex size the hw supports, - * if possible. - */ - first = ve[i].src_offset; - size = MIN2(16, vb->buffer->width0); } buffer->uploaded.start = MIN2(buffer->uploaded.start, first); diff --git a/src/gallium/drivers/svga/svga_state.c b/src/gallium/drivers/svga/svga_state.c index bb3e80a080f..55cc8417874 100644 --- a/src/gallium/drivers/svga/svga_state.c +++ b/src/gallium/drivers/svga/svga_state.c @@ -63,7 +63,6 @@ static const struct svga_tracked_state *hw_clear_state[] = */ static const struct svga_tracked_state *hw_draw_state[] = { - &svga_hw_update_zero_stride, &svga_hw_fs, &svga_hw_vs, &svga_hw_rss, diff --git a/src/gallium/drivers/svga/svga_state.h b/src/gallium/drivers/svga/svga_state.h index de76cc2c339..046c0330d58 100644 --- a/src/gallium/drivers/svga/svga_state.h +++ b/src/gallium/drivers/svga/svga_state.h @@ -66,7 +66,6 @@ extern struct svga_tracked_state svga_hw_clip_planes; extern struct svga_tracked_state svga_hw_vdecl; extern struct svga_tracked_state svga_hw_fs_parameters; extern struct svga_tracked_state svga_hw_vs_parameters; -extern struct svga_tracked_state svga_hw_update_zero_stride; /* SWTNL_DRAW */ diff --git a/src/gallium/drivers/svga/svga_state_constants.c b/src/gallium/drivers/svga/svga_state_constants.c index 1c0ed6cac94..c03ef0580e7 100644 --- a/src/gallium/drivers/svga/svga_state_constants.c +++ b/src/gallium/drivers/svga/svga_state_constants.c @@ -351,23 +351,6 @@ emit_vs_consts(struct svga_context *svga, unsigned dirty) return ret; } - /* SVGA_NEW_ZERO_STRIDE - * Put the zero-stride vertex array attributes into the const buffer. - */ - if (key->zero_stride_vertex_elements) { - unsigned i, curr_zero_stride = 0; - for (i = 0; i < PIPE_MAX_ATTRIBS; ++i) { - if (key->zero_stride_vertex_elements & (1 << i)) { - ret = emit_const( svga, PIPE_SHADER_VERTEX, offset++, - svga->curr.zero_stride_constants + - 4 * curr_zero_stride ); - if (ret != PIPE_OK) - return ret; - ++curr_zero_stride; - } - } - } - return PIPE_OK; } @@ -377,7 +360,6 @@ struct svga_tracked_state svga_hw_vs_parameters = "hw vs params", (SVGA_NEW_PRESCALE | SVGA_NEW_VS_CONST_BUFFER | - SVGA_NEW_ZERO_STRIDE | SVGA_NEW_VS_RESULT), emit_vs_consts }; diff --git a/src/gallium/drivers/svga/svga_state_vs.c b/src/gallium/drivers/svga/svga_state_vs.c index e8c953be1a8..efa7c150bf9 100644 --- a/src/gallium/drivers/svga/svga_state_vs.c +++ b/src/gallium/drivers/svga/svga_state_vs.c @@ -152,7 +152,7 @@ fail: return ret; } -/* SVGA_NEW_PRESCALE, SVGA_NEW_RAST, SVGA_NEW_ZERO_STRIDE, SVGA_NEW_FS +/* SVGA_NEW_PRESCALE, SVGA_NEW_RAST, SVGA_NEW_FS */ static void make_vs_key(struct svga_context *svga, struct svga_vs_compile_key *key) @@ -160,10 +160,6 @@ make_vs_key(struct svga_context *svga, struct svga_vs_compile_key *key) memset(key, 0, sizeof *key); key->need_prescale = svga->state.hw_clear.prescale.enabled; key->allow_psiz = svga->curr.rast->templ.point_size_per_vertex; - key->zero_stride_vertex_elements = - svga->curr.zero_stride_vertex_elements; - key->num_zero_stride_vertex_elements = - svga->curr.num_zero_stride_vertex_elements; /* SVGA_NEW_FS */ key->fs_generic_inputs = svga->curr.fs->generic_inputs; @@ -216,91 +212,6 @@ struct svga_tracked_state svga_hw_vs = (SVGA_NEW_VS | SVGA_NEW_FS | SVGA_NEW_PRESCALE | - SVGA_NEW_NEED_SWTNL | - SVGA_NEW_ZERO_STRIDE), + SVGA_NEW_NEED_SWTNL), emit_hw_vs }; - - -/** - * This function handles the special case of vertex attributes - * with stride=0. Basically, copy those values into the constant - * buffer and modify the vertex shader to get the values from the - * constant buffer rather than a vertex array. - */ -static enum pipe_error -update_zero_stride( struct svga_context *svga, - unsigned dirty ) -{ - unsigned i; - - svga->curr.zero_stride_vertex_elements = 0; - svga->curr.num_zero_stride_vertex_elements = 0; - - for (i = 0; i < svga->curr.velems->count; i++) { - const struct pipe_vertex_element *vel = &svga->curr.velems->velem[i]; - const struct pipe_vertex_buffer *vbuffer = &svga->curr.vb[ - vel->vertex_buffer_index]; - - if (vbuffer->stride == 0) { - unsigned const_idx = - svga->curr.num_zero_stride_vertex_elements; - struct pipe_transfer *transfer; - struct translate *translate; - struct translate_key key; - void *mapped_buffer; - - svga->curr.zero_stride_vertex_elements |= (1 << i); - ++svga->curr.num_zero_stride_vertex_elements; - - key.output_stride = 4 * sizeof(float); - key.nr_elements = 1; - key.element[0].type = TRANSLATE_ELEMENT_NORMAL; - key.element[0].input_format = vel->src_format; - key.element[0].output_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - key.element[0].input_buffer = vel->vertex_buffer_index; - key.element[0].input_offset = vel->src_offset; - key.element[0].instance_divisor = vel->instance_divisor; - key.element[0].output_offset = const_idx * 4 * sizeof(float); - - translate_key_sanitize(&key); - /* translate_generic_create is technically private but - * we don't want to code-generate, just want generic - * translation */ - translate = translate_generic_create(&key); - - assert(vel->src_offset == 0); - - mapped_buffer = pipe_buffer_map_range(&svga->pipe, - vbuffer->buffer, - vel->src_offset + vbuffer->buffer_offset, - util_format_get_blocksize(vel->src_format), - PIPE_TRANSFER_READ, - &transfer); - mapped_buffer = (uint8_t*)mapped_buffer - vel->src_offset; - - translate->set_buffer(translate, vel->vertex_buffer_index, - mapped_buffer, - vbuffer->stride, ~0); - translate->run(translate, 0, 1, 0, - svga->curr.zero_stride_constants); - - pipe_buffer_unmap(&svga->pipe, transfer); - - translate->release(translate); - } - } - - if (svga->curr.num_zero_stride_vertex_elements) - svga->dirty |= SVGA_NEW_ZERO_STRIDE; - - return PIPE_OK; -} - -struct svga_tracked_state svga_hw_update_zero_stride = -{ - "update zero_stride", - ( SVGA_NEW_VELEMENT | - SVGA_NEW_VBUFFER ), - update_zero_stride -}; diff --git a/src/gallium/drivers/svga/svga_tgsi.c b/src/gallium/drivers/svga/svga_tgsi.c index 02ce59f3931..8a1ed4aba79 100644 --- a/src/gallium/drivers/svga/svga_tgsi.c +++ b/src/gallium/drivers/svga/svga_tgsi.c @@ -284,7 +284,6 @@ svga_tgsi_translate( const struct svga_shader *shader, if (unit == PIPE_SHADER_VERTEX) { emit.imm_start += key.vkey.need_prescale ? 2 : 0; - emit.imm_start += key.vkey.num_zero_stride_vertex_elements; } emit.nr_hw_float_const = (emit.imm_start + emit.info.file_max[TGSI_FILE_IMMEDIATE] + 1); diff --git a/src/gallium/drivers/svga/svga_tgsi.h b/src/gallium/drivers/svga/svga_tgsi.h index 7e93bf5aca5..bb0c6d0e029 100644 --- a/src/gallium/drivers/svga/svga_tgsi.h +++ b/src/gallium/drivers/svga/svga_tgsi.h @@ -47,10 +47,8 @@ struct tgsi_token; struct svga_vs_compile_key { unsigned fs_generic_inputs; - unsigned zero_stride_vertex_elements; unsigned need_prescale:1; unsigned allow_psiz:1; - unsigned num_zero_stride_vertex_elements:6; }; struct svga_fs_compile_key diff --git a/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c b/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c index e9adf3a0cbb..becd159b79f 100644 --- a/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c +++ b/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c @@ -376,35 +376,19 @@ vs30_input(struct svga_shader_emitter *emit, dcl.values[0] = 0; dcl.values[1] = 0; - if (emit->key.vkey.zero_stride_vertex_elements & (1 << idx)) { - unsigned i; - unsigned offset = 0; - unsigned start_idx = emit->info.file_max[TGSI_FILE_CONSTANT] + 1; - /* adjust for prescale constants */ - start_idx += emit->key.vkey.need_prescale ? 2 : 0; - /* compute the offset from the start of zero stride constants */ - for (i = 0; i < PIPE_MAX_ATTRIBS && i < idx; ++i) { - if (emit->key.vkey.zero_stride_vertex_elements & (1<<i)) - ++offset; - } - emit->input_map[idx] = src_register( SVGA3DREG_CONST, - start_idx + offset ); - } else { - emit->input_map[idx] = src_register( SVGA3DREG_INPUT, idx ); - dcl.dst = dst_register( SVGA3DREG_INPUT, idx ); + emit->input_map[idx] = src_register( SVGA3DREG_INPUT, idx ); + dcl.dst = dst_register( SVGA3DREG_INPUT, idx ); - assert(dcl.dst.reserved0); + assert(dcl.dst.reserved0); - svga_generate_vdecl_semantics( idx, &usage, &index ); + svga_generate_vdecl_semantics( idx, &usage, &index ); - dcl.usage = usage; - dcl.index = index; - dcl.values[0] |= 1<<31; + dcl.usage = usage; + dcl.index = index; + dcl.values[0] |= 1<<31; - return (emit_instruction(emit, opcode) && - svga_shader_emit_dwords( emit, dcl.values, Elements(dcl.values))); - } - return TRUE; + return (emit_instruction(emit, opcode) && + svga_shader_emit_dwords( emit, dcl.values, Elements(dcl.values))); } |