gallium: consolidate jit image types between draw/llvmpipe
Reviewed-by: Roland Scheidegger <sroland@vmware.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18265>
This commit is contained in:
@@ -143,63 +143,6 @@ create_jit_dvbuffer_type(struct gallivm_state *gallivm,
|
||||
return dvbuffer_type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create LLVM type for struct draw_jit_texture
|
||||
*/
|
||||
static LLVMTypeRef
|
||||
create_jit_image_type(struct gallivm_state *gallivm, const char *struct_name)
|
||||
{
|
||||
LLVMTargetDataRef target = gallivm->target;
|
||||
LLVMTypeRef image_type;
|
||||
LLVMTypeRef elem_types[DRAW_JIT_IMAGE_NUM_FIELDS];
|
||||
LLVMTypeRef int32_type = LLVMInt32TypeInContext(gallivm->context);
|
||||
|
||||
elem_types[DRAW_JIT_IMAGE_WIDTH] =
|
||||
elem_types[DRAW_JIT_IMAGE_HEIGHT] =
|
||||
elem_types[DRAW_JIT_IMAGE_DEPTH] =
|
||||
elem_types[DRAW_JIT_IMAGE_ROW_STRIDE] =
|
||||
elem_types[DRAW_JIT_IMAGE_IMG_STRIDE] =
|
||||
elem_types[DRAW_JIT_IMAGE_NUM_SAMPLES] =
|
||||
elem_types[DRAW_JIT_IMAGE_SAMPLE_STRIDE] = int32_type;
|
||||
elem_types[DRAW_JIT_IMAGE_BASE] =
|
||||
LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0);
|
||||
|
||||
image_type = LLVMStructTypeInContext(gallivm->context, elem_types,
|
||||
ARRAY_SIZE(elem_types), 0);
|
||||
|
||||
(void) target; /* silence unused var warning for non-debug build */
|
||||
LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, width,
|
||||
target, image_type,
|
||||
DRAW_JIT_IMAGE_WIDTH);
|
||||
LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, height,
|
||||
target, image_type,
|
||||
DRAW_JIT_IMAGE_HEIGHT);
|
||||
LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, depth,
|
||||
target, image_type,
|
||||
DRAW_JIT_IMAGE_DEPTH);
|
||||
LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, base,
|
||||
target, image_type,
|
||||
DRAW_JIT_IMAGE_BASE);
|
||||
LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, row_stride,
|
||||
target, image_type,
|
||||
DRAW_JIT_IMAGE_ROW_STRIDE);
|
||||
LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, img_stride,
|
||||
target, image_type,
|
||||
DRAW_JIT_IMAGE_IMG_STRIDE);
|
||||
LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, num_samples,
|
||||
target, image_type,
|
||||
DRAW_JIT_IMAGE_NUM_SAMPLES);
|
||||
LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, sample_stride,
|
||||
target, image_type,
|
||||
DRAW_JIT_IMAGE_SAMPLE_STRIDE);
|
||||
|
||||
LP_CHECK_STRUCT_SIZE(struct draw_jit_image, target, image_type);
|
||||
|
||||
return image_type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create LLVM type for struct draw_jit_context
|
||||
*/
|
||||
@@ -209,7 +152,7 @@ create_jit_context_type(struct gallivm_state *gallivm, const char *struct_name)
|
||||
LLVMTypeRef buffer_type = lp_build_create_jit_buffer_type(gallivm);
|
||||
LLVMTypeRef texture_type = lp_build_create_jit_texture_type(gallivm);
|
||||
LLVMTypeRef sampler_type = lp_build_create_jit_sampler_type(gallivm);
|
||||
LLVMTypeRef image_type = create_jit_image_type(gallivm, "image");
|
||||
LLVMTypeRef image_type = lp_build_create_jit_image_type(gallivm);
|
||||
|
||||
LLVMTargetDataRef target = gallivm->target;
|
||||
LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context);
|
||||
@@ -2448,7 +2391,7 @@ draw_llvm_set_mapped_image(struct draw_context *draw,
|
||||
uint32_t num_samples,
|
||||
uint32_t sample_stride)
|
||||
{
|
||||
struct draw_jit_image *jit_image;
|
||||
struct lp_jit_image *jit_image;
|
||||
|
||||
switch (shader_stage) {
|
||||
case PIPE_SHADER_VERTEX:
|
||||
@@ -2587,7 +2530,7 @@ create_gs_jit_types(struct draw_gs_llvm_variant *var)
|
||||
|
||||
texture_type = lp_build_create_jit_texture_type(gallivm);
|
||||
sampler_type = lp_build_create_jit_sampler_type(gallivm);
|
||||
image_type = create_jit_image_type(gallivm, "image");
|
||||
image_type = lp_build_create_jit_image_type(gallivm);
|
||||
buffer_type = lp_build_create_jit_buffer_type(gallivm);
|
||||
|
||||
var->context_type = create_gs_jit_context_type(gallivm,
|
||||
@@ -2973,7 +2916,7 @@ create_tcs_jit_types(struct draw_tcs_llvm_variant *var)
|
||||
|
||||
texture_type = lp_build_create_jit_texture_type(gallivm);
|
||||
sampler_type = lp_build_create_jit_sampler_type(gallivm);
|
||||
image_type = create_jit_image_type(gallivm, "image");
|
||||
image_type = lp_build_create_jit_image_type(gallivm);
|
||||
buffer_type = lp_build_create_jit_buffer_type(gallivm);
|
||||
|
||||
var->context_type = create_tcs_jit_context_type(gallivm,
|
||||
@@ -3632,7 +3575,7 @@ create_tes_jit_types(struct draw_tes_llvm_variant *var)
|
||||
|
||||
texture_type = lp_build_create_jit_texture_type(gallivm);
|
||||
sampler_type = lp_build_create_jit_sampler_type(gallivm);
|
||||
image_type = create_jit_image_type(gallivm, "image");
|
||||
image_type = lp_build_create_jit_image_type(gallivm);
|
||||
buffer_type = lp_build_create_jit_buffer_type(gallivm);
|
||||
|
||||
var->context_type = create_tes_jit_context_type(gallivm,
|
||||
|
@@ -64,36 +64,12 @@ struct draw_image_static_state
|
||||
struct lp_static_texture_state image_state;
|
||||
};
|
||||
|
||||
struct draw_jit_image
|
||||
{
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t depth;
|
||||
const void *base;
|
||||
uint32_t row_stride;
|
||||
uint32_t img_stride;
|
||||
uint32_t num_samples;
|
||||
uint32_t sample_stride;
|
||||
};
|
||||
|
||||
enum {
|
||||
DRAW_JIT_VERTEX_VERTEX_ID = 0,
|
||||
DRAW_JIT_VERTEX_CLIP_POS,
|
||||
DRAW_JIT_VERTEX_DATA
|
||||
};
|
||||
|
||||
enum {
|
||||
DRAW_JIT_IMAGE_WIDTH = 0,
|
||||
DRAW_JIT_IMAGE_HEIGHT,
|
||||
DRAW_JIT_IMAGE_DEPTH,
|
||||
DRAW_JIT_IMAGE_BASE,
|
||||
DRAW_JIT_IMAGE_ROW_STRIDE,
|
||||
DRAW_JIT_IMAGE_IMG_STRIDE,
|
||||
DRAW_JIT_IMAGE_NUM_SAMPLES,
|
||||
DRAW_JIT_IMAGE_SAMPLE_STRIDE,
|
||||
DRAW_JIT_IMAGE_NUM_FIELDS /* number of fields above */
|
||||
};
|
||||
|
||||
/**
|
||||
* This structure is passed directly to the generated vertex shader.
|
||||
*
|
||||
@@ -113,7 +89,7 @@ struct draw_jit_context
|
||||
|
||||
struct lp_jit_texture textures[PIPE_MAX_SHADER_SAMPLER_VIEWS];
|
||||
struct lp_jit_sampler samplers[PIPE_MAX_SAMPLERS];
|
||||
struct draw_jit_image images[PIPE_MAX_SHADER_IMAGES];
|
||||
struct lp_jit_image images[PIPE_MAX_SHADER_IMAGES];
|
||||
|
||||
struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
|
||||
|
||||
@@ -198,7 +174,7 @@ struct draw_gs_jit_context
|
||||
* DRAW_JIT_CTX_SAMPLERS positions in the struct */
|
||||
struct lp_jit_texture textures[PIPE_MAX_SHADER_SAMPLER_VIEWS];
|
||||
struct lp_jit_sampler samplers[PIPE_MAX_SAMPLERS];
|
||||
struct draw_jit_image images[PIPE_MAX_SHADER_IMAGES];
|
||||
struct lp_jit_image images[PIPE_MAX_SHADER_IMAGES];
|
||||
|
||||
int **prim_lengths;
|
||||
int *emitted_vertices;
|
||||
@@ -254,7 +230,7 @@ struct draw_tcs_jit_context {
|
||||
* DRAW_JIT_CTX_SAMPLERS positions in the struct */
|
||||
struct lp_jit_texture textures[PIPE_MAX_SHADER_SAMPLER_VIEWS];
|
||||
struct lp_jit_sampler samplers[PIPE_MAX_SAMPLERS];
|
||||
struct draw_jit_image images[PIPE_MAX_SHADER_IMAGES];
|
||||
struct lp_jit_image images[PIPE_MAX_SHADER_IMAGES];
|
||||
|
||||
struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
|
||||
|
||||
@@ -291,7 +267,7 @@ struct draw_tes_jit_context {
|
||||
* DRAW_JIT_CTX_SAMPLERS positions in the struct */
|
||||
struct lp_jit_texture textures[PIPE_MAX_SHADER_SAMPLER_VIEWS];
|
||||
struct lp_jit_sampler samplers[PIPE_MAX_SAMPLERS];
|
||||
struct draw_jit_image images[PIPE_MAX_SHADER_IMAGES];
|
||||
struct lp_jit_image images[PIPE_MAX_SHADER_IMAGES];
|
||||
|
||||
struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
|
||||
|
||||
|
@@ -345,14 +345,14 @@ DRAW_LLVM_SAMPLER_MEMBER(max_aniso, LP_JIT_SAMPLER_MAX_ANISO, TRUE)
|
||||
}
|
||||
|
||||
|
||||
DRAW_LLVM_IMAGE_MEMBER(width, DRAW_JIT_IMAGE_WIDTH, TRUE)
|
||||
DRAW_LLVM_IMAGE_MEMBER(height, DRAW_JIT_IMAGE_HEIGHT, TRUE)
|
||||
DRAW_LLVM_IMAGE_MEMBER(depth, DRAW_JIT_IMAGE_DEPTH, TRUE)
|
||||
DRAW_LLVM_IMAGE_MEMBER(base_ptr, DRAW_JIT_IMAGE_BASE, TRUE)
|
||||
DRAW_LLVM_IMAGE_MEMBER_OUTTYPE(row_stride, DRAW_JIT_IMAGE_ROW_STRIDE, TRUE)
|
||||
DRAW_LLVM_IMAGE_MEMBER_OUTTYPE(img_stride, DRAW_JIT_IMAGE_IMG_STRIDE, TRUE)
|
||||
DRAW_LLVM_IMAGE_MEMBER(num_samples, DRAW_JIT_IMAGE_NUM_SAMPLES, TRUE)
|
||||
DRAW_LLVM_IMAGE_MEMBER(sample_stride, DRAW_JIT_IMAGE_SAMPLE_STRIDE, TRUE)
|
||||
DRAW_LLVM_IMAGE_MEMBER(width, LP_JIT_IMAGE_WIDTH, TRUE)
|
||||
DRAW_LLVM_IMAGE_MEMBER(height, LP_JIT_IMAGE_HEIGHT, TRUE)
|
||||
DRAW_LLVM_IMAGE_MEMBER(depth, LP_JIT_IMAGE_DEPTH, TRUE)
|
||||
DRAW_LLVM_IMAGE_MEMBER(base_ptr, LP_JIT_IMAGE_BASE, TRUE)
|
||||
DRAW_LLVM_IMAGE_MEMBER_OUTTYPE(row_stride, LP_JIT_IMAGE_ROW_STRIDE, TRUE)
|
||||
DRAW_LLVM_IMAGE_MEMBER_OUTTYPE(img_stride, LP_JIT_IMAGE_IMG_STRIDE, TRUE)
|
||||
DRAW_LLVM_IMAGE_MEMBER(num_samples, LP_JIT_IMAGE_NUM_SAMPLES, TRUE)
|
||||
DRAW_LLVM_IMAGE_MEMBER(sample_stride, LP_JIT_IMAGE_SAMPLE_STRIDE, TRUE)
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -193,3 +193,47 @@ lp_build_create_jit_sampler_type(struct gallivm_state *gallivm)
|
||||
gallivm->target, sampler_type);
|
||||
return sampler_type;
|
||||
}
|
||||
|
||||
LLVMTypeRef
|
||||
lp_build_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] =
|
||||
elem_types[LP_JIT_IMAGE_NUM_SAMPLES] =
|
||||
elem_types[LP_JIT_IMAGE_SAMPLE_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);
|
||||
LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, num_samples,
|
||||
gallivm->target, image_type,
|
||||
LP_JIT_IMAGE_NUM_SAMPLES);
|
||||
LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, sample_stride,
|
||||
gallivm->target, image_type,
|
||||
LP_JIT_IMAGE_SAMPLE_STRIDE);
|
||||
return image_type;
|
||||
}
|
||||
|
@@ -106,4 +106,31 @@ enum {
|
||||
LLVMTypeRef
|
||||
lp_build_create_jit_sampler_type(struct gallivm_state *gallivm);
|
||||
|
||||
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;
|
||||
uint32_t num_samples;
|
||||
uint32_t sample_stride;
|
||||
};
|
||||
|
||||
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_SAMPLES,
|
||||
LP_JIT_IMAGE_SAMPLE_STRIDE,
|
||||
LP_JIT_IMAGE_NUM_FIELDS /* number of fields above */
|
||||
};
|
||||
|
||||
LLVMTypeRef
|
||||
lp_build_create_jit_image_type(struct gallivm_state *gallivm);
|
||||
|
||||
#endif
|
||||
|
@@ -42,50 +42,6 @@
|
||||
#include "lp_screen.h"
|
||||
#include "lp_jit.h"
|
||||
|
||||
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] =
|
||||
elem_types[LP_JIT_IMAGE_NUM_SAMPLES] =
|
||||
elem_types[LP_JIT_IMAGE_SAMPLE_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);
|
||||
LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, num_samples,
|
||||
gallivm->target, image_type,
|
||||
LP_JIT_IMAGE_NUM_SAMPLES);
|
||||
LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, sample_stride,
|
||||
gallivm->target, image_type,
|
||||
LP_JIT_IMAGE_SAMPLE_STRIDE);
|
||||
return image_type;
|
||||
}
|
||||
|
||||
static void
|
||||
lp_jit_create_types(struct lp_fragment_shader_variant *lp)
|
||||
{
|
||||
@@ -117,7 +73,7 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
|
||||
buffer_type = lp_build_create_jit_buffer_type(gallivm);
|
||||
texture_type = lp_build_create_jit_texture_type(gallivm);
|
||||
sampler_type = lp_build_create_jit_sampler_type(gallivm);
|
||||
image_type = create_jit_image_type(gallivm);
|
||||
image_type = lp_build_create_jit_image_type(gallivm);
|
||||
|
||||
/* struct lp_jit_context */
|
||||
{
|
||||
@@ -323,7 +279,7 @@ lp_jit_create_cs_types(struct lp_compute_shader_variant *lp)
|
||||
buffer_type = lp_build_create_jit_buffer_type(gallivm);
|
||||
texture_type = lp_build_create_jit_texture_type(gallivm);
|
||||
sampler_type = lp_build_create_jit_sampler_type(gallivm);
|
||||
image_type = create_jit_image_type(gallivm);
|
||||
image_type = lp_build_create_jit_image_type(gallivm);
|
||||
|
||||
/* struct lp_jit_cs_thread_data */
|
||||
{
|
||||
|
@@ -56,37 +56,12 @@ struct lp_jit_viewport
|
||||
float max_depth;
|
||||
};
|
||||
|
||||
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;
|
||||
uint32_t num_samples;
|
||||
uint32_t sample_stride;
|
||||
};
|
||||
|
||||
enum {
|
||||
LP_JIT_VIEWPORT_MIN_DEPTH,
|
||||
LP_JIT_VIEWPORT_MAX_DEPTH,
|
||||
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_SAMPLES,
|
||||
LP_JIT_IMAGE_SAMPLE_STRIDE,
|
||||
LP_JIT_IMAGE_NUM_FIELDS /* number of fields above */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This structure is passed directly to the generated fragment shader.
|
||||
*
|
||||
|
Reference in New Issue
Block a user