summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/swr/swr_shader.cpp
diff options
context:
space:
mode:
authorTim Rowley <[email protected]>2017-06-01 13:08:04 -0500
committerTim Rowley <[email protected]>2017-06-16 16:20:16 -0500
commitb10cdb217a1638aa7cbd2c7bbb580d180512f3f3 (patch)
tree09085c173e4956e9c0359d101a90a6eb2d3306bf /src/gallium/drivers/swr/swr_shader.cpp
parent36ac8ba511bc1dd634194ac7a86dc4a527db7a2e (diff)
swr/rast: Rework attribute layout
Move fixed attributes to the top and pack single component SGVs. WIP to support dynamically allocated vertex size. Reviewed-by: Bruce Cherniak <[email protected]>
Diffstat (limited to 'src/gallium/drivers/swr/swr_shader.cpp')
-rw-r--r--src/gallium/drivers/swr/swr_shader.cpp78
1 files changed, 57 insertions, 21 deletions
diff --git a/src/gallium/drivers/swr/swr_shader.cpp b/src/gallium/drivers/swr/swr_shader.cpp
index 44988892691..2a772939e2d 100644
--- a/src/gallium/drivers/swr/swr_shader.cpp
+++ b/src/gallium/drivers/swr/swr_shader.cpp
@@ -404,10 +404,18 @@ BuilderSWR::swr_gs_llvm_emit_vertex(const struct lp_build_tgsi_gs_iface *gs_base
for (uint32_t attrib = 0; attrib < iface->num_outputs; ++attrib) {
uint32_t attribSlot = attrib;
- if (iface->info->output_semantic_name[attrib] == TGSI_SEMANTIC_PSIZE)
- attribSlot = VERTEX_POINT_SIZE_SLOT;
- else if (iface->info->output_semantic_name[attrib] == TGSI_SEMANTIC_LAYER)
- attribSlot = VERTEX_RTAI_SLOT;
+ uint32_t sgvChannel = 0;
+ if (iface->info->output_semantic_name[attrib] == TGSI_SEMANTIC_PSIZE) {
+ attribSlot = VERTEX_SGV_SLOT;
+ sgvChannel = VERTEX_SGV_POINT_SIZE_COMP;
+ } else if (iface->info->output_semantic_name[attrib] == TGSI_SEMANTIC_LAYER) {
+ attribSlot = VERTEX_SGV_SLOT;
+ sgvChannel = VERTEX_SGV_RTAI_COMP;
+ } else if (iface->info->output_semantic_name[attrib] == TGSI_SEMANTIC_POSITION) {
+ attribSlot = VERTEX_POSITION_SLOT;
+ } else {
+ attribSlot = VERTEX_ATTRIB_START_SLOT + attrib - 1;
+ }
#if USE_SIMD16_FRONTEND
Value *vOffsetsAttrib =
@@ -424,13 +432,21 @@ BuilderSWR::swr_gs_llvm_emit_vertex(const struct lp_build_tgsi_gs_iface *gs_base
ADD(vOffsetsAttrib, MUL(vSimdSlot, VIMMED1((uint32_t)sizeof(float))));
for (uint32_t channel = 0; channel < 4; ++channel) {
- Value *vData = LOAD(unwrap(outputs[attrib][channel]));
Value *vPtrs = GEP(pStream, vOffsetsAttrib);
+ Value *vData;
+
+ if (attribSlot == VERTEX_SGV_SLOT)
+ vData = LOAD(unwrap(outputs[attrib][0]));
+ else
+ vData = LOAD(unwrap(outputs[attrib][channel]));
- vPtrs = BITCAST(vPtrs,
- VectorType::get(PointerType::get(mFP32Ty, 0), 8));
+ if (attribSlot != VERTEX_SGV_SLOT ||
+ sgvChannel == channel) {
+ vPtrs = BITCAST(vPtrs,
+ VectorType::get(PointerType::get(mFP32Ty, 0), 8));
- MASKED_SCATTER(vData, vPtrs, 32, vMask1);
+ MASKED_SCATTER(vData, vPtrs, 32, vMask1);
+ }
#if USE_SIMD16_FRONTEND
vOffsetsAttrib =
@@ -597,8 +613,15 @@ BuilderSWR::CompileGS(struct swr_context *ctx, swr_jit_gs_key &key)
ubyte semantic_name = info->input_semantic_name[slot];
ubyte semantic_idx = info->input_semantic_index[slot];
- unsigned vs_slot =
- locate_linkage(semantic_name, semantic_idx, &ctx->vs->info.base) + 1;
+ unsigned vs_slot = locate_linkage(semantic_name, semantic_idx, &ctx->vs->info.base);
+
+ vs_slot += VERTEX_ATTRIB_START_SLOT;
+
+ if (ctx->vs->info.base.output_semantic_name[0] == TGSI_SEMANTIC_POSITION)
+ vs_slot--;
+
+ if (semantic_name == TGSI_SEMANTIC_POSITION)
+ vs_slot = VERTEX_POSITION_SLOT;
STORE(C(vs_slot), vtxAttribMap, {0, slot});
mapConstants.push_back(C(vs_slot));
@@ -789,11 +812,24 @@ BuilderSWR::CompileVS(struct swr_context *ctx, swr_jit_vs_key &key)
if (!outputs[attrib][channel])
continue;
- Value *val = LOAD(unwrap(outputs[attrib][channel]));
+ Value *val;
+ uint32_t outSlot;
+
+ if (swr_vs->info.base.output_semantic_name[attrib] == TGSI_SEMANTIC_PSIZE) {
+ if (channel != VERTEX_SGV_POINT_SIZE_COMP)
+ continue;
+ val = LOAD(unwrap(outputs[attrib][0]));
+ outSlot = VERTEX_SGV_SLOT;
+ } else if (swr_vs->info.base.output_semantic_name[attrib] == TGSI_SEMANTIC_POSITION) {
+ val = LOAD(unwrap(outputs[attrib][channel]));
+ outSlot = VERTEX_POSITION_SLOT;
+ } else {
+ val = LOAD(unwrap(outputs[attrib][channel]));
+ outSlot = VERTEX_ATTRIB_START_SLOT + attrib;
+ if (swr_vs->info.base.output_semantic_name[0] == TGSI_SEMANTIC_POSITION)
+ outSlot--;
+ }
- uint32_t outSlot = attrib;
- if (swr_vs->info.base.output_semantic_name[attrib] == TGSI_SEMANTIC_PSIZE)
- outSlot = VERTEX_POINT_SIZE_SLOT;
WriteVS(val, pVsCtx, vtxOutput, outSlot, channel);
}
}
@@ -804,8 +840,8 @@ BuilderSWR::CompileVS(struct swr_context *ctx, swr_jit_vs_key &key)
unsigned cv = 0;
if (swr_vs->info.base.writes_clipvertex) {
- cv = 1 + locate_linkage(TGSI_SEMANTIC_CLIPVERTEX, 0,
- &swr_vs->info.base);
+ cv = locate_linkage(TGSI_SEMANTIC_CLIPVERTEX, 0,
+ &swr_vs->info.base);
} else {
for (int i = 0; i < PIPE_MAX_SHADER_OUTPUTS; i++) {
if (swr_vs->info.base.output_semantic_name[i] == TGSI_SEMANTIC_POSITION &&
@@ -824,8 +860,8 @@ BuilderSWR::CompileVS(struct swr_context *ctx, swr_jit_vs_key &key)
// clip distance overrides user clip planes
if ((swr_vs->info.base.clipdist_writemask & clip_mask & (1 << val)) ||
((swr_vs->info.base.culldist_writemask << swr_vs->info.base.num_written_clipdistance) & (1 << val))) {
- unsigned cv = 1 + locate_linkage(TGSI_SEMANTIC_CLIPDIST, val < 4 ? 0 : 1,
- &swr_vs->info.base);
+ unsigned cv = locate_linkage(TGSI_SEMANTIC_CLIPDIST, val < 4 ? 0 : 1,
+ &swr_vs->info.base);
if (val < 4) {
LLVMValueRef dist = LLVMBuildLoad(gallivm->builder, outputs[cv][val], "");
WriteVS(unwrap(dist), pVsCtx, vtxOutput, VERTEX_CLIPCULL_DIST_LO_SLOT, val);
@@ -894,7 +930,7 @@ locate_linkage(ubyte name, ubyte index, struct tgsi_shader_info *info)
for (int i = 0; i < PIPE_MAX_SHADER_OUTPUTS; i++) {
if ((info->output_semantic_name[i] == name)
&& (info->output_semantic_index[i] == index)) {
- return i - 1; // position is not part of the linkage
+ return i;
}
}
@@ -1043,7 +1079,7 @@ BuilderSWR::CompileFS(struct swr_context *ctx, swr_jit_fs_key &key)
}
unsigned linkedAttrib =
- locate_linkage(semantic_name, semantic_idx, pPrevShader);
+ locate_linkage(semantic_name, semantic_idx, pPrevShader) - 1;
uint32_t extraAttribs = 0;
if (semantic_name == TGSI_SEMANTIC_PRIMID && !ctx->gs) {
@@ -1079,7 +1115,7 @@ BuilderSWR::CompileFS(struct swr_context *ctx, swr_jit_fs_key &key)
Value *offset = NULL;
if (semantic_name == TGSI_SEMANTIC_COLOR && key.light_twoside) {
bcolorAttrib = locate_linkage(
- TGSI_SEMANTIC_BCOLOR, semantic_idx, pPrevShader);
+ TGSI_SEMANTIC_BCOLOR, semantic_idx, pPrevShader) - 1;
/* Neither front nor back colors were available. Nothing to load. */
if (bcolorAttrib == 0xFFFFFFFF && linkedAttrib == 0xFFFFFFFF)
continue;