NULL /*struct lp_build_mask_context *mask*/,
consts_ptr,
system_values,
- NULL /*pos*/,
inputs,
outputs,
sampler,
int i;
struct gallivm_state *gallivm = variant->gallivm;
struct lp_type f32_type = vs_type;
+ const unsigned pos = draw_current_shader_position_output(variant->llvm->draw);
LLVMTypeRef vs_type_llvm = lp_build_vec_type(gallivm, vs_type);
- LLVMValueRef out3 = LLVMBuildLoad(builder, outputs[0][3], ""); /*w0 w1 .. wn*/
+ LLVMValueRef out3 = LLVMBuildLoad(builder, outputs[pos][3], ""); /*w0 w1 .. wn*/
LLVMValueRef const1 = lp_build_const_vec(gallivm, f32_type, 1.0); /*1.0 1.0 1.0 1.0*/
LLVMValueRef vp_ptr = draw_jit_context_viewport(gallivm, context_ptr);
/* for 1/w convention*/
out3 = LLVMBuildFDiv(builder, const1, out3, "");
- LLVMBuildStore(builder, out3, outputs[0][3]);
+ LLVMBuildStore(builder, out3, outputs[pos][3]);
/* Viewport Mapping */
for (i=0; i<3; i++) {
- LLVMValueRef out = LLVMBuildLoad(builder, outputs[0][i], ""); /*x0 x1 .. xn*/
+ LLVMValueRef out = LLVMBuildLoad(builder, outputs[pos][i], ""); /*x0 x1 .. xn*/
LLVMValueRef scale;
LLVMValueRef trans;
LLVMValueRef scale_i;
out = LLVMBuildFAdd(builder, out, trans, "");
/* store transformed outputs */
- LLVMBuildStore(builder, out, outputs[0][i]);
+ LLVMBuildStore(builder, out, outputs[pos][i]);
}
}
static LLVMValueRef
draw_gs_llvm_fetch_input(const struct lp_build_tgsi_gs_iface *gs_iface,
struct lp_build_tgsi_context * bld_base,
+ boolean is_indirect,
LLVMValueRef vertex_index,
LLVMValueRef attrib_index,
LLVMValueRef swizzle_index)
LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef indices[3];
LLVMValueRef res;
+ struct lp_type type = bld_base->base.type;
+
+ if (is_indirect) {
+ int i;
+ res = bld_base->base.zero;
+ for (i = 0; i < type.length; ++i) {
+ LLVMValueRef idx = lp_build_const_int32(gallivm, i);
+ LLVMValueRef vert_chan_index = LLVMBuildExtractElement(builder,
+ vertex_index, idx, "");
+ LLVMValueRef channel_vec, value;
+ indices[0] = vert_chan_index;
+ indices[1] = attrib_index;
+ indices[2] = swizzle_index;
+
+ channel_vec = LLVMBuildGEP(builder, gs->input, indices, 3, "");
+ channel_vec = LLVMBuildLoad(builder, channel_vec, "");
+ value = LLVMBuildExtractElement(builder, channel_vec, idx, "");
+
+ res = LLVMBuildInsertElement(builder, res, value, idx, "");
+ }
+ } else {
+ indices[0] = vertex_index;
+ indices[1] = attrib_index;
+ indices[2] = swizzle_index;
- indices[0] = vertex_index;
- indices[1] = attrib_index;
- indices[2] = swizzle_index;
-
- res = LLVMBuildGEP(builder, gs->input, indices, 3, "");
- res = LLVMBuildLoad(builder, res, "");
+ res = LLVMBuildGEP(builder, gs->input, indices, 3, "");
+ res = LLVMBuildLoad(builder, res, "");
+ }
return res;
}
LLVMValueRef clipmask = lp_build_const_int_vec(gallivm,
lp_int_type(gs_type), 0);
LLVMValueRef indices[LP_MAX_VECTOR_LENGTH];
- LLVMValueRef max_output_vertices =
- lp_build_const_int32(gallivm, variant->shader->base.max_output_vertices);
+ LLVMValueRef next_prim_offset =
+ lp_build_const_int32(gallivm, variant->shader->base.primitive_boundary);
LLVMValueRef io = variant->io_ptr;
unsigned i;
const struct tgsi_shader_info *gs_info = &variant->shader->base.info;
LLVMValueRef ind = lp_build_const_int32(gallivm, i);
LLVMValueRef currently_emitted =
LLVMBuildExtractElement(builder, emitted_vertices_vec, ind, "");
- indices[i] = LLVMBuildMul(builder, ind, max_output_vertices, "");
+ indices[i] = LLVMBuildMul(builder, ind, next_prim_offset, "");
indices[i] = LLVMBuildAdd(builder, indices[i], currently_emitted, "");
}
struct lp_build_sampler_soa *sampler = 0;
LLVMValueRef ret, clipmask_bool_ptr;
const struct draw_geometry_shader *gs = draw->gs.geometry_shader;
+ struct draw_llvm_variant_key *key = &variant->key;
/* If geometry shader is present we need to skip both the viewport
* transformation and clipping otherwise the inputs to the geometry
* shader will be incorrect.
*/
- const boolean bypass_viewport = gs || variant->key.bypass_viewport;
- const boolean enable_cliptest = !gs && (variant->key.clip_xy ||
- variant->key.clip_z ||
- variant->key.clip_user);
+ const boolean bypass_viewport = gs || key->bypass_viewport;
+ const boolean enable_cliptest = !gs && (key->clip_xy ||
+ key->clip_z ||
+ key->clip_user);
LLVMValueRef variant_func;
const unsigned pos = draw_current_shader_position_output(llvm->draw);
const unsigned cv = draw_current_shader_clipvertex_output(llvm->draw);
/* code generated texture sampling */
sampler = draw_llvm_sampler_soa_create(
- draw_llvm_variant_key_samplers(&variant->key),
+ draw_llvm_variant_key_samplers(key),
context_ptr);
if (elts) {
&system_values,
context_ptr,
sampler,
- variant->key.clamp_vertex_color);
+ key->clamp_vertex_color);
if (pos != -1 && cv != -1) {
/* store original positions in clip before further manipulation */
gallivm,
vs_type,
outputs,
- variant->key.clip_xy,
- variant->key.clip_z,
- variant->key.clip_user,
- variant->key.clip_halfz,
- variant->key.ucp_enable,
+ key->clip_xy,
+ key->clip_z,
+ key->clip_user,
+ key->clip_halfz,
+ key->ucp_enable,
context_ptr, &have_clipdist);
temp = LLVMBuildOr(builder, clipmask, temp, "");
/* store temporary clipping boolean value */
key->clip_z = llvm->draw->clip_z;
key->clip_user = llvm->draw->clip_user;
key->bypass_viewport = llvm->draw->identity_viewport;
- key->clip_halfz = !llvm->draw->rasterizer->gl_rasterization_rules;
+ key->clip_halfz = llvm->draw->rasterizer->clip_halfz;
key->need_edgeflags = (llvm->draw->vs.edgeflag_output ? TRUE : FALSE);
key->ucp_enable = llvm->draw->rasterizer->clip_plane_enable;
key->has_gs = llvm->draw->gs.geometry_shader != NULL;
&mask,
consts_ptr,
&system_values,
- NULL /*pos*/,
NULL,
outputs,
sampler,