Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion include/API/Enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ enum class StoreAction {
DontCare, ///< Contents may be discarded after the pass.
};

enum class PrimitiveTopology { TriangleList, PointList, PatchList };
enum class PrimitiveTopology { TriangleList, PointList, PatchList, LineList };

} // namespace offloadtest

Expand Down
1 change: 1 addition & 0 deletions include/Support/Pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,7 @@ template <> struct ScalarEnumerationTraits<offloadtest::PrimitiveTopology> {
ENUM_CASE(TriangleList);
ENUM_CASE(PointList);
ENUM_CASE(PatchList);
ENUM_CASE(LineList);
#undef ENUM_CASE
}
};
Expand Down
4 changes: 4 additions & 0 deletions lib/API/DX/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ getDXPrimitiveTopologyType(PrimitiveTopology Topology) {
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT;
case PrimitiveTopology::PatchList:
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_PATCH;
case PrimitiveTopology::LineList:
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE;
}
llvm_unreachable("All PrimitiveTopology cases handled");
}
Expand All @@ -131,6 +133,8 @@ getDXPrimitiveTopology(PrimitiveTopology Topology,
return static_cast<D3D_PRIMITIVE_TOPOLOGY>(
D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST +
(*PatchControlPoints - 1));
case PrimitiveTopology::LineList:
return D3D_PRIMITIVE_TOPOLOGY_LINELIST;
}
llvm_unreachable("All PrimitiveTopology cases handled");
}
Expand Down
2 changes: 2 additions & 0 deletions lib/API/VK/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ static VkPrimitiveTopology getVkPrimitiveTopology(PrimitiveTopology Topology) {
return VK_PRIMITIVE_TOPOLOGY_POINT_LIST;
case PrimitiveTopology::PatchList:
return VK_PRIMITIVE_TOPOLOGY_PATCH_LIST;
case PrimitiveTopology::LineList:
return VK_PRIMITIVE_TOPOLOGY_LINE_LIST;
}
llvm_unreachable("All PrimitiveTopology cases handled");
}
Expand Down
83 changes: 83 additions & 0 deletions test/Graphics/MeshShaders/SimpleLines.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#--- mesh.hlsl
struct PSInput
{
float4 position : SV_POSITION;
float4 color : COLOR;
};

float3 hueToRgb(in float hue) {
return saturate(float3(
abs(hue * 6.0 - 3.0) - 1.0,
2.0 - abs(hue * 6.0 - 2.0),
2.0 - abs(hue * 6.0 - 4.0)
));
}

[outputtopology("line")]
[numthreads(32, 1, 1)]
void main(uint groupThreadID: SV_GroupThreadID, out vertices PSInput verts[32], out indices uint2 lines[32]) {
SetMeshOutputCounts(32, 32);

const float radius = 0.5;
const float angle = float(groupThreadID) / 32.0f;
const float tau = 2.0 * 3.14159265359;
const float x = cos(angle * tau) * radius;
const float y = sin(angle * tau) * radius;

const float3 color = hueToRgb(angle);

verts[groupThreadID].position = float4(x, y, 0.0, 1.0);
verts[groupThreadID].color = float4(color, 1.0);

lines[groupThreadID] = uint2(groupThreadID, (groupThreadID + 1) % 32);
}

#--- pixel.hlsl
struct PSInput
{
float4 position : SV_POSITION;
float4 color : COLOR;
};

float4 main(PSInput input) : SV_TARGET
{
return saturate(input.color);
}
#--- pipeline.yaml
---
Shaders:
- Stage: Mesh
Entry: main
- Stage: Pixel
Entry: main
Buffers:
- Name: Output
Format: Float32
Channels: 4
FillSize: 1048576 # 256x256 @ 16 bytes per pixel
OutputProps:
Height: 256
Width: 256
Depth: 1
Bindings:
Topology: LineList # Only care about the line part
RenderTarget: Output
DescriptorSets: []
...
#--- rules.yaml
---
- Type: PixelPercent
Val: 0.2 # No more than 0.2% of pixels may be visibly different.
...
#--- end

REQUIRES: MeshShader

# Unimplemented https://github.com/llvm/llvm-project/issues/136966
# XFAIL: Clang

# RUN: split-file %s %t
# RUN: %dxc_target -T ms_6_5 -Fo %t-mesh.o %t/mesh.hlsl
# RUN: %dxc_target -T ps_6_5 -Fo %t-pixel.o %t/pixel.hlsl
# RUN: %offloader %t/pipeline.yaml %t-mesh.o %t-pixel.o -r Output -o %t/Output.png
# RUN: imgdiff %t/Output.png %goldenimage_dir/hlsl/Graphics/MeshShaders/SimpleLines.png -rules %t/rules.yaml
Loading