Skip to content
Open
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 test_conformance/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ if(VULKAN_IS_SUPPORTED)
add_subdirectory( common/vulkan_wrapper )
add_subdirectory( vulkan )
endif()
if(D3D12_IS_SUPPORTED)
if(D3D10_IS_SUPPORTED OR D3D11_IS_SUPPORTED OR D3D12_IS_SUPPORTED)
add_subdirectory(common/directx_wrapper)
endif ()

Expand Down
17 changes: 12 additions & 5 deletions test_conformance/common/directx_wrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ set(DIRECTX_WRAPPER_SOURCES

add_library(directx_wrapper STATIC ${DIRECTX_WRAPPER_SOURCES})

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(directx_wrapper
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})

include_directories(${CLConform_INCLUDE_DIR})
target_compile_definitions(directx_wrapper
PUBLIC
$<$<BOOL:${D3D10_IS_SUPPORTED}>:D3D10_IS_SUPPORTED>
$<$<BOOL:${D3D11_IS_SUPPORTED}>:D3D11_IS_SUPPORTED>
$<$<BOOL:${D3D12_IS_SUPPORTED}>:D3D12_IS_SUPPORTED>)

if (WIN32)
target_link_libraries(directx_wrapper d3d12)
endif ()
target_link_libraries(directx_wrapper
dxgi
$<$<BOOL:${D3D10_IS_SUPPORTED}>:d3d10>
$<$<BOOL:${D3D11_IS_SUPPORTED}>:d3d11>
$<$<BOOL:${D3D12_IS_SUPPORTED}>:d3d12>)
76 changes: 71 additions & 5 deletions test_conformance/common/directx_wrapper/directx_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
// limitations under the License.
//

#include <stdexcept>

#include "directx_wrapper.hpp"

DirectXWrapper::DirectXWrapper()
#if D3D12_IS_SUPPORTED
DirectX12Wrapper::DirectX12Wrapper()
{

HRESULT hr = D3D12CreateDevice(nullptr, D3D_FEATURE_LEVEL_12_0,
Expand Down Expand Up @@ -44,18 +47,18 @@ DirectXWrapper::DirectXWrapper()
}
}

ID3D12Device* DirectXWrapper::getDXDevice() const { return dx_device.Get(); }
ID3D12Device* DirectX12Wrapper::getDXDevice() const { return dx_device.Get(); }

ID3D12CommandQueue* DirectXWrapper::getDXCommandQueue() const
ID3D12CommandQueue* DirectX12Wrapper::getDXCommandQueue() const
{
return dx_command_queue.Get();
}
ID3D12CommandAllocator* DirectXWrapper::getDXCommandAllocator() const
ID3D12CommandAllocator* DirectX12Wrapper::getDXCommandAllocator() const
{
return dx_command_allocator.Get();
}

DirectXFenceWrapper::DirectXFenceWrapper(ID3D12Device* dx_device)
DirectX12FenceWrapper::DirectX12FenceWrapper(ID3D12Device* dx_device)
: dx_device(dx_device)
{
if (!dx_device)
Expand All @@ -69,3 +72,66 @@ DirectXFenceWrapper::DirectXFenceWrapper(ID3D12Device* dx_device)
throw std::runtime_error("Failed to create the DirectX fence");
}
}
#endif

#if D3D11_IS_SUPPORTED
DirectX11Wrapper::DirectX11Wrapper()
{
ComPtr<IDXGIFactory> factory;
HRESULT hr = CreateDXGIFactory(IID_PPV_ARGS(factory.GetAddressOf()));
if (FAILED(hr))
{
throw std::runtime_error("Failed to create DXGI factory");
}

UINT i = 0;
ComPtr<IDXGIAdapter> adapter;
while (factory->EnumAdapters(i, adapter.GetAddressOf())
!= DXGI_ERROR_NOT_FOUND)
{
++i;

ComPtr<ID3D11Device> device;
hr = D3D11CreateDevice(adapter.Get(), D3D_DRIVER_TYPE_HARDWARE, nullptr,
0, nullptr, 0, D3D11_SDK_VERSION,
device.GetAddressOf(), nullptr, nullptr);
if (FAILED(hr))
{
throw std::runtime_error("Failed to create DirectX 10 device");
}

devices.push_back({ adapter, device });
}
}
#endif

#if D3D10_IS_SUPPORTED
DirectX10Wrapper::DirectX10Wrapper()
{
ComPtr<IDXGIFactory> factory;
HRESULT hr = CreateDXGIFactory(IID_PPV_ARGS(factory.GetAddressOf()));
if (FAILED(hr))
{
throw std::runtime_error("Failed to create DXGI factory");
}

UINT i = 0;
ComPtr<IDXGIAdapter> adapter;
while (factory->EnumAdapters(i, adapter.GetAddressOf())
!= DXGI_ERROR_NOT_FOUND)
{
++i;

ComPtr<ID3D10Device> device;
hr = D3D10CreateDevice(adapter.Get(), D3D10_DRIVER_TYPE_HARDWARE,
nullptr, 0, D3D10_SDK_VERSION,
device.GetAddressOf());
if (FAILED(hr))
{
throw std::runtime_error("Failed to create DirectX 10 device");
}

devices.push_back({ adapter, device });
}
}
#endif
53 changes: 47 additions & 6 deletions test_conformance/common/directx_wrapper/directx_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,25 @@

#pragma once

#if D3D12_IS_SUPPORTED
#include <d3d12.h>
#endif
#if D3D11_IS_SUPPORTED
#include <cl/cl_d3d11.h>
#endif
#if D3D10_IS_SUPPORTED
#include <cl/cl_d3d10.h>
#endif

#include <vector>
#include <wrl/client.h>
#include <stdexcept>

using namespace Microsoft::WRL;

class DirectXWrapper {
#if D3D12_IS_SUPPORTED
class DirectX12Wrapper {
public:
DirectXWrapper();
DirectX12Wrapper();

[[nodiscard]] ID3D12Device* getDXDevice() const;
[[nodiscard]] ID3D12CommandQueue* getDXCommandQueue() const;
Expand All @@ -36,12 +46,43 @@ class DirectXWrapper {
ComPtr<ID3D12CommandAllocator> dx_command_allocator = nullptr;
};

class DirectXFenceWrapper {
class DirectX12FenceWrapper {
public:
DirectXFenceWrapper(ID3D12Device* dx_device);
DirectX12FenceWrapper(ID3D12Device* dx_device);
[[nodiscard]] ID3D12Fence* get() const { return dx_fence.Get(); }

private:
ComPtr<ID3D12Fence> dx_fence = nullptr;
ComPtr<ID3D12Device> dx_device = nullptr;
};
};
#endif

#if D3D11_IS_SUPPORTED
struct DirectX11Wrapper
{
struct DeviceEntry
{
ComPtr<IDXGIAdapter> dx_adapter;
ComPtr<ID3D11Device> dx_device;
};

DirectX11Wrapper();

std::vector<DeviceEntry> devices;
};
#endif

#if D3D10_IS_SUPPORTED
struct DirectX10Wrapper
{
struct DeviceEntry
{
ComPtr<IDXGIAdapter> dx_adapter;
ComPtr<ID3D10Device> dx_device;
};

DirectX10Wrapper();

std::vector<DeviceEntry> devices;
};
#endif
2 changes: 1 addition & 1 deletion test_conformance/d3d10/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set(${MODULE_NAME}_SOURCES
harness.cpp
)

list(APPEND CLConform_LIBRARIES d3d10 dxgi)
list(APPEND CLConform_LIBRARIES directx_wrapper)

include(../CMakeCommon.txt)
else()
Expand Down
10 changes: 3 additions & 7 deletions test_conformance/d3d10/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ void SubTestBuffer(
cl_mem mem = NULL;
cl_int result = CL_SUCCESS;

HarnessD3D10_TestBegin("Buffer: Size=%d, BindFlags=%s, Usage=%s, CPUAccess=%s",
props->ByteWidth,
props->name_BindFlags,
props->name_Usage,
props->name_CPUAccess);
log_info("Buffer: Size=%d, BindFlags=%s, Usage=%s, CPUAccess=%s",
props->ByteWidth, props->name_BindFlags, props->name_Usage,
props->name_CPUAccess);

// create the D3D10 resource
{
Expand Down Expand Up @@ -288,8 +286,6 @@ void SubTestBuffer(
{
clReleaseMemObject(mem);
}

HarnessD3D10_TestEnd();
}


Expand Down
Loading
Loading