Metal changes
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
import Common;
|
||||||
|
import MaterialParameter;
|
||||||
|
import VertexData;
|
||||||
|
import StaticMeshVertexData;
|
||||||
|
import Scene;
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
[shader("amplification")]
|
||||||
|
void taskMain(uint threadID: SV_GroupThreadID, uint groupID: SV_GroupID) { DispatchMesh(1, 1, 1, groupID); }
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
[shader("mesh")]
|
||||||
|
void meshMain(in payload uint taskGroupId, out vertices FragmentParameter vertices[MAX_VERTICES],
|
||||||
|
out indices uint3 indices[MAX_PRIMITIVES]) {
|
||||||
|
|
||||||
|
InstanceData inst = pScene.instances[pOffsets.instanceOffset + taskGroupId];
|
||||||
|
MeshData mesh = pScene.meshData[pOffsets.instanceOffset + taskGroupId];
|
||||||
|
MeshletDescription m = pScene.meshletInfos[mesh.meshletRange.offset];
|
||||||
|
SetMeshOutputCounts(m.vertexIndices.size, m.primitiveIndices.size);
|
||||||
|
|
||||||
|
for (uint p = 0; p < m.primitiveIndices.size; p++) {
|
||||||
|
uint baseIndex = m.primitiveIndices.offset + (p * 3);
|
||||||
|
uint local_idx0 = pScene.primitiveIndices[baseIndex + 0];
|
||||||
|
uint local_idx1 = pScene.primitiveIndices[baseIndex + 1];
|
||||||
|
uint local_idx2 = pScene.primitiveIndices[baseIndex + 2];
|
||||||
|
indices[p] = uint3(local_idx0, local_idx1, local_idx2);
|
||||||
|
}
|
||||||
|
for (uint v = 0; v < m.vertexIndices.size; v++) {
|
||||||
|
uint vertexIndex = pScene.vertexIndices[m.vertexIndices.offset + v];
|
||||||
|
VertexAttributes attr = pVertexData.getAttributes(m.indicesOffset + vertexIndex);
|
||||||
|
vertices[v] = attr.getParameter(inst.transformMatrix, inst.inverseTransformMatrix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[shader("pixel")]
|
||||||
|
void pixelMain(in FragmentParameter input, out float4 outColor : SV_Target) {
|
||||||
|
outColor = float4(1.0, 0.0, 0.0, 1.0);
|
||||||
|
}
|
||||||
+10
-5
@@ -21,8 +21,8 @@ static Gfx::OGraphics graphics;
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
std::string gameName = "MeshShadingDemo";
|
std::string gameName = "MeshShadingDemo";
|
||||||
std::filesystem::path outputPath = fmt::format("/home/dynamitos/{0}Game/", gameName);
|
std::filesystem::path outputPath = fmt::format("/Users/dynamitos/{0}Game/", gameName);
|
||||||
std::filesystem::path sourcePath = fmt::format("/home/dynamitos/{0}/", gameName);
|
std::filesystem::path sourcePath = fmt::format("/Users/dynamitos/{0}/", gameName);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
std::string libraryEnding = "dll";
|
std::string libraryEnding = "dll";
|
||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
@@ -45,9 +45,9 @@ int main() {
|
|||||||
AssetImporter::importFont(FontImportArgs{
|
AssetImporter::importFont(FontImportArgs{
|
||||||
.filePath = "./fonts/arial.ttf",
|
.filePath = "./fonts/arial.ttf",
|
||||||
});
|
});
|
||||||
AssetImporter::importEnvironmentMap(EnvironmentImportArgs{
|
// AssetImporter::importEnvironmentMap(EnvironmentImportArgs{
|
||||||
.filePath = sourcePath / "import" / "textures" / "newport_loft.hdr",
|
// .filePath = sourcePath / "import" / "textures" / "newport_loft.hdr",
|
||||||
});
|
// });
|
||||||
// AssetImporter::importTexture(TextureImportArgs{
|
// AssetImporter::importTexture(TextureImportArgs{
|
||||||
// .filePath = sourcePath / "import" / "textures" / "grass_block_side.png",
|
// .filePath = sourcePath / "import" / "textures" / "grass_block_side.png",
|
||||||
// .importPath = "",
|
// .importPath = "",
|
||||||
@@ -56,6 +56,11 @@ int main() {
|
|||||||
// .filePath = sourcePath / "import" / "models" / "main1_sponza" / "sponza.gltf",
|
// .filePath = sourcePath / "import" / "models" / "main1_sponza" / "sponza.gltf",
|
||||||
// .importPath = "sponza",
|
// .importPath = "sponza",
|
||||||
//});
|
//});
|
||||||
|
// AssetImporter::importMesh(MeshImportArgs{
|
||||||
|
// .filePath = sourcePath / "import" / "models" / "rttest.gltf",
|
||||||
|
// .importPath = "rttest",
|
||||||
|
// });
|
||||||
|
|
||||||
AssetImporter::importMesh(MeshImportArgs{
|
AssetImporter::importMesh(MeshImportArgs{
|
||||||
.filePath = sourcePath / "import" / "models" / "cube.fbx",
|
.filePath = sourcePath / "import" / "models" / "cube.fbx",
|
||||||
.importPath = "",
|
.importPath = "",
|
||||||
|
|||||||
@@ -116,13 +116,11 @@ void DescriptorSetHandle::updateBuffer(const std::string& name, uint32 index, Gf
|
|||||||
|
|
||||||
void DescriptorSetHandle::updateBuffer(const std::string& name, uint32 index, Gfx::PUniformBuffer uniformBuffer) {
|
void DescriptorSetHandle::updateBuffer(const std::string& name, uint32 index, Gfx::PUniformBuffer uniformBuffer) {
|
||||||
uint32 flattenedIndex = owner->getLayout()->variableMapping[name].index + index;
|
uint32 flattenedIndex = owner->getLayout()->variableMapping[name].index + index;
|
||||||
PIndexBuffer buffer = uniformBuffer.cast<IndexBuffer>();
|
PUniformBuffer buffer = uniformBuffer.cast<UniformBuffer>();
|
||||||
bufferWrites.add(BufferWriteInfo{
|
uniformWrites.add(UniformWriteInfo{
|
||||||
.index = flattenedIndex,
|
.index = flattenedIndex,
|
||||||
.buffer = buffer->getAlloc(),
|
.content = buffer->getContents(),
|
||||||
.access = owner->getLayout()->variableMapping[name].access,
|
|
||||||
});
|
});
|
||||||
boundResources.add(buffer->getAlloc());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorSetHandle::updateSampler(const std::string& name, uint32 index, Gfx::PSampler samplerState) {
|
void DescriptorSetHandle::updateSampler(const std::string& name, uint32 index, Gfx::PSampler samplerState) {
|
||||||
|
|||||||
Reference in New Issue
Block a user