llvmpipe: use new LP_JIT_CTX_ enums for jit context field positions
authorBrian Paul <brianp@vmware.com>
Tue, 16 Mar 2010 20:11:43 +0000 (14:11 -0600)
committerBrian Paul <brianp@vmware.com>
Wed, 17 Mar 2010 22:29:34 +0000 (16:29 -0600)
Use the new enum values rather than integers in a few places.

src/gallium/drivers/llvmpipe/lp_jit.c
src/gallium/drivers/llvmpipe/lp_jit.h
src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c

index 0254272eecad73b1f6e9ffc1c1ef75b0138db3f5..1eee9212e6fd4e5648dab89a347ade47488006f3 100644 (file)
@@ -91,40 +91,49 @@ lp_jit_init_globals(struct llvmpipe_screen *screen)
 
    /* struct lp_jit_context */
    {
-      LLVMTypeRef elem_types[9];
+      LLVMTypeRef elem_types[LP_JIT_CTX_COUNT];
       LLVMTypeRef context_type;
 
-      elem_types[0] = LLVMPointerType(LLVMFloatType(), 0); /* constants */
-      elem_types[1] = LLVMFloatType();                     /* alpha_ref_value */
-      elem_types[2] = LLVMArrayType(LLVMInt8Type(), 2);    /* stencil_refs */
-      elem_types[3] = LLVMFloatType();                     /* scissor_xmin */
-      elem_types[4] = LLVMFloatType();                     /* scissor_ymin */
-      elem_types[5] = LLVMFloatType();                     /* scissor_xmax */
-      elem_types[6] = LLVMFloatType();                     /* scissor_ymax */
-      elem_types[7] = LLVMPointerType(LLVMInt8Type(), 0);  /* blend_color */
-      elem_types[8] = LLVMArrayType(texture_type, PIPE_MAX_SAMPLERS); /* textures */
+      elem_types[LP_JIT_CTX_CONSTANTS] = LLVMPointerType(LLVMFloatType(), 0);
+      elem_types[LP_JIT_CTX_ALPHA_REF] = LLVMFloatType();
+      elem_types[LP_JIT_CTX_STENCIL_REF] = LLVMArrayType(LLVMInt8Type(), 2);
+      elem_types[LP_JIT_CTX_SCISSOR_XMIN] = LLVMFloatType();
+      elem_types[LP_JIT_CTX_SCISSOR_YMIN] = LLVMFloatType();
+      elem_types[LP_JIT_CTX_SCISSOR_XMAX] = LLVMFloatType();
+      elem_types[LP_JIT_CTX_SCISSOR_YMAX] = LLVMFloatType();
+      elem_types[LP_JIT_CTX_BLEND_COLOR] = LLVMPointerType(LLVMInt8Type(), 0);
+      elem_types[LP_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type,
+                                                      PIPE_MAX_SAMPLERS);
 
       context_type = LLVMStructType(elem_types, Elements(elem_types), 0);
 
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, constants,
-                             screen->target, context_type, 0);
+                             screen->target, context_type,
+                             LP_JIT_CTX_CONSTANTS);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, alpha_ref_value,
-                             screen->target, context_type, 1);
+                             screen->target, context_type,
+                             LP_JIT_CTX_ALPHA_REF);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, stencil_ref,
-                             screen->target, context_type, 2);
+                             screen->target, context_type,
+                             LP_JIT_CTX_STENCIL_REF);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_xmin,
-                             screen->target, context_type, 3);
+                             screen->target, context_type,
+                             LP_JIT_CTX_SCISSOR_XMIN);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_ymin,
-                             screen->target, context_type, 4);
+                             screen->target, context_type,
+                             LP_JIT_CTX_SCISSOR_YMIN);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_xmax,
-                             screen->target, context_type, 5);
+                             screen->target, context_type,
+                             LP_JIT_CTX_SCISSOR_XMAX);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_ymax,
-                             screen->target, context_type, 6);
+                             screen->target, context_type,
+                             LP_JIT_CTX_SCISSOR_YMAX);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, blend_color,
-                             screen->target, context_type, 7);
+                             screen->target, context_type,
+                             LP_JIT_CTX_BLEND_COLOR);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, textures,
                              screen->target, context_type,
-                             LP_JIT_CONTEXT_TEXTURES_INDEX);
+                             LP_JIT_CTX_TEXTURES);
       LP_CHECK_STRUCT_SIZE(struct lp_jit_context,
                            screen->target, context_type);
 
index 6864265ed025ef9df97a051839a4d72ac16de5d8..8f796f76d5ab4bf3091c645144e81d07633500bd 100644 (file)
@@ -84,7 +84,7 @@ struct lp_jit_context
 
    float alpha_ref_value;
 
-   ubyte stencil_ref[2];
+   uint8_t stencil_ref[2];
 
    /** floats, not ints */
    float scissor_xmin, scissor_ymin, scissor_xmax, scissor_ymax;
@@ -96,34 +96,50 @@ struct lp_jit_context
 };
 
 
+/**
+ * These enum values must match the position of the fields in the
+ * lp_jit_context struct above.
+ */
+enum {
+   LP_JIT_CTX_CONSTANTS = 0,
+   LP_JIT_CTX_ALPHA_REF,
+   LP_JIT_CTX_STENCIL_REF,
+   LP_JIT_CTX_SCISSOR_XMIN,
+   LP_JIT_CTX_SCISSOR_YMIN,
+   LP_JIT_CTX_SCISSOR_XMAX,
+   LP_JIT_CTX_SCISSOR_YMAX,
+   LP_JIT_CTX_BLEND_COLOR,
+   LP_JIT_CTX_TEXTURES,
+   LP_JIT_CTX_COUNT
+};
+
+
 #define lp_jit_context_constants(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 0, "constants")
+   lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_CONSTANTS, "constants")
 
 #define lp_jit_context_alpha_ref_value(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 1, "alpha_ref_value")
+   lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_ALPHA_REF, "alpha_ref_value")
 
 #define lp_jit_context_stencil_ref_value(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 2, "stencil_ref_values")
+   lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_STENCIL_REF, "stencil_ref")
 
 #define lp_jit_context_scissor_xmin_value(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 3, "scissor_xmin")
+   lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_SCISSOR_XMIN, "scissor_xmin")
 
 #define lp_jit_context_scissor_ymin_value(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 4, "scissor_ymin")
+   lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_SCISSOR_YMIN, "scissor_ymin")
 
 #define lp_jit_context_scissor_xmax_value(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 5, "scissor_xmax")
+   lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_SCISSOR_XMAX, "scissor_xmax")
 
 #define lp_jit_context_scissor_ymax_value(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 6, "scissor_ymax")
+   lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_SCISSOR_YMAX, "scissor_ymax")
 
 #define lp_jit_context_blend_color(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 7, "blend_color")
-
-#define LP_JIT_CONTEXT_TEXTURES_INDEX 8
+   lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_BLEND_COLOR, "blend_color")
 
 #define lp_jit_context_textures(_builder, _ptr) \
-   lp_build_struct_get_ptr(_builder, _ptr, LP_JIT_CONTEXT_TEXTURES_INDEX, "textures")
+   lp_build_struct_get_ptr(_builder, _ptr, LP_JIT_CONTEXT_TEXTURES, "textures")
 
 
 typedef void
index 662508af61a32e97e4f0564e973b622915413fbb..4715cfe4f62a8d58cc749cbd0f0986cd68b5fb83 100644 (file)
@@ -105,7 +105,7 @@ lp_llvm_texture_member(struct lp_sampler_dynamic_state *base,
    /* context[0] */
    indices[0] = LLVMConstInt(LLVMInt32Type(), 0, 0);
    /* context[0].textures */
-   indices[1] = LLVMConstInt(LLVMInt32Type(), LP_JIT_CONTEXT_TEXTURES_INDEX, 0);
+   indices[1] = LLVMConstInt(LLVMInt32Type(), LP_JIT_CTX_TEXTURES, 0);
    /* context[0].textures[unit] */
    indices[2] = LLVMConstInt(LLVMInt32Type(), unit, 0);
    /* context[0].textures[unit].member */