mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-19 02:20:27 +01:00
llvmpipe: introduce image jit type to fragment shader jit.
This adds the image type to the fragment shader jit context Reviewed-by: Roland Scheidegger <sroland@vmware.com>
This commit is contained in:
parent
039a2e3630
commit
b2be174be2
2 changed files with 67 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue