summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe/lp_jit.c
diff options
context:
space:
mode:
authorRoland Scheidegger <[email protected]>2013-01-28 06:50:36 -0800
committerRoland Scheidegger <[email protected]>2013-01-28 06:50:36 -0800
commitc789b981b244333cfc903bcd1e2fefc010500013 (patch)
tree0f0c5375916677240e11a1046af81bb2d5443030 /src/gallium/drivers/llvmpipe/lp_jit.c
parent87592cff57feef29565150b9203e220b50623f30 (diff)
gallivm: split sampler and texture state
Split the sampler interface to use separate sampler and texture (sampler_view) state. This is needed to support dx10-style sampling instructions. This is not quite complete since both draw/llvmpipe don't really track textures/samplers independently yet, as well as the gallivm code not quite using the right sampler or texture index respectively (but it should work for the sampling codes used by opengl). We are however losing some optimizations in the process, apply_max_lod will no longer work, and we potentially could end up with more (unnecessary) recompiles (if switching textures with/without mipmaps only so it shouldn't be too bad). v2: don't use different callback structs for sampler/sampler view functions (which just complicates things), fix up sampling code to actually use the right texture or sampler index, and similar for llvmpipe/draw actually distinguish between samplers and sampler views. v3: fix more of PIPE_MAX_SAMPLER / PIPE_MAX_SHADER_SAMPLER_VIEWS mismatches (both in draw and llvmpipe), based on feedback from José get rid of unneeded static sampler derived state.(which also fixes the only 2 piglit regressions due to a forgotten assignment), fix comments based on Brian's feedback. v4: remove some accidental unrelated whitespace changes Reviewed-by: José Fonseca <[email protected]> Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_jit.c')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_jit.c54
1 files changed, 37 insertions, 17 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c
index ea7c8054bfa..d0a791671e6 100644
--- a/src/gallium/drivers/llvmpipe/lp_jit.c
+++ b/src/gallium/drivers/llvmpipe/lp_jit.c
@@ -45,7 +45,7 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
{
struct gallivm_state *gallivm = lp->gallivm;
LLVMContextRef lc = gallivm->context;
- LLVMTypeRef texture_type;
+ LLVMTypeRef texture_type, sampler_type;
/* struct lp_jit_texture */
{
@@ -61,11 +61,6 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
elem_types[LP_JIT_TEXTURE_IMG_STRIDE] =
elem_types[LP_JIT_TEXTURE_MIP_OFFSETS] =
LLVMArrayType(LLVMInt32TypeInContext(lc), LP_MAX_TEXTURE_LEVELS);
- elem_types[LP_JIT_TEXTURE_MIN_LOD] =
- elem_types[LP_JIT_TEXTURE_MAX_LOD] =
- elem_types[LP_JIT_TEXTURE_LOD_BIAS] = LLVMFloatTypeInContext(lc);
- elem_types[LP_JIT_TEXTURE_BORDER_COLOR] =
- LLVMArrayType(LLVMFloatTypeInContext(lc), 4);
texture_type = LLVMStructTypeInContext(lc, elem_types,
Elements(elem_types), 0);
@@ -102,21 +97,41 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, mip_offsets,
gallivm->target, texture_type,
LP_JIT_TEXTURE_MIP_OFFSETS);
- LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, min_lod,
+ LP_CHECK_STRUCT_SIZE(struct lp_jit_texture,
+ gallivm->target, texture_type);
+ }
+
+ {
+ /* struct lp_jit_sampler */
+ LLVMTypeRef elem_types[LP_JIT_SAMPLER_NUM_FIELDS];
+ elem_types[LP_JIT_SAMPLER_MIN_LOD] =
+ elem_types[LP_JIT_SAMPLER_MAX_LOD] =
+ elem_types[LP_JIT_SAMPLER_LOD_BIAS] = LLVMFloatTypeInContext(lc);
+ elem_types[LP_JIT_SAMPLER_BORDER_COLOR] =
+ LLVMArrayType(LLVMFloatTypeInContext(lc), 4);
+
+ sampler_type = LLVMStructTypeInContext(lc, elem_types,
+ Elements(elem_types), 0);
+#if HAVE_LLVM < 0x0300
+ LLVMAddTypeName(gallivm->module, "texture", texture_type);
+
+ LLVMInvalidateStructLayout(gallivm->target, texture_type);
+#endif
+
+ LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, min_lod,
gallivm->target, texture_type,
- LP_JIT_TEXTURE_MIN_LOD);
- LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, max_lod,
+ LP_JIT_SAMPLER_MIN_LOD);
+ LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, max_lod,
gallivm->target, texture_type,
- LP_JIT_TEXTURE_MAX_LOD);
- LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, lod_bias,
+ LP_JIT_SAMPLER_MAX_LOD);
+ LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, lod_bias,
gallivm->target, texture_type,
- LP_JIT_TEXTURE_LOD_BIAS);
- LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, border_color,
+ LP_JIT_SAMPLER_LOD_BIAS);
+ LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, border_color,
gallivm->target, texture_type,
- LP_JIT_TEXTURE_BORDER_COLOR);
-
- LP_CHECK_STRUCT_SIZE(struct lp_jit_texture,
- gallivm->target, texture_type);
+ LP_JIT_SAMPLER_BORDER_COLOR);
+ LP_CHECK_STRUCT_SIZE(struct lp_jit_sampler,
+ gallivm->target, sampler_type);
}
/* struct lp_jit_context */
@@ -132,6 +147,8 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
elem_types[LP_JIT_CTX_U8_BLEND_COLOR] = LLVMPointerType(LLVMInt8TypeInContext(lc), 0);
elem_types[LP_JIT_CTX_F_BLEND_COLOR] = LLVMPointerType(LLVMFloatTypeInContext(lc), 0);
elem_types[LP_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type,
+ PIPE_MAX_SHADER_SAMPLER_VIEWS);
+ elem_types[LP_JIT_CTX_SAMPLERS] = LLVMArrayType(sampler_type,
PIPE_MAX_SAMPLERS);
context_type = LLVMStructTypeInContext(lc, elem_types,
@@ -164,6 +181,9 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, textures,
gallivm->target, context_type,
LP_JIT_CTX_TEXTURES);
+ LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, samplers,
+ gallivm->target, context_type,
+ LP_JIT_CTX_SAMPLERS);
LP_CHECK_STRUCT_SIZE(struct lp_jit_context,
gallivm->target, context_type);