summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/draw/draw_llvm.h
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2010-04-07 17:46:55 -0400
committerZack Rusin <[email protected]>2010-04-07 17:50:11 -0400
commit821abff8c03031603111abc17dabe7cfa28a31e1 (patch)
tree8def3a5f85f92382d72ad07ac9416e9d0b760e59 /src/gallium/auxiliary/draw/draw_llvm.h
parent40bac07f9b5182890719151c99e9d9035e7984e7 (diff)
draw llvm: highly reduce the compilation times for draw llvm
our code resets pipe_vertex_buffer's with different offsets when rendering vbo, meaning that we kept creating insane number of shaders even for simple apps e.g. geartrain had 54 shaders and it was taking almost 27 seconds just to compile them. this patch passes pipe_vertex_buffer's to the jit function and lets it to the stride/buffer_offset computation at run time. the slowdown at runtime is largely unnoticable but the we go from 54 shaders to 3, and from 27 seconds to less than 1.
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_llvm.h')
-rw-r--r--src/gallium/auxiliary/draw/draw_llvm.h58
1 files changed, 8 insertions, 50 deletions
diff --git a/src/gallium/auxiliary/draw/draw_llvm.h b/src/gallium/auxiliary/draw/draw_llvm.h
index 774eb16d90c..d1cbac4af97 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.h
+++ b/src/gallium/auxiliary/draw/draw_llvm.h
@@ -74,54 +74,13 @@ struct draw_jit_context
#define draw_jit_header_data(_builder, _ptr) \
lp_build_struct_get_ptr(_builder, _ptr, 2, "data")
-/* we are construction a function of the form:
-struct vertex_header {
- uint32 vertex_id;
+#define draw_jit_vbuffer_stride(_builder, _ptr) \
+ lp_build_struct_get(_builder, _ptr, 0, "stride")
- float clip[4];
- float data[][4];
-};
-
-struct draw_jit_context
-{
- const float *vs_constants;
- const float *gs_constants;
+#define draw_jit_vbuffer_offset(_builder, _ptr) \
+ lp_build_struct_get(_builder, _ptr, 2, "buffer_offset")
- struct draw_jit_texture textures[PIPE_MAX_SAMPLERS];
-};
-
-void
-draw_shader(struct draw_jit_context *context,
- struct vertex_header *io,
- const void *vbuffers[PIPE_MAX_ATTRIBS],
- unsigned start,
- unsigned count,
- unsigned stride)
-{
- // do a fetch and a run vertex shader
- for (int i = 0; i < count; ++i) {
- struct vertex_header *header = &io[i];
- header->vertex_id = 0xffff;
- // follows code-genarted fetch/translate section
- // for each vertex_element ...
- codegened_translate(header->data[num_element],
- context->vertex_elements[num_element],
- context->vertex_buffers,
- context->vbuffers);
-
- codegened_vertex_shader(header->data, context->vs_constants);
- }
-
- for (int i = 0; i < count; i += context->primitive_size) {
- struct vertex_header *prim[MAX_PRIMITIVE_SIZE];
- for (int j = 0; j < context->primitive_size; ++j) {
- header[j] = &io[i + j];
- }
- codegened_geometry_shader(prim, gs_constants);
- }
-}
-*/
typedef void
(*draw_jit_vert_func)(struct draw_jit_context *context,
@@ -129,7 +88,8 @@ typedef void
const char *vbuffers[PIPE_MAX_ATTRIBS],
unsigned start,
unsigned count,
- unsigned stride);
+ unsigned stride,
+ struct pipe_vertex_buffer *vertex_buffers);
struct draw_llvm {
struct draw_context *draw;
@@ -145,15 +105,13 @@ struct draw_llvm {
LLVMTypeRef context_ptr_type;
LLVMTypeRef vertex_header_ptr_type;
LLVMTypeRef buffer_ptr_type;
+ LLVMTypeRef vb_ptr_type;
};
-
struct draw_llvm_variant_key
{
- struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
- unsigned nr_vertex_buffers;
struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
- unsigned nr_vertex_elements;
+ unsigned nr_vertex_elements;
struct pipe_shader_state vs;
};