[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Transform feedback #1943

Draft
wants to merge 60 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
301d384
Advertise the VK_EXT_shader_demote_to_helper_invocation extension.
cdavis5e Oct 29, 2020
d010c61
Work around problems with explicit LoD with arrayed depth images on A…
cdavis5e Feb 3, 2023
0e5e28a
Merged in sample-dref-lod-array-workaround (pull request #5)
cdavis5e Feb 4, 2023
1c5cc7a
add in CMake build capability
gpx1000 May 18, 2023
ac64308
Advertise the VK_EXT_shader_demote_to_helper_invocation extension.
cdavis5e Oct 29, 2020
8aa8bfc
Merged in shader-demote-to-helper (pull request #6)
cdavis5e Jun 6, 2023
11aba7b
Transform Feedback initial implementation.
gpx1000 Jun 7, 2023
c00d168
Merge branch 'transform_feedback'
gpx1000 Jun 7, 2023
8450aa6
not sure how the merge commit didn't make it in.
gpx1000 Jun 7, 2023
56fa3b5
Merge remote-tracking branch 'origin/master'
gpx1000 Jun 14, 2023
dcd5873
Merge branch 'master' into transform_feedback
gpx1000 Jun 14, 2023
07bd3b0
make CMake work for all build types and fix the merge conflicts by up…
gpx1000 Jun 14, 2023
48c2a9c
1.) remove Query path as it is optional. We might add it in at a lat…
gpx1000 Jun 14, 2023
482c19a
put the counter buffers into the current graphics resources state.
gpx1000 Jun 19, 2023
c262cc4
address rest of comments.
gpx1000 Jun 19, 2023
39a9082
move buffers and try to write to them.
gpx1000 Jun 19, 2023
df3cd19
fix building
gpx1000 Jun 19, 2023
2489c0c
Add methods to map transform feedback bindings to Metal bindings.
cdavis5e Jun 19, 2023
f935aff
Working together with Chip
gpx1000 Jun 19, 2023
942b5bf
Working together with Chip
gpx1000 Jun 19, 2023
4cf27c6
update SPIRV-Cross_repo_revision to point at the right PR location.
gpx1000 Jun 19, 2023
bb1ddf6
Merge branch 'transform_feedback' into transform_feedback_public
gpx1000 Jun 19, 2023
8d131f2
Update SPIRV-Cross_repo_revision
gpx1000 Jun 20, 2023
17f5dc5
fix the build after merge conflicts
gpx1000 Jun 20, 2023
a7771ab
Merge remote-tracking branch 'upstream/transform_feedback_public' int…
gpx1000 Jun 20, 2023
2d7cc1f
Merge branch 'main' into transform_feedback_public
gpx1000 Jun 20, 2023
50830de
revert spriv-cross revision number
gpx1000 Jun 20, 2023
af071d3
Merge remote-tracking branch 'upstream/transform_feedback_public' int…
gpx1000 Jun 20, 2023
fc3c263
mystery merge error fix
gpx1000 Jun 20, 2023
6a8858c
Merge branch 'master' into transform_feedback
cdavis5e Jul 11, 2023
b5bcb0f
Add missing handling of `VK_EXT_transform_feedback` nuts and bolts.
cdavis5e Jul 17, 2023
01d6c1c
Remove extraneous `if`-branch.
cdavis5e Jul 17, 2023
244afc6
Merge remote-tracking branch 'origin/main' into transform_feedback
cdavis5e Sep 21, 2023
1bbfd3e
Checkpoint for transform feedback support.
cdavis5e Sep 22, 2023
c4977ad
Merge remote-tracking branch 'steve/transform_feedback_public' into t…
cdavis5e Sep 22, 2023
8c428a6
Really preliminary checkpoint for pass-through vertex shader support.
cdavis5e Oct 4, 2023
7f21588
Ridiculously small checkpoint with very little to show for it.
cdavis5e Oct 9, 2023
d112c8d
Grab outputs from the vertex shader in preparation for generating the…
cdavis5e Oct 11, 2023
2ed6387
Add bare-bones method to emit the pass-through vertex shader.
cdavis5e Oct 18, 2023
250a9a2
Incomplete checkpoint for getting XFB buffer indices and offsets from…
cdavis5e Oct 20, 2023
804fd9f
Add a little bit more reflection data for transform feedback.
cdavis5e Oct 23, 2023
92ea5ca
Add buffer parameters to the passthrough shader.
cdavis5e Oct 23, 2023
1f085a0
Generate the passthrough stage output structure.
cdavis5e Oct 25, 2023
5ccf045
Emit loads and stores in the passthrough vertex shader.
cdavis5e Oct 27, 2023
38c6533
Sort vertex shader outputs.
cdavis5e Oct 31, 2023
9422cbc
Emit the buffer structs.
cdavis5e Nov 2, 2023
3daf3f5
Return the XFB buffer stride.
cdavis5e Nov 3, 2023
d46b781
Emit padding for the buffer stride.
cdavis5e Nov 7, 2023
9976745
Remove redundant helper.
cdavis5e Nov 7, 2023
a4a7ac9
Handle clip/cull distances properly.
cdavis5e Nov 9, 2023
0e6d694
Also emit clip distance array to the rasterizer.
cdavis5e Nov 9, 2023
8fc4f2a
Recurisvely handle structure types in vertex input for XFB.
cdavis5e Nov 13, 2023
7eb2da8
Add the pass-through shader to the raster pipeline.
cdavis5e Nov 16, 2023
c6e3d88
Don't try to create a rasterization pipeline if we're not rasterizing.
cdavis5e Nov 17, 2023
c0581f4
Reserve buffer slots for the transform feedback buffers.
cdavis5e Nov 17, 2023
0fb9f33
Merge remote-tracking branch 'origin' into transform_feedback
cdavis5e Nov 17, 2023
159ee5f
Update some references to tessellation vertex shaders for XFB.
cdavis5e Nov 17, 2023
ba12429
Use the preexisting method on `MVKDevice` to get the XFB binding numb…
cdavis5e Nov 17, 2023
b604f13
Fix broken build.
cdavis5e Nov 18, 2023
be3a4b3
remove CMakeLists.txt from Transform Feedback PR.
gpx1000 Nov 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Also emit clip distance array to the rasterizer.
Fix clip/cull distance attribute for the fragment shader interface.
  • Loading branch information
cdavis5e committed Nov 9, 2023
commit 0e6d694f2f46b6fe84075020c14e80ada021ed5e
36 changes: 29 additions & 7 deletions MoltenVK/MoltenVK/GPUObjects/MVKShaderModule.mm
Original file line number Diff line number Diff line change
Expand Up @@ -476,17 +476,19 @@ static uint32_t getWorkgroupDimensionSize(const SPIRVWorkgroupSizeDimension& wgD
}
}

static std::string mvkBuiltInToAttr(spv::BuiltIn builtin) {
switch (builtin) {
static std::string mvkBuiltInToAttr(const SPIRVShaderOutput& output) {
std::ostringstream os;
switch (output.builtin) {
case spv::BuiltInPosition:
return "position";
case spv::BuiltInPointSize:
return "point_size";
case spv::BuiltInClipDistance:
return "clip_distance";
os << "user(clip" << output.arrayIndex << ")";
return os.str();
case spv::BuiltInCullDistance:
// XXX This doesn't have a Metal equivalent.
return "cull_distance";
os << "user(cull" << output.arrayIndex << ")";
return os.str();
default:
// No other builtins should appear as a vertex shader output.
return "unknown";
Expand All @@ -513,6 +515,7 @@ static uint32_t getWorkgroupDimensionSize(const SPIRVWorkgroupSizeDimension& wgD
SPIRVShaderOutputs vtxOutputs;
std::string errorLog;
std::unordered_map<uint32_t, std::vector<size_t>> xfbBuffers;
uint32_t clipDistances = 0;
getShaderOutputs(getSPIRV(), spv::ExecutionModelVertex, entryName, vtxOutputs, errorLog);
for (size_t i = 0; i < vtxOutputs.size(); ++i) {
xfbBuffers[vtxOutputs[i].xfbBufferIndex].push_back(i);
Expand Down Expand Up @@ -585,12 +588,20 @@ static uint32_t getWorkgroupDimensionSize(const SPIRVWorkgroupSizeDimension& wgD
for (const auto& output : vtxOutputs) {
conversionResult.msl += " " + mvkTypeToMSL(output) + " ";
if (output.builtin != spv::BuiltInMax) {
conversionResult.msl += mvkBuiltInToName(output) + " [[" + mvkBuiltInToAttr(output.builtin) + "]]";
conversionResult.msl += mvkBuiltInToName(output) + " [[" + mvkBuiltInToAttr(output) + "]]";
if (output.builtin == spv::BuiltInClipDistance) {
clipDistances++;
}
} else {
conversionResult.msl += mvkVertexAttrToName(output) + " [[user(" + mvkVertexAttrToUserAttr(output) + "]]";
}
conversionResult.msl += ";\n";
}
if (clipDistances > 0) {
std::ostringstream os;
os << " float gl_ClipDistance [[clip_distance]] [" << clipDistances << "];\n";
conversionResult.msl += os.str();
}
conversionResult.msl += "};\n\n";
conversionResult.msl += "vertex " + entryName + "_passthru " + entryName + "PassThru(";
std::ostringstream os;
Expand Down Expand Up @@ -627,7 +638,18 @@ static uint32_t getWorkgroupDimensionSize(const SPIRVWorkgroupSizeDimension& wgD
} else {
loadStore << mvkVertexAttrToName(output);
}
conversionResult.msl += " " + loadStore.str() + ";";
conversionResult.msl += " " + loadStore.str() + ";\n";
if (output.builtin == spv::BuiltInClipDistance) {
std::ostringstream clipLoadStore;
clipLoadStore << "out.gl_ClipDistance[" << output.arrayIndex << "] = ";
if (output.xfbBufferIndex == -1) {
clipLoadStore << "misc_in[gl_VertexIndex].";
} else {
clipLoadStore << "xfb" << output.xfbBufferIndex << "[gl_VertexIndex].";
}
clipLoadStore << mvkBuiltInToName(output);
conversionResult.msl += " " + clipLoadStore.str() + ";\n";
}
}
conversionResult.msl += " return out;\n"
"}\n";
Expand Down