gallivm: refactor common resources out of contexts

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22788>
This commit is contained in:
Dave Airlie 2022-08-27 06:35:43 +10:00 committed by Marge Bot
parent 90295bccc5
commit 5f32b2ecf5
35 changed files with 720 additions and 1006 deletions

View file

@ -398,6 +398,7 @@ llvm_gs_run(struct draw_geometry_shader *shader,
}
shader->current_variant->jit_func(shader->jit_context,
shader->jit_resources,
shader->gs_input->data,
input,
input_primitives,
@ -905,6 +906,7 @@ draw_create_geometry_shader(struct draw_context *draw,
gs->run = llvm_gs_run;
gs->jit_context = &draw->llvm->gs_jit_context;
gs->jit_resources = &draw->llvm->gs_jit_resources;
llvm_gs->variant_key_size =
draw_gs_llvm_variant_key_size(

View file

@ -100,6 +100,7 @@ struct draw_geometry_shader {
#ifdef DRAW_LLVM_AVAILABLE
struct draw_gs_inputs *gs_input;
struct draw_gs_jit_context *jit_context;
struct lp_jit_resources *jit_resources;
struct draw_gs_llvm_variant *current_variant;
struct vertex_header *gs_output[PIPE_MAX_VERTEX_STREAMS];

View file

@ -149,41 +149,16 @@ create_jit_dvbuffer_type(struct gallivm_state *gallivm,
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 = lp_build_create_jit_texture_type(gallivm);
LLVMTypeRef sampler_type = lp_build_create_jit_sampler_type(gallivm);
LLVMTypeRef image_type = lp_build_create_jit_image_type(gallivm);
LLVMTargetDataRef target = gallivm->target;
LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context);
LLVMTypeRef elem_types[DRAW_JIT_CTX_NUM_FIELDS];
elem_types[DRAW_JIT_CTX_CONSTANTS] = LLVMArrayType(buffer_type, LP_MAX_TGSI_CONST_BUFFERS);
elem_types[DRAW_JIT_CTX_SSBOS] = LLVMArrayType(buffer_type, LP_MAX_TGSI_SHADER_BUFFERS);
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_ANISO_FILTER_TABLE] = LLVMPointerType(float_type, 0);
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);
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, constants,
target, context_type, DRAW_JIT_CTX_CONSTANTS);
LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, ssbos,
target, context_type, DRAW_JIT_CTX_SSBOS);
LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, textures,
target, context_type,
DRAW_JIT_CTX_TEXTURES);
LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, samplers,
target, context_type,
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, aniso_filter_table,
target, context_type, DRAW_JIT_CTX_ANISO_FILTER_TABLE);
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,
@ -201,9 +176,6 @@ create_jit_context_type(struct gallivm_state *gallivm, const char *struct_name)
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)
{
LLVMTargetDataRef target = gallivm->target;
@ -212,17 +184,6 @@ create_gs_jit_context_type(struct gallivm_state *gallivm,
LLVMTypeRef elem_types[DRAW_GS_JIT_CTX_NUM_FIELDS];
LLVMTypeRef context_type;
elem_types[DRAW_GS_JIT_CTX_CONSTANTS] = LLVMArrayType(buffer_type, /* constants */
LP_MAX_TGSI_CONST_BUFFERS);
elem_types[DRAW_GS_JIT_CTX_SSBOS] = LLVMArrayType(buffer_type, /* ssbos */
LP_MAX_TGSI_SHADER_BUFFERS);
elem_types[DRAW_GS_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type,
PIPE_MAX_SHADER_SAMPLER_VIEWS); /* textures */
elem_types[DRAW_GS_JIT_CTX_SAMPLERS] = LLVMArrayType(sampler_type,
PIPE_MAX_SAMPLERS); /* samplers */
elem_types[DRAW_GS_JIT_CTX_IMAGES] = LLVMArrayType(image_type,
PIPE_MAX_SHADER_IMAGES); /* images */
elem_types[DRAW_GS_JIT_CTX_ANISO_FILTER_TABLE] = LLVMPointerType(float_type, 0); /* aniso table */
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 */
@ -238,20 +199,6 @@ create_gs_jit_context_type(struct gallivm_state *gallivm,
ARRAY_SIZE(elem_types), 0);
(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, ssbos,
target, context_type, DRAW_GS_JIT_CTX_SSBOS);
LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, textures,
target, context_type,
DRAW_GS_JIT_CTX_TEXTURES);
LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, samplers,
target, context_type,
DRAW_GS_JIT_CTX_SAMPLERS);
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,
target, context_type, DRAW_GS_JIT_CTX_ANISO_FILTER_TABLE);
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,
@ -374,62 +321,6 @@ create_jit_vertex_header(struct gallivm_state *gallivm, int data_elems)
return vertex_header;
}
/**
* Create LLVM type for struct draw_tcs_jit_context
*/
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 elem_types[DRAW_TCS_JIT_CTX_NUM_FIELDS];
LLVMTypeRef context_type;
elem_types[DRAW_TCS_JIT_CTX_CONSTANTS] = LLVMArrayType(buffer_type, /* constants */
LP_MAX_TGSI_CONST_BUFFERS);
elem_types[DRAW_TCS_JIT_CTX_SSBOS] = LLVMArrayType(buffer_type, /* ssbos */
LP_MAX_TGSI_SHADER_BUFFERS);
elem_types[DRAW_TCS_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type,
PIPE_MAX_SHADER_SAMPLER_VIEWS); /* textures */
elem_types[DRAW_TCS_JIT_CTX_SAMPLERS] = LLVMArrayType(sampler_type,
PIPE_MAX_SAMPLERS); /* samplers */
elem_types[DRAW_TCS_JIT_CTX_IMAGES] = LLVMArrayType(image_type,
PIPE_MAX_SHADER_IMAGES); /* images */
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, ssbos,
target, context_type, DRAW_TCS_JIT_CTX_SSBOS);
LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, textures,
target, context_type,
DRAW_TCS_JIT_CTX_TEXTURES);
LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, samplers,
target, context_type,
DRAW_TCS_JIT_CTX_SAMPLERS);
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,
target, context_type, DRAW_TCS_JIT_CTX_ANISO_FILTER_TABLE);
LP_CHECK_STRUCT_SIZE(struct draw_tcs_jit_context,
target, context_type);
return context_type;
}
static LLVMTypeRef
create_tcs_jit_input_type_deref(struct gallivm_state *gallivm)
{
@ -481,60 +372,6 @@ create_tes_jit_input_deref_type(struct gallivm_state *gallivm)
}
/**
* Create LLVM type for struct draw_tes_jit_context
*/
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 elem_types[DRAW_TES_JIT_CTX_NUM_FIELDS];
LLVMTypeRef context_type;
elem_types[DRAW_TES_JIT_CTX_CONSTANTS] = LLVMArrayType(buffer_type, /* constants */
LP_MAX_TGSI_CONST_BUFFERS);
elem_types[DRAW_TES_JIT_CTX_SSBOS] = LLVMArrayType(buffer_type, /* ssbos */
LP_MAX_TGSI_SHADER_BUFFERS);
elem_types[DRAW_TES_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type,
PIPE_MAX_SHADER_SAMPLER_VIEWS); /* textures */
elem_types[DRAW_TES_JIT_CTX_SAMPLERS] = LLVMArrayType(sampler_type,
PIPE_MAX_SAMPLERS); /* samplers */
elem_types[DRAW_TES_JIT_CTX_IMAGES] = LLVMArrayType(image_type,
PIPE_MAX_SHADER_IMAGES); /* images */
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, ssbos,
target, context_type, DRAW_TES_JIT_CTX_SSBOS);
LP_CHECK_MEMBER_OFFSET(struct draw_tes_jit_context, textures,
target, context_type,
DRAW_TES_JIT_CTX_TEXTURES);
LP_CHECK_MEMBER_OFFSET(struct draw_tes_jit_context, samplers,
target, context_type,
DRAW_TES_JIT_CTX_SAMPLERS);
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,
target, context_type, DRAW_TES_JIT_CTX_ANISO_FILTER_TABLE);
LP_CHECK_STRUCT_SIZE(struct draw_tes_jit_context,
target, context_type);
return context_type;
}
/**
* Create LLVM types for various structures.
*/
@ -546,6 +383,9 @@ create_jit_types(struct draw_llvm_variant *variant)
variant->context_type = create_jit_context_type(gallivm, "draw_jit_context");
variant->context_ptr_type = LLVMPointerType(variant->context_type, 0);
variant->resources_type = lp_build_jit_resources_type(gallivm);
variant->resources_ptr_type = LLVMPointerType(variant->resources_type, 0);
variant->buffer_type = create_jit_dvbuffer_type(gallivm, "draw_vertex_buffer");
variant->buffer_ptr_type = LLVMPointerType(variant->buffer_type, 0);
@ -794,6 +634,7 @@ generate_vs(struct draw_llvm_variant *variant,
const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS],
const struct lp_bld_tgsi_system_values *system_values,
LLVMValueRef context_ptr,
LLVMValueRef resources_ptr,
const struct lp_build_sampler_soa *draw_sampler,
const struct lp_build_image_soa *draw_image,
boolean clamp_vertex_color,
@ -802,9 +643,9 @@ generate_vs(struct draw_llvm_variant *variant,
struct draw_llvm *llvm = variant->llvm;
const struct tgsi_token *tokens = llvm->draw->vs.vertex_shader->state.tokens;
LLVMValueRef consts_ptr =
draw_jit_context_constants(variant, context_ptr);
lp_jit_resources_constants(variant->gallivm, variant->resources_type, resources_ptr);
LLVMValueRef ssbos_ptr =
draw_jit_context_ssbos(variant, context_ptr);
lp_jit_resources_ssbos(variant->gallivm, variant->resources_type, resources_ptr);
struct lp_build_tgsi_params params;
memset(&params, 0, sizeof(params));
@ -816,11 +657,15 @@ generate_vs(struct draw_llvm_variant *variant,
params.inputs = inputs;
params.context_type = variant->context_type;
params.context_ptr = context_ptr;
params.resources_type = variant->resources_type;
params.resources_ptr = resources_ptr;
params.sampler = draw_sampler;
params.info = &llvm->draw->vs.vertex_shader->info;
params.ssbo_ptr = ssbos_ptr;
params.image = draw_image;
params.aniso_filter_table = draw_jit_context_aniso_filter_table(variant, context_ptr);
params.aniso_filter_table = lp_jit_resources_aniso_filter_table(variant->gallivm,
variant->resources_type,
resources_ptr);
if (llvm->draw->vs.vertex_shader->state.ir.nir &&
llvm->draw->vs.vertex_shader->state.type == PIPE_SHADER_IR_NIR) {
@ -1741,10 +1586,11 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
struct gallivm_state *gallivm = variant->gallivm;
LLVMContextRef context = gallivm->context;
LLVMTypeRef int32_type = LLVMInt32TypeInContext(context);
LLVMTypeRef arg_types[13];
LLVMTypeRef arg_types[14];
unsigned num_arg_types = ARRAY_SIZE(arg_types);
LLVMTypeRef func_type;
LLVMValueRef context_ptr;
LLVMValueRef resources_ptr;
LLVMBasicBlockRef block;
LLVMBuilderRef builder;
char func_name[64];
@ -1797,6 +1643,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
i = 0;
arg_types[i++] = get_context_ptr_type(variant); /* context */
arg_types[i++] = variant->resources_ptr_type; /* context */
arg_types[i++] = get_vertex_header_ptr_type(variant); /* vertex_header */
arg_types[i++] = get_buffer_ptr_type(variant); /* vbuffers */
arg_types[i++] = int32_type; /* count */
@ -1809,6 +1656,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
arg_types[i++] = LLVMPointerType(int32_type, 0); /* fetch_elts */
arg_types[i++] = int32_type; /* draw_id */
arg_types[i++] = int32_type; /* view_id */
assert(i == ARRAY_SIZE(arg_types));
func_type = LLVMFunctionType(LLVMInt8TypeInContext(context),
arg_types, num_arg_types, 0);
@ -1825,26 +1673,28 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
return;
context_ptr = LLVMGetParam(variant_func, 0);
io_ptr = LLVMGetParam(variant_func, 1);
vbuffers_ptr = LLVMGetParam(variant_func, 2);
count = LLVMGetParam(variant_func, 3);
start = LLVMGetParam(variant_func, 4);
resources_ptr = LLVMGetParam(variant_func, 1);
io_ptr = LLVMGetParam(variant_func, 2);
vbuffers_ptr = LLVMGetParam(variant_func, 3);
count = LLVMGetParam(variant_func, 4);
start = LLVMGetParam(variant_func, 5);
/*
* XXX: stride is actually unused. The stride we use is strictly calculated
* from the number of outputs (including the draw_extra outputs).
* Should probably fix some day (we need a new vs just because of extra
* outputs which the generated vs won't touch).
*/
stride = LLVMGetParam(variant_func, 5);
vb_ptr = LLVMGetParam(variant_func, 6);
system_values.instance_id = LLVMGetParam(variant_func, 7);
vertex_id_offset = LLVMGetParam(variant_func, 8);
system_values.base_instance = LLVMGetParam(variant_func, 9);
fetch_elts = LLVMGetParam(variant_func, 10);
system_values.draw_id = LLVMGetParam(variant_func, 11);
system_values.view_index = LLVMGetParam(variant_func, 12);
stride = LLVMGetParam(variant_func, 6);
vb_ptr = LLVMGetParam(variant_func, 7);
system_values.instance_id = LLVMGetParam(variant_func, 8);
vertex_id_offset = LLVMGetParam(variant_func, 9);
system_values.base_instance = LLVMGetParam(variant_func, 10);
fetch_elts = LLVMGetParam(variant_func, 11);
system_values.draw_id = LLVMGetParam(variant_func, 12);
system_values.view_index = LLVMGetParam(variant_func, 13);
lp_build_name(context_ptr, "context");
lp_build_name(resources_ptr, "resources");
lp_build_name(io_ptr, "io");
lp_build_name(vbuffers_ptr, "vbuffers");
lp_build_name(count, "count");
@ -1900,7 +1750,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
}
have_elts = LLVMBuildICmp(builder, LLVMIntNE,
LLVMConstPointerNull(arg_types[10]), fetch_elts, "");
LLVMConstPointerNull(arg_types[11]), fetch_elts, "");
fetch_max = LLVMBuildSub(builder, count, bld.one, "fetch_max");
fetch_max = lp_build_broadcast_scalar(&blduivec, fetch_max);
@ -2140,6 +1990,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
ptr_aos,
&system_values,
context_ptr,
resources_ptr,
sampler,
image,
key->clamp_vertex_color,
@ -2337,20 +2188,20 @@ draw_llvm_set_mapped_texture(struct draw_context *draw,
switch (shader_stage) {
case PIPE_SHADER_VERTEX:
assert(sview_idx < ARRAY_SIZE(draw->llvm->jit_context.textures));
jit_tex = &draw->llvm->jit_context.textures[sview_idx];
assert(sview_idx < ARRAY_SIZE(draw->llvm->jit_resources.textures));
jit_tex = &draw->llvm->jit_resources.textures[sview_idx];
break;
case PIPE_SHADER_GEOMETRY:
assert(sview_idx < ARRAY_SIZE(draw->llvm->gs_jit_context.textures));
jit_tex = &draw->llvm->gs_jit_context.textures[sview_idx];
assert(sview_idx < ARRAY_SIZE(draw->llvm->gs_jit_resources.textures));
jit_tex = &draw->llvm->gs_jit_resources.textures[sview_idx];
break;
case PIPE_SHADER_TESS_CTRL:
assert(sview_idx < ARRAY_SIZE(draw->llvm->tcs_jit_context.textures));
jit_tex = &draw->llvm->tcs_jit_context.textures[sview_idx];
assert(sview_idx < ARRAY_SIZE(draw->llvm->tcs_jit_resources.textures));
jit_tex = &draw->llvm->tcs_jit_resources.textures[sview_idx];
break;
case PIPE_SHADER_TESS_EVAL:
assert(sview_idx < ARRAY_SIZE(draw->llvm->tes_jit_context.textures));
jit_tex = &draw->llvm->tes_jit_context.textures[sview_idx];
assert(sview_idx < ARRAY_SIZE(draw->llvm->tes_jit_resources.textures));
jit_tex = &draw->llvm->tes_jit_resources.textures[sview_idx];
break;
default:
assert(0);
@ -2389,20 +2240,20 @@ draw_llvm_set_mapped_image(struct draw_context *draw,
switch (shader_stage) {
case PIPE_SHADER_VERTEX:
assert(idx < ARRAY_SIZE(draw->llvm->jit_context.images));
jit_image = &draw->llvm->jit_context.images[idx];
assert(idx < ARRAY_SIZE(draw->llvm->jit_resources.images));
jit_image = &draw->llvm->jit_resources.images[idx];
break;
case PIPE_SHADER_GEOMETRY:
assert(idx < ARRAY_SIZE(draw->llvm->gs_jit_context.images));
jit_image = &draw->llvm->gs_jit_context.images[idx];
assert(idx < ARRAY_SIZE(draw->llvm->gs_jit_resources.images));
jit_image = &draw->llvm->gs_jit_resources.images[idx];
break;
case PIPE_SHADER_TESS_CTRL:
assert(idx < ARRAY_SIZE(draw->llvm->tcs_jit_context.images));
jit_image = &draw->llvm->tcs_jit_context.images[idx];
assert(idx < ARRAY_SIZE(draw->llvm->tcs_jit_resources.images));
jit_image = &draw->llvm->tcs_jit_resources.images[idx];
break;
case PIPE_SHADER_TESS_EVAL:
assert(idx < ARRAY_SIZE(draw->llvm->tes_jit_context.images));
jit_image = &draw->llvm->tes_jit_context.images[idx];
assert(idx < ARRAY_SIZE(draw->llvm->tes_jit_resources.images));
jit_image = &draw->llvm->tes_jit_resources.images[idx];
break;
default:
assert(0);
@ -2428,7 +2279,7 @@ draw_llvm_set_sampler_state(struct draw_context *draw,
switch (shader_type) {
case PIPE_SHADER_VERTEX:
for (unsigned i = 0; i < draw->num_samplers[PIPE_SHADER_VERTEX]; i++) {
struct lp_jit_sampler *jit_sam = &draw->llvm->jit_context.samplers[i];
struct lp_jit_sampler *jit_sam = &draw->llvm->jit_resources.samplers[i];
if (draw->samplers[PIPE_SHADER_VERTEX][i]) {
const struct pipe_sampler_state *s
@ -2443,7 +2294,7 @@ draw_llvm_set_sampler_state(struct draw_context *draw,
break;
case PIPE_SHADER_GEOMETRY:
for (unsigned i = 0; i < draw->num_samplers[PIPE_SHADER_GEOMETRY]; i++) {
struct lp_jit_sampler *jit_sam = &draw->llvm->gs_jit_context.samplers[i];
struct lp_jit_sampler *jit_sam = &draw->llvm->gs_jit_resources.samplers[i];
if (draw->samplers[PIPE_SHADER_GEOMETRY][i]) {
const struct pipe_sampler_state *s
@ -2458,7 +2309,7 @@ draw_llvm_set_sampler_state(struct draw_context *draw,
break;
case PIPE_SHADER_TESS_CTRL:
for (unsigned i = 0; i < draw->num_samplers[PIPE_SHADER_TESS_CTRL]; i++) {
struct lp_jit_sampler *jit_sam = &draw->llvm->tcs_jit_context.samplers[i];
struct lp_jit_sampler *jit_sam = &draw->llvm->tcs_jit_resources.samplers[i];
if (draw->samplers[PIPE_SHADER_TESS_CTRL][i]) {
const struct pipe_sampler_state *s
@ -2473,7 +2324,7 @@ draw_llvm_set_sampler_state(struct draw_context *draw,
break;
case PIPE_SHADER_TESS_EVAL:
for (unsigned i = 0; i < draw->num_samplers[PIPE_SHADER_TESS_EVAL]; i++) {
struct lp_jit_sampler *jit_sam = &draw->llvm->tes_jit_context.samplers[i];
struct lp_jit_sampler *jit_sam = &draw->llvm->tes_jit_resources.samplers[i];
if (draw->samplers[PIPE_SHADER_TESS_EVAL][i]) {
const struct pipe_sampler_state *s
@ -2520,21 +2371,14 @@ static void
create_gs_jit_types(struct draw_gs_llvm_variant *var)
{
struct gallivm_state *gallivm = var->gallivm;
LLVMTypeRef texture_type, sampler_type, image_type, buffer_type;
texture_type = lp_build_create_jit_texture_type(gallivm);
sampler_type = lp_build_create_jit_sampler_type(gallivm);
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,
var->shader->base.vector_length,
buffer_type,
texture_type, sampler_type,
image_type,
"draw_gs_jit_context");
var->context_ptr_type = LLVMPointerType(var->context_type, 0);
var->resources_type = lp_build_jit_resources_type(gallivm);
var->resources_ptr_type = LLVMPointerType(var->resources_type, 0);
var->input_array_type = create_gs_jit_input_type(gallivm);
}
@ -2578,10 +2422,11 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
struct gallivm_state *gallivm = variant->gallivm;
LLVMContextRef context = gallivm->context;
LLVMTypeRef int32_type = LLVMInt32TypeInContext(context);
LLVMTypeRef arg_types[8];
LLVMTypeRef arg_types[9];
LLVMTypeRef func_type;
LLVMValueRef variant_func;
LLVMValueRef context_ptr;
LLVMValueRef resources_ptr;
LLVMValueRef prim_id_ptr;
LLVMBasicBlockRef block;
LLVMBuilderRef builder;
@ -2610,13 +2455,14 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
LLVMTypeRef prim_id_type = LLVMVectorType(int32_type, vector_length);
arg_types[0] = get_gs_context_ptr_type(variant); /* context */
arg_types[1] = variant->input_array_type; /* input */
arg_types[2] = LLVMPointerType(variant->vertex_header_ptr_type, 0); /* vertex_header */
arg_types[3] = int32_type; /* num_prims */
arg_types[4] = int32_type; /* instance_id */
arg_types[5] = LLVMPointerType(prim_id_type, 0); /* prim_id_ptr */
arg_types[6] = int32_type;
arg_types[1] = variant->resources_ptr_type;
arg_types[2] = variant->input_array_type; /* input */
arg_types[3] = LLVMPointerType(variant->vertex_header_ptr_type, 0); /* vertex_header */
arg_types[4] = int32_type; /* num_prims */
arg_types[5] = int32_type; /* instance_id */
arg_types[6] = LLVMPointerType(prim_id_type, 0); /* prim_id_ptr */
arg_types[7] = int32_type;
arg_types[8] = int32_type;
func_type = LLVMFunctionType(int32_type, arg_types, ARRAY_SIZE(arg_types), 0);
@ -2633,15 +2479,17 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
if (gallivm->cache && gallivm->cache->data_size)
return;
context_ptr = LLVMGetParam(variant_func, 0);
input_array = LLVMGetParam(variant_func, 1);
io_ptr = LLVMGetParam(variant_func, 2);
num_prims = LLVMGetParam(variant_func, 3);
system_values.instance_id = LLVMGetParam(variant_func, 4);
prim_id_ptr = LLVMGetParam(variant_func, 5);
system_values.invocation_id = LLVMGetParam(variant_func, 6);
system_values.view_index = LLVMGetParam(variant_func, 7);
resources_ptr = LLVMGetParam(variant_func, 1);
input_array = LLVMGetParam(variant_func, 2);
io_ptr = LLVMGetParam(variant_func, 3);
num_prims = LLVMGetParam(variant_func, 4);
system_values.instance_id = LLVMGetParam(variant_func, 5);
prim_id_ptr = LLVMGetParam(variant_func, 6);
system_values.invocation_id = LLVMGetParam(variant_func, 7);
system_values.view_index = LLVMGetParam(variant_func, 8);
lp_build_name(context_ptr, "context");
lp_build_name(resources_ptr, "resources");
lp_build_name(input_array, "input");
lp_build_name(io_ptr, "io");
lp_build_name(num_prims, "num_prims");
@ -2678,9 +2526,9 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
gs_type.width = 32; /* 32-bit float */
gs_type.length = vector_length;
consts_ptr = draw_gs_jit_context_constants(variant, context_ptr);
consts_ptr = lp_jit_resources_constants(gallivm, variant->resources_type, resources_ptr);
ssbos_ptr = draw_gs_jit_context_ssbos(variant, context_ptr);
ssbos_ptr = lp_jit_resources_ssbos(gallivm, variant->resources_type, resources_ptr);
/* code generated texture sampling */
sampler = draw_llvm_sampler_soa_create(variant->key.samplers,
@ -2712,13 +2560,17 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
params.system_values = &system_values;
params.context_type = variant->context_type;
params.context_ptr = context_ptr;
params.resources_type = variant->resources_type;
params.resources_ptr = resources_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.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);
params.aniso_filter_table = lp_jit_resources_aniso_filter_table(gallivm,
variant->resources_type,
resources_ptr);
if (llvm->draw->gs.geometry_shader->state.type == PIPE_SHADER_IR_TGSI)
lp_build_tgsi_soa(variant->gallivm,
@ -2906,31 +2758,20 @@ static void
create_tcs_jit_types(struct draw_tcs_llvm_variant *var)
{
struct gallivm_state *gallivm = var->gallivm;
LLVMTypeRef texture_type, sampler_type, image_type, buffer_type;
texture_type = lp_build_create_jit_texture_type(gallivm);
sampler_type = lp_build_create_jit_sampler_type(gallivm);
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,
0,
buffer_type,
texture_type, sampler_type,
image_type,
"draw_tcs_jit_context");
var->resources_type = lp_build_jit_resources_type(gallivm);
var->resources_ptr_type = LLVMPointerType(var->resources_type, 0);
var->input_array_type = create_tcs_jit_input_type(gallivm);
var->output_array_type = create_tcs_jit_output_type(gallivm);
var->context_ptr_type = LLVMPointerType(var->context_type, 0);
}
static LLVMTypeRef
get_tcs_context_ptr_type(struct draw_tcs_llvm_variant *variant)
get_tcs_resources_ptr_type(struct draw_tcs_llvm_variant *variant)
{
if (!variant->context_ptr_type)
if (!variant->resources_ptr_type)
create_tcs_jit_types(variant);
return variant->context_ptr_type;
return variant->resources_ptr_type;
}
@ -3170,7 +3011,7 @@ draw_tcs_llvm_generate(struct draw_llvm *llvm,
LLVMTypeRef arg_types[7];
LLVMTypeRef func_type, coro_func_type;
LLVMValueRef variant_func, variant_coro;
LLVMValueRef context_ptr;
LLVMValueRef resources_ptr;
LLVMValueRef view_index;
LLVMValueRef input_array, output_array, prim_id, patch_vertices_in;
LLVMValueRef mask_val;
@ -3194,7 +3035,7 @@ draw_tcs_llvm_generate(struct draw_llvm *llvm,
snprintf(func_name_coro, sizeof(func_name_coro), "draw_llvm_tcs_coro_variant");
arg_types[0] = get_tcs_context_ptr_type(variant); /* context */
arg_types[0] = get_tcs_resources_ptr_type(variant); /* context */
arg_types[1] = variant->input_array_type; /* input */
arg_types[2] = variant->output_array_type;
arg_types[3] = int32_type;
@ -3226,14 +3067,14 @@ draw_tcs_llvm_generate(struct draw_llvm *llvm,
if (gallivm->cache && gallivm->cache->data_size)
return;
context_ptr = LLVMGetParam(variant_func, 0);
resources_ptr = LLVMGetParam(variant_func, 0);
input_array = LLVMGetParam(variant_func, 1);
output_array = LLVMGetParam(variant_func, 2);
prim_id = LLVMGetParam(variant_func, 3);
patch_vertices_in = LLVMGetParam(variant_func, 4);
view_index = LLVMGetParam(variant_func, 5);
lp_build_name(context_ptr, "context");
lp_build_name(resources_ptr, "resources");
lp_build_name(input_array, "input");
lp_build_name(output_array, "output");
lp_build_name(prim_id, "prim_id");
@ -3271,7 +3112,7 @@ draw_tcs_llvm_generate(struct draw_llvm *llvm,
lp_build_const_int32(gallivm, 0)); /* inner loop */
{
LLVMValueRef args[7];
args[0] = context_ptr;
args[0] = resources_ptr;
args[1] = input_array;
args[2] = output_array;
args[3] = prim_id;
@ -3314,16 +3155,16 @@ draw_tcs_llvm_generate(struct draw_llvm *llvm,
block = LLVMAppendBasicBlockInContext(gallivm->context, variant_coro, "entry");
LLVMPositionBuilderAtEnd(builder, block);
context_ptr = LLVMGetParam(variant_coro, 0);
resources_ptr = LLVMGetParam(variant_coro, 0);
input_array = LLVMGetParam(variant_coro, 1);
output_array = LLVMGetParam(variant_coro, 2);
prim_id = LLVMGetParam(variant_coro, 3);
patch_vertices_in = LLVMGetParam(variant_coro, 4);
view_index = LLVMGetParam(variant_coro, 5);
consts_ptr = draw_tcs_jit_context_constants(variant, context_ptr);
consts_ptr = lp_jit_resources_constants(gallivm, variant->resources_type, resources_ptr);
ssbos_ptr = draw_tcs_jit_context_ssbos(variant, context_ptr);
ssbos_ptr = lp_jit_resources_ssbos(gallivm, variant->resources_type, resources_ptr);
sampler = draw_llvm_sampler_soa_create(variant->key.samplers,
MAX2(variant->key.nr_samplers,
variant->key.nr_sampler_views));
@ -3371,15 +3212,17 @@ draw_tcs_llvm_generate(struct draw_llvm *llvm,
params.mask = &mask;
params.consts_ptr = consts_ptr;
params.system_values = &system_values;
params.context_type = variant->context_type;
params.context_ptr = context_ptr;
params.resources_type = variant->resources_type;
params.resources_ptr = resources_ptr;
params.sampler = sampler;
params.info = &llvm->draw->tcs.tess_ctrl_shader->info;
params.ssbo_ptr = ssbos_ptr;
params.image = image;
params.coro = &coro_info;
params.tcs_iface = &tcs_iface.base;
params.aniso_filter_table = draw_tcs_jit_context_aniso_filter_table(variant, context_ptr);
params.aniso_filter_table = lp_jit_resources_aniso_filter_table(gallivm,
variant->resources_type,
resources_ptr);
lp_build_nir_soa(variant->gallivm,
llvm->draw->tcs.tess_ctrl_shader->state.ir.nir,
@ -3565,32 +3408,20 @@ static void
create_tes_jit_types(struct draw_tes_llvm_variant *var)
{
struct gallivm_state *gallivm = var->gallivm;
LLVMTypeRef texture_type, sampler_type, image_type, buffer_type;
texture_type = lp_build_create_jit_texture_type(gallivm);
sampler_type = lp_build_create_jit_sampler_type(gallivm);
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,
0,
buffer_type,
texture_type, sampler_type,
image_type,
"draw_tes_jit_context");
var->context_ptr_type = LLVMPointerType(var->context_type, 0);
var->resources_type = lp_build_jit_resources_type(gallivm);
var->resources_ptr_type = LLVMPointerType(var->resources_type, 0);
var->input_array_deref_type = create_tes_jit_input_deref_type(gallivm);
var->input_array_type = LLVMPointerType(var->input_array_deref_type, 0); /* num vertices per prim */
}
static LLVMTypeRef
get_tes_context_ptr_type(struct draw_tes_llvm_variant *variant)
get_tes_resources_ptr_type(struct draw_tes_llvm_variant *variant)
{
if (!variant->context_ptr_type)
if (!variant->resources_ptr_type)
create_tes_jit_types(variant);
return variant->context_ptr_type;
return variant->resources_ptr_type;
}
@ -3739,7 +3570,7 @@ draw_tes_llvm_generate(struct draw_llvm *llvm,
LLVMTypeRef arg_types[11];
LLVMTypeRef func_type;
LLVMValueRef variant_func;
LLVMValueRef context_ptr;
LLVMValueRef resources_ptr;
LLVMValueRef tess_coord[2], io_ptr, input_array, num_tess_coord;
LLVMValueRef view_index;
LLVMValueRef tess_inner, tess_outer, prim_id, patch_vertices_in;
@ -3770,7 +3601,7 @@ draw_tes_llvm_generate(struct draw_llvm *llvm,
LLVMTypeRef tess_outer_deref_type = LLVMArrayType(flt_type, 4);
LLVMTypeRef tess_inner_deref_type = LLVMArrayType(flt_type, 2);
arg_types[0] = get_tes_context_ptr_type(variant); /* context */
arg_types[0] = get_tes_resources_ptr_type(variant); /* context */
arg_types[1] = variant->input_array_type; /* input */
arg_types[2] = variant->vertex_header_ptr_type;
arg_types[3] = int32_type;
@ -3794,7 +3625,7 @@ draw_tes_llvm_generate(struct draw_llvm *llvm,
if (gallivm->cache && gallivm->cache->data_size)
return;
context_ptr = LLVMGetParam(variant_func, 0);
resources_ptr = LLVMGetParam(variant_func, 0);
input_array = LLVMGetParam(variant_func, 1);
io_ptr = LLVMGetParam(variant_func, 2);
prim_id = LLVMGetParam(variant_func, 3);
@ -3806,7 +3637,7 @@ draw_tes_llvm_generate(struct draw_llvm *llvm,
patch_vertices_in = LLVMGetParam(variant_func, 9);
view_index = LLVMGetParam(variant_func, 10);
lp_build_name(context_ptr, "context");
lp_build_name(resources_ptr, "resources");
lp_build_name(input_array, "input");
lp_build_name(io_ptr, "io");
lp_build_name(prim_id, "prim_id");
@ -3837,9 +3668,9 @@ draw_tes_llvm_generate(struct draw_llvm *llvm,
tes_type.length = vector_length;
lp_build_context_init(&bldvec, variant->gallivm, lp_int_type(tes_type));
consts_ptr = draw_tes_jit_context_constants(variant, context_ptr);
consts_ptr = lp_jit_resources_constants(gallivm, variant->resources_type, resources_ptr);
ssbos_ptr = draw_tes_jit_context_ssbos(variant, context_ptr);
ssbos_ptr = lp_jit_resources_ssbos(gallivm, variant->resources_type, resources_ptr);
sampler = draw_llvm_sampler_soa_create(variant->key.samplers,
MAX2(variant->key.nr_samplers,
@ -3902,14 +3733,14 @@ draw_tes_llvm_generate(struct draw_llvm *llvm,
params.mask = &mask;
params.consts_ptr = consts_ptr;
params.system_values = &system_values;
params.context_type = variant->context_type;
params.context_ptr = context_ptr;
params.resources_type = variant->resources_type;
params.resources_ptr = resources_ptr;
params.sampler = sampler;
params.info = &llvm->draw->tes.tess_eval_shader->info;
params.ssbo_ptr = 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);
params.aniso_filter_table = lp_jit_resources_aniso_filter_table(gallivm, variant->resources_type, resources_ptr);
lp_build_nir_soa(variant->gallivm,
llvm->draw->tes.tess_eval_shader->state.ir.nir,

View file

@ -83,47 +83,16 @@ enum {
*/
struct draw_jit_context
{
struct lp_jit_buffer constants[LP_MAX_TGSI_CONST_BUFFERS];
struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_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 float *aniso_filter_table;
float (*planes) [DRAW_TOTAL_CLIP_PLANES][4];
struct pipe_viewport_state *viewports;
};
enum {
DRAW_JIT_CTX_CONSTANTS = 0,
DRAW_JIT_CTX_SSBOS = 1,
DRAW_JIT_CTX_TEXTURES = 2,
DRAW_JIT_CTX_SAMPLERS = 3,
DRAW_JIT_CTX_IMAGES = 4,
DRAW_JIT_CTX_ANISO_FILTER_TABLE = 5,
DRAW_JIT_CTX_PLANES = 6,
DRAW_JIT_CTX_VIEWPORT = 7,
DRAW_JIT_CTX_PLANES = 0,
DRAW_JIT_CTX_VIEWPORT = 1,
DRAW_JIT_CTX_NUM_FIELDS
};
#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_ssbos(_variant, _ptr) \
lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_JIT_CTX_SSBOS, "ssbos")
#define draw_jit_context_textures(_variant, _ptr) \
lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_JIT_CTX_TEXTURES, "textures")
#define draw_jit_context_samplers(_variant, _ptr) \
lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_JIT_CTX_SAMPLERS, "samplers")
#define draw_jit_context_images(_variant, _ptr) \
lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_JIT_CTX_IMAGES, "images")
#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")
#define draw_jit_context_planes(_gallivm, _type, _ptr) \
lp_build_struct_get2(_gallivm, _type, _ptr, DRAW_JIT_CTX_PLANES, "planes")
@ -173,13 +142,6 @@ enum {
*/
struct draw_gs_jit_context
{
struct lp_jit_buffer constants[LP_MAX_TGSI_CONST_BUFFERS];
struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_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 float *aniso_filter_table;
float (*planes) [DRAW_TOTAL_CLIP_PLANES][4];
struct pipe_viewport_state *viewports;
@ -189,38 +151,14 @@ struct draw_gs_jit_context
};
enum {
DRAW_GS_JIT_CTX_CONSTANTS = DRAW_JIT_CTX_CONSTANTS,
DRAW_GS_JIT_CTX_SSBOS = DRAW_JIT_CTX_SSBOS,
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_ANISO_FILTER_TABLE = DRAW_JIT_CTX_ANISO_FILTER_TABLE,
DRAW_GS_JIT_CTX_PLANES = 6,
DRAW_GS_JIT_CTX_VIEWPORT = 7,
DRAW_GS_JIT_CTX_PRIM_LENGTHS = 8,
DRAW_GS_JIT_CTX_EMITTED_VERTICES = 9,
DRAW_GS_JIT_CTX_EMITTED_PRIMS = 10,
DRAW_GS_JIT_CTX_NUM_FIELDS = 11
DRAW_GS_JIT_CTX_PLANES = 0,
DRAW_GS_JIT_CTX_VIEWPORT = 1,
DRAW_GS_JIT_CTX_PRIM_LENGTHS = 2,
DRAW_GS_JIT_CTX_EMITTED_VERTICES = 3,
DRAW_GS_JIT_CTX_EMITTED_PRIMS = 4,
DRAW_GS_JIT_CTX_NUM_FIELDS = 5
};
#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_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_textures(_variant, _ptr) \
lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_GS_JIT_CTX_TEXTURES, "textures")
#define draw_gs_jit_context_samplers(_variant, _ptr) \
lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_GS_JIT_CTX_SAMPLERS, "samplers")
#define draw_gs_jit_context_images(_variant, _ptr) \
lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_GS_JIT_CTX_IMAGES, "images")
#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")
#define draw_gs_jit_context_planes(_gallivm, _ptr) \
lp_build_struct_get(_gallivm, _ptr, DRAW_GS_JIT_CTX_PLANES, "planes")
@ -237,82 +175,9 @@ enum {
lp_build_struct_get2(_variant->gallivm, _variant->context_type, _ptr, DRAW_GS_JIT_CTX_EMITTED_PRIMS, "emitted_prims")
struct draw_tcs_jit_context {
struct lp_jit_buffer constants[LP_MAX_TGSI_CONST_BUFFERS];
struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_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 float *aniso_filter_table;
};
enum {
DRAW_TCS_JIT_CTX_CONSTANTS = DRAW_JIT_CTX_CONSTANTS,
DRAW_TCS_JIT_CTX_SSBOS = DRAW_JIT_CTX_SSBOS,
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_ANISO_FILTER_TABLE = DRAW_JIT_CTX_ANISO_FILTER_TABLE,
DRAW_TCS_JIT_CTX_NUM_FIELDS = 6,
};
#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_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_textures(_variant, _ptr) \
lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TCS_JIT_CTX_TEXTURES, "textures")
#define draw_tcs_jit_context_samplers(_variant, _ptr) \
lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TCS_JIT_CTX_SAMPLERS, "samplers")
#define draw_tcs_jit_context_images(_variant, _ptr) \
lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TCS_JIT_CTX_IMAGES, "images")
#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 {
struct lp_jit_buffer constants[LP_MAX_TGSI_CONST_BUFFERS];
struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_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 float *aniso_filter_table;
};
enum {
DRAW_TES_JIT_CTX_CONSTANTS = DRAW_JIT_CTX_CONSTANTS,
DRAW_TES_JIT_CTX_SSBOS = DRAW_JIT_CTX_SSBOS,
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_ANISO_FILTER_TABLE = DRAW_JIT_CTX_ANISO_FILTER_TABLE,
DRAW_TES_JIT_CTX_NUM_FIELDS = 6,
};
#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_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_textures(_variant, _ptr) \
lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TES_JIT_CTX_TEXTURES, "textures")
#define draw_tes_jit_context_samplers(_variant, _ptr) \
lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TES_JIT_CTX_SAMPLERS, "samplers")
#define draw_tes_jit_context_images(_variant, _ptr) \
lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TES_JIT_CTX_IMAGES, "images")
#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")
typedef boolean
(*draw_jit_vert_func)(struct draw_jit_context *context,
const struct lp_jit_resources *resources,
struct vertex_header *io,
const struct draw_vertex_buffer vbuffers[PIPE_MAX_ATTRIBS],
unsigned count,
@ -328,6 +193,7 @@ typedef boolean
typedef int
(*draw_gs_jit_func)(struct draw_gs_jit_context *context,
const struct lp_jit_resources *resources,
float inputs[6][PIPE_MAX_SHADER_INPUTS][TGSI_NUM_CHANNELS][TGSI_NUM_CHANNELS],
struct vertex_header **output,
unsigned num_prims,
@ -337,14 +203,14 @@ typedef int
unsigned view_id);
typedef int
(*draw_tcs_jit_func)(struct draw_tcs_jit_context *context,
(*draw_tcs_jit_func)(const struct lp_jit_resources *resources,
float inputs[32][NUM_TCS_INPUTS][TGSI_NUM_CHANNELS],
float outputs[32][PIPE_MAX_SHADER_INPUTS][TGSI_NUM_CHANNELS],
uint32_t prim_id, uint32_t patch_vertices_in,
unsigned view_id);
typedef int
(*draw_tes_jit_func)(struct draw_tes_jit_context *context,
(*draw_tes_jit_func)(const struct lp_jit_resources *resources,
float inputs[32][PIPE_MAX_SHADER_INPUTS][TGSI_NUM_CHANNELS],
struct vertex_header *io,
uint32_t prim_id, uint32_t num_tess_coord,
@ -553,6 +419,9 @@ struct draw_llvm_variant
LLVMTypeRef context_type;
LLVMTypeRef context_ptr_type;
LLVMTypeRef resources_type;
LLVMTypeRef resources_ptr_type;
LLVMTypeRef buffer_type;
LLVMTypeRef buffer_ptr_type;
@ -584,6 +453,9 @@ struct draw_gs_llvm_variant
LLVMTypeRef context_type;
LLVMTypeRef context_ptr_type;
LLVMTypeRef resources_type;
LLVMTypeRef resources_ptr_type;
LLVMTypeRef vertex_header_type;
LLVMTypeRef vertex_header_ptr_type;
@ -610,8 +482,8 @@ struct draw_tcs_llvm_variant
struct gallivm_state *gallivm;
/* LLVM JIT builder types */
LLVMTypeRef context_type;
LLVMTypeRef context_ptr_type;
LLVMTypeRef resources_type;
LLVMTypeRef resources_ptr_type;
LLVMTypeRef input_array_type;
LLVMTypeRef output_array_type;
@ -636,8 +508,8 @@ struct draw_tes_llvm_variant
struct gallivm_state *gallivm;
/* LLVM JIT builder types */
LLVMTypeRef context_type;
LLVMTypeRef context_ptr_type;
LLVMTypeRef resources_type;
LLVMTypeRef resources_ptr_type;
LLVMTypeRef vertex_header_ptr_type;
LLVMTypeRef input_array_type;
LLVMTypeRef patch_input_array_type;
@ -705,8 +577,11 @@ struct draw_llvm {
struct draw_jit_context jit_context;
struct draw_gs_jit_context gs_jit_context;
struct draw_tcs_jit_context tcs_jit_context;
struct draw_tes_jit_context tes_jit_context;
struct lp_jit_resources jit_resources;
struct lp_jit_resources gs_jit_resources;
struct lp_jit_resources tcs_jit_resources;
struct lp_jit_resources tes_jit_resources;
struct draw_llvm_variant_list_item vs_variants_list;
int nr_variants;

View file

@ -100,8 +100,8 @@ struct draw_llvm_image_soa
*/
static LLVMValueRef
draw_llvm_texture_member(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned texture_unit,
LLVMValueRef texture_unit_offset,
unsigned member_index,
@ -116,36 +116,36 @@ draw_llvm_texture_member(struct gallivm_state *gallivm,
assert(texture_unit < PIPE_MAX_SHADER_SAMPLER_VIEWS);
/* context[0] */
/* resources[0] */
indices[0] = lp_build_const_int32(gallivm, 0);
/* context[0].textures */
indices[1] = lp_build_const_int32(gallivm, DRAW_JIT_CTX_TEXTURES);
/* context[0].textures[unit] */
/* resources[0].textures */
indices[1] = lp_build_const_int32(gallivm, LP_JIT_RES_TEXTURES);
/* resources[0].textures[unit] */
indices[2] = lp_build_const_int32(gallivm, texture_unit);
if (texture_unit_offset) {
indices[2] = LLVMBuildAdd(gallivm->builder, indices[2], texture_unit_offset, "");
LLVMValueRef cond = LLVMBuildICmp(gallivm->builder, LLVMIntULT, indices[2], lp_build_const_int32(gallivm, PIPE_MAX_SHADER_SAMPLER_VIEWS), "");
indices[2] = LLVMBuildSelect(gallivm->builder, cond, indices[2], lp_build_const_int32(gallivm, texture_unit), "");
}
/* context[0].textures[unit].member */
/* resources[0].textures[unit].member */
indices[3] = lp_build_const_int32(gallivm, member_index);
ptr = LLVMBuildGEP2(builder, context_type, context_ptr, indices, ARRAY_SIZE(indices), "");
ptr = LLVMBuildGEP2(builder, resources_type, resources_ptr, indices, ARRAY_SIZE(indices), "");
if (emit_load) {
LLVMTypeRef tex_type = LLVMStructGetTypeAtIndex(context_type, DRAW_JIT_CTX_TEXTURES);
LLVMTypeRef tex_type = LLVMStructGetTypeAtIndex(resources_type, LP_JIT_RES_TEXTURES);
LLVMTypeRef res_type = LLVMStructGetTypeAtIndex(LLVMGetElementType(tex_type), member_index);
res = LLVMBuildLoad2(builder, res_type, ptr, "");
} else
res = ptr;
if (out_type) {
LLVMTypeRef tex_type = LLVMStructGetTypeAtIndex(context_type, DRAW_JIT_CTX_TEXTURES);
LLVMTypeRef tex_type = LLVMStructGetTypeAtIndex(resources_type, LP_JIT_RES_TEXTURES);
LLVMTypeRef res_type = LLVMStructGetTypeAtIndex(LLVMGetElementType(tex_type), member_index);
*out_type = res_type;
}
lp_build_name(res, "context.texture%u.%s", texture_unit, member_name);
lp_build_name(res, "resources.texture%u.%s", texture_unit, member_name);
return res;
}
@ -161,8 +161,8 @@ draw_llvm_texture_member(struct gallivm_state *gallivm,
*/
static LLVMValueRef
draw_llvm_sampler_member(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned sampler_unit,
unsigned member_index,
const char *member_name,
@ -175,25 +175,25 @@ draw_llvm_sampler_member(struct gallivm_state *gallivm,
assert(sampler_unit < PIPE_MAX_SAMPLERS);
/* context[0] */
/* resources[0] */
indices[0] = lp_build_const_int32(gallivm, 0);
/* context[0].samplers */
indices[1] = lp_build_const_int32(gallivm, DRAW_JIT_CTX_SAMPLERS);
/* context[0].samplers[unit] */
/* resources[0].samplers */
indices[1] = lp_build_const_int32(gallivm, LP_JIT_RES_SAMPLERS);
/* resources[0].samplers[unit] */
indices[2] = lp_build_const_int32(gallivm, sampler_unit);
/* context[0].samplers[unit].member */
/* resources[0].samplers[unit].member */
indices[3] = lp_build_const_int32(gallivm, member_index);
ptr = LLVMBuildGEP2(builder, context_type, context_ptr, indices, ARRAY_SIZE(indices), "");
ptr = LLVMBuildGEP2(builder, resources_type, resources_ptr, indices, ARRAY_SIZE(indices), "");
if (emit_load) {
LLVMTypeRef samp_type = LLVMStructGetTypeAtIndex(context_type, DRAW_JIT_CTX_SAMPLERS);
LLVMTypeRef samp_type = LLVMStructGetTypeAtIndex(resources_type, LP_JIT_RES_SAMPLERS);
LLVMTypeRef res_type = LLVMStructGetTypeAtIndex(LLVMGetElementType(samp_type), member_index);
res = LLVMBuildLoad2(builder, res_type, ptr, "");
} else
res = ptr;
lp_build_name(res, "context.sampler%u.%s", sampler_unit, member_name);
lp_build_name(res, "resources.sampler%u.%s", sampler_unit, member_name);
return res;
}
@ -208,8 +208,8 @@ draw_llvm_sampler_member(struct gallivm_state *gallivm,
*/
static LLVMValueRef
draw_llvm_image_member(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned image_unit,
LLVMValueRef image_unit_offset,
unsigned member_index,
@ -223,30 +223,30 @@ draw_llvm_image_member(struct gallivm_state *gallivm,
assert(image_unit < PIPE_MAX_SHADER_IMAGES);
/* context[0] */
/* resources[0] */
indices[0] = lp_build_const_int32(gallivm, 0);
/* context[0].textures */
indices[1] = lp_build_const_int32(gallivm, DRAW_JIT_CTX_IMAGES);
/* context[0].textures[unit] */
/* resources[0].textures */
indices[1] = lp_build_const_int32(gallivm, LP_JIT_RES_IMAGES);
/* resources[0].textures[unit] */
indices[2] = lp_build_const_int32(gallivm, image_unit);
if (image_unit_offset) {
indices[2] = LLVMBuildAdd(gallivm->builder, indices[2], image_unit_offset, "");
LLVMValueRef cond = LLVMBuildICmp(gallivm->builder, LLVMIntULT, indices[2], lp_build_const_int32(gallivm, PIPE_MAX_SHADER_IMAGES), "");
indices[2] = LLVMBuildSelect(gallivm->builder, cond, indices[2], lp_build_const_int32(gallivm, image_unit), "");
}
/* context[0].textures[unit].member */
/* resources[0].textures[unit].member */
indices[3] = lp_build_const_int32(gallivm, member_index);
ptr = LLVMBuildGEP2(builder, context_type, context_ptr, indices, ARRAY_SIZE(indices), "");
ptr = LLVMBuildGEP2(builder, resources_type, resources_ptr, indices, ARRAY_SIZE(indices), "");
if (emit_load) {
LLVMTypeRef img_type = LLVMStructGetTypeAtIndex(context_type, DRAW_JIT_CTX_IMAGES);
LLVMTypeRef img_type = LLVMStructGetTypeAtIndex(resources_type, LP_JIT_RES_IMAGES);
LLVMTypeRef res_type = LLVMStructGetTypeAtIndex(LLVMGetElementType(img_type), member_index);
res = LLVMBuildLoad2(builder, res_type, ptr, "");
} else
res = ptr;
lp_build_name(res, "context.image%u.%s", image_unit, member_name);
lp_build_name(res, "resources.image%u.%s", image_unit, member_name);
return res;
}
@ -263,12 +263,12 @@ draw_llvm_image_member(struct gallivm_state *gallivm,
#define DRAW_LLVM_TEXTURE_MEMBER(_name, _index, _emit_load) \
static LLVMValueRef \
draw_llvm_texture_##_name( struct gallivm_state *gallivm, \
LLVMTypeRef context_type, \
LLVMValueRef context_ptr, \
LLVMTypeRef resources_type, \
LLVMValueRef resources_ptr, \
unsigned texture_unit, \
LLVMValueRef texture_unit_offset) \
{ \
return draw_llvm_texture_member(gallivm, context_type, context_ptr, \
return draw_llvm_texture_member(gallivm, resources_type, resources_ptr, \
texture_unit, texture_unit_offset, \
_index, #_name, _emit_load, NULL ); \
}
@ -276,13 +276,13 @@ draw_llvm_image_member(struct gallivm_state *gallivm,
#define DRAW_LLVM_TEXTURE_MEMBER_OUTTYPE(_name, _index, _emit_load) \
static LLVMValueRef \
draw_llvm_texture_##_name( struct gallivm_state *gallivm, \
LLVMTypeRef context_type, \
LLVMValueRef context_ptr, \
LLVMTypeRef resources_type, \
LLVMValueRef resources_ptr, \
unsigned texture_unit, \
LLVMValueRef texture_unit_offset, \
LLVMTypeRef *out_type) \
{ \
return draw_llvm_texture_member(gallivm, context_type, context_ptr, \
return draw_llvm_texture_member(gallivm, resources_type, resources_ptr, \
texture_unit, texture_unit_offset, \
_index, #_name, _emit_load, out_type); \
}
@ -303,11 +303,11 @@ DRAW_LLVM_TEXTURE_MEMBER(sample_stride, LP_JIT_TEXTURE_SAMPLE_STRIDE, TRUE)
#define DRAW_LLVM_SAMPLER_MEMBER(_name, _index, _emit_load) \
static LLVMValueRef \
draw_llvm_sampler_##_name( struct gallivm_state *gallivm, \
LLVMTypeRef context_type, \
LLVMValueRef context_ptr, \
LLVMTypeRef resources_type, \
LLVMValueRef resources_ptr, \
unsigned sampler_unit) \
{ \
return draw_llvm_sampler_member(gallivm, context_type, context_ptr, \
return draw_llvm_sampler_member(gallivm, resources_type, resources_ptr, \
sampler_unit, _index, #_name, _emit_load ); \
}
@ -321,11 +321,11 @@ DRAW_LLVM_SAMPLER_MEMBER(max_aniso, LP_JIT_SAMPLER_MAX_ANISO, TRUE)
#define DRAW_LLVM_IMAGE_MEMBER(_name, _index, _emit_load) \
static LLVMValueRef \
draw_llvm_image_##_name( struct gallivm_state *gallivm, \
LLVMTypeRef context_type, \
LLVMValueRef context_ptr, \
LLVMTypeRef resources_type, \
LLVMValueRef resources_ptr, \
unsigned image_unit, LLVMValueRef image_unit_offset) \
{ \
return draw_llvm_image_member(gallivm, context_type, context_ptr, \
return draw_llvm_image_member(gallivm, resources_type, resources_ptr, \
image_unit, image_unit_offset, \
_index, #_name, _emit_load ); \
}
@ -333,13 +333,13 @@ DRAW_LLVM_SAMPLER_MEMBER(max_aniso, LP_JIT_SAMPLER_MAX_ANISO, TRUE)
#define DRAW_LLVM_IMAGE_MEMBER_OUTTYPE(_name, _index, _emit_load) \
static LLVMValueRef \
draw_llvm_image_##_name( struct gallivm_state *gallivm, \
LLVMTypeRef context_type, \
LLVMValueRef context_ptr, \
LLVMTypeRef resources_type, \
LLVMValueRef resources_ptr, \
unsigned image_unit, LLVMValueRef image_unit_offset, \
LLVMTypeRef *out_type) \
{ \
assert(!out_type); \
return draw_llvm_image_member(gallivm, context_type, context_ptr, \
return draw_llvm_image_member(gallivm, resources_type, resources_ptr, \
image_unit, image_unit_offset, \
_index, #_name, _emit_load); \
}

View file

@ -432,76 +432,76 @@ llvm_middle_end_bind_parameters(struct draw_pt_middle_end *middle)
struct draw_llvm *llvm = fpme->llvm;
unsigned i;
for (i = 0; i < ARRAY_SIZE(llvm->jit_context.constants); ++i) {
for (i = 0; i < ARRAY_SIZE(llvm->jit_resources.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.constants[i].f = draw->pt.user.vs_constants[i];
llvm->jit_context.constants[i].num_elements = num_consts;
llvm->jit_resources.constants[i].f = draw->pt.user.vs_constants[i];
llvm->jit_resources.constants[i].num_elements = num_consts;
if (num_consts == 0) {
llvm->jit_context.constants[i].f = fake_const_buf;
llvm->jit_resources.constants[i].f = fake_const_buf;
}
}
for (i = 0; i < ARRAY_SIZE(llvm->jit_context.ssbos); ++i) {
for (i = 0; i < ARRAY_SIZE(llvm->jit_resources.ssbos); ++i) {
int num_ssbos = draw->pt.user.vs_ssbos_size[i];
llvm->jit_context.ssbos[i].u = draw->pt.user.vs_ssbos[i];
llvm->jit_context.ssbos[i].num_elements = num_ssbos;
llvm->jit_resources.ssbos[i].u = draw->pt.user.vs_ssbos[i];
llvm->jit_resources.ssbos[i].num_elements = num_ssbos;
if (num_ssbos == 0) {
llvm->jit_context.ssbos[i].u = (const uint32_t *)fake_const_buf;
llvm->jit_resources.ssbos[i].u = (const uint32_t *)fake_const_buf;
}
}
for (i = 0; i < ARRAY_SIZE(llvm->gs_jit_context.constants); ++i) {
for (i = 0; i < ARRAY_SIZE(llvm->gs_jit_resources.constants); ++i) {
int num_consts = get_num_consts_robust(draw, draw->pt.user.gs_constants_size, i);
llvm->gs_jit_context.constants[i].f = draw->pt.user.gs_constants[i];
llvm->gs_jit_context.constants[i].num_elements = num_consts;
llvm->gs_jit_resources.constants[i].f = draw->pt.user.gs_constants[i];
llvm->gs_jit_resources.constants[i].num_elements = num_consts;
if (num_consts == 0) {
llvm->gs_jit_context.constants[i].f = fake_const_buf;
llvm->gs_jit_resources.constants[i].f = fake_const_buf;
}
}
for (i = 0; i < ARRAY_SIZE(llvm->gs_jit_context.ssbos); ++i) {
for (i = 0; i < ARRAY_SIZE(llvm->gs_jit_resources.ssbos); ++i) {
int num_ssbos = draw->pt.user.gs_ssbos_size[i];
llvm->gs_jit_context.ssbos[i].u = draw->pt.user.gs_ssbos[i];
llvm->gs_jit_context.ssbos[i].num_elements = num_ssbos;
llvm->gs_jit_resources.ssbos[i].u = draw->pt.user.gs_ssbos[i];
llvm->gs_jit_resources.ssbos[i].num_elements = num_ssbos;
if (num_ssbos == 0) {
llvm->gs_jit_context.ssbos[i].u = (const uint32_t *)fake_const_buf;
llvm->gs_jit_resources.ssbos[i].u = (const uint32_t *)fake_const_buf;
}
}
for (i = 0; i < ARRAY_SIZE(llvm->tcs_jit_context.constants); ++i) {
for (i = 0; i < ARRAY_SIZE(llvm->tcs_jit_resources.constants); ++i) {
int num_consts = get_num_consts_robust(draw, draw->pt.user.tcs_constants_size, i);
llvm->tcs_jit_context.constants[i].f = draw->pt.user.tcs_constants[i];
llvm->tcs_jit_context.constants[i].num_elements = num_consts;
llvm->tcs_jit_resources.constants[i].f = draw->pt.user.tcs_constants[i];
llvm->tcs_jit_resources.constants[i].num_elements = num_consts;
if (num_consts == 0) {
llvm->tcs_jit_context.constants[i].f = fake_const_buf;
llvm->tcs_jit_resources.constants[i].f = fake_const_buf;
}
}
for (i = 0; i < ARRAY_SIZE(llvm->tcs_jit_context.ssbos); ++i) {
for (i = 0; i < ARRAY_SIZE(llvm->tcs_jit_resources.ssbos); ++i) {
int num_ssbos = draw->pt.user.tcs_ssbos_size[i];
llvm->tcs_jit_context.ssbos[i].u = draw->pt.user.tcs_ssbos[i];
llvm->tcs_jit_context.ssbos[i].num_elements = num_ssbos;
llvm->tcs_jit_resources.ssbos[i].u = draw->pt.user.tcs_ssbos[i];
llvm->tcs_jit_resources.ssbos[i].num_elements = num_ssbos;
if (num_ssbos == 0) {
llvm->tcs_jit_context.ssbos[i].u = (const uint32_t *)fake_const_buf;
llvm->tcs_jit_resources.ssbos[i].u = (const uint32_t *)fake_const_buf;
}
}
for (i = 0; i < ARRAY_SIZE(llvm->tes_jit_context.constants); ++i) {
for (i = 0; i < ARRAY_SIZE(llvm->tes_jit_resources.constants); ++i) {
int num_consts = get_num_consts_robust(draw, draw->pt.user.tes_constants_size, i);
llvm->tes_jit_context.constants[i].f = draw->pt.user.tes_constants[i];
llvm->tes_jit_context.constants[i].num_elements = num_consts;
llvm->tes_jit_resources.constants[i].f = draw->pt.user.tes_constants[i];
llvm->tes_jit_resources.constants[i].num_elements = num_consts;
if (num_consts == 0) {
llvm->tes_jit_context.constants[i].f = fake_const_buf;
llvm->tes_jit_resources.constants[i].f = fake_const_buf;
}
}
for (i = 0; i < ARRAY_SIZE(llvm->tes_jit_context.ssbos); ++i) {
for (i = 0; i < ARRAY_SIZE(llvm->tes_jit_resources.ssbos); ++i) {
int num_ssbos = draw->pt.user.tes_ssbos_size[i];
llvm->tes_jit_context.ssbos[i].u = draw->pt.user.tes_ssbos[i];
llvm->tes_jit_context.ssbos[i].num_elements = num_ssbos;
llvm->tes_jit_resources.ssbos[i].u = draw->pt.user.tes_ssbos[i];
llvm->tes_jit_resources.ssbos[i].num_elements = num_ssbos;
if (num_ssbos == 0) {
llvm->tes_jit_context.ssbos[i].u = (const uint32_t *)fake_const_buf;
llvm->tes_jit_resources.ssbos[i].u = (const uint32_t *)fake_const_buf;
}
}
@ -513,10 +513,10 @@ llvm_middle_end_bind_parameters(struct draw_pt_middle_end *middle)
llvm->jit_context.viewports = draw->viewports;
llvm->gs_jit_context.viewports = draw->viewports;
llvm->jit_context.aniso_filter_table = lp_build_sample_aniso_filter_table();
llvm->gs_jit_context.aniso_filter_table = lp_build_sample_aniso_filter_table();
llvm->tcs_jit_context.aniso_filter_table = lp_build_sample_aniso_filter_table();
llvm->tes_jit_context.aniso_filter_table = lp_build_sample_aniso_filter_table();
llvm->jit_resources.aniso_filter_table = lp_build_sample_aniso_filter_table();
llvm->gs_jit_resources.aniso_filter_table = lp_build_sample_aniso_filter_table();
llvm->tcs_jit_resources.aniso_filter_table = lp_build_sample_aniso_filter_table();
llvm->tes_jit_resources.aniso_filter_table = lp_build_sample_aniso_filter_table();
}
@ -609,6 +609,7 @@ llvm_pipeline_generic(struct draw_pt_middle_end *middle,
}
/* Run vertex fetch shader */
clipped = fpme->current_variant->jit_func(&fpme->llvm->jit_context,
&fpme->llvm->jit_resources,
llvm_vert_info.verts,
draw->pt.user.vbuffer,
fetch_info->count,
@ -627,7 +628,6 @@ llvm_pipeline_generic(struct draw_pt_middle_end *middle,
vert_info = &llvm_vert_info;
}
if (opt & PT_SHADE) {
struct draw_vertex_shader *vshader = draw->vs.vertex_shader;
if (tcs_shader) {

View file

@ -145,7 +145,8 @@ llvm_store_tcs_output(struct draw_tess_ctrl_shader *shader,
static void
llvm_tcs_run(struct draw_tess_ctrl_shader *shader, uint32_t prim_id)
{
shader->current_variant->jit_func(shader->jit_context, shader->tcs_input->data, shader->tcs_output->data, prim_id,
shader->current_variant->jit_func(shader->jit_resources,
shader->tcs_input->data, shader->tcs_output->data, prim_id,
shader->draw->pt.vertices_per_patch, shader->draw->pt.user.viewid);
}
#endif
@ -307,7 +308,8 @@ llvm_tes_run(struct draw_tess_eval_shader *shader,
struct pipe_tessellation_factors *tess_factors,
struct vertex_header *output)
{
shader->current_variant->jit_func(shader->jit_context, shader->tes_input->data, output, prim_id,
shader->current_variant->jit_func(shader->jit_resources,
shader->tes_input->data, output, prim_id,
tess_data->num_domain_points, tess_data->domain_points_u, tess_data->domain_points_v,
tess_factors->outer_tf, tess_factors->inner_tf, patch_vertices_in,
shader->draw->pt.user.viewid);
@ -457,7 +459,7 @@ draw_create_tess_ctrl_shader(struct draw_context *draw,
tcs->tcs_output = align_malloc(sizeof(struct draw_tcs_outputs), 16);
memset(tcs->tcs_output, 0, sizeof(struct draw_tcs_outputs));
tcs->jit_context = &draw->llvm->tcs_jit_context;
tcs->jit_resources = &draw->llvm->tcs_jit_resources;
llvm_tcs->variant_key_size =
draw_tcs_llvm_variant_key_size(
tcs->info.file_max[TGSI_FILE_SAMPLER]+1,
@ -582,7 +584,7 @@ draw_create_tess_eval_shader(struct draw_context *draw,
tes->tes_input = align_malloc(sizeof(struct draw_tes_inputs), 16);
memset(tes->tes_input, 0, sizeof(struct draw_tes_inputs));
tes->jit_context = &draw->llvm->tes_jit_context;
tes->jit_resources = &draw->llvm->tes_jit_resources;
llvm_tes->variant_key_size =
draw_tes_llvm_variant_key_size(
tes->info.file_max[TGSI_FILE_SAMPLER]+1,

View file

@ -67,7 +67,7 @@ struct draw_tess_ctrl_shader {
#ifdef DRAW_LLVM_AVAILABLE
struct draw_tcs_inputs *tcs_input;
struct draw_tcs_outputs *tcs_output;
struct draw_tcs_jit_context *jit_context;
struct lp_jit_resources *jit_resources;
struct draw_tcs_llvm_variant *current_variant;
#endif
};
@ -94,7 +94,7 @@ struct draw_tess_eval_shader {
#ifdef DRAW_LLVM_AVAILABLE
struct draw_tes_inputs *tes_input;
struct draw_tes_jit_context *jit_context;
struct lp_jit_resources *jit_resources;
struct draw_tes_llvm_variant *current_variant;
#endif
};

View file

@ -31,7 +31,7 @@
#include "lp_bld_jit_types.h"
LLVMTypeRef
static LLVMTypeRef
lp_build_create_jit_buffer_type(struct gallivm_state *gallivm)
{
LLVMContextRef lc = gallivm->context;
@ -96,7 +96,7 @@ lp_llvm_buffer_num_elements(struct gallivm_state *gallivm,
return lp_llvm_buffer_member(gallivm, buffers_ptr, buffers_offset, buffers_limit, LP_JIT_BUFFER_NUM_ELEMENTS, "num_elements");
}
LLVMTypeRef
static LLVMTypeRef
lp_build_create_jit_texture_type(struct gallivm_state *gallivm)
{
LLVMContextRef lc = gallivm->context;
@ -158,7 +158,7 @@ lp_build_create_jit_texture_type(struct gallivm_state *gallivm)
return texture_type;
}
LLVMTypeRef
static LLVMTypeRef
lp_build_create_jit_sampler_type(struct gallivm_state *gallivm)
{
LLVMContextRef lc = gallivm->context;
@ -194,7 +194,7 @@ lp_build_create_jit_sampler_type(struct gallivm_state *gallivm)
return sampler_type;
}
LLVMTypeRef
static LLVMTypeRef
lp_build_create_jit_image_type(struct gallivm_state *gallivm)
{
LLVMContextRef lc = gallivm->context;
@ -237,3 +237,51 @@ lp_build_create_jit_image_type(struct gallivm_state *gallivm)
LP_JIT_IMAGE_SAMPLE_STRIDE);
return image_type;
}
LLVMTypeRef
lp_build_jit_resources_type(struct gallivm_state *gallivm)
{
LLVMTypeRef elem_types[LP_JIT_RES_COUNT];
LLVMTypeRef resources_type;
LLVMTypeRef texture_type, sampler_type, image_type, buffer_type;
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 = lp_build_create_jit_image_type(gallivm);
elem_types[LP_JIT_RES_CONSTANTS] = LLVMArrayType(buffer_type,
LP_MAX_TGSI_CONST_BUFFERS);
elem_types[LP_JIT_RES_SSBOS] =
LLVMArrayType(buffer_type, LP_MAX_TGSI_SHADER_BUFFERS);
elem_types[LP_JIT_RES_TEXTURES] = LLVMArrayType(texture_type,
PIPE_MAX_SHADER_SAMPLER_VIEWS);
elem_types[LP_JIT_RES_SAMPLERS] = LLVMArrayType(sampler_type,
PIPE_MAX_SAMPLERS);
elem_types[LP_JIT_RES_IMAGES] = LLVMArrayType(image_type,
PIPE_MAX_SHADER_IMAGES);
elem_types[LP_JIT_RES_ANISO_FILTER_TABLE] = LLVMPointerType(LLVMFloatTypeInContext(gallivm->context), 0);
resources_type = LLVMStructTypeInContext(gallivm->context, elem_types,
ARRAY_SIZE(elem_types), 0);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_resources, constants,
gallivm->target, resources_type,
LP_JIT_RES_CONSTANTS);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_resources, ssbos,
gallivm->target, resources_type,
LP_JIT_RES_SSBOS);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_resources, textures,
gallivm->target, resources_type,
LP_JIT_RES_TEXTURES);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_resources, samplers,
gallivm->target, resources_type,
LP_JIT_RES_SAMPLERS);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_resources, images,
gallivm->target, resources_type,
LP_JIT_RES_IMAGES);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_resources, aniso_filter_table,
gallivm->target, resources_type,
LP_JIT_RES_ANISO_FILTER_TABLE);
return resources_type;
}

View file

@ -39,9 +39,6 @@ enum {
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,
@ -82,9 +79,6 @@ enum {
LP_JIT_TEXTURE_NUM_FIELDS /* number of fields above */
};
LLVMTypeRef
lp_build_create_jit_texture_type(struct gallivm_state *gallivm);
struct lp_jit_sampler
{
float min_lod;
@ -103,9 +97,6 @@ enum {
LP_JIT_SAMPLER_NUM_FIELDS /* number of fields above */
};
LLVMTypeRef
lp_build_create_jit_sampler_type(struct gallivm_state *gallivm);
struct lp_jit_image
{
const void *base;
@ -130,7 +121,43 @@ enum {
LP_JIT_IMAGE_NUM_FIELDS /* number of fields above */
};
LLVMTypeRef
lp_build_create_jit_image_type(struct gallivm_state *gallivm);
struct lp_jit_resources {
struct lp_jit_buffer constants[LP_MAX_TGSI_CONST_BUFFERS];
struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_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 float *aniso_filter_table;
};
enum {
LP_JIT_RES_CONSTANTS = 0,
LP_JIT_RES_SSBOS,
LP_JIT_RES_TEXTURES,
LP_JIT_RES_SAMPLERS,
LP_JIT_RES_IMAGES,
LP_JIT_RES_ANISO_FILTER_TABLE,
LP_JIT_RES_COUNT,
};
#define lp_jit_resources_constants(_gallivm, _type, _ptr) \
lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_RES_CONSTANTS, "constants")
#define lp_jit_resources_ssbos(_gallivm, _type, _ptr) \
lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_RES_SSBOS, "ssbos")
#define lp_jit_resources_textures(_gallivm, _type, _ptr) \
lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_RES_TEXTURES, "textures")
#define lp_jit_resources_samplers(_gallivm, _type, _ptr) \
lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_RES_SAMPLERS, "samplers")
#define lp_jit_resources_images(_gallivm, _type, _ptr) \
lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_RES_IMAGES, "images")
#define lp_jit_resources_aniso_filter_table(_gallivm, _type, _ptr) \
lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_RES_ANISO_FILTER_TABLE, "aniso_filter_table")
LLVMTypeRef
lp_build_jit_resources_type(struct gallivm_state *gallivm);
#endif

View file

@ -246,6 +246,8 @@ struct lp_build_nir_soa_context
LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS];
LLVMTypeRef context_type;
LLVMValueRef context_ptr;
LLVMTypeRef resources_type;
LLVMValueRef resources_ptr;
LLVMTypeRef thread_data_type;
LLVMValueRef thread_data_ptr;

View file

@ -1559,8 +1559,8 @@ static void emit_image_op(struct lp_build_nir_context *bld_base,
struct gallivm_state *gallivm = bld_base->base.gallivm;
params->type = bld_base->base.type;
params->context_type = bld->context_type;
params->context_ptr = bld->context_ptr;
params->resources_type = bld->resources_type;
params->resources_ptr = bld->resources_ptr;
params->thread_data_type = bld->thread_data_type;
params->thread_data_ptr = bld->thread_data_ptr;
params->exec_mask = mask_vec(bld_base);
@ -1582,9 +1582,8 @@ static void emit_image_size(struct lp_build_nir_context *bld_base,
struct gallivm_state *gallivm = bld_base->base.gallivm;
params->int_type = bld_base->int_bld.type;
params->context_type = bld->context_type;
params->context_ptr = bld->context_ptr;
params->resources_type = bld->resources_type;
params->resources_ptr = bld->resources_ptr;
if (params->texture_unit_offset)
params->texture_unit_offset = LLVMBuildExtractElement(gallivm->builder, params->texture_unit_offset,
first_active_invocation(bld_base), "");
@ -1639,8 +1638,8 @@ static void emit_tex(struct lp_build_nir_context *bld_base,
struct gallivm_state *gallivm = bld_base->base.gallivm;
params->type = bld_base->base.type;
params->context_type = bld->context_type;
params->context_ptr = bld->context_ptr;
params->resources_type = bld->resources_type;
params->resources_ptr = bld->resources_ptr;
params->thread_data_type = bld->thread_data_type;
params->thread_data_ptr = bld->thread_data_ptr;
@ -1709,9 +1708,8 @@ static void emit_tex_size(struct lp_build_nir_context *bld_base,
struct lp_build_nir_soa_context *bld = (struct lp_build_nir_soa_context *)bld_base;
params->int_type = bld_base->int_bld.type;
params->context_type = bld->context_type;
params->context_ptr = bld->context_ptr;
params->resources_type = bld->resources_type;
params->resources_ptr = bld->resources_ptr;
if (params->texture_unit_offset)
params->texture_unit_offset = LLVMBuildExtractElement(bld_base->base.gallivm->builder,
params->texture_unit_offset,
@ -2732,8 +2730,8 @@ void lp_build_nir_soa(struct gallivm_state *gallivm,
bld.sampler = params->sampler;
// bld.bld_base.info = params->info;
bld.context_type = params->context_type;
bld.context_ptr = params->context_ptr;
bld.resources_type = params->resources_type;
bld.resources_ptr = params->resources_ptr;
bld.thread_data_type = params->thread_data_type;
bld.thread_data_ptr = params->thread_data_ptr;
bld.bld_base.aniso_filter_table = params->aniso_filter_table;

View file

@ -842,8 +842,8 @@ lp_build_lod_selector(struct lp_build_sample_context *bld,
* This is hit during mipmap generation.
*/
LLVMValueRef min_lod =
dynamic_state->min_lod(bld->gallivm, bld->context_type,
bld->context_ptr, sampler_unit);
dynamic_state->min_lod(bld->gallivm, bld->resources_type,
bld->resources_ptr, sampler_unit);
lod = lp_build_broadcast_scalar(lodf_bld, min_lod);
} else {
@ -940,8 +940,8 @@ lp_build_lod_selector(struct lp_build_sample_context *bld,
/* add sampler lod bias */
if (bld->static_sampler_state->lod_bias_non_zero) {
LLVMValueRef sampler_lod_bias =
dynamic_state->lod_bias(bld->gallivm, bld->context_type,
bld->context_ptr, sampler_unit);
dynamic_state->lod_bias(bld->gallivm, bld->resources_type,
bld->resources_ptr, sampler_unit);
sampler_lod_bias = lp_build_broadcast_scalar(lodf_bld,
sampler_lod_bias);
lod = LLVMBuildFAdd(builder, lod, sampler_lod_bias, "sampler_lod_bias");
@ -954,16 +954,16 @@ lp_build_lod_selector(struct lp_build_sample_context *bld,
/* clamp lod */
if (bld->static_sampler_state->apply_max_lod) {
LLVMValueRef max_lod =
dynamic_state->max_lod(bld->gallivm, bld->context_type,
bld->context_ptr, sampler_unit);
dynamic_state->max_lod(bld->gallivm, bld->resources_type,
bld->resources_ptr, sampler_unit);
max_lod = lp_build_broadcast_scalar(lodf_bld, max_lod);
lod = lp_build_min(lodf_bld, lod, max_lod);
}
if (bld->static_sampler_state->apply_min_lod) {
LLVMValueRef min_lod =
dynamic_state->min_lod(bld->gallivm, bld->context_type,
bld->context_ptr, sampler_unit);
dynamic_state->min_lod(bld->gallivm, bld->resources_type,
bld->resources_ptr, sampler_unit);
min_lod = lp_build_broadcast_scalar(lodf_bld, min_lod);
lod = lp_build_max(lodf_bld, lod, min_lod);

View file

@ -106,8 +106,8 @@ struct lp_sampler_params
unsigned sampler_index;
LLVMValueRef texture_index_offset;
unsigned sample_key;
LLVMTypeRef context_type;
LLVMValueRef context_ptr;
LLVMTypeRef resources_type;
LLVMValueRef resources_ptr;
LLVMTypeRef thread_data_type;
LLVMValueRef thread_data_ptr;
const LLVMValueRef *coords;
@ -126,8 +126,8 @@ struct lp_sampler_size_query_params
unsigned texture_unit;
LLVMValueRef texture_unit_offset;
unsigned target;
LLVMTypeRef context_type;
LLVMValueRef context_ptr;
LLVMTypeRef resources_type;
LLVMValueRef resources_ptr;
boolean is_sviewinfo;
bool samples_only;
enum lp_sampler_lod_property lod_property;
@ -149,8 +149,8 @@ struct lp_img_params
unsigned target;
LLVMAtomicRMWBinOp op;
LLVMValueRef exec_mask;
LLVMTypeRef context_type;
LLVMValueRef context_ptr;
LLVMTypeRef resources_type;
LLVMValueRef resources_ptr;
LLVMTypeRef thread_data_type;
LLVMValueRef thread_data_ptr;
const LLVMValueRef *coords;
@ -232,81 +232,81 @@ struct lp_sampler_dynamic_state
/** Obtain the base texture width (or number of elements) (returns int32) */
LLVMValueRef
(*width)(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned texture_unit, LLVMValueRef texture_unit_offset);
/** Obtain the base texture height (returns int32) */
LLVMValueRef
(*height)(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned texture_unit, LLVMValueRef texture_unit_offset);
/** Obtain the base texture depth (or array size) (returns int32) */
LLVMValueRef
(*depth)(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned texture_unit, LLVMValueRef texture_unit_offset);
/** Obtain the first mipmap level (base level) (returns int32) */
LLVMValueRef
(*first_level)(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned texture_unit, LLVMValueRef texture_unit_offset);
/** Obtain the number of mipmap levels minus one (returns int32) */
LLVMValueRef
(*last_level)(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned texture_unit, LLVMValueRef texture_unit_offset);
/** Obtain stride in bytes between image rows/blocks (returns int32) */
LLVMValueRef
(*row_stride)(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned texture_unit, LLVMValueRef texture_unit_offset,
LLVMTypeRef *out_type);
/** Obtain stride in bytes between image slices (returns int32) */
LLVMValueRef
(*img_stride)(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned texture_unit, LLVMValueRef texture_unit_offset,\
LLVMTypeRef *out_type);
/** Obtain pointer to base of texture */
LLVMValueRef
(*base_ptr)(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned texture_unit, LLVMValueRef texture_unit_offset);
/** Obtain pointer to array of mipmap offsets */
LLVMValueRef
(*mip_offsets)(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned texture_unit, LLVMValueRef texture_unit_offset,
LLVMTypeRef *out_type);
/** Obtain number of samples (returns int32) */
LLVMValueRef
(*num_samples)(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned texture_unit, LLVMValueRef texture_unit_offset);
/** Obtain multisample stride (returns int32) */
LLVMValueRef
(*sample_stride)(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned texture_unit, LLVMValueRef texture_unit_offset);
/* These are callbacks for sampler state */
@ -314,36 +314,36 @@ struct lp_sampler_dynamic_state
/** Obtain texture min lod (returns float) */
LLVMValueRef
(*min_lod)(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned sampler_unit);
/** Obtain texture max lod (returns float) */
LLVMValueRef
(*max_lod)(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned sampler_unit);
/** Obtain texture lod bias (returns float) */
LLVMValueRef
(*lod_bias)(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned sampler_unit);
/** Obtain texture border color (returns ptr to float[4]) */
LLVMValueRef
(*border_color)(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned sampler_unit);
/** Obtain maximum anisotropy */
LLVMValueRef
(*max_aniso)(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned sampler_unit);
/**
@ -464,8 +464,8 @@ struct lp_build_sample_context
LLVMValueRef border_color_clamped;
LLVMTypeRef context_type;
LLVMValueRef context_ptr;
LLVMTypeRef resources_type;
LLVMValueRef resources_ptr;
LLVMValueRef aniso_filter_table;
};

View file

@ -2017,8 +2017,8 @@ lp_build_layer_coord(struct lp_build_sample_context *bld,
LLVMValueRef num_layers;
struct lp_build_context *int_coord_bld = &bld->int_coord_bld;
num_layers = bld->dynamic_state->depth(bld->gallivm, bld->context_type,
bld->context_ptr, texture_unit, NULL);
num_layers = bld->dynamic_state->depth(bld->gallivm, bld->resources_type,
bld->resources_ptr, texture_unit, NULL);
if (out_of_bounds) {
LLVMValueRef out1, out;
@ -2541,12 +2541,12 @@ lp_build_sample_common(struct lp_build_sample_context *bld,
*/
first_level = bld->dynamic_state->first_level(bld->gallivm,
bld->context_type,
bld->context_ptr,
bld->resources_type,
bld->resources_ptr,
texture_index, NULL);
last_level = bld->dynamic_state->last_level(bld->gallivm,
bld->context_type,
bld->context_ptr,
bld->resources_type,
bld->resources_ptr,
texture_index, NULL);
/*
@ -2610,8 +2610,8 @@ lp_build_sample_common(struct lp_build_sample_context *bld,
if (aniso)
max_aniso = bld->dynamic_state->max_aniso(bld->gallivm,
bld->context_type,
bld->context_ptr,
bld->resources_type,
bld->resources_ptr,
sampler_index);
/* Need to compute lod either to choose mipmap levels or to
@ -2704,8 +2704,8 @@ lp_build_clamp_border_color(struct lp_build_sample_context *bld,
LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef border_color_ptr =
bld->dynamic_state->border_color(gallivm,
bld->context_type,
bld->context_ptr, sampler_unit);
bld->resources_type,
bld->resources_ptr, sampler_unit);
LLVMValueRef border_color;
const struct util_format_description *format_desc = bld->format_desc;
struct lp_type vec4_type = bld->texel_type;
@ -3104,8 +3104,8 @@ lp_build_fetch_texel(struct lp_build_sample_context *bld,
LLVMValueRef width, height, depth, i, j;
LLVMValueRef offset, out_of_bounds, out1;
LLVMValueRef first_level = bld->dynamic_state->first_level(bld->gallivm,
bld->context_type,
bld->context_ptr, texture_unit, NULL);
bld->resources_type,
bld->resources_ptr, texture_unit, NULL);
out_of_bounds = int_coord_bld->zero;
@ -3117,8 +3117,8 @@ lp_build_fetch_texel(struct lp_build_sample_context *bld,
ilevel = explicit_lod;
}
LLVMValueRef last_level = bld->dynamic_state->last_level(bld->gallivm,
bld->context_type,
bld->context_ptr, texture_unit, NULL);
bld->resources_type,
bld->resources_ptr, texture_unit, NULL);
first_level = lp_build_broadcast_scalar(&bld->leveli_bld, first_level);
last_level = lp_build_broadcast_scalar(&bld->leveli_bld, last_level);
lp_build_nearest_mip_level(bld,
@ -3194,12 +3194,12 @@ lp_build_fetch_texel(struct lp_build_sample_context *bld,
if (bld->fetch_ms) {
LLVMValueRef num_samples = bld->dynamic_state->num_samples(bld->gallivm,
bld->context_type,
bld->context_ptr,
bld->resources_type,
bld->resources_ptr,
texture_unit, NULL);
LLVMValueRef sample_stride = bld->dynamic_state->sample_stride(bld->gallivm,
bld->context_type,
bld->context_ptr,
bld->resources_type,
bld->resources_ptr,
texture_unit,
NULL);
lp_build_sample_ms_offset(int_coord_bld, ms_index, num_samples, sample_stride,
@ -3294,8 +3294,8 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm,
unsigned sample_key,
unsigned texture_index,
unsigned sampler_index,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
LLVMTypeRef thread_data_type,
LLVMValueRef thread_data_ptr,
const LLVMValueRef *coords,
@ -3374,8 +3374,8 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm,
/* Setup our build context */
memset(&bld, 0, sizeof bld);
bld.gallivm = gallivm;
bld.context_type = context_type;
bld.context_ptr = context_ptr;
bld.resources_type = resources_type;
bld.resources_ptr = resources_ptr;
bld.aniso_filter_table = aniso_filter_table;
bld.static_sampler_state = &derived_sampler_state;
bld.static_texture_state = static_texture_state;
@ -3555,19 +3555,19 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm,
lp_build_context_init(&bld.lodi_bld, gallivm, bld.lodi_type);
/* Get the dynamic state */
LLVMValueRef tex_width = dynamic_state->width(gallivm, context_type,
context_ptr, texture_index,
LLVMValueRef tex_width = dynamic_state->width(gallivm, resources_type,
resources_ptr, texture_index,
NULL);
bld.row_stride_array = dynamic_state->row_stride(gallivm, context_type,
context_ptr, texture_index, NULL,
bld.row_stride_array = dynamic_state->row_stride(gallivm, resources_type,
resources_ptr, texture_index, NULL,
&bld.row_stride_type);
bld.img_stride_array = dynamic_state->img_stride(gallivm, context_type,
context_ptr, texture_index, NULL,
bld.img_stride_array = dynamic_state->img_stride(gallivm, resources_type,
resources_ptr, texture_index, NULL,
&bld.img_stride_type);
bld.base_ptr = dynamic_state->base_ptr(gallivm, context_type,
context_ptr, texture_index, NULL);
bld.mip_offsets = dynamic_state->mip_offsets(gallivm, context_type,
context_ptr, texture_index, NULL,
bld.base_ptr = dynamic_state->base_ptr(gallivm, resources_type,
resources_ptr, texture_index, NULL);
bld.mip_offsets = dynamic_state->mip_offsets(gallivm, resources_type,
resources_ptr, texture_index, NULL,
&bld.mip_offsets_type);
/* Note that mip_offsets is an array[level] of offsets to texture images */
@ -3609,8 +3609,8 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm,
LLVMConstInt(i32t, 0, 0), "");
if (dims >= 2) {
LLVMValueRef tex_height =
dynamic_state->height(gallivm, context_type,
context_ptr, texture_index, NULL);
dynamic_state->height(gallivm, resources_type,
resources_ptr, texture_index, NULL);
bld.int_size = LLVMBuildInsertElement(builder, bld.int_size,
tex_height,
LLVMConstInt(i32t, 1, 0), "");
@ -3625,7 +3625,7 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm,
LLVMConstInt(i32t, 1, 0), "");
if (dims >= 3) {
LLVMValueRef tex_depth =
dynamic_state->depth(gallivm, context_type, context_ptr,
dynamic_state->depth(gallivm, resources_type, resources_ptr,
texture_index, NULL);
bld.int_size = LLVMBuildInsertElement(builder, bld.int_size,
tex_depth,
@ -3788,8 +3788,8 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm,
bld4.no_rho_approx = bld.no_rho_approx;
bld4.no_brilinear = bld.no_brilinear;
bld4.gallivm = bld.gallivm;
bld4.context_type = bld.context_type;
bld4.context_ptr = bld.context_ptr;
bld4.resources_type = bld.resources_type;
bld4.resources_ptr = bld.resources_ptr;
bld4.aniso_filter_table = aniso_filter_table;
bld4.static_texture_state = bld.static_texture_state;
bld4.static_sampler_state = bld.static_sampler_state;
@ -3990,7 +3990,7 @@ lp_build_sample_gen_func(struct gallivm_state *gallivm,
const struct lp_static_sampler_state *static_sampler_state,
struct lp_sampler_dynamic_state *dynamic_state,
struct lp_type type,
LLVMTypeRef context_type,
LLVMTypeRef resources_type,
LLVMTypeRef thread_data_type,
unsigned texture_index,
unsigned sampler_index,
@ -4005,7 +4005,7 @@ lp_build_sample_gen_func(struct gallivm_state *gallivm,
LLVMValueRef offsets[3] = { NULL };
LLVMValueRef lod = NULL;
LLVMValueRef ms_index = NULL;
LLVMValueRef context_ptr;
LLVMValueRef resources_ptr;
LLVMValueRef thread_data_ptr = NULL;
LLVMValueRef aniso_filter_table = NULL;
LLVMValueRef texel_out[4];
@ -4038,7 +4038,7 @@ lp_build_sample_gen_func(struct gallivm_state *gallivm,
}
/* "unpack" arguments */
context_ptr = LLVMGetParam(function, num_param++);
resources_ptr = LLVMGetParam(function, num_param++);
if (has_aniso_filter_table)
aniso_filter_table = LLVMGetParam(function, num_param++);
if (need_cache) {
@ -4095,8 +4095,8 @@ lp_build_sample_gen_func(struct gallivm_state *gallivm,
sample_key,
texture_index,
sampler_index,
context_type,
context_ptr,
resources_type,
resources_ptr,
thread_data_type,
thread_data_ptr,
coords,
@ -4183,7 +4183,7 @@ lp_build_sample_soa_func(struct gallivm_state *gallivm,
* Generate the function prototype.
*/
arg_types[num_param++] = LLVMTypeOf(params->context_ptr);
arg_types[num_param++] = LLVMTypeOf(params->resources_ptr);
if (params->aniso_filter_table)
arg_types[num_param++] = LLVMTypeOf(params->aniso_filter_table);
if (need_cache) {
@ -4244,7 +4244,7 @@ lp_build_sample_soa_func(struct gallivm_state *gallivm,
static_sampler_state,
dynamic_state,
params->type,
params->context_type,
params->resources_type,
params->thread_data_type,
texture_index,
sampler_index,
@ -4255,7 +4255,7 @@ lp_build_sample_soa_func(struct gallivm_state *gallivm,
}
unsigned num_args = 0;
args[num_args++] = params->context_ptr;
args[num_args++] = params->resources_ptr;
if (params->aniso_filter_table)
args[num_args++] = params->aniso_filter_table;
if (need_cache) {
@ -4365,8 +4365,8 @@ lp_build_sample_soa(const struct lp_static_texture_state *static_texture_state,
params->sample_key,
params->texture_index,
params->sampler_index,
params->context_type,
params->context_ptr,
params->resources_type,
params->resources_ptr,
params->thread_data_type,
params->thread_data_ptr,
params->coords,
@ -4388,8 +4388,8 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
{
LLVMValueRef first_level = NULL;
const unsigned num_lods = 1;
LLVMTypeRef context_type = params->context_type;
LLVMValueRef context_ptr = params->context_ptr;
LLVMTypeRef resources_type = params->resources_type;
LLVMValueRef resources_ptr = params->resources_ptr;
const unsigned texture_unit = params->texture_unit;
const enum pipe_texture_target target = params->target;
LLVMValueRef texture_unit_offset = params->texture_unit_offset;
@ -4451,8 +4451,8 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
lp_build_broadcast(gallivm,
lp_build_vec_type(gallivm, params->int_type),
dynamic_state->num_samples(gallivm,
context_type,
context_ptr,
resources_type,
resources_ptr,
texture_unit,
texture_unit_offset));
return;
@ -4464,8 +4464,8 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
/* FIXME: this needs to honor per-element lod */
lod = LLVMBuildExtractElement(gallivm->builder, params->explicit_lod,
lp_build_const_int32(gallivm, 0), "");
first_level = dynamic_state->first_level(gallivm, context_type,
context_ptr, texture_unit,
first_level = dynamic_state->first_level(gallivm, resources_type,
resources_ptr, texture_unit,
texture_unit_offset);
level = LLVMBuildAdd(gallivm->builder, lod, first_level, "level");
lod = lp_build_broadcast_scalar(&bld_int_vec4, level);
@ -4490,8 +4490,8 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
res_bh = bh = 1;
size = LLVMBuildInsertElement(gallivm->builder, size,
dynamic_state->width(gallivm,
context_type,
context_ptr,
resources_type,
resources_ptr,
texture_unit,
texture_unit_offset),
lp_build_const_int32(gallivm, 0), "");
@ -4507,8 +4507,8 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
if (dims >= 2) {
size = LLVMBuildInsertElement(gallivm->builder, size,
dynamic_state->height(gallivm,
context_type,
context_ptr,
resources_type,
resources_ptr,
texture_unit,
texture_unit_offset),
lp_build_const_int32(gallivm, 1), "");
@ -4526,8 +4526,8 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
if (dims >= 3) {
size = LLVMBuildInsertElement(gallivm->builder, size,
dynamic_state->depth(gallivm,
context_type,
context_ptr,
resources_type,
resources_ptr,
texture_unit,
texture_unit_offset),
lp_build_const_int32(gallivm, 2), "");
@ -4547,8 +4547,8 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
tex_blocksize_log2, view_blocksize);
if (has_array) {
LLVMValueRef layers = dynamic_state->depth(gallivm, context_type,
context_ptr, texture_unit,
LLVMValueRef layers = dynamic_state->depth(gallivm, resources_type,
resources_ptr, texture_unit,
texture_unit_offset);
if (target == PIPE_TEXTURE_CUBE_ARRAY) {
/*
@ -4574,8 +4574,8 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
/* everything is scalar for now */
lp_build_context_init(&leveli_bld, gallivm, lp_type_int_vec(32, 32));
last_level = dynamic_state->last_level(gallivm, context_type,
context_ptr, texture_unit,
last_level = dynamic_state->last_level(gallivm, resources_type,
resources_ptr, texture_unit,
texture_unit_offset);
out = lp_build_cmp(&leveli_bld, PIPE_FUNC_LESS, level, first_level);
@ -4619,8 +4619,8 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
} else {
LLVMValueRef last_level;
last_level = dynamic_state->last_level(gallivm, context_type,
context_ptr, texture_unit,
last_level = dynamic_state->last_level(gallivm, resources_type,
resources_ptr, texture_unit,
texture_unit_offset);
num_levels = lp_build_sub(&bld_int_scalar, last_level, first_level);
num_levels = lp_build_add(&bld_int_scalar, num_levels,
@ -4779,28 +4779,28 @@ lp_build_img_op_soa(const struct lp_static_texture_state *static_texture_state,
}
LLVMValueRef row_stride = dynamic_state->row_stride(gallivm,
params->context_type,
params->context_ptr,
params->resources_type,
params->resources_ptr,
params->image_index, NULL, NULL);
LLVMValueRef img_stride = dynamic_state->img_stride(gallivm,
params->context_type,
params->context_ptr,
params->resources_type,
params->resources_ptr,
params->image_index, NULL, NULL);
LLVMValueRef base_ptr = dynamic_state->base_ptr(gallivm,
params->context_type,
params->context_ptr,
params->resources_type,
params->resources_ptr,
params->image_index, NULL);
LLVMValueRef width = dynamic_state->width(gallivm,
params->context_type,
params->context_ptr,
params->resources_type,
params->resources_ptr,
params->image_index, NULL);
LLVMValueRef height = dynamic_state->height(gallivm,
params->context_type,
params->context_ptr,
params->resources_type,
params->resources_ptr,
params->image_index, NULL);
LLVMValueRef depth = dynamic_state->depth(gallivm,
params->context_type,
params->context_ptr,
params->resources_type,
params->resources_ptr,
params->image_index, NULL);
boolean layer_coord = has_layer_coord(target);
@ -4839,12 +4839,12 @@ lp_build_img_op_soa(const struct lp_static_texture_state *static_texture_state,
if (params->ms_index) {
LLVMValueRef num_samples = dynamic_state->num_samples(gallivm,
params->context_type,
params->context_ptr,
params->resources_type,
params->resources_ptr,
params->image_index, NULL);
LLVMValueRef sample_stride = dynamic_state->sample_stride(gallivm,
params->context_type,
params->context_ptr,
params->resources_type,
params->resources_ptr,
params->image_index, NULL);
lp_build_sample_ms_offset(&int_coord_bld,
params->ms_index, num_samples,

View file

@ -269,6 +269,8 @@ struct lp_build_tgsi_params {
const LLVMValueRef (*inputs)[4];
LLVMTypeRef context_type;
LLVMValueRef context_ptr;
LLVMTypeRef resources_type;
LLVMValueRef resources_ptr;
LLVMTypeRef thread_data_type;
LLVMValueRef thread_data_ptr;
const struct lp_build_sampler_soa *sampler;
@ -525,6 +527,8 @@ struct lp_build_tgsi_soa_context
LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS];
LLVMTypeRef context_type;
LLVMValueRef context_ptr;
LLVMTypeRef resources_type;
LLVMValueRef resources_ptr;
LLVMTypeRef thread_data_type;
LLVMValueRef thread_data_ptr;

View file

@ -2273,8 +2273,8 @@ emit_tex( struct lp_build_tgsi_soa_context *bld,
params.sample_key = sample_key;
params.texture_index = unit;
params.sampler_index = unit;
params.context_type = bld->context_type;
params.context_ptr = bld->context_ptr;
params.resources_type = bld->resources_type;
params.resources_ptr = bld->resources_ptr;
params.thread_data_type = bld->thread_data_type;
params.thread_data_ptr = bld->thread_data_ptr;
params.coords = coords;
@ -2444,8 +2444,8 @@ emit_sample(struct lp_build_tgsi_soa_context *bld,
params.sample_key = sample_key;
params.texture_index = texture_unit;
params.sampler_index = sampler_unit;
params.context_type = bld->context_type;
params.context_ptr = bld->context_ptr;
params.resources_type = bld->resources_type;
params.resources_ptr = bld->resources_ptr;
params.thread_data_type = bld->thread_data_type;
params.thread_data_ptr = bld->thread_data_ptr;
params.coords = coords;
@ -2584,8 +2584,8 @@ emit_fetch_texels( struct lp_build_tgsi_soa_context *bld,
* can exceed this.
*/
params.sampler_index = 0;
params.context_type = bld->context_type;
params.context_ptr = bld->context_ptr;
params.resources_type = bld->resources_type;
params.resources_ptr = bld->resources_ptr;
params.thread_data_type = bld->thread_data_type;
params.thread_data_ptr = bld->thread_data_ptr;
params.coords = coords;
@ -2671,8 +2671,8 @@ emit_size_query( struct lp_build_tgsi_soa_context *bld,
params.texture_unit = unit;
params.texture_unit_offset = NULL;
params.target = pipe_target;
params.context_type = bld->context_type;
params.context_ptr = bld->context_ptr;
params.resources_type = bld->resources_type;
params.resources_ptr = bld->resources_ptr;
params.is_sviewinfo = TRUE;
params.lod_property = lod_property;
params.explicit_lod = explicit_lod;
@ -3460,8 +3460,8 @@ img_load_emit(
memset(&params, 0, sizeof(params));
params.type = bld->bld_base.base.type;
params.context_type = bld->context_type;
params.context_ptr = bld->context_ptr;
params.resources_type = bld->resources_type;
params.resources_ptr = bld->resources_ptr;
params.thread_data_type = bld->thread_data_type;
params.thread_data_ptr = bld->thread_data_ptr;
params.coords = coords;
@ -3610,8 +3610,8 @@ img_store_emit(
memset(&params, 0, sizeof(params));
params.type = bld->bld_base.base.type;
params.context_type = bld->context_type;
params.context_ptr = bld->context_ptr;
params.resources_type = bld->resources_type;
params.resources_ptr = bld->resources_ptr;
params.thread_data_type = bld->thread_data_type;
params.thread_data_ptr = bld->thread_data_ptr;
params.coords = coords;
@ -3721,8 +3721,8 @@ resq_emit(
params.int_type = bld->bld_base.int_bld.type;
params.texture_unit = buf;
params.target = tgsi_to_pipe_tex_target(target);
params.context_type = bld->context_type;
params.context_ptr = bld->context_ptr;
params.resources_type = bld->resources_type;
params.resources_ptr = bld->resources_ptr;
params.sizes_out = emit_data->output;
bld->image->emit_size_query(bld->image,
@ -3763,9 +3763,8 @@ img_atomic_emit(
memset(&params, 0, sizeof(params));
params.type = bld->bld_base.base.type;
params.context_type = bld->context_type;
params.context_ptr = bld->context_ptr;
params.thread_data_type = bld->thread_data_type;
params.resources_type = bld->resources_type;
params.resources_ptr = bld->resources_ptr;
params.thread_data_ptr = bld->thread_data_ptr;
params.exec_mask = mask_vec(bld_base);
params.image_index = emit_data->inst->Src[0].Register.Index;
@ -4499,6 +4498,8 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm,
bld.indirect_files = params->info->indirect_files;
bld.context_type = params->context_type;
bld.context_ptr = params->context_ptr;
bld.resources_type = params->resources_type;
bld.resources_ptr = params->resources_ptr;
bld.thread_data_type = params->thread_data_type;
bld.thread_data_ptr = params->thread_data_ptr;
bld.image = params->image;

View file

@ -47,7 +47,7 @@ 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, image_type, buffer_type;
LLVMTypeRef viewport_type;
LLVMTypeRef linear_elem_type;
/* struct lp_jit_viewport */
@ -70,27 +70,12 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
gallivm->target, viewport_type);
}
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 = lp_build_create_jit_image_type(gallivm);
/* struct lp_jit_context */
{
LLVMTypeRef elem_types[LP_JIT_CTX_COUNT];
LLVMTypeRef context_type;
elem_types[LP_JIT_CTX_CONSTANTS] = LLVMArrayType(buffer_type,
LP_MAX_TGSI_CONST_BUFFERS);
elem_types[LP_JIT_CTX_SSBOS] =
LLVMArrayType(buffer_type, LP_MAX_TGSI_SHADER_BUFFERS);
elem_types[LP_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type,
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_ANISO_FILTER_TABLE] = LLVMPointerType(LLVMFloatTypeInContext(lc), 0);
elem_types[LP_JIT_CTX_ALPHA_REF] = LLVMFloatTypeInContext(lc);
elem_types[LP_JIT_CTX_SAMPLE_MASK] =
elem_types[LP_JIT_CTX_STENCIL_REF_FRONT] =
@ -102,24 +87,6 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
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, ssbos,
gallivm->target, context_type,
LP_JIT_CTX_SSBOS);
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, 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, aniso_filter_table,
gallivm->target, context_type,
LP_JIT_CTX_ANISO_FILTER_TABLE);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, alpha_ref_value,
gallivm->target, context_type,
LP_JIT_CTX_ALPHA_REF);
@ -146,6 +113,8 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
lp->jit_context_type = context_type;
lp->jit_context_ptr_type = LLVMPointerType(context_type, 0);
lp->jit_resources_type = lp_build_jit_resources_type(gallivm);
lp->jit_resources_ptr_type = LLVMPointerType(lp->jit_resources_type, 0);
}
/* struct lp_jit_thread_data */
@ -275,12 +244,6 @@ lp_jit_create_cs_types(struct lp_compute_shader_variant *lp)
{
struct gallivm_state *gallivm = lp->gallivm;
LLVMContextRef lc = gallivm->context;
LLVMTypeRef texture_type, sampler_type, image_type, buffer_type;
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 = lp_build_create_jit_image_type(gallivm);
/* struct lp_jit_cs_thread_data */
{
@ -303,41 +266,12 @@ lp_jit_create_cs_types(struct lp_compute_shader_variant *lp)
LLVMTypeRef elem_types[LP_JIT_CS_CTX_COUNT];
LLVMTypeRef cs_context_type;
elem_types[LP_JIT_CS_CTX_CONSTANTS] =
LLVMArrayType(buffer_type, LP_MAX_TGSI_CONST_BUFFERS);
elem_types[LP_JIT_CS_CTX_SSBOS] =
LLVMArrayType(buffer_type, LP_MAX_TGSI_SHADER_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,
PIPE_MAX_SAMPLERS);
elem_types[LP_JIT_CS_CTX_IMAGES] = LLVMArrayType(image_type,
PIPE_MAX_SHADER_IMAGES);
elem_types[LP_JIT_CS_CTX_ANISO_FILTER_TABLE] = LLVMPointerType(LLVMFloatTypeInContext(lc), 0);
elem_types[LP_JIT_CS_CTX_KERNEL_ARGS] = LLVMPointerType(LLVMInt8TypeInContext(lc), 0);
elem_types[LP_JIT_CS_CTX_SHARED_SIZE] = LLVMInt32TypeInContext(lc);
cs_context_type = LLVMStructTypeInContext(lc, elem_types,
ARRAY_SIZE(elem_types), 0);
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, ssbos,
gallivm->target, cs_context_type,
LP_JIT_CS_CTX_SSBOS);
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, samplers,
gallivm->target, cs_context_type,
LP_JIT_CS_CTX_SAMPLERS);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, images,
gallivm->target, cs_context_type,
LP_JIT_CS_CTX_IMAGES);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, aniso_filter_table,
gallivm->target, cs_context_type,
LP_JIT_CS_CTX_ANISO_FILTER_TABLE);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, kernel_args,
gallivm->target, cs_context_type,
LP_JIT_CS_CTX_KERNEL_ARGS);
@ -349,6 +283,8 @@ lp_jit_create_cs_types(struct lp_compute_shader_variant *lp)
lp->jit_cs_context_type = cs_context_type;
lp->jit_cs_context_ptr_type = LLVMPointerType(cs_context_type, 0);
lp->jit_resources_type = lp_build_jit_resources_type(gallivm);
lp->jit_resources_ptr_type = LLVMPointerType(lp->jit_resources_type, 0);
}
if (gallivm_debug & GALLIVM_DEBUG_IR) {

View file

@ -75,13 +75,6 @@ enum {
*/
struct lp_jit_context
{
struct lp_jit_buffer constants[LP_MAX_TGSI_CONST_BUFFERS];
struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_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 float *aniso_filter_table;
float alpha_ref_value;
uint32_t stencil_ref_front, stencil_ref_back;
@ -100,12 +93,6 @@ struct lp_jit_context
* lp_jit_context struct above.
*/
enum {
LP_JIT_CTX_CONSTANTS = 0,
LP_JIT_CTX_SSBOS,
LP_JIT_CTX_TEXTURES,
LP_JIT_CTX_SAMPLERS,
LP_JIT_CTX_IMAGES,
LP_JIT_CTX_ANISO_FILTER_TABLE,
LP_JIT_CTX_ALPHA_REF,
LP_JIT_CTX_STENCIL_REF_FRONT,
LP_JIT_CTX_STENCIL_REF_BACK,
@ -116,25 +103,6 @@ enum {
LP_JIT_CTX_COUNT
};
#define lp_jit_context_constants(_gallivm, _type, _ptr) \
lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CTX_CONSTANTS, "constants")
#define lp_jit_context_ssbos(_gallivm, _type, _ptr) \
lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CTX_SSBOS, "ssbos")
#define lp_jit_context_textures(_gallivm, _type, _ptr) \
lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CTX_TEXTURES, "textures")
#define lp_jit_context_samplers(_gallivm, _type, _ptr) \
lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CTX_SAMPLERS, "samplers")
#define lp_jit_context_images(_gallivm, _type, _ptr) \
lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CTX_IMAGES, "images")
#define lp_jit_context_aniso_filter_table(_gallivm, _type, _ptr) \
lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_CTX_ANISO_FILTER_TABLE, "aniso_filter_table")
#define lp_jit_context_alpha_ref_value(_gallivm, _type, _ptr) \
lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_CTX_ALPHA_REF, "alpha_ref_value")
@ -221,6 +189,7 @@ enum {
*/
typedef void
(*lp_jit_frag_func)(const struct lp_jit_context *context,
const struct lp_jit_resources *res,
uint32_t x,
uint32_t y,
uint32_t facing,
@ -348,13 +317,6 @@ enum {
struct lp_jit_cs_context
{
struct lp_jit_buffer constants[LP_MAX_TGSI_CONST_BUFFERS];
struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_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 float *aniso_filter_table;
const void *kernel_args;
uint32_t shared_size;
@ -365,12 +327,6 @@ struct lp_jit_cs_context
* lp_jit_context struct above.
*/
enum {
LP_JIT_CS_CTX_CONSTANTS = 0,
LP_JIT_CS_CTX_SSBOS,
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_ANISO_FILTER_TABLE,
LP_JIT_CS_CTX_KERNEL_ARGS,
LP_JIT_CS_CTX_SHARED_SIZE,
LP_JIT_CS_CTX_COUNT
@ -394,14 +350,15 @@ enum {
#define lp_jit_cs_context_aniso_filter_table(_gallivm, _type, _ptr) \
lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_ANISO_FILTER_TABLE, "aniso_filter_table")
#define lp_jit_cs_context_shared_size(_gallivm, _type, _ptr) \
lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_SHARED_SIZE, "shared_size")
#define lp_jit_cs_context_kernel_args(_gallivm, _type, _ptr) \
lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_KERNEL_ARGS, "kernel_args")
#define lp_jit_cs_context_shared_size(_gallivm, _type, _ptr) \
lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_SHARED_SIZE, "shared_size")
typedef void
(*lp_jit_cs_func)(const struct lp_jit_cs_context *context,
const struct lp_jit_resources *resources,
uint32_t x,
uint32_t y,
uint32_t z,

View file

@ -104,10 +104,10 @@ lp_fs_linear_run(const struct lp_rast_state *state,
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.constants[0].num_elements;
nr_consts = state->jit_resources.constants[0].num_elements;
}
for (int i = 0; i < nr_consts; i++){
float val = state->jit_context.constants[0].f[i];
float val = state->jit_resources.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);
@ -181,7 +181,7 @@ lp_fs_linear_run(const struct lp_rast_state *state,
if (!lp_linear_init_sampler(&samp[i], tex_info,
lp_fs_variant_key_sampler_idx(&variant->key, samp_unit),
&state->jit_context.textures[tex_unit],
&state->jit_resources.textures[tex_unit],
x, y, width, height, a0, dadx, dady)) {
if (LP_DEBUG & DEBUG_LINEAR2)
debug_printf(" -- init_sampler(%d) failed\n", i);

View file

@ -66,8 +66,8 @@ lp_linear_blit_rgba_blit(const struct lp_rast_state *state,
uint8_t *color,
unsigned stride)
{
const struct lp_jit_context *context = &state->jit_context;
const struct lp_jit_texture *texture = &context->textures[0];
const struct lp_jit_resources *resources = &state->jit_resources;
const struct lp_jit_texture *texture = &resources->textures[0];
LP_DBG(DEBUG_RAST, "%s\n", __func__);
@ -115,8 +115,8 @@ lp_linear_blit_rgb1_blit(const struct lp_rast_state *state,
uint8_t *color,
unsigned stride)
{
const struct lp_jit_context *context = &state->jit_context;
const struct lp_jit_texture *texture = &context->textures[0];
const struct lp_jit_resources *resources = &state->jit_resources;
const struct lp_jit_texture *texture = &resources->textures[0];
LP_DBG(DEBUG_RAST, "%s\n", __func__);

View file

@ -361,6 +361,7 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task,
/* run shader on 4x4 block */
BEGIN_JIT_CALL(state, task);
variant->jit_function[RAST_WHOLE](&state->jit_context,
&state->jit_resources,
tile_x + x, tile_y + y,
inputs->frontfacing,
GET_A0(inputs),
@ -468,6 +469,7 @@ lp_rast_shade_quads_mask_sample(struct lp_rasterizer_task *task,
/* run shader on 4x4 block */
BEGIN_JIT_CALL(state, task);
variant->jit_function[RAST_EDGE_TEST](&state->jit_context,
&state->jit_resources,
x, y,
inputs->frontfacing,
GET_A0(inputs),
@ -511,7 +513,7 @@ lp_rast_blit_tile_to_dest(struct lp_rasterizer_task *task,
const struct lp_rast_shader_inputs *inputs = arg.shade_tile;
const struct lp_rast_state *state = task->state;
struct lp_fragment_shader_variant *variant = state->variant;
const struct lp_jit_texture *texture = &state->jit_context.textures[0];
const struct lp_jit_texture *texture = &state->jit_resources.textures[0];
struct pipe_surface *cbuf = scene->fb.cbufs[0];
const unsigned face_slice = cbuf->u.tex.first_layer;
const unsigned level = cbuf->u.tex.level;

View file

@ -86,6 +86,7 @@ struct lp_rast_state {
* the fragment shader, such as blend color and alpha ref value.
*/
struct lp_jit_context jit_context;
struct lp_jit_resources jit_resources;
/* The shader itself. Probably we also need to pass a pointer to
* the tile color/z/stencil data somehow

View file

@ -109,6 +109,7 @@ shade_quads(struct lp_rasterizer_task *task,
BEGIN_JIT_CALL(state, task);
const unsigned fn_index = mask == 0xffff ? RAST_WHOLE : RAST_EDGE_TEST;
variant->jit_function[fn_index](&state->jit_context,
&state->jit_resources,
x, y,
inputs->frontfacing,
GET_A0(inputs),

View file

@ -271,6 +271,7 @@ lp_rast_shade_quads_all(struct lp_rasterizer_task *task,
/* run shader on 4x4 block */
BEGIN_JIT_CALL(state, task);
variant->jit_function[RAST_WHOLE](&state->jit_context,
&state->jit_resources,
x, y,
inputs->frontfacing,
GET_A0(inputs),

View file

@ -686,7 +686,7 @@ lp_setup_set_fs_images(struct lp_setup_context *setup,
struct pipe_resource *res = image->resource;
struct llvmpipe_resource *lp_res = llvmpipe_resource(res);
struct lp_jit_image *jit_image = &setup->fs.current.jit_context.images[i];
struct lp_jit_image *jit_image = &setup->fs.current.jit_resources.images[i];
if (!lp_res)
continue;
@ -940,7 +940,7 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
struct pipe_resource *res = view->texture;
struct llvmpipe_resource *lp_tex = llvmpipe_resource(res);
struct lp_jit_texture *jit_tex;
jit_tex = &setup->fs.current.jit_context.textures[i];
jit_tex = &setup->fs.current.jit_resources.textures[i];
/* We're referencing the texture's internal data, so save a
* reference to it.
@ -1080,7 +1080,7 @@ lp_setup_set_fragment_sampler_state(struct lp_setup_context *setup,
if (sampler) {
struct lp_jit_sampler *jit_sam;
jit_sam = &setup->fs.current.jit_context.samplers[i];
jit_sam = &setup->fs.current.jit_resources.samplers[i];
jit_sam->min_lod = sampler->min_lod;
jit_sam->max_lod = sampler->max_lod;
@ -1257,18 +1257,18 @@ try_update_scene_state(struct lp_setup_context *setup)
setup->constants[i].stored_size = current_size;
setup->constants[i].stored_data = stored;
}
setup->fs.current.jit_context.constants[i].f =
setup->fs.current.jit_resources.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].f = fake_const_buf;
setup->fs.current.jit_resources.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.constants[i].num_elements = num_constants;
setup->fs.current.jit_resources.constants[i].num_elements = num_constants;
setup->dirty |= LP_SETUP_NEW_FS;
}
}
@ -1285,13 +1285,13 @@ try_update_scene_state(struct lp_setup_context *setup)
if (current_data) {
current_data += setup->ssbos[i].current.buffer_offset;
setup->fs.current.jit_context.ssbos[i].u =
setup->fs.current.jit_resources.ssbos[i].u =
(const uint32_t *)current_data;
setup->fs.current.jit_context.ssbos[i].num_elements =
setup->fs.current.jit_resources.ssbos[i].num_elements =
setup->ssbos[i].current.buffer_size;
} else {
setup->fs.current.jit_context.ssbos[i].u = NULL;
setup->fs.current.jit_context.ssbos[i].num_elements = 0;
setup->fs.current.jit_resources.ssbos[i].u = NULL;
setup->fs.current.jit_resources.ssbos[i].num_elements = 0;
}
setup->dirty |= LP_SETUP_NEW_FS;
}
@ -1316,8 +1316,11 @@ try_update_scene_state(struct lp_setup_context *setup)
memcpy(&stored->jit_context,
&setup->fs.current.jit_context,
sizeof setup->fs.current.jit_context);
memcpy(&stored->jit_resources,
&setup->fs.current.jit_resources,
sizeof setup->fs.current.jit_resources);
stored->jit_context.aniso_filter_table =
stored->jit_resources.aniso_filter_table =
lp_build_sample_aniso_filter_table();
stored->variant = setup->fs.current.variant;

View file

@ -147,7 +147,7 @@ lp_setup_is_blit(const struct lp_setup_context *setup,
* Detect blits.
*/
const struct lp_jit_texture *texture =
&setup->fs.current.jit_context.textures[0];
&setup->fs.current.jit_resources.textures[0];
/* XXX: dadx vs dady confusion below?
*/

View file

@ -239,7 +239,7 @@ check_opaque(const struct lp_setup_context *setup,
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].f;
const float *constants = setup->fs.current.jit_resources.constants[0].f;
float alpha = constants[alpha_info->u.index*4 +
alpha_info->swizzle];
return alpha == 1.0f;

View file

@ -73,10 +73,10 @@ generate_compute(struct llvmpipe_context *lp,
struct gallivm_state *gallivm = variant->gallivm;
const struct lp_compute_shader_variant_key *key = &variant->key;
char func_name[64], func_name_coro[64];
LLVMTypeRef arg_types[19];
LLVMTypeRef arg_types[20];
LLVMTypeRef func_type, coro_func_type;
LLVMTypeRef int32_type = LLVMInt32TypeInContext(gallivm->context);
LLVMValueRef context_ptr;
LLVMValueRef context_ptr, resources_ptr;
LLVMValueRef block_x_size_arg, block_y_size_arg, block_z_size_arg;
LLVMValueRef grid_x_arg, grid_y_arg, grid_z_arg;
LLVMValueRef grid_size_x_arg, grid_size_y_arg, grid_size_z_arg;
@ -107,24 +107,25 @@ generate_compute(struct llvmpipe_context *lp,
snprintf(func_name_coro, sizeof(func_name), "cs_co_variant");
arg_types[0] = variant->jit_cs_context_ptr_type; /* context */
arg_types[1] = int32_type; /* block_x_size */
arg_types[2] = int32_type; /* block_y_size */
arg_types[3] = int32_type; /* block_z_size */
arg_types[4] = int32_type; /* grid_x */
arg_types[5] = int32_type; /* grid_y */
arg_types[6] = int32_type; /* grid_z */
arg_types[7] = int32_type; /* grid_size_x */
arg_types[8] = int32_type; /* grid_size_y */
arg_types[9] = int32_type; /* grid_size_z */
arg_types[10] = int32_type; /* work dim */
arg_types[11] = variant->jit_cs_thread_data_ptr_type; /* per thread data */
arg_types[12] = int32_type; /* coro only - num X loops */
arg_types[13] = int32_type; /* coro only - partials */
arg_types[14] = int32_type; /* coro block_x_size */
arg_types[15] = int32_type; /* coro block_y_size */
arg_types[16] = int32_type; /* coro block_z_size */
arg_types[17] = int32_type; /* coro idx */
arg_types[18] = LLVMPointerType(LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0), 0);
arg_types[1]= variant->jit_resources_ptr_type;
arg_types[2] = int32_type; /* block_x_size */
arg_types[3] = int32_type; /* block_y_size */
arg_types[4] = int32_type; /* block_z_size */
arg_types[5] = int32_type; /* grid_x */
arg_types[6] = int32_type; /* grid_y */
arg_types[7] = int32_type; /* grid_z */
arg_types[8] = int32_type; /* grid_size_x */
arg_types[9] = int32_type; /* grid_size_y */
arg_types[10] = int32_type; /* grid_size_z */
arg_types[11] = int32_type; /* work dim */
arg_types[12] = variant->jit_cs_thread_data_ptr_type; /* per thread data */
arg_types[13] = int32_type; /* coro only - num X loops */
arg_types[14] = int32_type; /* coro only - partials */
arg_types[15] = int32_type; /* coro block_x_size */
arg_types[16] = int32_type; /* coro block_y_size */
arg_types[17] = int32_type; /* coro block_z_size */
arg_types[18] = int32_type; /* coro idx */
arg_types[19] = LLVMPointerType(LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0), 0);
func_type = LLVMFunctionType(LLVMVoidTypeInContext(gallivm->context),
arg_types, ARRAY_SIZE(arg_types) - 7, 0);
@ -152,19 +153,21 @@ generate_compute(struct llvmpipe_context *lp,
return;
context_ptr = LLVMGetParam(function, 0);
block_x_size_arg = LLVMGetParam(function, 1);
block_y_size_arg = LLVMGetParam(function, 2);
block_z_size_arg = LLVMGetParam(function, 3);
grid_x_arg = LLVMGetParam(function, 4);
grid_y_arg = LLVMGetParam(function, 5);
grid_z_arg = LLVMGetParam(function, 6);
grid_size_x_arg = LLVMGetParam(function, 7);
grid_size_y_arg = LLVMGetParam(function, 8);
grid_size_z_arg = LLVMGetParam(function, 9);
work_dim_arg = LLVMGetParam(function, 10);
thread_data_ptr = LLVMGetParam(function, 11);
resources_ptr = LLVMGetParam(function, 1);
block_x_size_arg = LLVMGetParam(function, 2);
block_y_size_arg = LLVMGetParam(function, 3);
block_z_size_arg = LLVMGetParam(function, 4);
grid_x_arg = LLVMGetParam(function, 5);
grid_y_arg = LLVMGetParam(function, 6);
grid_z_arg = LLVMGetParam(function, 7);
grid_size_x_arg = LLVMGetParam(function, 8);
grid_size_y_arg = LLVMGetParam(function, 9);
grid_size_z_arg = LLVMGetParam(function, 10);
work_dim_arg = LLVMGetParam(function, 11);
thread_data_ptr = LLVMGetParam(function, 12);
lp_build_name(context_ptr, "context");
lp_build_name(resources_ptr, "resources");
lp_build_name(block_x_size_arg, "x_size");
lp_build_name(block_y_size_arg, "y_size");
lp_build_name(block_z_size_arg, "z_size");
@ -221,24 +224,25 @@ generate_compute(struct llvmpipe_context *lp,
lp_build_loop_begin(&loop_state[0], gallivm,
lp_build_const_int32(gallivm, 0)); /* x loop */
{
LLVMValueRef args[19];
LLVMValueRef args[20];
args[0] = context_ptr;
args[1] = loop_state[0].counter;
args[2] = loop_state[1].counter;
args[3] = loop_state[2].counter;
args[4] = grid_x_arg;
args[5] = grid_y_arg;
args[6] = grid_z_arg;
args[7] = grid_size_x_arg;
args[8] = grid_size_y_arg;
args[9] = grid_size_z_arg;
args[10] = work_dim_arg;
args[11] = thread_data_ptr;
args[12] = num_x_loop;
args[13] = partials;
args[14] = block_x_size_arg;
args[15] = block_y_size_arg;
args[16] = block_z_size_arg;
args[1] = resources_ptr;
args[2] = loop_state[0].counter;
args[3] = loop_state[1].counter;
args[4] = loop_state[2].counter;
args[5] = grid_x_arg;
args[6] = grid_y_arg;
args[7] = grid_z_arg;
args[8] = grid_size_x_arg;
args[9] = grid_size_y_arg;
args[10] = grid_size_z_arg;
args[11] = work_dim_arg;
args[12] = thread_data_ptr;
args[13] = num_x_loop;
args[14] = partials;
args[15] = block_x_size_arg;
args[16] = block_y_size_arg;
args[17] = block_z_size_arg;
/* idx = (z * (size_x * size_y) + y * size_x + x */
LLVMValueRef coro_hdl_idx = LLVMBuildMul(gallivm->builder, loop_state[2].counter,
@ -249,9 +253,9 @@ generate_compute(struct llvmpipe_context *lp,
coro_hdl_idx = LLVMBuildAdd(gallivm->builder, coro_hdl_idx,
loop_state[0].counter, "");
args[17] = coro_hdl_idx;
args[18] = coro_hdl_idx;
args[18] = coro_mem;
args[19] = coro_mem;
LLVMValueRef coro_entry = LLVMBuildGEP2(gallivm->builder, hdl_ptr_type, coro_hdls, &coro_hdl_idx, 1, "");
LLVMValueRef coro_hdl = LLVMBuildLoad2(gallivm->builder, hdl_ptr_type, coro_entry, "coro_hdl");
@ -261,7 +265,7 @@ generate_compute(struct llvmpipe_context *lp,
lp_build_const_int32(gallivm, 0), "");
/* first time here - call the coroutine function entry point */
lp_build_if(&ifstate, gallivm, cmp);
LLVMValueRef coro_ret = LLVMBuildCall2(gallivm->builder, coro_func_type, coro, args, 19, "");
LLVMValueRef coro_ret = LLVMBuildCall2(gallivm->builder, coro_func_type, coro, args, 20, "");
LLVMBuildStore(gallivm->builder, coro_ret, coro_entry);
lp_build_else(&ifstate);
/* subsequent calls for this invocation - check if done. */
@ -301,24 +305,25 @@ generate_compute(struct llvmpipe_context *lp,
/* This is stage (b) - generate the compute shader code inside the coroutine. */
LLVMValueRef x_size_arg, y_size_arg, z_size_arg;
context_ptr = LLVMGetParam(coro, 0);
x_size_arg = LLVMGetParam(coro, 1);
y_size_arg = LLVMGetParam(coro, 2);
z_size_arg = LLVMGetParam(coro, 3);
grid_x_arg = LLVMGetParam(coro, 4);
grid_y_arg = LLVMGetParam(coro, 5);
grid_z_arg = LLVMGetParam(coro, 6);
grid_size_x_arg = LLVMGetParam(coro, 7);
grid_size_y_arg = LLVMGetParam(coro, 8);
grid_size_z_arg = LLVMGetParam(coro, 9);
work_dim_arg = LLVMGetParam(coro, 10);
thread_data_ptr = LLVMGetParam(coro, 11);
num_x_loop = LLVMGetParam(coro, 12);
partials = LLVMGetParam(coro, 13);
block_x_size_arg = LLVMGetParam(coro, 14);
block_y_size_arg = LLVMGetParam(coro, 15);
block_z_size_arg = LLVMGetParam(coro, 16);
LLVMValueRef coro_idx = LLVMGetParam(coro, 17);
coro_mem = LLVMGetParam(coro, 18);
resources_ptr = LLVMGetParam(coro, 1);
x_size_arg = LLVMGetParam(coro, 2);
y_size_arg = LLVMGetParam(coro, 3);
z_size_arg = LLVMGetParam(coro, 4);
grid_x_arg = LLVMGetParam(coro, 5);
grid_y_arg = LLVMGetParam(coro, 6);
grid_z_arg = LLVMGetParam(coro, 7);
grid_size_x_arg = LLVMGetParam(coro, 8);
grid_size_y_arg = LLVMGetParam(coro, 9);
grid_size_z_arg = LLVMGetParam(coro, 10);
work_dim_arg = LLVMGetParam(coro, 11);
thread_data_ptr = LLVMGetParam(coro, 12);
num_x_loop = LLVMGetParam(coro, 13);
partials = LLVMGetParam(coro, 14);
block_x_size_arg = LLVMGetParam(coro, 15);
block_y_size_arg = LLVMGetParam(coro, 16);
block_z_size_arg = LLVMGetParam(coro, 17);
LLVMValueRef coro_idx = LLVMGetParam(coro, 18);
coro_mem = LLVMGetParam(coro, 19);
block = LLVMAppendBasicBlockInContext(gallivm->context, coro, "entry");
LLVMPositionBuilderAtEnd(builder, block);
{
@ -330,12 +335,8 @@ generate_compute(struct llvmpipe_context *lp,
struct lp_bld_tgsi_system_values system_values;
memset(&system_values, 0, sizeof(system_values));
consts_ptr = lp_jit_cs_context_constants(gallivm,
variant->jit_cs_context_type,
context_ptr);
ssbo_ptr = lp_jit_cs_context_ssbos(gallivm,
variant->jit_cs_context_type,
context_ptr);
consts_ptr = lp_jit_resources_constants(gallivm, variant->jit_resources_type, resources_ptr);
ssbo_ptr = lp_jit_resources_ssbos(gallivm, variant->jit_resources_type, resources_ptr);
kernel_args_ptr = lp_jit_cs_context_kernel_args(gallivm,
variant->jit_cs_context_type,
context_ptr);
@ -450,6 +451,8 @@ generate_compute(struct llvmpipe_context *lp,
params.system_values = &system_values;
params.context_type = variant->jit_cs_context_type;
params.context_ptr = context_ptr;
params.resources_type = variant->jit_resources_type;
params.resources_ptr = resources_ptr;
params.sampler = sampler;
params.info = &shader->info.base;
params.ssbo_ptr = ssbo_ptr;
@ -457,9 +460,9 @@ generate_compute(struct llvmpipe_context *lp,
params.shared_ptr = shared_ptr;
params.coro = &coro_info;
params.kernel_args = kernel_args_ptr;
params.aniso_filter_table = lp_jit_cs_context_aniso_filter_table(gallivm,
variant->jit_cs_context_type,
context_ptr);
params.aniso_filter_table = lp_jit_resources_aniso_filter_table(gallivm,
variant->jit_resources_type,
resources_ptr);
if (shader->base.type == PIPE_SHADER_IR_TGSI)
lp_build_tgsi_soa(gallivm, shader->base.tokens, &params, NULL);
@ -985,7 +988,7 @@ lp_csctx_set_sampler_views(struct lp_cs_context *csctx,
struct pipe_resource *res = view->texture;
struct llvmpipe_resource *lp_tex = llvmpipe_resource(res);
struct lp_jit_texture *jit_tex;
jit_tex = &csctx->cs.current.jit_context.textures[i];
jit_tex = &csctx->cs.current.jit_resources.textures[i];
/* We're referencing the texture's internal data, so save a
* reference to it.
@ -1134,7 +1137,7 @@ lp_csctx_set_sampler_state(struct lp_cs_context *csctx,
if (sampler) {
struct lp_jit_sampler *jit_sam;
jit_sam = &csctx->cs.current.jit_context.samplers[i];
jit_sam = &csctx->cs.current.jit_resources.samplers[i];
jit_sam->min_lod = sampler->min_lod;
jit_sam->max_lod = sampler->max_lod;
@ -1204,7 +1207,7 @@ lp_csctx_set_cs_images(struct lp_cs_context *csctx,
struct llvmpipe_resource *lp_res = llvmpipe_resource(res);
struct lp_jit_image *jit_image;
jit_image = &csctx->cs.current.jit_context.images[i];
jit_image = &csctx->cs.current.jit_resources.images[i];
if (!lp_res)
continue;
if (!lp_res->dt) {
@ -1297,14 +1300,14 @@ update_csctx_consts(struct llvmpipe_context *llvmpipe)
if (current_data && current_size >= sizeof(float)) {
current_data += csctx->constants[i].current.buffer_offset;
csctx->cs.current.jit_context.constants[i].f = (const float *)current_data;
csctx->cs.current.jit_context.constants[i].num_elements =
csctx->cs.current.jit_resources.constants[i].f = (const float *)current_data;
csctx->cs.current.jit_resources.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].f = fake_const_buf;
csctx->cs.current.jit_context.constants[i].num_elements = 0;
csctx->cs.current.jit_resources.constants[i].f = fake_const_buf;
csctx->cs.current.jit_resources.constants[i].num_elements = 0;
}
}
}
@ -1325,11 +1328,11 @@ update_csctx_ssbo(struct llvmpipe_context *llvmpipe)
if (current_data) {
current_data += csctx->ssbos[i].current.buffer_offset;
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;
csctx->cs.current.jit_resources.ssbos[i].u = (const uint32_t *)current_data;
csctx->cs.current.jit_resources.ssbos[i].num_elements = csctx->ssbos[i].current.buffer_size;
} else {
csctx->cs.current.jit_context.ssbos[i].u = NULL;
csctx->cs.current.jit_context.ssbos[i].num_elements = 0;
csctx->cs.current.jit_resources.ssbos[i].u = NULL;
csctx->cs.current.jit_resources.ssbos[i].num_elements = 0;
}
}
}
@ -1368,7 +1371,7 @@ llvmpipe_cs_update_derived(struct llvmpipe_context *llvmpipe, const void *input)
llvmpipe->images[PIPE_SHADER_COMPUTE]);
struct lp_cs_context *csctx = llvmpipe->csctx;
csctx->cs.current.jit_context.aniso_filter_table = lp_build_sample_aniso_filter_table();
csctx->cs.current.jit_resources.aniso_filter_table = lp_build_sample_aniso_filter_table();
if (input) {
csctx->input = input;
csctx->cs.current.jit_context.kernel_args = input;
@ -1411,6 +1414,7 @@ cs_exec_fn(void *init_data, int iter_idx, struct lp_cs_local_mem *lmem)
grid_x += job_info->grid_base[0];
struct lp_compute_shader_variant *variant = job_info->current->variant;
variant->jit_function(&job_info->current->jit_context,
&job_info->current->jit_resources,
job_info->block_size[0], job_info->block_size[1], job_info->block_size[2],
grid_x, grid_y, grid_z,
job_info->grid_size[0], job_info->grid_size[1], job_info->grid_size[2], job_info->work_dim,

View file

@ -82,6 +82,8 @@ struct lp_compute_shader_variant
LLVMTypeRef jit_cs_context_type;
LLVMTypeRef jit_cs_context_ptr_type;
LLVMTypeRef jit_cs_thread_data_type;
LLVMTypeRef jit_resources_type;
LLVMTypeRef jit_resources_ptr_type;
LLVMTypeRef jit_cs_thread_data_ptr_type;
LLVMValueRef function;
@ -123,6 +125,7 @@ struct lp_compute_shader {
struct lp_cs_exec {
struct lp_jit_cs_context jit_context;
struct lp_jit_resources jit_resources;
struct lp_compute_shader_variant *variant;
};

View file

@ -637,6 +637,8 @@ generate_fs_loop(struct gallivm_state *gallivm,
struct lp_type type,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
LLVMTypeRef sample_pos_type,
LLVMValueRef sample_pos_array,
LLVMValueRef num_loop,
@ -746,9 +748,9 @@ generate_fs_loop(struct gallivm_state *gallivm,
stencil_refs[0] = lp_build_broadcast(gallivm, int_vec_type, stencil_refs[0]);
stencil_refs[1] = lp_build_broadcast(gallivm, int_vec_type, stencil_refs[1]);
LLVMValueRef consts_ptr = lp_jit_context_constants(gallivm, context_type, context_ptr);
LLVMValueRef consts_ptr = lp_jit_resources_constants(gallivm, resources_type, resources_ptr);
LLVMValueRef ssbo_ptr = lp_jit_context_ssbos(gallivm, context_type, context_ptr);
LLVMValueRef ssbo_ptr = lp_jit_resources_ssbos(gallivm, resources_type, resources_ptr);
LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][TGSI_NUM_CHANNELS];
memset(outputs, 0, sizeof outputs);
@ -1048,13 +1050,15 @@ generate_fs_loop(struct gallivm_state *gallivm,
params.inputs = interp->inputs;
params.context_type = context_type;
params.context_ptr = context_ptr;
params.resources_type = resources_type;
params.resources_ptr = resources_ptr;
params.thread_data_type = thread_data_type;
params.thread_data_ptr = thread_data_ptr;
params.sampler = sampler;
params.info = &shader->info.base;
params.ssbo_ptr = ssbo_ptr;
params.image = image;
params.aniso_filter_table = lp_jit_context_aniso_filter_table(gallivm, context_type, context_ptr);
params.aniso_filter_table = lp_jit_resources_aniso_filter_table(gallivm, resources_type, resources_ptr);
/* Build the actual shader */
if (shader->base.type == PIPE_SHADER_IR_TGSI)
@ -3100,13 +3104,14 @@ generate_fragment(struct llvmpipe_context *lp,
struct lp_shader_input inputs[PIPE_MAX_SHADER_INPUTS];
LLVMTypeRef fs_elem_type;
LLVMTypeRef blend_vec_type;
LLVMTypeRef arg_types[15];
LLVMTypeRef arg_types[16];
LLVMTypeRef func_type;
LLVMTypeRef int32_type = LLVMInt32TypeInContext(gallivm->context);
LLVMTypeRef int32p_type = LLVMPointerType(int32_type, 0);
LLVMTypeRef int8_type = LLVMInt8TypeInContext(gallivm->context);
LLVMTypeRef int8p_type = LLVMPointerType(int8_type, 0);
LLVMValueRef context_ptr;
LLVMValueRef resources_ptr;
LLVMValueRef x;
LLVMValueRef y;
LLVMValueRef a0_ptr;
@ -3183,20 +3188,21 @@ generate_fragment(struct llvmpipe_context *lp,
partial_mask ? "partial" : "whole");
arg_types[0] = variant->jit_context_ptr_type; /* context */
arg_types[1] = int32_type; /* x */
arg_types[2] = int32_type; /* y */
arg_types[3] = int32_type; /* facing */
arg_types[4] = LLVMPointerType(fs_elem_type, 0); /* a0 */
arg_types[5] = LLVMPointerType(fs_elem_type, 0); /* dadx */
arg_types[6] = LLVMPointerType(fs_elem_type, 0); /* dady */
arg_types[7] = LLVMPointerType(int8p_type, 0); /* color */
arg_types[8] = int8p_type; /* depth */
arg_types[9] = LLVMInt64TypeInContext(gallivm->context); /* mask_input */
arg_types[10] = variant->jit_thread_data_ptr_type; /* per thread data */
arg_types[11] = int32p_type; /* stride */
arg_types[12] = int32_type; /* depth_stride */
arg_types[13] = int32p_type; /* color sample strides */
arg_types[14] = int32_type; /* depth sample stride */
arg_types[1] = variant->jit_resources_ptr_type; /* context */
arg_types[2] = int32_type; /* x */
arg_types[3] = int32_type; /* y */
arg_types[4] = int32_type; /* facing */
arg_types[5] = LLVMPointerType(fs_elem_type, 0); /* a0 */
arg_types[6] = LLVMPointerType(fs_elem_type, 0); /* dadx */
arg_types[7] = LLVMPointerType(fs_elem_type, 0); /* dady */
arg_types[8] = LLVMPointerType(int8p_type, 0); /* color */
arg_types[9] = int8p_type; /* depth */
arg_types[10] = LLVMInt64TypeInContext(gallivm->context); /* mask_input */
arg_types[11] = variant->jit_thread_data_ptr_type; /* per thread data */
arg_types[12] = int32p_type; /* stride */
arg_types[13] = int32_type; /* depth_stride */
arg_types[14] = int32p_type; /* color sample strides */
arg_types[15] = int32_type; /* depth sample stride */
func_type = LLVMFunctionType(LLVMVoidTypeInContext(gallivm->context),
arg_types, ARRAY_SIZE(arg_types), 0);
@ -3217,22 +3223,24 @@ generate_fragment(struct llvmpipe_context *lp,
return;
context_ptr = LLVMGetParam(function, 0);
x = LLVMGetParam(function, 1);
y = LLVMGetParam(function, 2);
facing = LLVMGetParam(function, 3);
a0_ptr = LLVMGetParam(function, 4);
dadx_ptr = LLVMGetParam(function, 5);
dady_ptr = LLVMGetParam(function, 6);
color_ptr_ptr = LLVMGetParam(function, 7);
depth_ptr = LLVMGetParam(function, 8);
mask_input = LLVMGetParam(function, 9);
thread_data_ptr = LLVMGetParam(function, 10);
stride_ptr = LLVMGetParam(function, 11);
depth_stride = LLVMGetParam(function, 12);
color_sample_stride_ptr = LLVMGetParam(function, 13);
depth_sample_stride = LLVMGetParam(function, 14);
resources_ptr = LLVMGetParam(function, 1);
x = LLVMGetParam(function, 2);
y = LLVMGetParam(function, 3);
facing = LLVMGetParam(function, 4);
a0_ptr = LLVMGetParam(function, 5);
dadx_ptr = LLVMGetParam(function, 6);
dady_ptr = LLVMGetParam(function, 7);
color_ptr_ptr = LLVMGetParam(function, 8);
depth_ptr = LLVMGetParam(function, 9);
mask_input = LLVMGetParam(function, 10);
thread_data_ptr = LLVMGetParam(function, 11);
stride_ptr = LLVMGetParam(function, 12);
depth_stride = LLVMGetParam(function, 13);
color_sample_stride_ptr = LLVMGetParam(function, 14);
depth_sample_stride = LLVMGetParam(function, 15);
lp_build_name(context_ptr, "context");
lp_build_name(resources_ptr, "resources");
lp_build_name(x, "x");
lp_build_name(y, "y");
lp_build_name(a0_ptr, "a0");
@ -3404,6 +3412,8 @@ generate_fragment(struct llvmpipe_context *lp,
fs_type,
variant->jit_context_type,
context_ptr,
variant->jit_resources_type,
resources_ptr,
LLVMTypeOf(sample_pos_array),
glob_sample_pos,
num_loop,

View file

@ -176,6 +176,8 @@ struct lp_fragment_shader_variant
LLVMTypeRef jit_context_type;
LLVMTypeRef jit_context_ptr_type;
LLVMTypeRef jit_thread_data_type;
LLVMTypeRef jit_resources_type;
LLVMTypeRef jit_resources_ptr_type;
LLVMTypeRef jit_thread_data_ptr_type;
LLVMTypeRef jit_linear_context_type;
LLVMTypeRef jit_linear_context_ptr_type;

View file

@ -44,6 +44,7 @@
static void
no_op(const struct lp_jit_context *context,
const struct lp_jit_resources *resources,
uint32_t x,
uint32_t y,
uint32_t facing,
@ -142,6 +143,7 @@ opaque_color(uint8_t **cbufs, unsigned *strides,
*/
static void
red(const struct lp_jit_context *context,
const struct lp_jit_resources *resources,
uint32_t x,
uint32_t y,
uint32_t facing,
@ -169,6 +171,7 @@ red(const struct lp_jit_context *context,
*/
static void
green(const struct lp_jit_context *context,
const struct lp_jit_resources *resources,
uint32_t x,
uint32_t y,
uint32_t facing,

View file

@ -360,8 +360,8 @@ blit_rgba_blit(const struct lp_rast_state *state,
uint8_t *color,
unsigned stride)
{
const struct lp_jit_context *context = &state->jit_context;
const struct lp_jit_texture *texture = &context->textures[0];
const struct lp_jit_resources *resources = &state->jit_resources;
const struct lp_jit_texture *texture = &resources->textures[0];
const uint8_t *src;
unsigned src_stride;
int src_x, src_y;
@ -412,8 +412,8 @@ blit_rgb1_blit(const struct lp_rast_state *state,
uint8_t *color,
unsigned stride)
{
const struct lp_jit_context *context = &state->jit_context;
const struct lp_jit_texture *texture = &context->textures[0];
const struct lp_jit_resources *resources = &state->jit_resources;
const struct lp_jit_texture *texture = &resources->textures[0];
const uint8_t *src;
unsigned src_stride;
int src_x, src_y;
@ -472,14 +472,14 @@ blit_rgba(const struct lp_rast_state *state,
uint8_t *color,
unsigned stride)
{
const struct lp_jit_context *context = &state->jit_context;
const struct lp_jit_resources *resources = &state->jit_resources;
struct nearest_sampler samp;
struct color_blend blend;
LP_DBG(DEBUG_RAST, "%s\n", __func__);
if (!init_nearest_sampler(&samp,
&context->textures[0],
&resources->textures[0],
x, y, width, height,
a0[1][0], dadx[1][0], dady[1][0],
a0[1][1], dadx[1][1], dady[1][1],
@ -511,7 +511,7 @@ blit_rgb1(const struct lp_rast_state *state,
uint8_t *color,
unsigned stride)
{
const struct lp_jit_context *context = &state->jit_context;
const struct lp_jit_resources *resources = &state->jit_resources;
struct nearest_sampler samp;
struct color_blend blend;
struct shader shader;
@ -519,7 +519,7 @@ blit_rgb1(const struct lp_rast_state *state,
LP_DBG(DEBUG_RAST, "%s\n", __func__);
if (!init_nearest_sampler(&samp,
&context->textures[0],
&resources->textures[0],
x, y, width, height,
a0[1][0], dadx[1][0], dady[1][0],
a0[1][1], dadx[1][1], dady[1][1],
@ -555,14 +555,14 @@ blit_rgba_blend_premul(const struct lp_rast_state *state,
uint8_t *color,
unsigned stride)
{
const struct lp_jit_context *context = &state->jit_context;
const struct lp_jit_resources *resources = &state->jit_resources;
struct nearest_sampler samp;
struct color_blend blend;
LP_DBG(DEBUG_RAST, "%s\n", __func__);
if (!init_nearest_sampler(&samp,
&context->textures[0],
&resources->textures[0],
x, y, width, height,
a0[1][0], dadx[1][0], dady[1][0],
a0[1][1], dadx[1][1], dady[1][1],

View file

@ -110,8 +110,8 @@ struct lp_llvm_image_soa
*/
static LLVMValueRef
lp_llvm_texture_member(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned texture_unit,
LLVMValueRef texture_unit_offset,
unsigned member_index,
@ -124,11 +124,11 @@ lp_llvm_texture_member(struct gallivm_state *gallivm,
assert(texture_unit < PIPE_MAX_SHADER_SAMPLER_VIEWS);
/* context[0] */
/* resources[0] */
indices[0] = lp_build_const_int32(gallivm, 0);
/* context[0].textures */
indices[1] = lp_build_const_int32(gallivm, LP_JIT_CTX_TEXTURES);
/* context[0].textures[unit] */
/* resources[0].textures */
indices[1] = lp_build_const_int32(gallivm, LP_JIT_RES_TEXTURES);
/* resources[0].textures[unit] */
indices[2] = lp_build_const_int32(gallivm, texture_unit);
if (texture_unit_offset) {
indices[2] = LLVMBuildAdd(gallivm->builder, indices[2],
@ -142,27 +142,27 @@ lp_llvm_texture_member(struct gallivm_state *gallivm,
lp_build_const_int32(gallivm,
texture_unit), "");
}
/* context[0].textures[unit].member */
/* resources[0].textures[unit].member */
indices[3] = lp_build_const_int32(gallivm, member_index);
LLVMValueRef ptr =
LLVMBuildGEP2(builder, context_type, context_ptr, indices, ARRAY_SIZE(indices), "");
LLVMBuildGEP2(builder, resources_type, resources_ptr, indices, ARRAY_SIZE(indices), "");
LLVMValueRef res;
if (emit_load) {
LLVMTypeRef tex_type = LLVMStructGetTypeAtIndex(context_type, LP_JIT_CTX_TEXTURES);
LLVMTypeRef tex_type = LLVMStructGetTypeAtIndex(resources_type, LP_JIT_RES_TEXTURES);
LLVMTypeRef res_type = LLVMStructGetTypeAtIndex(LLVMGetElementType(tex_type), member_index);
res = LLVMBuildLoad2(builder, res_type, ptr, "");
} else
res = ptr;
if (out_type) {
LLVMTypeRef tex_type = LLVMStructGetTypeAtIndex(context_type, LP_JIT_CTX_TEXTURES);
LLVMTypeRef tex_type = LLVMStructGetTypeAtIndex(resources_type, LP_JIT_RES_TEXTURES);
LLVMTypeRef res_type = LLVMStructGetTypeAtIndex(LLVMGetElementType(tex_type), member_index);
*out_type = res_type;
}
lp_build_name(res, "context.texture%u.%s", texture_unit, member_name);
lp_build_name(res, "resources.texture%u.%s", texture_unit, member_name);
return res;
}
@ -180,12 +180,12 @@ lp_llvm_texture_member(struct gallivm_state *gallivm,
#define LP_LLVM_TEXTURE_MEMBER(_name, _index, _emit_load) \
static LLVMValueRef \
lp_llvm_texture_##_name(struct gallivm_state *gallivm, \
LLVMTypeRef context_type, \
LLVMValueRef context_ptr, \
LLVMTypeRef resources_type, \
LLVMValueRef resources_ptr, \
unsigned texture_unit, \
LLVMValueRef texture_unit_offset) \
{ \
return lp_llvm_texture_member(gallivm, context_type, context_ptr, \
return lp_llvm_texture_member(gallivm, resources_type, resources_ptr, \
texture_unit, texture_unit_offset, \
_index, #_name, _emit_load, NULL ); \
}
@ -228,8 +228,8 @@ LP_LLVM_TEXTURE_MEMBER(sample_stride, LP_JIT_TEXTURE_SAMPLE_STRIDE, TRUE)
*/
static LLVMValueRef
lp_llvm_sampler_member(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned sampler_unit,
unsigned member_index,
const char *member_name,
@ -240,27 +240,27 @@ lp_llvm_sampler_member(struct gallivm_state *gallivm,
assert(sampler_unit < PIPE_MAX_SAMPLERS);
/* context[0] */
/* resources[0] */
indices[0] = lp_build_const_int32(gallivm, 0);
/* context[0].samplers */
indices[1] = lp_build_const_int32(gallivm, LP_JIT_CTX_SAMPLERS);
/* context[0].samplers[unit] */
/* resources[0].samplers */
indices[1] = lp_build_const_int32(gallivm, LP_JIT_RES_SAMPLERS);
/* resources[0].samplers[unit] */
indices[2] = lp_build_const_int32(gallivm, sampler_unit);
/* context[0].samplers[unit].member */
/* resources[0].samplers[unit].member */
indices[3] = lp_build_const_int32(gallivm, member_index);
LLVMValueRef ptr =
LLVMBuildGEP2(builder, context_type, context_ptr, indices, ARRAY_SIZE(indices), "");
LLVMBuildGEP2(builder, resources_type, resources_ptr, indices, ARRAY_SIZE(indices), "");
LLVMValueRef res;
if (emit_load) {
LLVMTypeRef samp_type = LLVMStructGetTypeAtIndex(context_type, LP_JIT_CTX_SAMPLERS);
LLVMTypeRef samp_type = LLVMStructGetTypeAtIndex(resources_type, LP_JIT_RES_SAMPLERS);
LLVMTypeRef res_type = LLVMStructGetTypeAtIndex(LLVMGetElementType(samp_type), member_index);
res = LLVMBuildLoad2(builder, res_type, ptr, "");
} else
res = ptr;
lp_build_name(res, "context.sampler%u.%s", sampler_unit, member_name);
lp_build_name(res, "resources.sampler%u.%s", sampler_unit, member_name);
return res;
}
@ -269,11 +269,11 @@ lp_llvm_sampler_member(struct gallivm_state *gallivm,
#define LP_LLVM_SAMPLER_MEMBER(_name, _index, _emit_load) \
static LLVMValueRef \
lp_llvm_sampler_##_name(struct gallivm_state *gallivm, \
LLVMTypeRef context_type, \
LLVMValueRef context_ptr, \
LLVMTypeRef resources_type, \
LLVMValueRef resources_ptr, \
unsigned sampler_unit) \
{ \
return lp_llvm_sampler_member(gallivm, context_type, context_ptr, \
return lp_llvm_sampler_member(gallivm, resources_type, resources_ptr, \
sampler_unit, _index, #_name, _emit_load); \
}
@ -295,8 +295,8 @@ LP_LLVM_SAMPLER_MEMBER(max_aniso, LP_JIT_SAMPLER_MAX_ANISO, TRUE)
*/
static LLVMValueRef
lp_llvm_image_member(struct gallivm_state *gallivm,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef resources_type,
LLVMValueRef resources_ptr,
unsigned image_unit,
LLVMValueRef image_unit_offset,
unsigned member_index,
@ -308,32 +308,32 @@ lp_llvm_image_member(struct gallivm_state *gallivm,
assert(image_unit < PIPE_MAX_SHADER_IMAGES);
/* context[0] */
/* resources[0] */
indices[0] = lp_build_const_int32(gallivm, 0);
/* context[0].images */
indices[1] = lp_build_const_int32(gallivm, LP_JIT_CTX_IMAGES);
/* context[0].images[unit] */
/* resources[0].images */
indices[1] = lp_build_const_int32(gallivm, LP_JIT_RES_IMAGES);
/* resources[0].images[unit] */
indices[2] = lp_build_const_int32(gallivm, image_unit);
if (image_unit_offset) {
indices[2] = LLVMBuildAdd(gallivm->builder, indices[2], image_unit_offset, "");
LLVMValueRef cond = LLVMBuildICmp(gallivm->builder, LLVMIntULT, indices[2], lp_build_const_int32(gallivm, PIPE_MAX_SHADER_IMAGES), "");
indices[2] = LLVMBuildSelect(gallivm->builder, cond, indices[2], lp_build_const_int32(gallivm, image_unit), "");
}
/* context[0].images[unit].member */
/* resources[0].images[unit].member */
indices[3] = lp_build_const_int32(gallivm, member_index);
LLVMValueRef ptr =
LLVMBuildGEP2(builder, context_type, context_ptr, indices, ARRAY_SIZE(indices), "");
LLVMBuildGEP2(builder, resources_type, resources_ptr, indices, ARRAY_SIZE(indices), "");
LLVMValueRef res;
if (emit_load) {
LLVMTypeRef img_type = LLVMStructGetTypeAtIndex(context_type, LP_JIT_CTX_IMAGES);
LLVMTypeRef img_type = LLVMStructGetTypeAtIndex(resources_type, LP_JIT_RES_IMAGES);
LLVMTypeRef res_type = LLVMStructGetTypeAtIndex(LLVMGetElementType(img_type), member_index);
res = LLVMBuildLoad2(builder, res_type, ptr, "");
} else
res = ptr;
lp_build_name(res, "context.image%u.%s", image_unit, member_name);
lp_build_name(res, "resources.image%u.%s", image_unit, member_name);
return res;
}
@ -351,11 +351,11 @@ lp_llvm_image_member(struct gallivm_state *gallivm,
#define LP_LLVM_IMAGE_MEMBER(_name, _index, _emit_load) \
static LLVMValueRef \
lp_llvm_image_##_name(struct gallivm_state *gallivm, \
LLVMTypeRef context_type, \
LLVMValueRef context_ptr, \
LLVMTypeRef resources_type, \
LLVMValueRef resources_ptr, \
unsigned image_unit, LLVMValueRef image_unit_offset) \
{ \
return lp_llvm_image_member(gallivm, context_type, context_ptr, \
return lp_llvm_image_member(gallivm, resources_type, resources_ptr, \
image_unit, image_unit_offset, \
_index, #_name, _emit_load); \
}
@ -363,13 +363,13 @@ lp_llvm_image_member(struct gallivm_state *gallivm,
#define LP_LLVM_IMAGE_MEMBER_OUTTYPE(_name, _index, _emit_load) \
static LLVMValueRef \
lp_llvm_image_##_name(struct gallivm_state *gallivm, \
LLVMTypeRef context_type, \
LLVMValueRef context_ptr, \
LLVMTypeRef resources_type, \
LLVMValueRef resources_ptr, \
unsigned image_unit, LLVMValueRef image_unit_offset, \
LLVMTypeRef *out_type) \
{ \
assert(!out_type); \
return lp_llvm_image_member(gallivm, context_type, context_ptr, \
return lp_llvm_image_member(gallivm, resources_type, resources_ptr, \
image_unit, image_unit_offset, \
_index, #_name, _emit_load); \
}