} 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 {
#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
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);
*/
static const struct svga_tracked_state *hw_draw_state[] =
{
- &svga_hw_update_zero_stride,
&svga_hw_fs,
&svga_hw_vs,
&svga_hw_rss,
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
*/
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;
}
"hw vs params",
(SVGA_NEW_PRESCALE |
SVGA_NEW_VS_CONST_BUFFER |
- SVGA_NEW_ZERO_STRIDE |
SVGA_NEW_VS_RESULT),
emit_vs_consts
};
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)
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;
(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
-};
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);
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
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)));
}