summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2019-07-19 16:29:10 +1000
committerDave Airlie <[email protected]>2019-08-27 12:29:51 +1000
commitb2be174be270d653fcdf190e8252e266ff8176c3 (patch)
tree41f5e9fd9d4262530a43a82bf2b90919fa8cdacd
parent039a2e3630359f4f81a8f0a5427ddc9291c533d5 (diff)
llvmpipe: introduce image jit type to fragment shader jit.
This adds the image type to the fragment shader jit context Reviewed-by: Roland Scheidegger <[email protected]>
-rw-r--r--src/gallium/drivers/llvmpipe/lp_jit.c44
-rw-r--r--src/gallium/drivers/llvmpipe/lp_jit.h25
2 files changed, 67 insertions, 2 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c
index 6270340ef61..035cc284e03 100644
--- a/src/gallium/drivers/llvmpipe/lp_jit.c
+++ b/src/gallium/drivers/llvmpipe/lp_jit.c
@@ -126,12 +126,48 @@ create_jit_sampler_type(struct gallivm_state *gallivm)
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 */
{
@@ -155,6 +191,7 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
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 */
{
@@ -175,6 +212,8 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
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] =
@@ -212,6 +251,9 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
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);
diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h
index 7868cf4eefa..81e0019a8b0 100644
--- a/src/gallium/drivers/llvmpipe/lp_jit.h
+++ b/src/gallium/drivers/llvmpipe/lp_jit.h
@@ -78,6 +78,16 @@ struct lp_jit_viewport
};
+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,
@@ -107,7 +117,15 @@ enum {
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.
*
@@ -135,6 +153,7 @@ struct lp_jit_context
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];
@@ -156,6 +175,7 @@ enum {
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
@@ -192,6 +212,9 @@ enum {
#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")