return sampler_type;
}
+static LLVMTypeRef
+create_jit_image_type(struct gallivm_state *gallivm)
+{
+ LLVMContextRef lc = gallivm->context;
+ LLVMTypeRef image_type;
+ LLVMTypeRef elem_types[LP_JIT_IMAGE_NUM_FIELDS];
+ elem_types[LP_JIT_IMAGE_WIDTH] =
+ elem_types[LP_JIT_IMAGE_HEIGHT] =
+ elem_types[LP_JIT_IMAGE_DEPTH] = LLVMInt32TypeInContext(lc);
+ elem_types[LP_JIT_IMAGE_BASE] = LLVMPointerType(LLVMInt8TypeInContext(lc), 0);
+ elem_types[LP_JIT_IMAGE_ROW_STRIDE] =
+ elem_types[LP_JIT_IMAGE_IMG_STRIDE] = LLVMInt32TypeInContext(lc);
+
+ image_type = LLVMStructTypeInContext(lc, elem_types,
+ ARRAY_SIZE(elem_types), 0);
+ LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, width,
+ gallivm->target, image_type,
+ LP_JIT_IMAGE_WIDTH);
+ LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, height,
+ gallivm->target, image_type,
+ LP_JIT_IMAGE_HEIGHT);
+ LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, depth,
+ gallivm->target, image_type,
+ LP_JIT_IMAGE_DEPTH);
+ LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, base,
+ gallivm->target, image_type,
+ LP_JIT_IMAGE_BASE);
+ LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, row_stride,
+ gallivm->target, image_type,
+ LP_JIT_IMAGE_ROW_STRIDE);
+ LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, img_stride,
+ gallivm->target, image_type,
+ LP_JIT_IMAGE_IMG_STRIDE);
+ return image_type;
+}
+
static void
lp_jit_create_types(struct lp_fragment_shader_variant *lp)
{
struct gallivm_state *gallivm = lp->gallivm;
LLVMContextRef lc = gallivm->context;
- LLVMTypeRef viewport_type, texture_type, sampler_type;
+ LLVMTypeRef viewport_type, texture_type, sampler_type, image_type;
/* struct lp_jit_viewport */
{
texture_type = create_jit_texture_type(gallivm);
sampler_type = create_jit_sampler_type(gallivm);
+ image_type = create_jit_image_type(gallivm);
/* struct lp_jit_context */
{
PIPE_MAX_SHADER_SAMPLER_VIEWS);
elem_types[LP_JIT_CTX_SAMPLERS] = LLVMArrayType(sampler_type,
PIPE_MAX_SAMPLERS);
+ elem_types[LP_JIT_CTX_IMAGES] = LLVMArrayType(image_type,
+ PIPE_MAX_SHADER_IMAGES);
elem_types[LP_JIT_CTX_SSBOS] =
LLVMArrayType(LLVMPointerType(LLVMInt32TypeInContext(lc), 0), LP_MAX_TGSI_SHADER_BUFFERS);
elem_types[LP_JIT_CTX_NUM_SSBOS] =
LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, samplers,
gallivm->target, context_type,
LP_JIT_CTX_SAMPLERS);
+ LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, images,
+ gallivm->target, context_type,
+ LP_JIT_CTX_IMAGES);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, ssbos,
gallivm->target, context_type,
LP_JIT_CTX_SSBOS);
};
+struct lp_jit_image
+{
+ uint32_t width; /* same as number of elements */
+ uint32_t height;
+ uint32_t depth;
+ const void *base;
+ uint32_t row_stride;
+ uint32_t img_stride;
+};
+
enum {
LP_JIT_TEXTURE_WIDTH = 0,
LP_JIT_TEXTURE_HEIGHT,
LP_JIT_VIEWPORT_NUM_FIELDS /* number of fields above */
};
-
+enum {
+ LP_JIT_IMAGE_WIDTH = 0,
+ LP_JIT_IMAGE_HEIGHT,
+ LP_JIT_IMAGE_DEPTH,
+ LP_JIT_IMAGE_BASE,
+ LP_JIT_IMAGE_ROW_STRIDE,
+ LP_JIT_IMAGE_IMG_STRIDE,
+ LP_JIT_IMAGE_NUM_FIELDS /* number of fields above */
+};
/**
* This structure is passed directly to the generated fragment shader.
*
struct lp_jit_texture textures[PIPE_MAX_SHADER_SAMPLER_VIEWS];
struct lp_jit_sampler samplers[PIPE_MAX_SAMPLERS];
+ struct lp_jit_image images[PIPE_MAX_SHADER_IMAGES];
const uint32_t *ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
int num_ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
LP_JIT_CTX_VIEWPORTS,
LP_JIT_CTX_TEXTURES,
LP_JIT_CTX_SAMPLERS,
+ LP_JIT_CTX_IMAGES,
LP_JIT_CTX_SSBOS,
LP_JIT_CTX_NUM_SSBOS,
LP_JIT_CTX_COUNT
#define lp_jit_context_samplers(_gallivm, _ptr) \
lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_SAMPLERS, "samplers")
+#define lp_jit_context_images(_gallivm, _ptr) \
+ lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_IMAGES, "images")
+
#define lp_jit_context_ssbos(_gallivm, _ptr) \
lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_SSBOS, "ssbos")