Skip to content

Commit 0e7e05f

Browse files
committed
Fix the corruption in The Talos Principle2.
1 parent 8252cfa commit 0e7e05f

File tree

8 files changed

+178
-402
lines changed

8 files changed

+178
-402
lines changed

lgc/builder/InOutBuilder.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -513,31 +513,6 @@ void BuilderImpl::markGenericInputOutputUsage(bool isOutput, unsigned location,
513513
// Mark usage for interpolation info.
514514
markInterpolationInfo(inOutInfo);
515515
}
516-
517-
if (isOutput && m_shaderStage == ShaderStage::Mesh) {
518-
// Record number of components for mesh shader outputs
519-
for (unsigned i = 0; i < locationCount; ++i) {
520-
unsigned numComponents = 0;
521-
if (inOutInfo.getNumComponents() > 4) {
522-
assert(locationCount % 2 == 0); // Must have even number of locations for 64-bit data type
523-
assert(inOutInfo.getComponent() == 0); // Start component must be 0 in this case
524-
// NOTE: For 64-bit vec3/vec4 data types, they will occupy two consecutive locations, we only record the number
525-
// of components to the former one and skip the latter one.
526-
if (i % 2 != 0)
527-
continue;
528-
numComponents = inOutInfo.getNumComponents();
529-
} else {
530-
numComponents = inOutInfo.getComponent() + inOutInfo.getNumComponents();
531-
}
532-
533-
if (inOutInfo.isPerPrimitive())
534-
resUsage->inOutUsage.mesh.primitiveOutputComponents[location + i] = {numComponents,
535-
static_cast<BuiltInKind>(InvalidValue)};
536-
else
537-
resUsage->inOutUsage.mesh.vertexOutputComponents[location + i] = {numComponents,
538-
static_cast<BuiltInKind>(InvalidValue)};
539-
}
540-
}
541516
}
542517

543518
// =====================================================================================================================

lgc/include/lgc/state/ResourceUsage.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,9 @@ struct ResourceUsage {
462462
std::map<BuiltInKind, unsigned> vertexBuiltInExportSlots;
463463
std::map<BuiltInKind, unsigned> primitiveBuiltInExportSlots;
464464

465-
// Map from output locations to their number of components: <location, <numComponents, forBuiltIn>> (including
466-
// those special outputs to which built-ins are mapped)
467-
std::map<unsigned, std::pair<unsigned, BuiltInKind>> vertexOutputComponents;
468-
std::map<unsigned, std::pair<unsigned, BuiltInKind>> primitiveOutputComponents;
465+
// Export count for generic outputs (excluding those special outputs to which the built-ins are mapped)
466+
unsigned vertexGenericOutputExportCount = 0;
467+
unsigned primitiveGenericOutputExportCount = 0;
469468
} mesh;
470469

471470
struct {

lgc/interface/lgc/LgcDialect.td

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -254,19 +254,30 @@ def GetMeshBuiltinInputOp : LgcOp<"get.mesh.builtin.input", [Memory<[]>, WillRet
254254
}];
255255
}
256256

257-
def WriteMeshOutputOp : LgcOp<"write.mesh.output", [Memory<[]>]> {
258-
let arguments = (ins AttrI1:$is_primitive, AttrI32:$location, I32:$location_offset, I32:$component_index, I32:$prim_or_vertex_index, value:$output_value);
257+
def WriteMeshVertexOutputOp : LgcOp<"write.mesh.vertex.output", [Memory<[]>]> {
258+
let arguments = (ins I32:$output_offset, I32:$vertex_index, value:$output_value);
259259
let results = (outs);
260260

261-
let summary = "Write mesh shader primitive/vertex outputs";
261+
let summary = "Write mesh shader vertex outputs";
262262
let description = [{
263-
In the mesh shader, write mesh shader primitive/vertex outputs to LDS.
263+
In the mesh shader, write mesh shader vertex outputs to LDS.
264264

265-
`is_primitive` indicates if this write is for a primitive output or for a vertex output.
266-
`location` is the start location of this output.
267-
`location_offset` is the relative location offset of this output, used by arrayed outputs.
268-
`component_index` is the component index of this output when component addressing is involved.
269-
`prim_or_vertex_index` is the primitive/vertex index specifying which primitive/vertex to write.
265+
`output_offset` is the relative offset of this output (in dwords) within all outputs of the indexed vertex.
266+
`vertex_index` is the vertex index specifying which vertex to write.
267+
`output_value` is the output value to write.
268+
}];
269+
}
270+
271+
def WriteMeshPrimitiveOutputOp : LgcOp<"write.mesh.primitive.output", [Memory<[]>]> {
272+
let arguments = (ins I32:$output_offset, I32:$primitive_index, value:$output_value);
273+
let results = (outs);
274+
275+
let summary = "Write mesh shader primitive outputs";
276+
let description = [{
277+
In the mesh shader, write mesh shader primitive outputs to LDS.
278+
279+
`output_offset` is the relative offset of this output (in dwords) within all outputs of the indexed primitive.
280+
`primitive_index` is the primitive index specifying which primitive to write.
270281
`output_value` is the output value to write.
271282
}];
272283
}

0 commit comments

Comments
 (0)