#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_prim.h"
-
+#include "util/ralloc.h"
/* fixme: move it from here */
#define MAX_PRIMITIVES 64
static inline boolean
draw_gs_should_flush(struct draw_geometry_shader *shader)
{
- return (shader->fetched_prim_count == shader->vector_length);
+ return (shader->fetched_prim_count == shader->vector_length || shader->num_invocations > 1);
}
/*#define DEBUG_OUTPUTS 1*/
unsigned input_vertex_stride = shader->input_vertex_stride;
const float (*input_ptr)[4];
+ int primid_sv = machine->SysSemanticToIndex[TGSI_SEMANTIC_PRIMID];
+ if (primid_sv != -1) {
+ for (unsigned j = 0; j < TGSI_QUAD_SIZE; j++)
+ machine->SystemValue[primid_sv].xyzw[0].i[j] = shader->in_prim_idx;
+ }
+
input_ptr = shader->input;
for (i = 0; i < num_vertices; ++i) {
const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS])
{
struct tgsi_exec_machine *machine = shader->machine;
- int j;
tgsi_exec_set_constant_buffers(machine, PIPE_MAX_CONSTANT_BUFFERS,
constants, constants_size);
-
- if (shader->info.uses_invocationid) {
- unsigned i = machine->SysSemanticToIndex[TGSI_SEMANTIC_INVOCATIONID];
- for (j = 0; j < TGSI_QUAD_SIZE; j++)
- machine->SystemValue[i].xyzw[0].i[j] = shader->invocation_id;
- }
}
static void tgsi_gs_run(struct draw_geometry_shader *shader,
struct tgsi_exec_machine *machine = shader->machine;
int i;
+ if (shader->info.uses_invocationid) {
+ unsigned i = machine->SysSemanticToIndex[TGSI_SEMANTIC_INVOCATIONID];
+ for (int j = 0; j < TGSI_QUAD_SIZE; j++)
+ machine->SystemValue[i].xyzw[0].i[j] = shader->invocation_id;
+ }
+
/* run interpreter */
tgsi_exec_machine_run(machine, 0);
output_ptr += shader->stream[stream].emitted_vertices * shader->vertex_size;
for (i = 0; i < shader->vector_length - 1; ++i) {
- int current_verts = shader->llvm_emitted_vertices[i];
+ int current_verts = shader->llvm_emitted_vertices[i + (stream * shader->vector_length)];
int next_verts = shader->llvm_emitted_vertices[i + 1 + (stream * shader->vector_length)];
#if 0
int j;
int num_prims = shader->llvm_emitted_primitives[i + (stream * shader->vector_length)];
for (j = 0; j < num_prims; ++j) {
int prim_length =
- shader->llvm_prim_lengths[j][i];
+ shader->llvm_prim_lengths[j * shader->num_vertex_streams + stream][i];
shader->stream[stream].primitive_lengths[shader->stream[stream].emitted_primitives + prim_idx] =
prim_length;
++prim_idx;
debug_assert(input_primitives > 0 &&
input_primitives <= 4);
- shader->run(shader, input_primitives, out_prim_count);
- for (i = 0; i < shader->num_vertex_streams; i++) {
- shader->fetch_outputs(shader, i, out_prim_count[i],
- &shader->stream[i].tmp_output);
+ for (unsigned invocation = 0; invocation < shader->num_invocations; invocation++) {
+ shader->invocation_id = invocation;
+ shader->run(shader, input_primitives, out_prim_count);
+ for (i = 0; i < shader->num_vertex_streams; i++) {
+ shader->fetch_outputs(shader, i, out_prim_count[i],
+ &shader->stream[i].tmp_output);
+ }
}
#if 0
* overflown vertices into some area where they won't harm anyone */
unsigned total_verts_per_buffer = shader->primitive_boundary *
num_in_primitives;
- unsigned invocation;
int i;
//Assume at least one primitive
max_out_prims = MAX2(max_out_prims, 1);
}
#if 0
- debug_printf("%s count = %d (in prims # = %d)\n",
- __FUNCTION__, num_input_verts, num_in_primitives);
+ debug_printf("%s count = %d (in prims # = %d, invocs = %d, streams = %d)\n",
+ __FUNCTION__, num_input_verts, num_in_primitives,
+ shader->num_invocations, shader->num_vertex_streams);
debug_printf("\tlinear = %d, prim_info->count = %d\n",
input_prim->linear, input_prim->count);
- debug_printf("\tprim pipe = %s, shader in = %s, shader out = %s\n"
+ debug_printf("\tprim pipe = %s, shader in = %s, shader out = %s\n",
u_prim_name(input_prim->prim),
u_prim_name(shader->input_primitive),
u_prim_name(shader->output_primitive));
if (max_out_prims > shader->max_out_prims) {
unsigned i;
if (shader->llvm_prim_lengths) {
- for (i = 0; i < shader->max_out_prims; ++i) {
+ for (i = 0; i < shader->num_vertex_streams * shader->max_out_prims; ++i) {
align_free(shader->llvm_prim_lengths[i]);
}
FREE(shader->llvm_prim_lengths);
}
- shader->llvm_prim_lengths = MALLOC(max_out_prims * sizeof(unsigned*));
- for (i = 0; i < max_out_prims; ++i) {
+ shader->llvm_prim_lengths = MALLOC(shader->num_vertex_streams * max_out_prims * sizeof(unsigned*));
+ for (i = 0; i < shader->num_vertex_streams * max_out_prims; ++i) {
int vector_size = shader->vector_length * sizeof(unsigned);
shader->llvm_prim_lengths[i] =
align_malloc(vector_size, vector_size);
}
#endif
- for (invocation = 0; invocation < shader->num_invocations; invocation++) {
- shader->invocation_id = invocation;
+ shader->prepare(shader, constants, constants_size);
- shader->prepare(shader, constants, constants_size);
+ if (input_prim->linear)
+ gs_run(shader, input_prim, input_verts,
+ output_prims, output_verts);
+ else
+ gs_run_elts(shader, input_prim, input_verts,
+ output_prims, output_verts);
- if (input_prim->linear)
- gs_run(shader, input_prim, input_verts,
- output_prims, output_verts);
- else
- gs_run_elts(shader, input_prim, input_verts,
- output_prims, output_verts);
-
- /* Flush the remaining primitives. Will happen if
- * num_input_primitives % 4 != 0
- */
- if (shader->fetched_prim_count > 0) {
- gs_flush(shader);
- }
- debug_assert(shader->fetched_prim_count == 0);
+ /* Flush the remaining primitives. Will happen if
+ * num_input_primitives % 4 != 0
+ */
+ if (shader->fetched_prim_count > 0) {
+ gs_flush(shader);
}
+ debug_assert(shader->fetched_prim_count == 0);
/* Update prim_info:
*/
memset(gs->gs_input, 0, sizeof(struct draw_gs_inputs));
gs->llvm_prim_lengths = 0;
- gs->llvm_emitted_primitives = align_malloc(vector_size * PIPE_MAX_VERTEX_STREAMS, vector_size);
- gs->llvm_emitted_vertices = align_malloc(vector_size * PIPE_MAX_VERTEX_STREAMS, vector_size);
- gs->llvm_prim_ids = align_malloc(vector_size, vector_size);
+ gs->llvm_emitted_primitives = align_malloc(vector_size * gs->num_vertex_streams, vector_size);
+ gs->llvm_emitted_vertices = align_malloc(vector_size * gs->num_vertex_streams, vector_size);
+ gs->llvm_prim_ids = align_calloc(vector_size, vector_size);
gs->fetch_outputs = llvm_fetch_gs_outputs;
gs->fetch_inputs = llvm_fetch_gs_input;
if (dgs->llvm_prim_lengths) {
unsigned i;
- for (i = 0; i < dgs->max_out_prims; ++i) {
+ for (i = 0; i < dgs->num_vertex_streams * dgs->max_out_prims; ++i) {
align_free(dgs->llvm_prim_lengths[i]);
}
FREE(dgs->llvm_prim_lengths);
for (i = 0; i < TGSI_MAX_VERTEX_STREAMS; i++)
FREE(dgs->stream[i].primitive_lengths);
+
+ if (dgs->state.ir.nir)
+ ralloc_free(dgs->state.ir.nir);
FREE((void*) dgs->state.tokens);
FREE(dgs);
}