#include "tgsi/tgsi_scan.h"
#include "tgsi/tgsi_info.h"
-#define LP_CHAN_ALL ~0
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define LP_CHAN_ALL ~0u
#define LP_MAX_INSTRUCTIONS 256
*/
unsigned indirect_textures:1;
+ /*
+ * Whether any of the texture (sample) ocpodes use different sampler
+ * and sampler view unit.
+ */
+ unsigned sampler_texture_units_different:1;
+
/*
* Whether any immediate values are outside the range of 0 and 1
*/
struct lp_bld_tgsi_system_values {
LLVMValueRef instance_id;
LLVMValueRef vertex_id;
+ LLVMValueRef vertex_id_nobase;
LLVMValueRef prim_id;
+ LLVMValueRef basevertex;
+ LLVMValueRef invocation_id;
};
(*destroy)( struct lp_build_sampler_soa *sampler );
void
- (*emit_fetch_texel)( const struct lp_build_sampler_soa *sampler,
- struct gallivm_state *gallivm,
- struct lp_type type,
- boolean is_fetch,
- unsigned texture_index,
- unsigned sampler_index,
- const LLVMValueRef *coords,
- const LLVMValueRef *offsets,
- const struct lp_derivatives *derivs,
- LLVMValueRef lod_bias, /* optional */
- LLVMValueRef explicit_lod, /* optional */
- enum lp_sampler_lod_property,
- LLVMValueRef *texel);
+ (*emit_tex_sample)(const struct lp_build_sampler_soa *sampler,
+ struct gallivm_state *gallivm,
+ const struct lp_sampler_params *params);
void
(*emit_size_query)( const struct lp_build_sampler_soa *sampler,
struct gallivm_state *gallivm,
- struct lp_type type,
- unsigned unit,
- unsigned target,
- boolean need_nr_mips,
- enum lp_sampler_lod_property,
- LLVMValueRef explicit_lod, /* optional */
- LLVMValueRef *sizes_out);
+ const struct lp_sampler_size_query_params *params);
};
struct lp_build_sampler_aos
{
LLVMValueRef
- (*emit_fetch_texel)( struct lp_build_sampler_aos *sampler,
+ (*emit_fetch_texel)( const struct lp_build_sampler_aos *sampler,
struct lp_build_context *bld,
unsigned target, /* TGSI_TEXTURE_* */
unsigned unit,
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],
- struct lp_build_sampler_soa *sampler,
+ 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);
+ const struct lp_build_tgsi_gs_iface *gs_iface,
+ LLVMValueRef ssbo_ptr,
+ LLVMValueRef ssbo_sizes_ptr);
void
LLVMValueRef consts_ptr,
const LLVMValueRef *inputs,
LLVMValueRef *outputs,
- struct lp_build_sampler_aos *sampler,
+ const struct lp_build_sampler_aos *sampler,
const struct tgsi_shader_info *info);
LLVMTypeRef int_vec_type;
- LLVMValueRef cond_stack[LP_MAX_TGSI_NESTING];
- int cond_stack_size;
- LLVMValueRef cond_mask;
-
- /* keep track if break belongs to switch or loop */
- enum lp_exec_mask_break_type break_type_stack[LP_MAX_TGSI_NESTING];
- enum lp_exec_mask_break_type break_type;
+ LLVMValueRef exec_mask;
- struct {
- LLVMValueRef switch_val;
- LLVMValueRef switch_mask;
- LLVMValueRef switch_mask_default;
- boolean switch_in_default;
- unsigned switch_pc;
- } switch_stack[LP_MAX_TGSI_NESTING];
- int switch_stack_size;
- LLVMValueRef switch_val;
+ LLVMValueRef ret_mask;
+ LLVMValueRef cond_mask;
LLVMValueRef switch_mask; /* current switch exec mask */
- LLVMValueRef switch_mask_default; /* reverse of switch mask used for default */
- boolean switch_in_default; /* if switch exec is currently in default */
- unsigned switch_pc; /* when used points to default or endswitch-1 */
-
- LLVMBasicBlockRef loop_block;
LLVMValueRef cont_mask;
LLVMValueRef break_mask;
- LLVMValueRef break_var;
- struct {
- LLVMBasicBlockRef loop_block;
- LLVMValueRef cont_mask;
- LLVMValueRef break_mask;
- LLVMValueRef break_var;
- } loop_stack[LP_MAX_TGSI_NESTING];
- int loop_stack_size;
- LLVMValueRef ret_mask;
- struct {
+ struct function_ctx {
int pc;
LLVMValueRef ret_mask;
- } call_stack[LP_MAX_TGSI_NESTING];
- int call_stack_size;
- LLVMValueRef exec_mask;
- LLVMValueRef loop_limiter;
+ LLVMValueRef cond_stack[LP_MAX_TGSI_NESTING];
+ int cond_stack_size;
+
+ /* keep track if break belongs to switch or loop */
+ enum lp_exec_mask_break_type break_type_stack[LP_MAX_TGSI_NESTING];
+ enum lp_exec_mask_break_type break_type;
+
+ struct {
+ LLVMValueRef switch_val;
+ LLVMValueRef switch_mask;
+ LLVMValueRef switch_mask_default;
+ boolean switch_in_default;
+ unsigned switch_pc;
+ } switch_stack[LP_MAX_TGSI_NESTING];
+ int switch_stack_size;
+ LLVMValueRef switch_val;
+ LLVMValueRef switch_mask_default; /* reverse of switch mask used for default */
+ boolean switch_in_default; /* if switch exec is currently in default */
+ unsigned switch_pc; /* when used points to default or endswitch-1 */
+
+ LLVMValueRef loop_limiter;
+ LLVMBasicBlockRef loop_block;
+ LLVMValueRef break_var;
+ struct {
+ LLVMBasicBlockRef loop_block;
+ LLVMValueRef cont_mask;
+ LLVMValueRef break_mask;
+ LLVMValueRef break_var;
+ } loop_stack[LP_MAX_TGSI_NESTING];
+ int loop_stack_size;
+
+ } *function_stack;
+ int function_stack_size;
};
struct lp_build_tgsi_inst_list
unsigned lp_bld_tgsi_add_instruction(
struct lp_build_tgsi_context * bld_base,
- struct tgsi_full_instruction *inst_to_add);
+ const struct tgsi_full_instruction *inst_to_add);
struct lp_build_tgsi_context;
struct lp_build_context uint_bld;
struct lp_build_context int_bld;
+ struct lp_build_context dbl_bld;
+
+ struct lp_build_context uint64_bld;
+ struct lp_build_context int64_bld;
+
/** This array stores functions that are used to transform TGSI opcodes to
* LLVM instructions.
*/
struct lp_build_tgsi_action sqrt_action;
+ struct lp_build_tgsi_action drsq_action;
+
+ struct lp_build_tgsi_action dsqrt_action;
const struct tgsi_shader_info *info;
lp_build_emit_fetch_fn emit_fetch_funcs[TGSI_FILE_COUNT];
LLVMValueRef (*emit_swizzle)(struct lp_build_tgsi_context *,
LLVMValueRef, unsigned, unsigned, unsigned, unsigned);
+
+ void (*emit_debug)(struct lp_build_tgsi_context *,
+ const struct tgsi_full_instruction *,
+ const struct tgsi_opcode_info *);
+
void (*emit_store)(struct lp_build_tgsi_context *,
const struct tgsi_full_instruction *,
const struct tgsi_opcode_info *,
+ unsigned index,
LLVMValueRef dst[4]);
void (*emit_declaration)(struct lp_build_tgsi_context *,
LLVMValueRef max_output_vertices_vec;
LLVMValueRef consts_ptr;
+ LLVMValueRef const_sizes_ptr;
+ LLVMValueRef consts[LP_MAX_TGSI_CONST_BUFFERS];
+ LLVMValueRef consts_sizes[LP_MAX_TGSI_CONST_BUFFERS];
const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS];
LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS];
+ LLVMValueRef context_ptr;
+ LLVMValueRef thread_data_ptr;
+
+ LLVMValueRef ssbo_ptr;
+ LLVMValueRef ssbo_sizes_ptr;
+ LLVMValueRef ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
+ LLVMValueRef ssbo_sizes[LP_MAX_TGSI_SHADER_BUFFERS];
const struct lp_build_sampler_soa *sampler;
struct tgsi_declaration_sampler_view sv[PIPE_MAX_SHADER_SAMPLER_VIEWS];
- LLVMValueRef immediates[LP_MAX_TGSI_IMMEDIATES][TGSI_NUM_CHANNELS];
- LLVMValueRef temps[LP_MAX_TGSI_TEMPS][TGSI_NUM_CHANNELS];
+ LLVMValueRef immediates[LP_MAX_INLINED_IMMEDIATES][TGSI_NUM_CHANNELS];
+ LLVMValueRef temps[LP_MAX_INLINED_TEMPS][TGSI_NUM_CHANNELS];
LLVMValueRef addr[LP_MAX_TGSI_ADDRS][TGSI_NUM_CHANNELS];
- LLVMValueRef preds[LP_MAX_TGSI_PREDS][TGSI_NUM_CHANNELS];
/* We allocate/use this array of temps if (1 << TGSI_FILE_TEMPORARY) is
* set in the indirect_files field.
struct lp_exec_mask exec_mask;
uint num_immediates;
-
+ boolean use_immediates_array;
};
void
const LLVMValueRef *inputs;
LLVMValueRef *outputs;
- struct lp_build_sampler_aos *sampler;
+ const struct lp_build_sampler_aos *sampler;
- LLVMValueRef immediates[LP_MAX_TGSI_IMMEDIATES];
- LLVMValueRef temps[LP_MAX_TGSI_TEMPS];
+ struct tgsi_declaration_sampler_view sv[PIPE_MAX_SHADER_SAMPLER_VIEWS];
+
+ LLVMValueRef immediates[LP_MAX_INLINED_IMMEDIATES];
+ LLVMValueRef temps[LP_MAX_INLINED_TEMPS];
LLVMValueRef addr[LP_MAX_TGSI_ADDRS];
- LLVMValueRef preds[LP_MAX_TGSI_PREDS];
/* We allocate/use this array of temps if (1 << TGSI_FILE_TEMPORARY) is
* set in the indirect_files field.
};
-static INLINE struct lp_build_tgsi_soa_context *
+static inline struct lp_build_tgsi_soa_context *
lp_soa_context(struct lp_build_tgsi_context *bld_base)
{
return (struct lp_build_tgsi_soa_context *)bld_base;
}
-static INLINE struct lp_build_tgsi_aos_context *
+static inline struct lp_build_tgsi_aos_context *
lp_aos_context(struct lp_build_tgsi_context *bld_base)
{
return (struct lp_build_tgsi_aos_context *)bld_base;
struct lp_build_tgsi_context * bld_base,
const struct tgsi_full_instruction *inst);
+LLVMValueRef
+lp_build_emit_fetch_src(
+ struct lp_build_tgsi_context *bld_base,
+ const struct tgsi_full_src_register *reg,
+ enum tgsi_opcode_type stype,
+ const unsigned chan_index);
+
LLVMValueRef
lp_build_emit_fetch(
struct lp_build_tgsi_context *bld_base,
struct lp_build_tgsi_context * bld_base,
const struct tgsi_token *tokens);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* LP_BLD_TGSI_H */