static LLVMTypeRef
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 = create_jit_texture_type(gallivm, "texture");
LLVMTypeRef sampler_type = create_jit_sampler_type(gallivm, "sampler");
LLVMTypeRef image_type = create_jit_image_type(gallivm, "image");
LLVMTargetDataRef target = gallivm->target;
LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context);
- LLVMTypeRef int_type = LLVMInt32TypeInContext(gallivm->context);
LLVMTypeRef elem_types[DRAW_JIT_CTX_NUM_FIELDS];
- elem_types[DRAW_JIT_CTX_CONSTANTS] = LLVMArrayType(LLVMPointerType(float_type, 0), LP_MAX_TGSI_CONST_BUFFERS);
- elem_types[DRAW_JIT_CTX_NUM_CONSTANTS] = LLVMArrayType(int_type, LP_MAX_TGSI_CONST_BUFFERS);
+ elem_types[DRAW_JIT_CTX_CONSTANTS] = LLVMArrayType(buffer_type, LP_MAX_TGSI_CONST_BUFFERS);
elem_types[DRAW_JIT_CTX_PLANES] = LLVMPointerType(LLVMArrayType(LLVMArrayType(float_type, 4), DRAW_TOTAL_CLIP_PLANES), 0);
elem_types[DRAW_JIT_CTX_VIEWPORT] = LLVMPointerType(float_type, 0);
elem_types[DRAW_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type, PIPE_MAX_SHADER_SAMPLER_VIEWS);
elem_types[DRAW_JIT_CTX_SAMPLERS] = LLVMArrayType(sampler_type, PIPE_MAX_SAMPLERS);
elem_types[DRAW_JIT_CTX_IMAGES] = LLVMArrayType(image_type, PIPE_MAX_SHADER_IMAGES);
- elem_types[DRAW_JIT_CTX_SSBOS] = LLVMArrayType(LLVMPointerType(int_type, 0), LP_MAX_TGSI_SHADER_BUFFERS);
- elem_types[DRAW_JIT_CTX_NUM_SSBOS] = LLVMArrayType(int_type, LP_MAX_TGSI_SHADER_BUFFERS);
+ elem_types[DRAW_JIT_CTX_SSBOS] = LLVMArrayType(buffer_type, LP_MAX_TGSI_SHADER_BUFFERS);
elem_types[DRAW_JIT_CTX_ANISO_FILTER_TABLE] = LLVMPointerType(float_type, 0);
LLVMTypeRef context_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_context, vs_constants,
+ LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, constants,
target, context_type, DRAW_JIT_CTX_CONSTANTS);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, num_vs_constants,
- target, context_type, DRAW_JIT_CTX_NUM_CONSTANTS);
LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, planes,
target, context_type, DRAW_JIT_CTX_PLANES);
LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, viewports,
DRAW_JIT_CTX_SAMPLERS);
LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, images,
target, context_type, DRAW_JIT_CTX_IMAGES);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, vs_ssbos,
+ LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, ssbos,
target, context_type, DRAW_JIT_CTX_SSBOS);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, num_vs_ssbos,
- target, context_type, DRAW_JIT_CTX_NUM_SSBOS);
LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, aniso_filter_table,
target, context_type, DRAW_JIT_CTX_ANISO_FILTER_TABLE);
LP_CHECK_STRUCT_SIZE(struct draw_jit_context,
static LLVMTypeRef
create_gs_jit_context_type(struct gallivm_state *gallivm,
unsigned vector_length,
+ LLVMTypeRef buffer_type,
LLVMTypeRef texture_type, LLVMTypeRef sampler_type,
LLVMTypeRef image_type,
const char *struct_name)
LLVMTypeRef elem_types[DRAW_GS_JIT_CTX_NUM_FIELDS];
LLVMTypeRef context_type;
- elem_types[DRAW_GS_JIT_CTX_CONSTANTS] = LLVMArrayType(LLVMPointerType(float_type, 0), /* constants */
+ elem_types[DRAW_GS_JIT_CTX_CONSTANTS] = LLVMArrayType(buffer_type, /* constants */
LP_MAX_TGSI_CONST_BUFFERS);
- elem_types[DRAW_GS_JIT_CTX_NUM_CONSTANTS] = LLVMArrayType(int_type, /* num_constants */
- LP_MAX_TGSI_CONST_BUFFERS);
elem_types[DRAW_GS_JIT_CTX_PLANES] = LLVMPointerType(LLVMArrayType(LLVMArrayType(float_type, 4),
DRAW_TOTAL_CLIP_PLANES), 0);
elem_types[DRAW_GS_JIT_CTX_VIEWPORT] = LLVMPointerType(float_type, 0); /* viewports */
elem_types[DRAW_GS_JIT_CTX_EMITTED_PRIMS] = LLVMPointerType(LLVMVectorType(int_type,
vector_length), 0);
- elem_types[DRAW_GS_JIT_CTX_SSBOS] = LLVMArrayType(LLVMPointerType(int_type, 0), /* ssbos */
+ elem_types[DRAW_GS_JIT_CTX_SSBOS] = LLVMArrayType(buffer_type, /* ssbos */
LP_MAX_TGSI_SHADER_BUFFERS);
- elem_types[DRAW_GS_JIT_CTX_NUM_SSBOS] = LLVMArrayType(int_type, /* num_ssbos */
- LP_MAX_TGSI_SHADER_BUFFERS);
elem_types[DRAW_GS_JIT_CTX_ANISO_FILTER_TABLE] = LLVMPointerType(float_type, 0); /* aniso table */
context_type = LLVMStructTypeInContext(gallivm->context, elem_types,
(void) target; /* silence unused var warning for non-debug build */
LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, constants,
target, context_type, DRAW_GS_JIT_CTX_CONSTANTS);
- LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, num_constants,
- target, context_type, DRAW_GS_JIT_CTX_NUM_CONSTANTS);
LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, planes,
target, context_type, DRAW_GS_JIT_CTX_PLANES);
LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, viewports,
DRAW_GS_JIT_CTX_EMITTED_PRIMS);
LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, ssbos,
target, context_type, DRAW_GS_JIT_CTX_SSBOS);
- LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, num_ssbos,
- target, context_type, DRAW_GS_JIT_CTX_NUM_SSBOS);
LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, images,
target, context_type, DRAW_GS_JIT_CTX_IMAGES);
LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, aniso_filter_table,
static LLVMTypeRef
create_tcs_jit_context_type(struct gallivm_state *gallivm,
unsigned vector_length,
+ LLVMTypeRef buffer_type,
LLVMTypeRef texture_type, LLVMTypeRef sampler_type,
LLVMTypeRef image_type,
const char *struct_name)
{
LLVMTargetDataRef target = gallivm->target;
LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context);
- LLVMTypeRef int_type = LLVMInt32TypeInContext(gallivm->context);
LLVMTypeRef elem_types[DRAW_TCS_JIT_CTX_NUM_FIELDS];
LLVMTypeRef context_type;
- elem_types[DRAW_TCS_JIT_CTX_CONSTANTS] = LLVMArrayType(LLVMPointerType(float_type, 0), /* constants */
+
+ elem_types[DRAW_TCS_JIT_CTX_CONSTANTS] = LLVMArrayType(buffer_type, /* constants */
LP_MAX_TGSI_CONST_BUFFERS);
- elem_types[DRAW_TCS_JIT_CTX_NUM_CONSTANTS] = LLVMArrayType(int_type, /* num_constants */
- LP_MAX_TGSI_CONST_BUFFERS);
elem_types[DRAW_TCS_JIT_CTX_DUMMY1] = LLVMInt32TypeInContext(gallivm->context);
elem_types[DRAW_TCS_JIT_CTX_DUMMY2] = LLVMInt32TypeInContext(gallivm->context);
elem_types[DRAW_TCS_JIT_CTX_IMAGES] = LLVMArrayType(image_type,
PIPE_MAX_SHADER_IMAGES); /* images */
- elem_types[DRAW_TCS_JIT_CTX_SSBOS] = LLVMArrayType(LLVMPointerType(int_type, 0), /* ssbos */
+ elem_types[DRAW_TCS_JIT_CTX_SSBOS] = LLVMArrayType(buffer_type, /* ssbos */
LP_MAX_TGSI_SHADER_BUFFERS);
- elem_types[DRAW_TCS_JIT_CTX_NUM_SSBOS] = LLVMArrayType(int_type, /* num_ssbos */
- LP_MAX_TGSI_SHADER_BUFFERS);
elem_types[DRAW_TCS_JIT_CTX_ANISO_FILTER_TABLE] = LLVMPointerType(float_type, 0); /* aniso table */
+
context_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_tcs_jit_context, constants,
target, context_type, DRAW_TCS_JIT_CTX_CONSTANTS);
- LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, num_constants,
- target, context_type, DRAW_TCS_JIT_CTX_NUM_CONSTANTS);
LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, textures,
target, context_type,
DRAW_TCS_JIT_CTX_TEXTURES);
DRAW_TCS_JIT_CTX_SAMPLERS);
LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, ssbos,
target, context_type, DRAW_TCS_JIT_CTX_SSBOS);
- LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, num_ssbos,
- target, context_type, DRAW_TCS_JIT_CTX_NUM_SSBOS);
LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, images,
target, context_type, DRAW_TCS_JIT_CTX_IMAGES);
LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, aniso_filter_table,
static LLVMTypeRef
create_tes_jit_context_type(struct gallivm_state *gallivm,
unsigned vector_length,
+ LLVMTypeRef buffer_type,
LLVMTypeRef texture_type, LLVMTypeRef sampler_type,
LLVMTypeRef image_type,
const char *struct_name)
{
LLVMTargetDataRef target = gallivm->target;
LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context);
- LLVMTypeRef int_type = LLVMInt32TypeInContext(gallivm->context);
LLVMTypeRef elem_types[DRAW_TES_JIT_CTX_NUM_FIELDS];
LLVMTypeRef context_type;
- elem_types[DRAW_TES_JIT_CTX_CONSTANTS] = LLVMArrayType(LLVMPointerType(float_type, 0), /* constants */
+ elem_types[DRAW_TES_JIT_CTX_CONSTANTS] = LLVMArrayType(buffer_type, /* constants */
LP_MAX_TGSI_CONST_BUFFERS);
- elem_types[DRAW_TES_JIT_CTX_NUM_CONSTANTS] = LLVMArrayType(int_type, /* num_constants */
- LP_MAX_TGSI_CONST_BUFFERS);
elem_types[DRAW_TES_JIT_CTX_DUMMY1] = LLVMInt32TypeInContext(gallivm->context);
elem_types[DRAW_TES_JIT_CTX_DUMMY2] = LLVMInt32TypeInContext(gallivm->context);
elem_types[DRAW_TES_JIT_CTX_IMAGES] = LLVMArrayType(image_type,
PIPE_MAX_SHADER_IMAGES); /* images */
- elem_types[DRAW_TES_JIT_CTX_SSBOS] = LLVMArrayType(LLVMPointerType(int_type, 0), /* ssbos */
+ elem_types[DRAW_TES_JIT_CTX_SSBOS] = LLVMArrayType(buffer_type, /* ssbos */
LP_MAX_TGSI_SHADER_BUFFERS);
- elem_types[DRAW_TES_JIT_CTX_NUM_SSBOS] = LLVMArrayType(int_type, /* num_ssbos */
- LP_MAX_TGSI_SHADER_BUFFERS);
elem_types[DRAW_TES_JIT_CTX_ANISO_FILTER_TABLE] = LLVMPointerType(float_type, 0); /* aniso table */
+
context_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_tes_jit_context, constants,
target, context_type, DRAW_TES_JIT_CTX_CONSTANTS);
- LP_CHECK_MEMBER_OFFSET(struct draw_tes_jit_context, num_constants,
- target, context_type, DRAW_TES_JIT_CTX_NUM_CONSTANTS);
LP_CHECK_MEMBER_OFFSET(struct draw_tes_jit_context, textures,
target, context_type,
DRAW_TES_JIT_CTX_TEXTURES);
DRAW_TES_JIT_CTX_SAMPLERS);
LP_CHECK_MEMBER_OFFSET(struct draw_tes_jit_context, ssbos,
target, context_type, DRAW_TES_JIT_CTX_SSBOS);
- LP_CHECK_MEMBER_OFFSET(struct draw_tes_jit_context, num_ssbos,
- target, context_type, DRAW_TES_JIT_CTX_NUM_SSBOS);
LP_CHECK_MEMBER_OFFSET(struct draw_tes_jit_context, images,
target, context_type, DRAW_TES_JIT_CTX_IMAGES);
LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, aniso_filter_table,
struct draw_llvm *llvm = variant->llvm;
const struct tgsi_token *tokens = llvm->draw->vs.vertex_shader->state.tokens;
LLVMValueRef consts_ptr =
- draw_jit_context_vs_constants(variant, context_ptr);
- LLVMValueRef num_consts_ptr =
- draw_jit_context_num_vs_constants(variant, context_ptr);
+ draw_jit_context_constants(variant, context_ptr);
LLVMValueRef ssbos_ptr =
- draw_jit_context_vs_ssbos(variant, context_ptr);
- LLVMValueRef num_ssbos_ptr =
- draw_jit_context_num_vs_ssbos(variant, context_ptr);
+ draw_jit_context_ssbos(variant, context_ptr);
struct lp_build_tgsi_params params;
memset(¶ms, 0, sizeof(params));
params.type = vs_type;
params.mask = bld_mask;
params.consts_ptr = consts_ptr;
- params.const_sizes_ptr = num_consts_ptr;
params.system_values = system_values;
params.inputs = inputs;
params.context_ptr = context_ptr;
params.sampler = draw_sampler;
params.info = &llvm->draw->vs.vertex_shader->info;
params.ssbo_ptr = ssbos_ptr;
- params.ssbo_sizes_ptr = num_ssbos_ptr;
params.image = draw_image;
params.aniso_filter_table = draw_jit_context_aniso_filter_table(variant, context_ptr);
create_gs_jit_types(struct draw_gs_llvm_variant *var)
{
struct gallivm_state *gallivm = var->gallivm;
- LLVMTypeRef texture_type, sampler_type, image_type;
+ LLVMTypeRef texture_type, sampler_type, image_type, buffer_type;
texture_type = create_jit_texture_type(gallivm, "texture");
sampler_type = create_jit_sampler_type(gallivm, "sampler");
image_type = create_jit_image_type(gallivm, "image");
+ buffer_type = lp_build_create_jit_buffer_type(gallivm);
var->context_type = create_gs_jit_context_type(gallivm,
var->shader->base.vector_length,
+ buffer_type,
texture_type, sampler_type,
image_type,
"draw_gs_jit_context");
unsigned i;
struct draw_gs_llvm_iface gs_iface;
const struct tgsi_token *tokens = variant->shader->base.state.tokens;
- LLVMValueRef consts_ptr, num_consts_ptr;
- LLVMValueRef ssbos_ptr, num_ssbos_ptr;
+ LLVMValueRef consts_ptr;
+ LLVMValueRef ssbos_ptr;
LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][TGSI_NUM_CHANNELS];
struct lp_build_mask_context mask;
const struct tgsi_shader_info *gs_info = &variant->shader->base.info;
gs_type.length = vector_length;
consts_ptr = draw_gs_jit_context_constants(variant, context_ptr);
- num_consts_ptr =
- draw_gs_jit_context_num_constants(variant, context_ptr);
ssbos_ptr = draw_gs_jit_context_ssbos(variant, context_ptr);
- num_ssbos_ptr =
- draw_gs_jit_context_num_ssbos(variant, context_ptr);
/* code generated texture sampling */
sampler = draw_llvm_sampler_soa_create(variant->key.samplers,
params.type = gs_type;
params.mask = &mask;
params.consts_ptr = consts_ptr;
- params.const_sizes_ptr = num_consts_ptr;
params.system_values = &system_values;
params.context_ptr = context_ptr;
params.sampler = sampler;
params.info = &llvm->draw->gs.geometry_shader->info;
params.gs_iface = (const struct lp_build_gs_iface *)&gs_iface;
params.ssbo_ptr = ssbos_ptr;
- params.ssbo_sizes_ptr = num_ssbos_ptr;
params.image = image;
params.gs_vertex_streams = variant->shader->base.num_vertex_streams;
params.aniso_filter_table = draw_gs_jit_context_aniso_filter_table(variant, context_ptr);
create_tcs_jit_types(struct draw_tcs_llvm_variant *var)
{
struct gallivm_state *gallivm = var->gallivm;
- LLVMTypeRef texture_type, sampler_type, image_type;
+ LLVMTypeRef texture_type, sampler_type, image_type, buffer_type;
texture_type = create_jit_texture_type(gallivm, "texture");
sampler_type = create_jit_sampler_type(gallivm, "sampler");
image_type = create_jit_image_type(gallivm, "image");
+ buffer_type = lp_build_create_jit_buffer_type(gallivm);
var->context_type = create_tcs_jit_context_type(gallivm,
0,
+ buffer_type,
texture_type, sampler_type,
image_type,
"draw_tcs_jit_context");
unsigned i;
struct draw_tcs_llvm_iface tcs_iface;
struct lp_build_mask_context mask;
- LLVMValueRef consts_ptr, num_consts_ptr;
- LLVMValueRef ssbos_ptr, num_ssbos_ptr;
+ LLVMValueRef consts_ptr;
+ LLVMValueRef ssbos_ptr;
struct lp_type tcs_type;
unsigned vector_length = variant->shader->base.vector_length;
view_index = LLVMGetParam(variant_coro, 5);
consts_ptr = draw_tcs_jit_context_constants(variant, context_ptr);
- num_consts_ptr =
- draw_tcs_jit_context_num_constants(variant, context_ptr);
ssbos_ptr = draw_tcs_jit_context_ssbos(variant, context_ptr);
- num_ssbos_ptr =
- draw_tcs_jit_context_num_ssbos(variant, context_ptr);
sampler = draw_llvm_sampler_soa_create(variant->key.samplers,
MAX2(variant->key.nr_samplers,
variant->key.nr_sampler_views));
params.type = tcs_type;
params.mask = &mask;
params.consts_ptr = consts_ptr;
- params.const_sizes_ptr = num_consts_ptr;
params.system_values = &system_values;
params.context_ptr = context_ptr;
params.sampler = sampler;
params.info = &llvm->draw->tcs.tess_ctrl_shader->info;
params.ssbo_ptr = ssbos_ptr;
- params.ssbo_sizes_ptr = num_ssbos_ptr;
params.image = image;
params.coro = &coro_info;
params.tcs_iface = &tcs_iface.base;
create_tes_jit_types(struct draw_tes_llvm_variant *var)
{
struct gallivm_state *gallivm = var->gallivm;
- LLVMTypeRef texture_type, sampler_type, image_type;
+ LLVMTypeRef texture_type, sampler_type, image_type, buffer_type;
texture_type = create_jit_texture_type(gallivm, "texture");
sampler_type = create_jit_sampler_type(gallivm, "sampler");
image_type = create_jit_image_type(gallivm, "image");
+ buffer_type = lp_build_create_jit_buffer_type(gallivm);
var->context_type = create_tes_jit_context_type(gallivm,
0,
+ buffer_type,
texture_type, sampler_type,
image_type,
"draw_tes_jit_context");
struct draw_tes_llvm_iface tes_iface;
LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][TGSI_NUM_CHANNELS];
struct lp_build_mask_context mask;
- LLVMValueRef consts_ptr, num_consts_ptr;
- LLVMValueRef ssbos_ptr, num_ssbos_ptr;
+ LLVMValueRef consts_ptr;
+ LLVMValueRef ssbos_ptr;
LLVMValueRef step;
struct lp_type tes_type;
unsigned vector_length = variant->shader->base.vector_length;
lp_build_context_init(&bldvec, variant->gallivm, lp_int_type(tes_type));
consts_ptr = draw_tes_jit_context_constants(variant, context_ptr);
- num_consts_ptr =
- draw_tes_jit_context_num_constants(variant, context_ptr);
ssbos_ptr = draw_tes_jit_context_ssbos(variant, context_ptr);
- num_ssbos_ptr =
- draw_tes_jit_context_num_ssbos(variant, context_ptr);
+
sampler = draw_llvm_sampler_soa_create(variant->key.samplers,
MAX2(variant->key.nr_samplers,
variant->key.nr_sampler_views));
params.type = tes_type;
params.mask = &mask;
params.consts_ptr = consts_ptr;
- params.const_sizes_ptr = num_consts_ptr;
params.system_values = &system_values;
params.context_ptr = context_ptr;
params.sampler = sampler;
params.info = &llvm->draw->tes.tess_eval_shader->info;
params.ssbo_ptr = ssbos_ptr;
- params.ssbo_sizes_ptr = num_ssbos_ptr;
params.image = image;
params.tes_iface = &tes_iface.base;
params.aniso_filter_table = draw_tes_jit_context_aniso_filter_table(variant, context_ptr);
#include "gallivm/lp_bld_sample.h"
#include "gallivm/lp_bld_limits.h"
+#include "gallivm/lp_bld_jit_types.h"
#include "pipe/p_context.h"
#include "util/list.h"
*/
struct draw_jit_context
{
- const float *vs_constants[LP_MAX_TGSI_CONST_BUFFERS];
- int num_vs_constants[LP_MAX_TGSI_CONST_BUFFERS];
+ struct lp_jit_buffer constants[LP_MAX_TGSI_CONST_BUFFERS];
float (*planes) [DRAW_TOTAL_CLIP_PLANES][4];
struct pipe_viewport_state *viewports;
struct draw_jit_sampler samplers[PIPE_MAX_SAMPLERS];
struct draw_jit_image images[PIPE_MAX_SHADER_IMAGES];
- const uint32_t *vs_ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
- int num_vs_ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
+ struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
const float *aniso_filter_table;
};
enum {
DRAW_JIT_CTX_CONSTANTS = 0,
- DRAW_JIT_CTX_NUM_CONSTANTS = 1,
- DRAW_JIT_CTX_PLANES = 2,
- DRAW_JIT_CTX_VIEWPORT = 3,
- DRAW_JIT_CTX_TEXTURES = 4,
- DRAW_JIT_CTX_SAMPLERS = 5,
- DRAW_JIT_CTX_IMAGES = 6,
- DRAW_JIT_CTX_SSBOS = 7,
- DRAW_JIT_CTX_NUM_SSBOS = 8,
- DRAW_JIT_CTX_ANISO_FILTER_TABLE = 9,
+ DRAW_JIT_CTX_PLANES = 1,
+ DRAW_JIT_CTX_VIEWPORT = 2,
+ DRAW_JIT_CTX_TEXTURES = 3,
+ DRAW_JIT_CTX_SAMPLERS = 4,
+ DRAW_JIT_CTX_IMAGES = 5,
+ DRAW_JIT_CTX_SSBOS = 6,
+ DRAW_JIT_CTX_ANISO_FILTER_TABLE = 7,
DRAW_JIT_CTX_NUM_FIELDS
};
-#define draw_jit_context_vs_constants(_variant, _ptr) \
- lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_JIT_CTX_CONSTANTS, "vs_constants")
-
-#define draw_jit_context_num_vs_constants(_variant, _ptr) \
- lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_JIT_CTX_NUM_CONSTANTS, "num_vs_constants")
+#define draw_jit_context_constants(_variant, _ptr) \
+ lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_JIT_CTX_CONSTANTS, "constants")
#define draw_jit_context_planes(_gallivm, _type, _ptr) \
lp_build_struct_get2(_gallivm, _type, _ptr, DRAW_JIT_CTX_PLANES, "planes")
#define draw_jit_context_images(_gallivm, _ptr) \
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_JIT_CTX_IMAGES, "images")
-#define draw_jit_context_vs_ssbos(_variant, _ptr) \
- lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_JIT_CTX_SSBOS, "vs_ssbos")
-
-#define draw_jit_context_num_vs_ssbos(_variant, _ptr) \
- lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_JIT_CTX_NUM_SSBOS, "num_vs_ssbos")
+#define draw_jit_context_ssbos(_variant, _ptr) \
+ lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_JIT_CTX_SSBOS, "ssbos")
#define draw_jit_context_aniso_filter_table(_variant, _ptr) \
lp_build_struct_get2(_variant->gallivm, _variant->context_type, _ptr, DRAW_JIT_CTX_ANISO_FILTER_TABLE, "aniso_filter_table")
*/
struct draw_gs_jit_context
{
- const float *constants[LP_MAX_TGSI_CONST_BUFFERS];
- int num_constants[LP_MAX_TGSI_CONST_BUFFERS];
+ struct lp_jit_buffer constants[LP_MAX_TGSI_CONST_BUFFERS];
float (*planes) [DRAW_TOTAL_CLIP_PLANES][4];
struct pipe_viewport_state *viewports;
int **prim_lengths;
int *emitted_vertices;
int *emitted_prims;
- const uint32_t *ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
- int num_ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
+ struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
const float *aniso_filter_table;
};
enum {
DRAW_GS_JIT_CTX_CONSTANTS = 0,
- DRAW_GS_JIT_CTX_NUM_CONSTANTS = 1,
- DRAW_GS_JIT_CTX_PLANES = 2,
- DRAW_GS_JIT_CTX_VIEWPORT = 3,
+ DRAW_GS_JIT_CTX_PLANES = 1,
+ DRAW_GS_JIT_CTX_VIEWPORT = 2,
/* Textures and samples are reserved for DRAW_JIT_CTX_TEXTURES
* and DRAW_JIT_CTX_SAMPLERS, because they both need
* to be at exactly the same locations as they are in the
DRAW_GS_JIT_CTX_TEXTURES = DRAW_JIT_CTX_TEXTURES,
DRAW_GS_JIT_CTX_SAMPLERS = DRAW_JIT_CTX_SAMPLERS,
DRAW_GS_JIT_CTX_IMAGES = DRAW_JIT_CTX_IMAGES,
- DRAW_GS_JIT_CTX_PRIM_LENGTHS = 7,
- DRAW_GS_JIT_CTX_EMITTED_VERTICES = 8,
- DRAW_GS_JIT_CTX_EMITTED_PRIMS = 9,
- DRAW_GS_JIT_CTX_SSBOS = 10,
- DRAW_GS_JIT_CTX_NUM_SSBOS = 11,
- DRAW_GS_JIT_CTX_ANISO_FILTER_TABLE = 12,
- DRAW_GS_JIT_CTX_NUM_FIELDS = 13
+ DRAW_GS_JIT_CTX_PRIM_LENGTHS = 6,
+ DRAW_GS_JIT_CTX_EMITTED_VERTICES = 7,
+ DRAW_GS_JIT_CTX_EMITTED_PRIMS = 8,
+ DRAW_GS_JIT_CTX_SSBOS = 9,
+ DRAW_GS_JIT_CTX_ANISO_FILTER_TABLE = 10,
+ DRAW_GS_JIT_CTX_NUM_FIELDS = 11
};
#define draw_gs_jit_context_constants(_variant, _ptr) \
lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_GS_JIT_CTX_CONSTANTS, "constants")
-#define draw_gs_jit_context_num_constants(_variant, _ptr) \
- lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_GS_JIT_CTX_NUM_CONSTANTS, "num_constants")
-
#define draw_gs_jit_context_planes(_gallivm, _ptr) \
lp_build_struct_get(_gallivm, _ptr, DRAW_GS_JIT_CTX_PLANES, "planes")
#define draw_gs_jit_context_ssbos(_variant, _ptr) \
lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_GS_JIT_CTX_SSBOS, "ssbos")
-#define draw_gs_jit_context_num_ssbos(_variant, _ptr) \
- lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_GS_JIT_CTX_NUM_SSBOS, "num_ssbos")
-
#define draw_gs_jit_context_aniso_filter_table(_variant, _ptr) \
lp_build_struct_get2(_variant->gallivm, _variant->context_type, _ptr, DRAW_GS_JIT_CTX_ANISO_FILTER_TABLE, "aniso_filter_table")
struct draw_tcs_jit_context {
- const float *constants[LP_MAX_TGSI_CONST_BUFFERS];
- int num_constants[LP_MAX_TGSI_CONST_BUFFERS];
+ struct lp_jit_buffer constants[LP_MAX_TGSI_CONST_BUFFERS];
int dummy1;
int dummy2;
struct draw_jit_sampler samplers[PIPE_MAX_SAMPLERS];
struct draw_jit_image images[PIPE_MAX_SHADER_IMAGES];
- const uint32_t *ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
- int num_ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
+ struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
const float *aniso_filter_table;
};
enum {
DRAW_TCS_JIT_CTX_CONSTANTS = 0,
- DRAW_TCS_JIT_CTX_NUM_CONSTANTS = 1,
- DRAW_TCS_JIT_CTX_DUMMY1 = 2,
- DRAW_TCS_JIT_CTX_DUMMY2 = 3,
+ DRAW_TCS_JIT_CTX_DUMMY1 = 1,
+ DRAW_TCS_JIT_CTX_DUMMY2 = 2,
DRAW_TCS_JIT_CTX_TEXTURES = DRAW_JIT_CTX_TEXTURES,
DRAW_TCS_JIT_CTX_SAMPLERS = DRAW_JIT_CTX_SAMPLERS,
DRAW_TCS_JIT_CTX_IMAGES = DRAW_JIT_CTX_IMAGES,
- DRAW_TCS_JIT_CTX_SSBOS = 7,
- DRAW_TCS_JIT_CTX_NUM_SSBOS = 8,
- DRAW_TCS_JIT_CTX_ANISO_FILTER_TABLE = 9,
- DRAW_TCS_JIT_CTX_NUM_FIELDS = 10,
+ DRAW_TCS_JIT_CTX_SSBOS = 6,
+ DRAW_TCS_JIT_CTX_ANISO_FILTER_TABLE = 7,
+ DRAW_TCS_JIT_CTX_NUM_FIELDS = 8,
};
#define draw_tcs_jit_context_constants(_variant, _ptr) \
lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TCS_JIT_CTX_CONSTANTS, "constants")
-#define draw_tcs_jit_context_num_constants(_variant, _ptr) \
- lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TCS_JIT_CTX_NUM_CONSTANTS, "num_constants")
-
#define draw_tcs_jit_context_textures(_gallivm, _ptr) \
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_TCS_JIT_CTX_TEXTURES, "textures")
#define draw_tcs_jit_context_ssbos(_variant, _ptr) \
lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TCS_JIT_CTX_SSBOS, "ssbos")
-#define draw_tcs_jit_context_num_ssbos(_variant, _ptr) \
- lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TCS_JIT_CTX_NUM_SSBOS, "num_ssbos")
-
#define draw_tcs_jit_context_aniso_filter_table(_variant, _ptr) \
lp_build_struct_get2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TCS_JIT_CTX_ANISO_FILTER_TABLE, "aniso_filter_table")
struct draw_tes_jit_context {
- const float *constants[LP_MAX_TGSI_CONST_BUFFERS];
- int num_constants[LP_MAX_TGSI_CONST_BUFFERS];
+ struct lp_jit_buffer constants[LP_MAX_TGSI_CONST_BUFFERS];
int dummy1;
int dummy2;
struct draw_jit_sampler samplers[PIPE_MAX_SAMPLERS];
struct draw_jit_image images[PIPE_MAX_SHADER_IMAGES];
- const uint32_t *ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
- int num_ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
+ struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
const float *aniso_filter_table;
};
enum {
DRAW_TES_JIT_CTX_CONSTANTS = 0,
- DRAW_TES_JIT_CTX_NUM_CONSTANTS = 1,
- DRAW_TES_JIT_CTX_DUMMY1 = 2,
- DRAW_TES_JIT_CTX_DUMMY2 = 3,
+ DRAW_TES_JIT_CTX_DUMMY1 = 1,
+ DRAW_TES_JIT_CTX_DUMMY2 = 2,
DRAW_TES_JIT_CTX_TEXTURES = DRAW_JIT_CTX_TEXTURES,
DRAW_TES_JIT_CTX_SAMPLERS = DRAW_JIT_CTX_SAMPLERS,
DRAW_TES_JIT_CTX_IMAGES = DRAW_JIT_CTX_IMAGES,
- DRAW_TES_JIT_CTX_SSBOS = 7,
- DRAW_TES_JIT_CTX_NUM_SSBOS = 8,
- DRAW_TES_JIT_CTX_ANISO_FILTER_TABLE = 9,
- DRAW_TES_JIT_CTX_NUM_FIELDS = 10,
+ DRAW_TES_JIT_CTX_SSBOS = 6,
+ DRAW_TES_JIT_CTX_ANISO_FILTER_TABLE = 7,
+ DRAW_TES_JIT_CTX_NUM_FIELDS = 8,
};
#define draw_tes_jit_context_constants(_variant, _ptr) \
lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TES_JIT_CTX_CONSTANTS, "constants")
-#define draw_tes_jit_context_num_constants(_variant, _ptr) \
- lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TES_JIT_CTX_NUM_CONSTANTS, "num_constants")
-
#define draw_tes_jit_context_textures(_gallivm, _ptr) \
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_TES_JIT_CTX_TEXTURES, "textures")
#define draw_tes_jit_context_ssbos(_variant, _ptr) \
lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TES_JIT_CTX_SSBOS, "ssbos")
-#define draw_tes_jit_context_num_ssbos(_variant, _ptr) \
- lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TES_JIT_CTX_NUM_SSBOS, "num_ssbos")
-
#define draw_tes_jit_context_aniso_filter_table(_variant, _ptr) \
lp_build_struct_get2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TES_JIT_CTX_ANISO_FILTER_TABLE, "aniso_filter_table")
struct draw_llvm *llvm = fpme->llvm;
unsigned i;
- for (i = 0; i < ARRAY_SIZE(llvm->jit_context.vs_constants); ++i) {
+ for (i = 0; i < ARRAY_SIZE(llvm->jit_context.constants); ++i) {
/*
* There could be a potential issue with rounding this up, as the
* shader expects 16-byte allocations, the fix is likely to move
* to LOAD intrinsic in the future and remove the vec4 constraint.
*/
int num_consts = get_num_consts_robust(draw, draw->pt.user.vs_constants_size, i);
- llvm->jit_context.vs_constants[i] = draw->pt.user.vs_constants[i];
- llvm->jit_context.num_vs_constants[i] = num_consts;
+ llvm->jit_context.constants[i].f = draw->pt.user.vs_constants[i];
+ llvm->jit_context.constants[i].num_elements = num_consts;
if (num_consts == 0) {
- llvm->jit_context.vs_constants[i] = fake_const_buf;
+ llvm->jit_context.constants[i].f = fake_const_buf;
}
}
- for (i = 0; i < ARRAY_SIZE(llvm->jit_context.vs_ssbos); ++i) {
+ for (i = 0; i < ARRAY_SIZE(llvm->jit_context.ssbos); ++i) {
int num_ssbos = draw->pt.user.vs_ssbos_size[i];
- llvm->jit_context.vs_ssbos[i] = draw->pt.user.vs_ssbos[i];
- llvm->jit_context.num_vs_ssbos[i] = num_ssbos;
+ llvm->jit_context.ssbos[i].u = draw->pt.user.vs_ssbos[i];
+ llvm->jit_context.ssbos[i].num_elements = num_ssbos;
if (num_ssbos == 0) {
- llvm->jit_context.vs_ssbos[i] = (const uint32_t *)fake_const_buf;
+ llvm->jit_context.ssbos[i].u = (const uint32_t *)fake_const_buf;
}
}
for (i = 0; i < ARRAY_SIZE(llvm->gs_jit_context.constants); ++i) {
int num_consts = get_num_consts_robust(draw, draw->pt.user.gs_constants_size, i);
- llvm->gs_jit_context.constants[i] = draw->pt.user.gs_constants[i];
- llvm->gs_jit_context.num_constants[i] = num_consts;
+ llvm->gs_jit_context.constants[i].f = draw->pt.user.gs_constants[i];
+ llvm->gs_jit_context.constants[i].num_elements = num_consts;
if (num_consts == 0) {
- llvm->gs_jit_context.constants[i] = fake_const_buf;
+ llvm->gs_jit_context.constants[i].f = fake_const_buf;
}
}
for (i = 0; i < ARRAY_SIZE(llvm->gs_jit_context.ssbos); ++i) {
int num_ssbos = draw->pt.user.gs_ssbos_size[i];
- llvm->gs_jit_context.ssbos[i] = draw->pt.user.gs_ssbos[i];
- llvm->gs_jit_context.num_ssbos[i] = num_ssbos;
+ llvm->gs_jit_context.ssbos[i].u = draw->pt.user.gs_ssbos[i];
+ llvm->gs_jit_context.ssbos[i].num_elements = num_ssbos;
if (num_ssbos == 0) {
- llvm->gs_jit_context.ssbos[i] = (const uint32_t *)fake_const_buf;
+ llvm->gs_jit_context.ssbos[i].u = (const uint32_t *)fake_const_buf;
}
}
for (i = 0; i < ARRAY_SIZE(llvm->tcs_jit_context.constants); ++i) {
int num_consts = get_num_consts_robust(draw, draw->pt.user.tcs_constants_size, i);
- llvm->tcs_jit_context.constants[i] = draw->pt.user.tcs_constants[i];
- llvm->tcs_jit_context.num_constants[i] = num_consts;
+ llvm->tcs_jit_context.constants[i].f = draw->pt.user.tcs_constants[i];
+ llvm->tcs_jit_context.constants[i].num_elements = num_consts;
if (num_consts == 0) {
- llvm->tcs_jit_context.constants[i] = fake_const_buf;
+ llvm->tcs_jit_context.constants[i].f = fake_const_buf;
}
}
for (i = 0; i < ARRAY_SIZE(llvm->tcs_jit_context.ssbos); ++i) {
int num_ssbos = draw->pt.user.tcs_ssbos_size[i];
- llvm->tcs_jit_context.ssbos[i] = draw->pt.user.tcs_ssbos[i];
- llvm->tcs_jit_context.num_ssbos[i] = num_ssbos;
+ llvm->tcs_jit_context.ssbos[i].u = draw->pt.user.tcs_ssbos[i];
+ llvm->tcs_jit_context.ssbos[i].num_elements = num_ssbos;
if (num_ssbos == 0) {
- llvm->tcs_jit_context.ssbos[i] = (const uint32_t *)fake_const_buf;
+ llvm->tcs_jit_context.ssbos[i].u = (const uint32_t *)fake_const_buf;
}
}
for (i = 0; i < ARRAY_SIZE(llvm->tes_jit_context.constants); ++i) {
int num_consts = get_num_consts_robust(draw, draw->pt.user.tes_constants_size, i);
- llvm->tes_jit_context.constants[i] = draw->pt.user.tes_constants[i];
- llvm->tes_jit_context.num_constants[i] = num_consts;
+ llvm->tes_jit_context.constants[i].f = draw->pt.user.tes_constants[i];
+ llvm->tes_jit_context.constants[i].num_elements = num_consts;
if (num_consts == 0) {
- llvm->tes_jit_context.constants[i] = fake_const_buf;
+ llvm->tes_jit_context.constants[i].f = fake_const_buf;
}
}
for (i = 0; i < ARRAY_SIZE(llvm->tes_jit_context.ssbos); ++i) {
int num_ssbos = draw->pt.user.tes_ssbos_size[i];
- llvm->tes_jit_context.ssbos[i] = draw->pt.user.tes_ssbos[i];
- llvm->tes_jit_context.num_ssbos[i] = num_ssbos;
+ llvm->tes_jit_context.ssbos[i].u = draw->pt.user.tes_ssbos[i];
+ llvm->tes_jit_context.ssbos[i].num_elements = num_ssbos;
if (num_ssbos == 0) {
- llvm->tes_jit_context.ssbos[i] = (const uint32_t *)fake_const_buf;
+ llvm->tes_jit_context.ssbos[i].u = (const uint32_t *)fake_const_buf;
}
}
--- /dev/null
+/*
+ * Copyright 2022 Red Hat.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "pipe/p_compiler.h"
+#include "gallivm/lp_bld.h"
+#include "gallivm/lp_bld_init.h"
+#include "gallivm/lp_bld_struct.h"
+#include "gallivm/lp_bld_const.h"
+#include "gallivm/lp_bld_debug.h"
+#include "gallivm/lp_bld_ir_common.h"
+#include "lp_bld_jit_types.h"
+
+
+LLVMTypeRef
+lp_build_create_jit_buffer_type(struct gallivm_state *gallivm)
+{
+ LLVMContextRef lc = gallivm->context;
+ LLVMTypeRef buffer_type;
+ LLVMTypeRef elem_types[LP_JIT_BUFFER_NUM_FIELDS];
+
+ elem_types[LP_JIT_BUFFER_BASE] = LLVMPointerType(LLVMInt32TypeInContext(lc), 0);
+ elem_types[LP_JIT_BUFFER_NUM_ELEMENTS] = LLVMInt32TypeInContext(lc);
+
+ buffer_type = LLVMStructTypeInContext(lc, elem_types,
+ ARRAY_SIZE(elem_types), 0);
+
+ LP_CHECK_MEMBER_OFFSET(struct lp_jit_buffer, f,
+ gallivm->target, buffer_type,
+ LP_JIT_BUFFER_BASE);
+
+ LP_CHECK_MEMBER_OFFSET(struct lp_jit_buffer, num_elements,
+ gallivm->target, buffer_type,
+ LP_JIT_BUFFER_NUM_ELEMENTS);
+ return buffer_type;
+}
+
+static LLVMValueRef
+lp_llvm_buffer_member(struct gallivm_state *gallivm,
+ LLVMValueRef buffers_ptr,
+ LLVMValueRef buffers_offset,
+ unsigned buffers_limit,
+ unsigned member_index,
+ const char *member_name,
+ boolean emit_load)
+{
+ LLVMBuilderRef builder = gallivm->builder;
+ LLVMValueRef indices[3];
+
+ indices[0] = lp_build_const_int32(gallivm, 0);
+ LLVMValueRef cond = LLVMBuildICmp(gallivm->builder, LLVMIntULT, buffers_offset, lp_build_const_int32(gallivm, buffers_limit), "");
+ indices[1] = LLVMBuildSelect(gallivm->builder, cond, buffers_offset, lp_build_const_int32(gallivm, 0), "");
+ indices[2] = lp_build_const_int32(gallivm, member_index);
+
+ LLVMValueRef ptr =
+ LLVMBuildGEP(builder, buffers_ptr, indices, ARRAY_SIZE(indices), "");
+
+ LLVMValueRef res = emit_load ? LLVMBuildLoad(builder, ptr, "") : ptr;
+
+ lp_build_name(res, "buffer.%s", member_name);
+
+ return res;
+}
+
+/**
+ * Helper macro to instantiate the functions that generate the code to
+ * fetch the members of lp_jit_buffer to fulfill the sampler code
+ * generator requests.
+ *
+ * This complexity is the price we have to pay to keep the image
+ * sampler code generator a reusable module without dependencies to
+ * llvmpipe internals.
+ */
+#define LP_LLVM_BUFFER_MEMBER(_name, _index, _emit_load) \
+ LLVMValueRef \
+ lp_llvm_buffer_##_name(struct gallivm_state *gallivm, \
+ LLVMValueRef buffers_ptr, \
+ LLVMValueRef buffers_offset, unsigned buffers_limit) \
+ { \
+ return lp_llvm_buffer_member(gallivm, buffers_ptr, \
+ buffers_offset, buffers_limit, \
+ _index, #_name, _emit_load ); \
+ }
+
+LP_LLVM_BUFFER_MEMBER(base, LP_JIT_BUFFER_BASE, TRUE)
+LP_LLVM_BUFFER_MEMBER(num_elements, LP_JIT_BUFFER_NUM_ELEMENTS, TRUE)
--- /dev/null
+/*
+ * Copyright 2022 Red Hat.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef LP_BLD_JIT_TYPES_H
+#define LP_BLD_JIT_TYPES_H
+
+struct lp_jit_buffer
+{
+ union {
+ const uint32_t *u;
+ const float *f;
+ };
+ uint32_t num_elements;
+};
+
+enum {
+ LP_JIT_BUFFER_BASE = 0,
+ LP_JIT_BUFFER_NUM_ELEMENTS,
+ LP_JIT_BUFFER_NUM_FIELDS,
+};
+
+LLVMTypeRef
+lp_build_create_jit_buffer_type(struct gallivm_state *gallivm);
+
+LLVMValueRef
+lp_llvm_buffer_base(struct gallivm_state *gallivm,
+ LLVMValueRef buffers_ptr,
+ LLVMValueRef buffers_offset, unsigned buffers_limit);
+
+LLVMValueRef
+lp_llvm_buffer_num_elements(struct gallivm_state *gallivm,
+ LLVMValueRef buffers_ptr,
+ LLVMValueRef buffers_offset, unsigned buffers_limit);
+
+
+#endif
struct lp_build_context uint_elem_bld;
LLVMValueRef consts_ptr;
- LLVMValueRef const_sizes_ptr;
LLVMValueRef consts[LP_MAX_TGSI_CONST_BUFFERS];
LLVMValueRef consts_sizes[LP_MAX_TGSI_CONST_BUFFERS];
const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS];
LLVMValueRef thread_data_ptr;
LLVMValueRef ssbo_ptr;
- LLVMValueRef ssbo_sizes_ptr;
LLVMValueRef ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
LLVMValueRef ssbo_sizes[LP_MAX_TGSI_SHADER_BUFFERS];
#include "lp_bld_gather.h"
#include "lp_bld_const.h"
#include "lp_bld_struct.h"
+#include "lp_bld_jit_types.h"
#include "lp_bld_arit.h"
#include "lp_bld_bitarit.h"
#include "lp_bld_coro.h"
LLVMBuilderRef builder = gallivm->builder;
struct lp_build_context *uint_bld = &bld_base->uint_bld;
struct lp_build_context *bld_broad = get_int_bld(bld_base, true, bit_size);
- LLVMValueRef consts_ptr = lp_build_array_get(gallivm, bld->consts_ptr, index);
- LLVMValueRef num_consts = lp_build_array_get(gallivm, bld->const_sizes_ptr, index);
+ LLVMValueRef consts_ptr = lp_llvm_buffer_base(gallivm, bld->consts_ptr, index, LP_MAX_TGSI_CONST_BUFFERS);
+ LLVMValueRef num_consts = lp_llvm_buffer_num_elements(gallivm, bld->consts_ptr, index, LP_MAX_TGSI_CONST_BUFFERS);
unsigned size_shift = bit_size_to_shift_size(bit_size);
if (size_shift)
offset = lp_build_shr(uint_bld, offset, lp_build_const_int_vec(gallivm, uint_bld->type, size_shift));
uint32_t shift_val = bit_size_to_shift_size(bit_size);
LLVMValueRef ssbo_idx = LLVMBuildExtractElement(gallivm->builder, index, invocation, "");
- LLVMValueRef ssbo_size_ptr = lp_build_array_get(gallivm, bld->ssbo_sizes_ptr, ssbo_idx);
- LLVMValueRef ssbo_ptr = lp_build_array_get(gallivm, bld->ssbo_ptr, ssbo_idx);
+ LLVMValueRef ssbo_size_ptr = lp_llvm_buffer_num_elements(gallivm, bld->ssbo_ptr, ssbo_idx, LP_MAX_TGSI_SHADER_BUFFERS);
+ LLVMValueRef ssbo_ptr = lp_llvm_buffer_base(gallivm, bld->ssbo_ptr, ssbo_idx, LP_MAX_TGSI_SHADER_BUFFERS);
if (bounds)
*bounds = LLVMBuildAShr(gallivm->builder, ssbo_size_ptr, lp_build_const_int32(gallivm, shift_val), "");
struct lp_build_nir_soa_context *bld = (struct lp_build_nir_soa_context *)bld_base;
LLVMBuilderRef builder = bld->bld_base.base.gallivm->builder;
struct lp_build_context *bld_broad = &bld_base->uint_bld;
- LLVMValueRef size_ptr = lp_build_array_get(bld_base->base.gallivm, bld->ssbo_sizes_ptr,
- LLVMBuildExtractElement(builder, index, lp_build_const_int32(gallivm, 0), ""));
+ LLVMValueRef size_ptr = lp_llvm_buffer_num_elements(gallivm, bld->ssbo_ptr, LLVMBuildExtractElement(builder, index, lp_build_const_int32(gallivm, 0), ""), LP_MAX_TGSI_SHADER_BUFFERS);
+
return lp_build_broadcast_scalar(bld_broad, size_ptr);
}
bld.inputs = params->inputs;
bld.outputs = outputs;
bld.consts_ptr = params->consts_ptr;
- bld.const_sizes_ptr = params->const_sizes_ptr;
bld.ssbo_ptr = params->ssbo_ptr;
- bld.ssbo_sizes_ptr = params->ssbo_sizes_ptr;
bld.sampler = params->sampler;
// bld.bld_base.info = params->info;
LLVMValueRef max_output_vertices_vec;
LLVMValueRef consts_ptr;
- LLVMValueRef const_sizes_ptr;
LLVMValueRef consts[LP_MAX_TGSI_CONST_BUFFERS];
LLVMValueRef consts_sizes[LP_MAX_TGSI_CONST_BUFFERS];
const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS];
LLVMValueRef thread_data_ptr;
LLVMValueRef ssbo_ptr;
- LLVMValueRef ssbo_sizes_ptr;
LLVMValueRef ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
LLVMValueRef ssbo_sizes[LP_MAX_TGSI_SHADER_BUFFERS];
#include "lp_bld_printf.h"
#include "lp_bld_sample.h"
#include "lp_bld_struct.h"
+#include "lp_bld_jit_types.h"
#define DUMP_GS_EMITS 0
unsigned idx2D = decl->Dim.Index2D;
LLVMValueRef index2D = lp_build_const_int32(gallivm, idx2D);
assert(idx2D < LP_MAX_TGSI_CONST_BUFFERS);
- bld->consts[idx2D] =
- lp_build_array_get(gallivm, bld->consts_ptr, index2D);
- bld->consts_sizes[idx2D] =
- lp_build_array_get(gallivm, bld->const_sizes_ptr, index2D);
+ bld->consts[idx2D] = lp_llvm_buffer_base(gallivm, bld->consts_ptr,
+ index2D, LP_MAX_TGSI_CONST_BUFFERS);
+ bld->consts[idx2D] = LLVMBuildBitCast(gallivm->builder, bld->consts[idx2D], LLVMPointerType(LLVMFloatTypeInContext(gallivm->context), 0), "");
+ bld->consts_sizes[idx2D] = lp_llvm_buffer_num_elements(gallivm, bld->consts_ptr,
+ index2D, LP_MAX_TGSI_CONST_BUFFERS);
}
break;
case TGSI_FILE_BUFFER:
LLVMValueRef index = lp_build_const_int32(gallivm, idx);
assert(idx < LP_MAX_TGSI_SHADER_BUFFERS);
bld->ssbos[idx] =
- lp_build_array_get(gallivm, bld->ssbo_ptr, index);
+ lp_llvm_buffer_base(gallivm, bld->ssbo_ptr,
+ index, LP_MAX_TGSI_SHADER_BUFFERS);
bld->ssbo_sizes[idx] =
- lp_build_array_get(gallivm, bld->ssbo_sizes_ptr, index);
+ lp_llvm_buffer_num_elements(gallivm, bld->ssbo_ptr,
+ index, LP_MAX_TGSI_SHADER_BUFFERS);
}
break;
bld.inputs = params->inputs;
bld.outputs = outputs;
bld.consts_ptr = params->consts_ptr;
- bld.const_sizes_ptr = params->const_sizes_ptr;
bld.ssbo_ptr = params->ssbo_ptr;
- bld.ssbo_sizes_ptr = params->ssbo_sizes_ptr;
bld.sampler = params->sampler;
bld.bld_base.info = params->info;
bld.indirect_files = params->info->indirect_files;
'gallivm/lp_bld_intr.h',
'gallivm/lp_bld_ir_common.c',
'gallivm/lp_bld_ir_common.h',
+ 'gallivm/lp_bld_jit_types.h',
+ 'gallivm/lp_bld_jit_types.c',
'gallivm/lp_bld_limits.h',
'gallivm/lp_bld_logic.c',
'gallivm/lp_bld_logic.h',
{
struct gallivm_state *gallivm = lp->gallivm;
LLVMContextRef lc = gallivm->context;
- LLVMTypeRef viewport_type, texture_type, sampler_type, image_type;
+ LLVMTypeRef viewport_type, texture_type, sampler_type, image_type, buffer_type;
LLVMTypeRef linear_elem_type;
/* struct lp_jit_viewport */
gallivm->target, viewport_type);
}
+ buffer_type = lp_build_create_jit_buffer_type(gallivm);
texture_type = create_jit_texture_type(gallivm);
sampler_type = create_jit_sampler_type(gallivm);
image_type = create_jit_image_type(gallivm);
LLVMTypeRef elem_types[LP_JIT_CTX_COUNT];
LLVMTypeRef context_type;
- elem_types[LP_JIT_CTX_CONSTANTS] =
- LLVMArrayType(LLVMPointerType(LLVMFloatTypeInContext(lc), 0), LP_MAX_TGSI_CONST_BUFFERS);
- elem_types[LP_JIT_CTX_NUM_CONSTANTS] =
- LLVMArrayType(LLVMInt32TypeInContext(lc), LP_MAX_TGSI_CONST_BUFFERS);
+ elem_types[LP_JIT_CTX_CONSTANTS] = LLVMArrayType(buffer_type,
+ LP_MAX_TGSI_CONST_BUFFERS);
elem_types[LP_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type,
PIPE_MAX_SHADER_SAMPLER_VIEWS);
elem_types[LP_JIT_CTX_SAMPLERS] = LLVMArrayType(sampler_type,
elem_types[LP_JIT_CTX_VIEWPORTS] = LLVMPointerType(viewport_type, 0);
elem_types[LP_JIT_CTX_ANISO_FILTER_TABLE] = LLVMPointerType(LLVMFloatTypeInContext(lc), 0);
elem_types[LP_JIT_CTX_SSBOS] =
- LLVMArrayType(LLVMPointerType(LLVMInt32TypeInContext(lc), 0), LP_MAX_TGSI_SHADER_BUFFERS);
- elem_types[LP_JIT_CTX_NUM_SSBOS] =
- LLVMArrayType(LLVMInt32TypeInContext(lc), LP_MAX_TGSI_SHADER_BUFFERS);
+ LLVMArrayType(buffer_type, LP_MAX_TGSI_SHADER_BUFFERS);
context_type = LLVMStructTypeInContext(lc, elem_types,
ARRAY_SIZE(elem_types), 0);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, constants,
gallivm->target, context_type,
LP_JIT_CTX_CONSTANTS);
- LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, num_constants,
- gallivm->target, context_type,
- LP_JIT_CTX_NUM_CONSTANTS);
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, ssbos,
gallivm->target, context_type,
LP_JIT_CTX_SSBOS);
- LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, num_ssbos,
- gallivm->target, context_type,
- LP_JIT_CTX_NUM_SSBOS);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, sample_mask,
gallivm->target, context_type,
LP_JIT_CTX_SAMPLE_MASK);
{
struct gallivm_state *gallivm = lp->gallivm;
LLVMContextRef lc = gallivm->context;
- LLVMTypeRef texture_type, sampler_type, image_type;
+ LLVMTypeRef texture_type, sampler_type, image_type, buffer_type;
+ buffer_type = lp_build_create_jit_buffer_type(gallivm);
texture_type = create_jit_texture_type(gallivm);
sampler_type = create_jit_sampler_type(gallivm);
image_type = create_jit_image_type(gallivm);
LLVMTypeRef cs_context_type;
elem_types[LP_JIT_CS_CTX_CONSTANTS] =
- LLVMArrayType(LLVMPointerType(LLVMFloatTypeInContext(lc), 0), LP_MAX_TGSI_CONST_BUFFERS);
- elem_types[LP_JIT_CS_CTX_NUM_CONSTANTS] =
- LLVMArrayType(LLVMInt32TypeInContext(lc), LP_MAX_TGSI_CONST_BUFFERS);
+ LLVMArrayType(buffer_type, LP_MAX_TGSI_CONST_BUFFERS);
elem_types[LP_JIT_CS_CTX_TEXTURES] = LLVMArrayType(texture_type,
PIPE_MAX_SHADER_SAMPLER_VIEWS);
elem_types[LP_JIT_CS_CTX_SAMPLERS] = LLVMArrayType(sampler_type,
elem_types[LP_JIT_CS_CTX_IMAGES] = LLVMArrayType(image_type,
PIPE_MAX_SHADER_IMAGES);
elem_types[LP_JIT_CS_CTX_SSBOS] =
- LLVMArrayType(LLVMPointerType(LLVMInt32TypeInContext(lc), 0), LP_MAX_TGSI_SHADER_BUFFERS);
- elem_types[LP_JIT_CS_CTX_NUM_SSBOS] =
- LLVMArrayType(LLVMInt32TypeInContext(lc), LP_MAX_TGSI_SHADER_BUFFERS);
+ LLVMArrayType(buffer_type, LP_MAX_TGSI_SHADER_BUFFERS);
elem_types[LP_JIT_CS_CTX_SHARED_SIZE] = LLVMInt32TypeInContext(lc);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, constants,
gallivm->target, cs_context_type,
LP_JIT_CS_CTX_CONSTANTS);
- LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, num_constants,
- gallivm->target, cs_context_type,
- LP_JIT_CS_CTX_NUM_CONSTANTS);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, textures,
gallivm->target, cs_context_type,
LP_JIT_CS_CTX_TEXTURES);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, ssbos,
gallivm->target, cs_context_type,
LP_JIT_CS_CTX_SSBOS);
- LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, num_ssbos,
- gallivm->target, cs_context_type,
- LP_JIT_CS_CTX_NUM_SSBOS);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, shared_size,
gallivm->target, cs_context_type,
LP_JIT_CS_CTX_SHARED_SIZE);
#include "gallivm/lp_bld_struct.h"
#include "gallivm/lp_bld_limits.h"
+#include "gallivm/lp_bld_jit_types.h"
#include "pipe/p_state.h"
#include "lp_texture.h"
*/
struct lp_jit_context
{
- const float *constants[LP_MAX_TGSI_CONST_BUFFERS];
- int num_constants[LP_MAX_TGSI_CONST_BUFFERS];
+ struct lp_jit_buffer constants[LP_MAX_TGSI_CONST_BUFFERS];
struct lp_jit_texture textures[PIPE_MAX_SHADER_SAMPLER_VIEWS];
struct lp_jit_sampler samplers[PIPE_MAX_SAMPLERS];
struct lp_jit_viewport *viewports;
- const uint32_t *ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
- int num_ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
+ struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
uint32_t sample_mask;
*/
enum {
LP_JIT_CTX_CONSTANTS = 0,
- LP_JIT_CTX_NUM_CONSTANTS,
LP_JIT_CTX_TEXTURES,
LP_JIT_CTX_SAMPLERS,
LP_JIT_CTX_IMAGES,
LP_JIT_CTX_F_BLEND_COLOR,
LP_JIT_CTX_VIEWPORTS,
LP_JIT_CTX_SSBOS,
- LP_JIT_CTX_NUM_SSBOS,
LP_JIT_CTX_SAMPLE_MASK,
LP_JIT_CTX_ANISO_FILTER_TABLE,
LP_JIT_CTX_COUNT
#define lp_jit_context_constants(_gallivm, _ptr) \
lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_CONSTANTS, "constants")
-#define lp_jit_context_num_constants(_gallivm, _ptr) \
- lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_NUM_CONSTANTS, "num_constants")
-
#define lp_jit_context_textures(_gallivm, _ptr) \
lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_TEXTURES, "textures")
#define lp_jit_context_ssbos(_gallivm, _ptr) \
lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_SSBOS, "ssbos")
-#define lp_jit_context_num_ssbos(_gallivm, _ptr) \
- lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_NUM_SSBOS, "num_ssbos")
-
#define lp_jit_context_sample_mask(_gallivm, _ptr) \
lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_SAMPLE_MASK, "sample_mask")
struct lp_jit_cs_context
{
- const float *constants[LP_MAX_TGSI_CONST_BUFFERS];
- int num_constants[LP_MAX_TGSI_CONST_BUFFERS];
+ struct lp_jit_buffer constants[LP_MAX_TGSI_CONST_BUFFERS];
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];
+ struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
void *kernel_args;
*/
enum {
LP_JIT_CS_CTX_CONSTANTS = 0,
- LP_JIT_CS_CTX_NUM_CONSTANTS,
LP_JIT_CS_CTX_TEXTURES, /* must match the LP_JIT_CTX_TEXTURES */
LP_JIT_CS_CTX_SAMPLERS,
LP_JIT_CS_CTX_IMAGES,
LP_JIT_CS_CTX_SSBOS,
- LP_JIT_CS_CTX_NUM_SSBOS,
LP_JIT_CS_CTX_KERNEL_ARGS,
LP_JIT_CS_CTX_SHARED_SIZE,
LP_JIT_CS_CTX_ANISO_FILTER_TABLE,
#define lp_jit_cs_context_constants(_gallivm, _ptr) \
lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CS_CTX_CONSTANTS, "constants")
-#define lp_jit_cs_context_num_constants(_gallivm, _ptr) \
- lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CS_CTX_NUM_CONSTANTS, "num_constants")
-
#define lp_jit_cs_context_textures(_gallivm, _ptr) \
lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CS_CTX_TEXTURES, "textures")
#define lp_jit_cs_context_ssbos(_gallivm, _ptr) \
lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CS_CTX_SSBOS, "ssbos")
-#define lp_jit_cs_context_num_ssbos(_gallivm, _ptr) \
- lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CS_CTX_NUM_SSBOS, "num_ssbos")
-
#define lp_jit_cs_context_shared_size(_gallivm, _ptr) \
lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CS_CTX_SHARED_SIZE, "shared_size")
if (variant->shader->base.type == PIPE_SHADER_IR_TGSI) {
nr_consts = (info->base.file_max[TGSI_FILE_CONSTANT] + 1) * 4;
} else {
- nr_consts = state->jit_context.num_constants[0];
+ nr_consts = state->jit_context.constants[0].num_elements;
}
for (int i = 0; i < nr_consts; i++){
- float val = state->jit_context.constants[0][i];
+ float val = state->jit_context.constants[0].f[i];
if (val < 0.0f || val > 1.0f) {
if (LP_DEBUG & DEBUG_LINEAR2)
debug_printf(" -- const[%d] out of range %f\n", i, val);
setup->constants[i].stored_size = current_size;
setup->constants[i].stored_data = stored;
}
- setup->fs.current.jit_context.constants[i] =
+ setup->fs.current.jit_context.constants[i].f =
setup->constants[i].stored_data;
}
else {
setup->constants[i].stored_size = 0;
setup->constants[i].stored_data = NULL;
- setup->fs.current.jit_context.constants[i] = fake_const_buf;
+ setup->fs.current.jit_context.constants[i].f = fake_const_buf;
}
const int num_constants =
DIV_ROUND_UP(setup->constants[i].stored_size,
lp_get_constant_buffer_stride(scene->pipe->screen));
- setup->fs.current.jit_context.num_constants[i] = num_constants;
+ setup->fs.current.jit_context.constants[i].num_elements = num_constants;
setup->dirty |= LP_SETUP_NEW_FS;
}
}
if (current_data) {
current_data += setup->ssbos[i].current.buffer_offset;
- setup->fs.current.jit_context.ssbos[i] =
+ setup->fs.current.jit_context.ssbos[i].u =
(const uint32_t *)current_data;
- setup->fs.current.jit_context.num_ssbos[i] =
+ setup->fs.current.jit_context.ssbos[i].num_elements =
setup->ssbos[i].current.buffer_size;
} else {
- setup->fs.current.jit_context.ssbos[i] = NULL;
- setup->fs.current.jit_context.num_ssbos[i] = 0;
+ setup->fs.current.jit_context.ssbos[i].u = NULL;
+ setup->fs.current.jit_context.ssbos[i].num_elements = 0;
}
setup->dirty |= LP_SETUP_NEW_FS;
}
const struct lp_tgsi_channel_info *alpha_info = &variant->shader->info.cbuf[0][3];
if (alpha_info->file == TGSI_FILE_CONSTANT) {
- const float *constants = setup->fs.current.jit_context.constants[0];
+ const float *constants = setup->fs.current.jit_context.constants[0].f;
float alpha = constants[alpha_info->u.index*4 +
alpha_info->swizzle];
return alpha == 1.0f;
block = LLVMAppendBasicBlockInContext(gallivm->context, coro, "entry");
LLVMPositionBuilderAtEnd(builder, block);
{
- LLVMValueRef consts_ptr, num_consts_ptr;
- LLVMValueRef ssbo_ptr, num_ssbo_ptr;
+ LLVMValueRef consts_ptr;
+ LLVMValueRef ssbo_ptr;
LLVMValueRef shared_ptr;
LLVMValueRef kernel_args_ptr;
struct lp_build_mask_context mask;
memset(&system_values, 0, sizeof(system_values));
consts_ptr = lp_jit_cs_context_constants(gallivm, context_ptr);
- num_consts_ptr = lp_jit_cs_context_num_constants(gallivm, context_ptr);
ssbo_ptr = lp_jit_cs_context_ssbos(gallivm, context_ptr);
- num_ssbo_ptr = lp_jit_cs_context_num_ssbos(gallivm, context_ptr);
kernel_args_ptr = lp_jit_cs_context_kernel_args(gallivm, context_ptr);
shared_ptr = lp_jit_cs_thread_data_shared(gallivm, thread_data_ptr);
params.type = cs_type;
params.mask = &mask;
params.consts_ptr = consts_ptr;
- params.const_sizes_ptr = num_consts_ptr;
params.system_values = &system_values;
params.context_ptr = context_ptr;
params.sampler = sampler;
params.info = &shader->info.base;
params.ssbo_ptr = ssbo_ptr;
- params.ssbo_sizes_ptr = num_ssbo_ptr;
params.image = image;
params.shared_ptr = shared_ptr;
params.coro = &coro_info;
if (current_data && current_size >= sizeof(float)) {
current_data += csctx->constants[i].current.buffer_offset;
- csctx->cs.current.jit_context.constants[i] = (const float *)current_data;
- csctx->cs.current.jit_context.num_constants[i] =
+ csctx->cs.current.jit_context.constants[i].f = (const float *)current_data;
+ csctx->cs.current.jit_context.constants[i].num_elements =
DIV_ROUND_UP(csctx->constants[i].current.buffer_size,
lp_get_constant_buffer_stride(llvmpipe->pipe.screen));
} else {
static const float fake_const_buf[4];
- csctx->cs.current.jit_context.constants[i] = fake_const_buf;
- csctx->cs.current.jit_context.num_constants[i] = 0;
+ csctx->cs.current.jit_context.constants[i].f = fake_const_buf;
+ csctx->cs.current.jit_context.constants[i].num_elements = 0;
}
}
}
if (current_data) {
current_data += csctx->ssbos[i].current.buffer_offset;
- csctx->cs.current.jit_context.ssbos[i] = (const uint32_t *)current_data;
- csctx->cs.current.jit_context.num_ssbos[i] = csctx->ssbos[i].current.buffer_size;
+ csctx->cs.current.jit_context.ssbos[i].u = (const uint32_t *)current_data;
+ csctx->cs.current.jit_context.ssbos[i].num_elements = csctx->ssbos[i].current.buffer_size;
} else {
- csctx->cs.current.jit_context.ssbos[i] = NULL;
- csctx->cs.current.jit_context.num_ssbos[i] = 0;
+ csctx->cs.current.jit_context.ssbos[i].u = NULL;
+ csctx->cs.current.jit_context.ssbos[i].num_elements = 0;
}
}
}
stencil_refs[1] = lp_build_broadcast(gallivm, int_vec_type, stencil_refs[1]);
LLVMValueRef consts_ptr = lp_jit_context_constants(gallivm, context_ptr);
- LLVMValueRef num_consts_ptr = lp_jit_context_num_constants(gallivm,
- context_ptr);
LLVMValueRef ssbo_ptr = lp_jit_context_ssbos(gallivm, context_ptr);
- LLVMValueRef num_ssbo_ptr = lp_jit_context_num_ssbos(gallivm, context_ptr);
LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][TGSI_NUM_CHANNELS];
memset(outputs, 0, sizeof outputs);
params.mask = &mask;
params.fs_iface = &fs_iface.base;
params.consts_ptr = consts_ptr;
- params.const_sizes_ptr = num_consts_ptr;
params.system_values = &system_values;
params.inputs = interp->inputs;
params.context_ptr = context_ptr;
params.sampler = sampler;
params.info = &shader->info.base;
params.ssbo_ptr = ssbo_ptr;
- params.ssbo_sizes_ptr = num_ssbo_ptr;
params.image = image;
params.aniso_filter_table = lp_jit_context_aniso_filter_table(gallivm, context_ptr);