Commit 2631fd3b authored by Dave Airlie's avatar Dave Airlie
Browse files

gallivm: rework lp_build_tgsi_soa to take a struct



The parameters were getting messy and I have to add a few more
for compute shaders, so clean it up before proceeding.

Reviewed-by: default avatarRoland Scheidegger <sroland@vmware.com>
parent 9700e454
Pipeline #50794 passed with stages
in 7 minutes
......@@ -637,20 +637,24 @@ generate_vs(struct draw_llvm_variant *variant,
LLVMValueRef num_ssbos_ptr =
draw_jit_context_num_vs_ssbos(variant->gallivm, context_ptr);
struct lp_build_tgsi_params params = {};
params.type = vs_type;
params.mask = bld_mask;
params.consts_ptr = consts_ptr;
params.const_sizes_ptr = num_consts_ptr;
params.system_values = system_values;
params.inputs = inputs;
params.context_ptr = context_ptr;
params.sampler = draw_sampler;
params.info = &llvm->draw->vs.vertex_shader->info;
params.ssbo_ptr = ssbos_ptr;
params.ssbo_sizes_ptr = num_ssbos_ptr;
lp_build_tgsi_soa(variant->gallivm,
tokens,
vs_type,
bld_mask, /*struct lp_build_mask_context *mask*/
consts_ptr,
num_consts_ptr,
system_values,
inputs,
outputs,
context_ptr,
NULL,
draw_sampler,
&llvm->draw->vs.vertex_shader->info,
NULL, ssbos_ptr, num_ssbos_ptr);
&params,
outputs);
{
LLVMValueRef out;
......@@ -2375,20 +2379,24 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
draw_gs_llvm_dump_variant_key(&variant->key);
}
struct lp_build_tgsi_params params = {};
params.type = gs_type;
params.mask = &mask;
params.consts_ptr = consts_ptr;
params.const_sizes_ptr = num_consts_ptr;
params.system_values = &system_values;
params.context_ptr = context_ptr;
params.sampler = sampler;
params.info = &llvm->draw->gs.geometry_shader->info;
params.gs_iface = (const struct lp_build_tgsi_gs_iface *)&gs_iface;
params.ssbo_ptr = ssbos_ptr;
params.ssbo_sizes_ptr = num_ssbos_ptr;
lp_build_tgsi_soa(variant->gallivm,
tokens,
gs_type,
&mask,
consts_ptr,
num_consts_ptr,
&system_values,
NULL,
outputs,
context_ptr,
NULL,
sampler,
&llvm->draw->gs.geometry_shader->info,
(const struct lp_build_tgsi_gs_iface *)&gs_iface, ssbos_ptr, num_ssbos_ptr);
&params,
outputs);
sampler->destroy(sampler);
......
......@@ -216,23 +216,27 @@ lp_build_tgsi_info(const struct tgsi_token *tokens,
struct lp_tgsi_info *info);
struct lp_build_tgsi_params {
struct lp_type type;
struct lp_build_mask_context *mask;
LLVMValueRef consts_ptr;
LLVMValueRef const_sizes_ptr;
const struct lp_bld_tgsi_system_values *system_values;
const LLVMValueRef (*inputs)[4];
LLVMValueRef context_ptr;
LLVMValueRef thread_data_ptr;
const struct lp_build_sampler_soa *sampler;
const struct tgsi_shader_info *info;
const struct lp_build_tgsi_gs_iface *gs_iface;
LLVMValueRef ssbo_ptr;
LLVMValueRef ssbo_sizes_ptr;
};
void
lp_build_tgsi_soa(struct gallivm_state *gallivm,
const struct tgsi_token *tokens,
struct lp_type type,
struct lp_build_mask_context *mask,
LLVMValueRef consts_ptr,
LLVMValueRef const_sizes_ptr,
const struct lp_bld_tgsi_system_values *system_values,
const LLVMValueRef (*inputs)[4],
LLVMValueRef (*outputs)[4],
LLVMValueRef context_ptr,
LLVMValueRef thread_data_ptr,
const struct lp_build_sampler_soa *sampler,
const struct tgsi_shader_info *info,
const struct lp_build_tgsi_gs_iface *gs_iface,
LLVMValueRef ssbo_ptr,
LLVMValueRef ssbo_sizes_ptr);
const struct lp_build_tgsi_params *params,
LLVMValueRef (*outputs)[4]);
void
......
......@@ -4124,23 +4124,11 @@ static void emit_epilogue(struct lp_build_tgsi_context * bld_base)
void
lp_build_tgsi_soa(struct gallivm_state *gallivm,
const struct tgsi_token *tokens,
struct lp_type type,
struct lp_build_mask_context *mask,
LLVMValueRef consts_ptr,
LLVMValueRef const_sizes_ptr,
const struct lp_bld_tgsi_system_values *system_values,
const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS],
LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS],
LLVMValueRef context_ptr,
LLVMValueRef thread_data_ptr,
const struct lp_build_sampler_soa *sampler,
const struct tgsi_shader_info *info,
const struct lp_build_tgsi_gs_iface *gs_iface,
LLVMValueRef ssbo_ptr,
LLVMValueRef ssbo_sizes_ptr)
const struct lp_build_tgsi_params *params,
LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS])
{
struct lp_build_tgsi_soa_context bld;
struct lp_type type = params->type;
struct lp_type res_type;
assert(type.length <= LP_MAX_VECTOR_LENGTH);
......@@ -4173,25 +4161,25 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm,
int64_type.width *= 2;
lp_build_context_init(&bld.bld_base.int64_bld, gallivm, int64_type);
}
bld.mask = mask;
bld.inputs = inputs;
bld.mask = params->mask;
bld.inputs = params->inputs;
bld.outputs = outputs;
bld.consts_ptr = consts_ptr;
bld.const_sizes_ptr = const_sizes_ptr;
bld.ssbo_ptr = ssbo_ptr;
bld.ssbo_sizes_ptr = ssbo_sizes_ptr;
bld.sampler = sampler;
bld.bld_base.info = info;
bld.indirect_files = info->indirect_files;
bld.context_ptr = context_ptr;
bld.thread_data_ptr = thread_data_ptr;
bld.consts_ptr = params->consts_ptr;
bld.const_sizes_ptr = params->const_sizes_ptr;
bld.ssbo_ptr = params->ssbo_ptr;
bld.ssbo_sizes_ptr = params->ssbo_sizes_ptr;
bld.sampler = params->sampler;
bld.bld_base.info = params->info;
bld.indirect_files = params->info->indirect_files;
bld.context_ptr = params->context_ptr;
bld.thread_data_ptr = params->thread_data_ptr;
/*
* If the number of temporaries is rather large then we just
* allocate them as an array right from the start and treat
* like indirect temporaries.
*/
if (info->file_max[TGSI_FILE_TEMPORARY] >= LP_MAX_INLINED_TEMPS) {
if (params->info->file_max[TGSI_FILE_TEMPORARY] >= LP_MAX_INLINED_TEMPS) {
bld.indirect_files |= (1 << TGSI_FILE_TEMPORARY);
}
/*
......@@ -4200,7 +4188,7 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm,
* a dynamically allocated array.
*/
bld.use_immediates_array =
(info->file_max[TGSI_FILE_IMMEDIATE] >= LP_MAX_INLINED_IMMEDIATES);
(params->info->file_max[TGSI_FILE_IMMEDIATE] >= LP_MAX_INLINED_IMMEDIATES);
if (bld.use_immediates_array) {
bld.indirect_files |= (1 << TGSI_FILE_IMMEDIATE);
}
......@@ -4284,7 +4272,7 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm,
bld.bld_base.op_actions[TGSI_OPCODE_ATOMIMIN].emit = atomic_emit;
bld.bld_base.op_actions[TGSI_OPCODE_ATOMIMAX].emit = atomic_emit;
if (gs_iface) {
if (params->gs_iface) {
/* There's no specific value for this because it should always
* be set, but apps using ext_geometry_shader4 quite often
* were forgetting so we're using MAX_VERTEX_VARYING from
......@@ -4294,13 +4282,13 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm,
/* inputs are always indirect with gs */
bld.indirect_files |= (1 << TGSI_FILE_INPUT);
bld.gs_iface = gs_iface;
bld.gs_iface = params->gs_iface;
bld.bld_base.emit_fetch_funcs[TGSI_FILE_INPUT] = emit_fetch_gs_input;
bld.bld_base.op_actions[TGSI_OPCODE_EMIT].emit = emit_vertex;
bld.bld_base.op_actions[TGSI_OPCODE_ENDPRIM].emit = end_primitive;
max_output_vertices =
info->properties[TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES];
params->info->properties[TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES];
if (!max_output_vertices)
max_output_vertices = 32;
......@@ -4311,7 +4299,7 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm,
lp_exec_mask_init(&bld.exec_mask, &bld.bld_base.int_bld);
bld.system_values = *system_values;
bld.system_values = *params->system_values;
lp_build_tgsi_llvm(&bld.bld_base, tokens);
......
......@@ -478,12 +478,24 @@ generate_fs_loop(struct gallivm_state *gallivm,
lp_build_interp_soa_update_inputs_dyn(interp, gallivm, loop_state.counter);
struct lp_build_tgsi_params params = {};
params.type = type;
params.mask = &mask;
params.consts_ptr = consts_ptr;
params.const_sizes_ptr = num_consts_ptr;
params.system_values = &system_values;
params.inputs = interp->inputs;
params.context_ptr = context_ptr;
params.thread_data_ptr = thread_data_ptr;
params.sampler = sampler;
params.info = &shader->info.base;
params.ssbo_ptr = ssbo_ptr;
params.ssbo_sizes_ptr = num_ssbo_ptr;
/* Build the actual shader */
lp_build_tgsi_soa(gallivm, tokens, type, &mask,
consts_ptr, num_consts_ptr, &system_values,
interp->inputs,
outputs, context_ptr, thread_data_ptr,
sampler, &shader->info.base, NULL, ssbo_ptr, num_ssbo_ptr);
lp_build_tgsi_soa(gallivm, tokens, &params,
outputs);
/* Alpha test */
if (key->alpha.enabled) {
......
......@@ -681,21 +681,22 @@ BuilderSWR::CompileGS(struct swr_context *ctx, swr_jit_gs_key &key)
gs_iface.info = info;
gs_iface.pVtxAttribMap = vtxAttribMap;
struct lp_build_tgsi_params params = {};
params.type = lp_type_float_vec(32, 32 * 8);
params.mask = & mask;
params.consts_ptr = wrap(consts_ptr);
params.const_sizes_ptr = wrap(const_sizes_ptr);
params.system_values = &system_values;
params.inputs = inputs;
params.context_ptr = wrap(hPrivateData);
params.sampler = sampler;
params.info = &gs->info.base;
params.gs_iface = &gs_iface.base;
lp_build_tgsi_soa(gallivm,
gs->pipe.tokens,
lp_type_float_vec(32, 32 * 8),
&mask,
wrap(consts_ptr),
wrap(const_sizes_ptr),
&system_values,
inputs,
outputs,
wrap(hPrivateData), // (sampler context)
NULL, // thread data
sampler,
&gs->info.base,
&gs_iface.base,
NULL, NULL); // ssbos
&params,
outputs);
lp_build_mask_end(&mask);
......@@ -833,21 +834,20 @@ BuilderSWR::CompileVS(struct swr_context *ctx, swr_jit_vs_key &key)
uint32_t vectorWidth = mVWidth;
#endif
struct lp_build_tgsi_params params = {};
params.type = lp_type_float_vec(32, 32 * vectorWidth);
params.consts_ptr = wrap(consts_ptr);
params.const_sizes_ptr = wrap(const_sizes_ptr);
params.system_values = &system_values;
params.inputs = inputs;
params.context_ptr = wrap(hPrivateData);
params.sampler = sampler;
params.info = &swr_vs->info.base;
lp_build_tgsi_soa(gallivm,
swr_vs->pipe.tokens,
lp_type_float_vec(32, 32 * vectorWidth),
NULL, // mask
wrap(consts_ptr),
wrap(const_sizes_ptr),
&system_values,
inputs,
outputs,
wrap(hPrivateData), // (sampler context)
NULL, // thread data
sampler, // sampler
&swr_vs->info.base,
NULL, // geometry shader face
NULL, NULL); // ssbos
&params,
outputs);
sampler->destroy(sampler);
......@@ -1324,21 +1324,21 @@ BuilderSWR::CompileFS(struct swr_context *ctx, swr_jit_fs_key &key)
uses_mask = true;
}
struct lp_build_tgsi_params params = {};
params.type = lp_type_float_vec(32, 32 * 8);
params.mask = uses_mask ? &mask : NULL;
params.consts_ptr = wrap(consts_ptr);
params.const_sizes_ptr = wrap(const_sizes_ptr);
params.system_values = &system_values;
params.inputs = inputs;
params.context_ptr = wrap(hPrivateData);
params.sampler = sampler;
params.info = &swr_fs->info.base;
lp_build_tgsi_soa(gallivm,
swr_fs->pipe.tokens,
lp_type_float_vec(32, 32 * 8),
uses_mask ? &mask : NULL, // mask
wrap(consts_ptr),
wrap(const_sizes_ptr),
&system_values,
inputs,
outputs,
wrap(hPrivateData),
NULL, // thread data
sampler, // sampler
&swr_fs->info.base,
NULL, // geometry shader face
NULL, NULL); //ssbos
&params,
outputs);
sampler->destroy(sampler);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment