Skip to content

Commit

Permalink
enable more metal testing
Browse files Browse the repository at this point in the history
  • Loading branch information
skallweitNV committed Sep 3, 2024
1 parent 5233911 commit 258e680
Show file tree
Hide file tree
Showing 31 changed files with 382 additions and 60 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ endif()

set(SLANG_RHI_SLANG_INCLUDE_DIR ${SLANG_RHI_SLANG_INCLUDE_DIR} CACHE STRING "Slang include directory")
set(SLANG_RHI_SLANG_BINARY_DIR ${SLANG_RHI_SLANG_BINARY_DIR} CACHE STRING "Slang binary directory")
# Use the variables from the cache.
unset(SLANG_RHI_SLANG_INCLUDE_DIR)
unset(SLANG_RHI_SLANG_BINARY_DIR)

if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-assume -Wno-switch")
Expand Down
8 changes: 5 additions & 3 deletions src/metal/metal-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Result DeviceImpl::createCommandQueue(const ICommandQueue::Desc& desc, ICommandQ
RefPtr<CommandQueueImpl> result = new CommandQueueImpl;
result->init(this, m_commandQueue);
returnComPtr(outQueue, result);
m_queueAllocCount++;
// m_queueAllocCount++;
return SLANG_OK;
}

Expand Down Expand Up @@ -445,7 +445,8 @@ Result DeviceImpl::createTexture(const TextureDesc& descIn, const SubresourceDat
textureImpl->m_textureType = textureDesc->textureType();
textureImpl->m_pixelFormat = textureDesc->pixelFormat();

textureImpl->m_texture->setLabel(MetalUtil::createString(desc.label).get());
if (desc.label)
textureImpl->m_texture->setLabel(MetalUtil::createString(desc.label).get());

// TODO: handle initData
if (initData)
Expand Down Expand Up @@ -533,7 +534,8 @@ Result DeviceImpl::createBuffer(const BufferDesc& descIn, const void* initData,
return SLANG_FAIL;
}

buffer->m_buffer->addDebugMarker(MetalUtil::createString(desc.label).get(), NS::Range(0, desc.size));
if (desc.label)
buffer->m_buffer->addDebugMarker(MetalUtil::createString(desc.label).get(), NS::Range(0, desc.size));

if (initData)
{
Expand Down
12 changes: 7 additions & 5 deletions src/metal/metal-render-pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ Result RenderPassLayoutImpl::init(DeviceImpl* device, const IRenderPassLayout::D
colorAttachment->setStoreAction(translateStoreOp(desc.renderTargetAccess[i].storeOp));
}

m_renderPassDesc->depthAttachment()->setLoadAction(translateLoadOp(desc.depthStencilAccess->loadOp));
m_renderPassDesc->depthAttachment()->setStoreAction(translateStoreOp(desc.depthStencilAccess->storeOp));

m_renderPassDesc->stencilAttachment()->setLoadAction(translateLoadOp(desc.depthStencilAccess->loadOp));
m_renderPassDesc->stencilAttachment()->setStoreAction(translateStoreOp(desc.depthStencilAccess->storeOp));
if (desc.depthStencilAccess)
{
m_renderPassDesc->depthAttachment()->setLoadAction(translateLoadOp(desc.depthStencilAccess->loadOp));
m_renderPassDesc->depthAttachment()->setStoreAction(translateStoreOp(desc.depthStencilAccess->storeOp));
m_renderPassDesc->stencilAttachment()->setLoadAction(translateLoadOp(desc.depthStencilAccess->loadOp));
m_renderPassDesc->stencilAttachment()->setStoreAction(translateStoreOp(desc.depthStencilAccess->storeOp));
}

return SLANG_OK;
}
Expand Down
12 changes: 10 additions & 2 deletions tests/test-buffer-barrier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ void testBufferBarrier(GpuTestContext* ctx, DeviceType deviceType)

TEST_CASE("buffer-barrier")
{
// D3D11 doesn't work
runGpuTests(testBufferBarrier, {DeviceType::D3D12, DeviceType::Vulkan, DeviceType::CUDA, DeviceType::CPU});
// D3D11 and Metal don't work
runGpuTests(
testBufferBarrier,
{
DeviceType::D3D12,
DeviceType::Vulkan,
DeviceType::CUDA,
DeviceType::CPU,
}
);
}
10 changes: 8 additions & 2 deletions tests/test-clear-texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ void testClearTexture(GpuTestContext* ctx, DeviceType deviceType)

TEST_CASE("clear-texture")
{
// D3D11, CUDA, CPU don't support clearResourceView
runGpuTests(testClearTexture, {DeviceType::D3D12, DeviceType::Vulkan});
// D3D11, Metal, CUDA, CPU don't support clearResourceView
runGpuTests(
testClearTexture,
{
DeviceType::D3D12,
DeviceType::Vulkan,
}
);
}
9 changes: 8 additions & 1 deletion tests/test-compute-smoke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ TEST_CASE("compute-smoke")
{
runGpuTests(
testComputeSmoke,
{DeviceType::D3D11, DeviceType::D3D12, DeviceType::Vulkan, DeviceType::CUDA, DeviceType::CPU}
{
DeviceType::D3D11,
DeviceType::D3D12,
DeviceType::Vulkan,
DeviceType::Metal,
DeviceType::CUDA,
DeviceType::CPU,
}
);
}
9 changes: 8 additions & 1 deletion tests/test-compute-trivial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ TEST_CASE("compute-trivial")
{
runGpuTests(
testComputeTrivial,
{DeviceType::D3D11, DeviceType::D3D12, DeviceType::Vulkan, DeviceType::CUDA, DeviceType::CPU}
{
DeviceType::D3D11,
DeviceType::D3D12,
DeviceType::Vulkan,
DeviceType::Metal,
DeviceType::CUDA,
DeviceType::CPU,
}
);
}
66 changes: 57 additions & 9 deletions tests/test-copy-texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,44 +788,92 @@ void testCopyTexture(GpuTestContext* ctx, DeviceType deviceType)
}
}

// Texture support is currently very limited for D3D11, CUDA and CPU
// Texture support is currently very limited for D3D11, Metal, CUDA and CPU

TEST_CASE("copy-texture-simple")
{
runGpuTests(testCopyTexture<SimpleCopyTexture>, {DeviceType::D3D12, DeviceType::Vulkan});
runGpuTests(
testCopyTexture<SimpleCopyTexture>,
{
DeviceType::D3D12,
DeviceType::Vulkan,
}
);
}

TEST_CASE("copy-texture-section")
{
runGpuTests(testCopyTexture<CopyTextureSection>, {DeviceType::D3D12, DeviceType::Vulkan});
runGpuTests(
testCopyTexture<CopyTextureSection>,
{
DeviceType::D3D12,
DeviceType::Vulkan,
}
);
}

TEST_CASE("copy-texture-large-to-small")
{
runGpuTests(testCopyTexture<LargeSrcToSmallDst>, {DeviceType::D3D12, DeviceType::Vulkan});
runGpuTests(
testCopyTexture<LargeSrcToSmallDst>,
{
DeviceType::D3D12,
DeviceType::Vulkan,
}
);
}

TEST_CASE("copy-texture-small-to-large")
{
runGpuTests(testCopyTexture<SmallSrcToLargeDst>, {DeviceType::D3D12, DeviceType::Vulkan});
runGpuTests(
testCopyTexture<SmallSrcToLargeDst>,
{
DeviceType::D3D12,
DeviceType::Vulkan,
}
);
}

TEST_CASE("copy-texture-between-mips")
{
runGpuTests(testCopyTexture<CopyBetweenMips>, {DeviceType::D3D12, DeviceType::Vulkan});
runGpuTests(
testCopyTexture<CopyBetweenMips>,
{
DeviceType::D3D12,
DeviceType::Vulkan,
}
);
}

TEST_CASE("copy-texture-between-layers")
{
runGpuTests(testCopyTexture<CopyBetweenLayers>, {DeviceType::D3D12, DeviceType::Vulkan});
runGpuTests(
testCopyTexture<CopyBetweenLayers>,
{
DeviceType::D3D12,
DeviceType::Vulkan,
}
);
}

TEST_CASE("copy-texture-with-offsets")
{
runGpuTests(testCopyTexture<CopyWithOffsets>, {DeviceType::D3D12, DeviceType::Vulkan});
runGpuTests(
testCopyTexture<CopyWithOffsets>,
{
DeviceType::D3D12,
DeviceType::Vulkan,
}
);
}

TEST_CASE("copy-texture-with-extent")
{
runGpuTests(testCopyTexture<CopySectionWithSetExtent>, {DeviceType::D3D12, DeviceType::Vulkan});
runGpuTests(
testCopyTexture<CopySectionWithSetExtent>,
{
DeviceType::D3D12,
DeviceType::Vulkan,
}
);
}
8 changes: 7 additions & 1 deletion tests/test-create-buffer-from-handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,11 @@ void testCreateBufferFromHandle(GpuTestContext* ctx, DeviceType deviceType)

TEST_CASE("create-buffer-from-handle")
{
runGpuTests(testCreateBufferFromHandle, {DeviceType::D3D12, DeviceType::Vulkan});
runGpuTests(
testCreateBufferFromHandle,
{
DeviceType::D3D12,
DeviceType::Vulkan,
}
);
}
9 changes: 8 additions & 1 deletion tests/test-existing-device-handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,12 @@ void testExistingDeviceHandle(GpuTestContext* ctx, DeviceType deviceType)

TEST_CASE("existing-device-handle")
{
runGpuTests(testExistingDeviceHandle, {DeviceType::Vulkan, DeviceType::D3D12, DeviceType::CUDA});
runGpuTests(
testExistingDeviceHandle,
{
DeviceType::Vulkan,
DeviceType::D3D12,
DeviceType::CUDA,
}
);
}
8 changes: 7 additions & 1 deletion tests/test-formats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,5 +1101,11 @@ void testFormats(GpuTestContext* ctx, DeviceType deviceType)

TEST_CASE("formats")
{
runGpuTests(testFormats, {DeviceType::D3D12, DeviceType::Vulkan});
runGpuTests(
testFormats,
{
DeviceType::D3D12,
DeviceType::Vulkan,
}
);
}
36 changes: 32 additions & 4 deletions tests/test-instanced-draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,20 +496,48 @@ void testDraw(GpuTestContext* ctx, DeviceType deviceType)

TEST_CASE("draw-instanced")
{
runGpuTests(testDraw<DrawInstancedTest>, {DeviceType::D3D11, DeviceType::D3D12, DeviceType::Vulkan});
runGpuTests(
testDraw<DrawInstancedTest>,
{
DeviceType::D3D11,
DeviceType::D3D12,
DeviceType::Vulkan,
DeviceType::Metal,
}
);
}

TEST_CASE("draw-indexed-instanced")
{
runGpuTests(testDraw<DrawIndexedInstancedTest>, {DeviceType::D3D11, DeviceType::D3D12, DeviceType::Vulkan});
runGpuTests(
testDraw<DrawIndexedInstancedTest>,
{
DeviceType::D3D11,
DeviceType::D3D12,
DeviceType::Vulkan,
DeviceType::Metal,
}
);
}

TEST_CASE("draw-indirect")
{
runGpuTests(testDraw<DrawIndirectTest>, {DeviceType::D3D12, DeviceType::Vulkan});
runGpuTests(
testDraw<DrawIndirectTest>,
{
DeviceType::D3D12,
DeviceType::Vulkan,
}
);
}

TEST_CASE("draw-indexed-indirect")
{
runGpuTests(testDraw<DrawIndexedIndirectTest>, {DeviceType::D3D12, DeviceType::Vulkan});
runGpuTests(
testDraw<DrawIndexedIndirectTest>,
{
DeviceType::D3D12,
DeviceType::Vulkan,
}
);
}
8 changes: 7 additions & 1 deletion tests/test-link-time-constant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,11 @@ void testLinkTimeConstant(GpuTestContext* ctx, DeviceType deviceType)
// TODO_TESTING crashes slang
// TEST_CASE("link-time-constant")
// {
// runGpuTests(testLinkTimeConstant, {DeviceType::D3D12, DeviceType::Vulkan});
// runGpuTests(
// testLinkTimeConstant,
// {
// DeviceType::D3D12,
// DeviceType::Vulkan,
// }
// );
// }
11 changes: 10 additions & 1 deletion tests/test-link-time-default.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,14 @@ void testLinkTimeDefault(GpuTestContext* ctx, DeviceType deviceType)
TEST_CASE("link-time-default")
{
// Fails on CUDA
runGpuTests(testLinkTimeDefault, {DeviceType::D3D11, DeviceType::D3D12, DeviceType::Vulkan, DeviceType::CPU});
runGpuTests(
testLinkTimeDefault,
{
DeviceType::D3D11,
DeviceType::D3D12,
DeviceType::Vulkan,
DeviceType::Metal,
DeviceType::CPU,
}
);
}
9 changes: 8 additions & 1 deletion tests/test-link-time-options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,12 @@ void testLinkTimeOptions(GpuTestContext* ctx, DeviceType deviceType)
TEST_CASE("link-time-options")
{
// Doesn't work on D3D11, CUDA and CPU
runGpuTests(testLinkTimeOptions, {DeviceType::D3D12, /*DeviceType::Vulkan,*/});
runGpuTests(
testLinkTimeOptions,
{
DeviceType::D3D12,
// DeviceType::Vulkan,
// DeviceType::Metal,
}
);
}
11 changes: 10 additions & 1 deletion tests/test-link-time-type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,14 @@ void testLinkTimeType(GpuTestContext* ctx, DeviceType deviceType)
TEST_CASE("link-time-type")
{
// Doesn't work on CUDA.
runGpuTests(testLinkTimeType, {DeviceType::D3D11, DeviceType::D3D12, DeviceType::Vulkan, DeviceType::CPU});
runGpuTests(
testLinkTimeType,
{
DeviceType::D3D11,
DeviceType::D3D12,
DeviceType::Vulkan,
DeviceType::Metal,
DeviceType::CPU,
}
);
}
9 changes: 8 additions & 1 deletion tests/test-mutable-shader-object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ TEST_CASE("mutable-shader-object")
{
runGpuTests(
testMutableShaderObject,
{DeviceType::D3D11, DeviceType::D3D12, DeviceType::Vulkan, DeviceType::CUDA, DeviceType::CPU}
{
DeviceType::D3D11,
DeviceType::D3D12,
DeviceType::Vulkan,
// DeviceType::Metal,
DeviceType::CUDA,
DeviceType::CPU,
}
);
}
Loading

0 comments on commit 258e680

Please sign in to comment.