|
|
|
@ -94,7 +94,7 @@ class D3D12ResourceTestBase : public DawnTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> CreateExternalImage(
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> CreateExternalImage(
|
|
|
|
|
WGPUDevice targetDevice,
|
|
|
|
|
ID3D11Texture2D* d3d11Texture,
|
|
|
|
|
const wgpu::TextureDescriptor* dawnDesc) const {
|
|
|
|
@ -107,13 +107,13 @@ class D3D12ResourceTestBase : public DawnTest {
|
|
|
|
|
&textureSharedHandle),
|
|
|
|
|
S_OK);
|
|
|
|
|
|
|
|
|
|
dawn::native::d3d12::ExternalImageDescriptorDXGISharedHandle externalImageDesc;
|
|
|
|
|
dawn::native::d3d::ExternalImageDescriptorDXGISharedHandle externalImageDesc;
|
|
|
|
|
externalImageDesc.cTextureDescriptor =
|
|
|
|
|
reinterpret_cast<const WGPUTextureDescriptor*>(dawnDesc);
|
|
|
|
|
externalImageDesc.sharedHandle = textureSharedHandle;
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage =
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGI::Create(targetDevice, &externalImageDesc);
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage =
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGI::Create(targetDevice, &externalImageDesc);
|
|
|
|
|
|
|
|
|
|
// Now that we've created all of our resources, we can close the handle
|
|
|
|
|
// since we no longer need it.
|
|
|
|
@ -127,12 +127,12 @@ class D3D12ResourceTestBase : public DawnTest {
|
|
|
|
|
const D3D11_TEXTURE2D_DESC* baseD3dDescriptor,
|
|
|
|
|
wgpu::Texture* dawnTexture,
|
|
|
|
|
ID3D11Texture2D** d3d11TextureOut,
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI>* externalImageOut) const {
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI>* externalImageOut) const {
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
HRESULT hr = mD3d11Device->CreateTexture2D(baseD3dDescriptor, nullptr, &d3d11Texture);
|
|
|
|
|
ASSERT_EQ(hr, S_OK);
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage =
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage =
|
|
|
|
|
CreateExternalImage(device.Get(), d3d11Texture.Get(), dawnDesc);
|
|
|
|
|
|
|
|
|
|
// Cannot access a non-existent external image (ex. validation error).
|
|
|
|
@ -140,7 +140,7 @@ class D3D12ResourceTestBase : public DawnTest {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc;
|
|
|
|
|
externalAccessDesc.usage = static_cast<WGPUTextureUsageFlags>(dawnDesc->usage);
|
|
|
|
|
|
|
|
|
|
*dawnTexture = wgpu::Texture::Acquire(externalImage->BeginAccess(&externalAccessDesc));
|
|
|
|
@ -173,13 +173,13 @@ TEST_P(D3D12SharedHandleValidation, Success) {
|
|
|
|
|
|
|
|
|
|
wgpu::Texture texture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture,
|
|
|
|
|
&externalImage);
|
|
|
|
|
|
|
|
|
|
ASSERT_NE(texture.Get(), nullptr);
|
|
|
|
|
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
externalImage->EndAccess(texture.Get(), &signalFence);
|
|
|
|
|
texture.Destroy();
|
|
|
|
|
}
|
|
|
|
@ -195,13 +195,13 @@ TEST_P(D3D12SharedHandleValidation, SuccessWithInternalUsageDescriptor) {
|
|
|
|
|
|
|
|
|
|
wgpu::Texture texture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture,
|
|
|
|
|
&externalImage);
|
|
|
|
|
|
|
|
|
|
ASSERT_NE(texture.Get(), nullptr);
|
|
|
|
|
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
externalImage->EndAccess(texture.Get(), &signalFence);
|
|
|
|
|
texture.Destroy();
|
|
|
|
|
}
|
|
|
|
@ -216,7 +216,7 @@ TEST_P(D3D12SharedHandleValidation, InvalidTextureDescriptor) {
|
|
|
|
|
|
|
|
|
|
wgpu::Texture texture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
ASSERT_DEVICE_ERROR(WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture,
|
|
|
|
|
&d3d11Texture, &externalImage));
|
|
|
|
|
|
|
|
|
@ -230,7 +230,7 @@ TEST_P(D3D12SharedHandleValidation, InvalidMipLevelCount) {
|
|
|
|
|
|
|
|
|
|
wgpu::Texture texture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
ASSERT_DEVICE_ERROR(WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture,
|
|
|
|
|
&d3d11Texture, &externalImage));
|
|
|
|
|
|
|
|
|
@ -244,7 +244,7 @@ TEST_P(D3D12SharedHandleValidation, InvalidDepth) {
|
|
|
|
|
|
|
|
|
|
wgpu::Texture texture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
ASSERT_DEVICE_ERROR(WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture,
|
|
|
|
|
&d3d11Texture, &externalImage));
|
|
|
|
|
|
|
|
|
@ -258,7 +258,7 @@ TEST_P(D3D12SharedHandleValidation, InvalidSampleCount) {
|
|
|
|
|
|
|
|
|
|
wgpu::Texture texture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
ASSERT_DEVICE_ERROR(WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture,
|
|
|
|
|
&d3d11Texture, &externalImage));
|
|
|
|
|
|
|
|
|
@ -272,7 +272,7 @@ TEST_P(D3D12SharedHandleValidation, InvalidWidth) {
|
|
|
|
|
|
|
|
|
|
wgpu::Texture texture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
ASSERT_DEVICE_ERROR(WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture,
|
|
|
|
|
&d3d11Texture, &externalImage));
|
|
|
|
|
|
|
|
|
@ -286,7 +286,7 @@ TEST_P(D3D12SharedHandleValidation, InvalidHeight) {
|
|
|
|
|
|
|
|
|
|
wgpu::Texture texture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
ASSERT_DEVICE_ERROR(WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture,
|
|
|
|
|
&d3d11Texture, &externalImage));
|
|
|
|
|
|
|
|
|
@ -300,7 +300,7 @@ TEST_P(D3D12SharedHandleValidation, InvalidFormat) {
|
|
|
|
|
|
|
|
|
|
wgpu::Texture texture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
ASSERT_DEVICE_ERROR(WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture,
|
|
|
|
|
&d3d11Texture, &externalImage));
|
|
|
|
|
|
|
|
|
@ -314,7 +314,7 @@ TEST_P(D3D12SharedHandleValidation, InvalidNumD3DMipLevels) {
|
|
|
|
|
|
|
|
|
|
wgpu::Texture texture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
ASSERT_DEVICE_ERROR(WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture,
|
|
|
|
|
&d3d11Texture, &externalImage));
|
|
|
|
|
|
|
|
|
@ -328,7 +328,7 @@ TEST_P(D3D12SharedHandleValidation, InvalidD3DArraySize) {
|
|
|
|
|
|
|
|
|
|
wgpu::Texture texture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
ASSERT_DEVICE_ERROR(WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture,
|
|
|
|
|
&d3d11Texture, &externalImage));
|
|
|
|
|
|
|
|
|
@ -440,17 +440,17 @@ class D3D12SharedHandleUsageTests : public D3D12ResourceTestBase {
|
|
|
|
|
HANDLE fenceSharedHandle,
|
|
|
|
|
uint64_t fenceWaitValue,
|
|
|
|
|
wgpu::Texture* dawnTextureOut,
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI>* externalImageOut,
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI>* externalImageOut,
|
|
|
|
|
bool isInitialized) const {
|
|
|
|
|
dawn::native::d3d12::ExternalImageDescriptorDXGISharedHandle externalImageDesc = {};
|
|
|
|
|
dawn::native::d3d::ExternalImageDescriptorDXGISharedHandle externalImageDesc = {};
|
|
|
|
|
externalImageDesc.sharedHandle = sharedHandle;
|
|
|
|
|
externalImageDesc.cTextureDescriptor =
|
|
|
|
|
reinterpret_cast<const WGPUTextureDescriptor*>(&dawnDescriptor);
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage =
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGI::Create(device.Get(), &externalImageDesc);
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage =
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGI::Create(device.Get(), &externalImageDesc);
|
|
|
|
|
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc;
|
|
|
|
|
externalAccessDesc.isInitialized = isInitialized;
|
|
|
|
|
externalAccessDesc.usage = static_cast<WGPUTextureUsageFlags>(dawnDescriptor.usage);
|
|
|
|
|
if (fenceSharedHandle != nullptr) {
|
|
|
|
@ -467,7 +467,7 @@ class D3D12SharedHandleUsageTests : public D3D12ResourceTestBase {
|
|
|
|
|
const wgpu::Color& clearColor,
|
|
|
|
|
wgpu::Texture* dawnTextureOut,
|
|
|
|
|
ID3D11Texture2D** d3d11TextureOut,
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI>* externalImageOut,
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI>* externalImageOut,
|
|
|
|
|
bool isInitialized = true) const {
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
ComPtr<ID3D11Fence> d3d11Fence;
|
|
|
|
@ -490,10 +490,9 @@ class D3D12SharedHandleUsageTests : public D3D12ResourceTestBase {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExpectPixelRGBA8EQ(
|
|
|
|
|
ID3D11Texture2D* d3d11Texture,
|
|
|
|
|
void ExpectPixelRGBA8EQ(ID3D11Texture2D* d3d11Texture,
|
|
|
|
|
const wgpu::Color& color,
|
|
|
|
|
const dawn::native::d3d12::ExternalImageDXGIFenceDescriptor* waitFence) {
|
|
|
|
|
const dawn::native::d3d::ExternalImageDXGIFenceDescriptor* waitFence) {
|
|
|
|
|
D3D11_TEXTURE2D_DESC texture2DDesc;
|
|
|
|
|
d3d11Texture->GetDesc(&texture2DDesc);
|
|
|
|
|
|
|
|
|
@ -570,7 +569,7 @@ TEST_P(D3D12SharedHandleUsageTests, ClearInD3D11CopyAndReadbackInD3D12) {
|
|
|
|
|
const wgpu::Color clearColor{1.0f, 1.0f, 0.0f, 1.0f};
|
|
|
|
|
wgpu::Texture dawnSrcTexture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
WrapAndClearD3D11Texture(baseDawnDescriptor, baseD3dDescriptor, clearColor, &dawnSrcTexture,
|
|
|
|
|
&d3d11Texture, &externalImage);
|
|
|
|
|
ASSERT_NE(dawnSrcTexture.Get(), nullptr);
|
|
|
|
@ -579,7 +578,7 @@ TEST_P(D3D12SharedHandleUsageTests, ClearInD3D11CopyAndReadbackInD3D12) {
|
|
|
|
|
wgpu::Texture dawnCopyDestTexture = device.CreateTexture(&baseDawnDescriptor);
|
|
|
|
|
SimpleCopyTextureToTexture(dawnSrcTexture, dawnCopyDestTexture);
|
|
|
|
|
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
externalImage->EndAccess(dawnSrcTexture.Get(), &signalFence);
|
|
|
|
|
dawnSrcTexture.Destroy();
|
|
|
|
|
|
|
|
|
@ -598,7 +597,7 @@ TEST_P(D3D12SharedHandleUsageTests, ClearInD3D11ReadbackInD3D12) {
|
|
|
|
|
const wgpu::Color clearColor{1.0f, 1.0f, 0.0f, 1.0f};
|
|
|
|
|
wgpu::Texture dawnTexture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
WrapAndClearD3D11Texture(baseDawnDescriptor, baseD3dDescriptor, clearColor, &dawnTexture,
|
|
|
|
|
&d3d11Texture, &externalImage);
|
|
|
|
|
ASSERT_NE(dawnTexture.Get(), nullptr);
|
|
|
|
@ -609,7 +608,7 @@ TEST_P(D3D12SharedHandleUsageTests, ClearInD3D11ReadbackInD3D12) {
|
|
|
|
|
clearColor.a * 255),
|
|
|
|
|
dawnTexture, 0, 0);
|
|
|
|
|
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
externalImage->EndAccess(dawnTexture.Get(), &signalFence);
|
|
|
|
|
dawnTexture.Destroy();
|
|
|
|
|
}
|
|
|
|
@ -627,7 +626,7 @@ TEST_P(D3D12SharedHandleUsageTests, ClearInD3D12ReadbackInD3D11) {
|
|
|
|
|
const wgpu::Color d3d11ClearColor{1.0f, 1.0f, 0.0f, 1.0f};
|
|
|
|
|
wgpu::Texture dawnTexture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
WrapAndClearD3D11Texture(baseDawnDescriptor, baseD3dDescriptor, d3d11ClearColor, &dawnTexture,
|
|
|
|
|
&d3d11Texture, &externalImage, /*isInitialized=*/true);
|
|
|
|
|
ASSERT_NE(dawnTexture.Get(), nullptr);
|
|
|
|
@ -635,7 +634,7 @@ TEST_P(D3D12SharedHandleUsageTests, ClearInD3D12ReadbackInD3D11) {
|
|
|
|
|
const wgpu::Color d3d12ClearColor{0.0f, 0.0f, 1.0f, 1.0f};
|
|
|
|
|
ClearImage(dawnTexture, d3d12ClearColor, device);
|
|
|
|
|
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
externalImage->EndAccess(dawnTexture.Get(), &signalFence);
|
|
|
|
|
dawnTexture.Destroy();
|
|
|
|
|
|
|
|
|
@ -659,7 +658,7 @@ TEST_P(D3D12SharedHandleUsageTests, ClearTwiceInD3D12ReadbackInD3D11) {
|
|
|
|
|
const wgpu::Color d3d11ClearColor{1.0f, 1.0f, 0.0f, 1.0f};
|
|
|
|
|
wgpu::Texture dawnTexture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
WrapAndClearD3D11Texture(baseDawnDescriptor, baseD3dDescriptor, d3d11ClearColor, &dawnTexture,
|
|
|
|
|
&d3d11Texture, &externalImage, /*isInitialized=*/true);
|
|
|
|
|
ASSERT_NE(dawnTexture.Get(), nullptr);
|
|
|
|
@ -670,7 +669,7 @@ TEST_P(D3D12SharedHandleUsageTests, ClearTwiceInD3D12ReadbackInD3D11) {
|
|
|
|
|
const wgpu::Color d3d12ClearColor2{0.0f, 1.0f, 1.0f, 1.0f};
|
|
|
|
|
ClearImage(dawnTexture, d3d12ClearColor2, device);
|
|
|
|
|
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
externalImage->EndAccess(dawnTexture.Get(), &signalFence);
|
|
|
|
|
dawnTexture.Destroy();
|
|
|
|
|
|
|
|
|
@ -689,7 +688,7 @@ TEST_P(D3D12SharedHandleUsageTests, UninitializedTextureIsCleared) {
|
|
|
|
|
const wgpu::Color clearColor{1.0f, 0.0f, 0.0f, 1.0f};
|
|
|
|
|
wgpu::Texture dawnTexture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
WrapAndClearD3D11Texture(baseDawnDescriptor, baseD3dDescriptor, clearColor, &dawnTexture,
|
|
|
|
|
&d3d11Texture, &externalImage, /*isInitialized=*/false);
|
|
|
|
|
ASSERT_NE(dawnTexture.Get(), nullptr);
|
|
|
|
@ -698,7 +697,7 @@ TEST_P(D3D12SharedHandleUsageTests, UninitializedTextureIsCleared) {
|
|
|
|
|
// to clear the source texture on the D3D device.
|
|
|
|
|
EXPECT_PIXEL_RGBA8_EQ(utils::RGBA8(0, 0, 0, 0), dawnTexture, 0, 0);
|
|
|
|
|
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
externalImage->EndAccess(dawnTexture.Get(), &signalFence);
|
|
|
|
|
dawnTexture.Destroy();
|
|
|
|
|
}
|
|
|
|
@ -712,7 +711,7 @@ TEST_P(D3D12SharedHandleUsageTests, ReuseExternalImage) {
|
|
|
|
|
// Create the first Dawn texture then clear it to red.
|
|
|
|
|
wgpu::Texture texture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture,
|
|
|
|
|
&externalImage);
|
|
|
|
|
{
|
|
|
|
@ -725,12 +724,12 @@ TEST_P(D3D12SharedHandleUsageTests, ReuseExternalImage) {
|
|
|
|
|
|
|
|
|
|
// Once finished with the first texture, destroy it so we may re-acquire the external image
|
|
|
|
|
// again.
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
externalImage->EndAccess(texture.Get(), &signalFence);
|
|
|
|
|
texture.Destroy();
|
|
|
|
|
|
|
|
|
|
// Create another Dawn texture then clear it with another color.
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc;
|
|
|
|
|
externalAccessDesc.isInitialized = true;
|
|
|
|
|
externalAccessDesc.usage = static_cast<WGPUTextureUsageFlags>(baseDawnDescriptor.usage);
|
|
|
|
|
externalAccessDesc.waitFences.push_back(signalFence);
|
|
|
|
@ -771,7 +770,7 @@ TEST_P(D3D12SharedHandleUsageTests, ConcurrentExternalImageReadAccess) {
|
|
|
|
|
// Create Dawn texture with write access, then clear it to red.
|
|
|
|
|
wgpu::Texture texture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture,
|
|
|
|
|
&externalImage);
|
|
|
|
|
|
|
|
|
@ -780,35 +779,35 @@ TEST_P(D3D12SharedHandleUsageTests, ConcurrentExternalImageReadAccess) {
|
|
|
|
|
ASSERT_NE(texture.Get(), nullptr);
|
|
|
|
|
ClearImage(texture.Get(), solidRed, device);
|
|
|
|
|
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
externalImage->EndAccess(texture.Get(), &signalFence);
|
|
|
|
|
texture.Destroy();
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage2 =
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage2 =
|
|
|
|
|
CreateExternalImage(device2.Get(), d3d11Texture.Get(), &baseDawnDescriptor);
|
|
|
|
|
EXPECT_NE(externalImage2, nullptr);
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage3 =
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage3 =
|
|
|
|
|
CreateExternalImage(device3.Get(), d3d11Texture.Get(), &baseDawnDescriptor);
|
|
|
|
|
EXPECT_NE(externalImage3, nullptr);
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage4 =
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage4 =
|
|
|
|
|
CreateExternalImage(device4.Get(), d3d11Texture.Get(), &baseDawnDescriptor);
|
|
|
|
|
EXPECT_NE(externalImage4, nullptr);
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage5 =
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage5 =
|
|
|
|
|
CreateExternalImage(device5.Get(), d3d11Texture.Get(), &baseDawnDescriptor);
|
|
|
|
|
EXPECT_NE(externalImage5, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create two Dawn textures for concurrent read on second device.
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc;
|
|
|
|
|
externalAccessDesc.isInitialized = true;
|
|
|
|
|
externalAccessDesc.usage = WGPUTextureUsage_CopySrc;
|
|
|
|
|
externalAccessDesc.waitFences = {signalFence};
|
|
|
|
|
|
|
|
|
|
// Concurrent read access on device 2 and 3.
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIFenceDescriptor signalFence2;
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIFenceDescriptor signalFence3;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence2;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence3;
|
|
|
|
|
{
|
|
|
|
|
wgpu::Texture texture2 =
|
|
|
|
|
wgpu::Texture::Acquire(externalImage2->BeginAccess(&externalAccessDesc));
|
|
|
|
@ -834,7 +833,7 @@ TEST_P(D3D12SharedHandleUsageTests, ConcurrentExternalImageReadAccess) {
|
|
|
|
|
externalAccessDesc.waitFences = {signalFence2, signalFence3};
|
|
|
|
|
|
|
|
|
|
// Exclusive read-write access on device 4.
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIFenceDescriptor signalFence4;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence4;
|
|
|
|
|
{
|
|
|
|
|
wgpu::Texture texture4 =
|
|
|
|
|
wgpu::Texture::Acquire(externalImage4->BeginAccess(&externalAccessDesc));
|
|
|
|
@ -855,7 +854,7 @@ TEST_P(D3D12SharedHandleUsageTests, ConcurrentExternalImageReadAccess) {
|
|
|
|
|
externalAccessDesc.waitFences = {signalFence4};
|
|
|
|
|
|
|
|
|
|
// Import texture on device 5, but do nothing with it.
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIFenceDescriptor signalFence5;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence5;
|
|
|
|
|
{
|
|
|
|
|
wgpu::Texture texture5 =
|
|
|
|
|
wgpu::Texture::Acquire(externalImage5->BeginAccess(&externalAccessDesc));
|
|
|
|
@ -911,16 +910,16 @@ TEST_P(D3D12SharedHandleUsageTests, ExternalImageUsage) {
|
|
|
|
|
|
|
|
|
|
wgpu::Texture texture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture,
|
|
|
|
|
&externalImage);
|
|
|
|
|
ASSERT_NE(texture.Get(), nullptr);
|
|
|
|
|
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
externalImage->EndAccess(texture.Get(), &signalFence);
|
|
|
|
|
texture.Destroy();
|
|
|
|
|
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc;
|
|
|
|
|
externalAccessDesc.isInitialized = true;
|
|
|
|
|
externalAccessDesc.usage = WGPUTextureUsage_StorageBinding;
|
|
|
|
|
externalAccessDesc.waitFences.push_back(signalFence);
|
|
|
|
@ -940,7 +939,7 @@ TEST_P(D3D12SharedHandleUsageTests, InvalidateExternalImageOnDestroyDevice) {
|
|
|
|
|
|
|
|
|
|
wgpu::Texture texture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
|
|
|
|
|
// Create the Dawn texture then clear it to red.
|
|
|
|
|
WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture,
|
|
|
|
@ -949,14 +948,14 @@ TEST_P(D3D12SharedHandleUsageTests, InvalidateExternalImageOnDestroyDevice) {
|
|
|
|
|
ASSERT_NE(texture.Get(), nullptr);
|
|
|
|
|
ClearImage(texture.Get(), solidRed, device);
|
|
|
|
|
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
externalImage->EndAccess(texture.Get(), &signalFence);
|
|
|
|
|
texture.Destroy();
|
|
|
|
|
|
|
|
|
|
// Do not readback pixels since that requires device to be alive during DawnTest::TearDown().
|
|
|
|
|
DestroyDevice();
|
|
|
|
|
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc;
|
|
|
|
|
externalAccessDesc.isInitialized = true;
|
|
|
|
|
externalAccessDesc.usage = static_cast<WGPUTextureUsageFlags>(baseDawnDescriptor.usage);
|
|
|
|
|
|
|
|
|
@ -969,7 +968,7 @@ TEST_P(D3D12SharedHandleUsageTests, DisallowExternalImageAfterDestroyDevice) {
|
|
|
|
|
|
|
|
|
|
wgpu::Texture texture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
|
|
|
|
|
DestroyDevice();
|
|
|
|
|
|
|
|
|
@ -987,7 +986,7 @@ TEST_P(D3D12SharedHandleUsageTests, CallWriteBufferBeforeDestroyingExternalImage
|
|
|
|
|
|
|
|
|
|
wgpu::Texture texture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture,
|
|
|
|
|
&externalImage);
|
|
|
|
|
|
|
|
|
@ -997,7 +996,7 @@ TEST_P(D3D12SharedHandleUsageTests, CallWriteBufferBeforeDestroyingExternalImage
|
|
|
|
|
wgpu::Buffer buffer = utils::CreateBufferFromData(
|
|
|
|
|
device, wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst, {kExpected});
|
|
|
|
|
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
externalImage->EndAccess(texture.Get(), &signalFence);
|
|
|
|
|
texture.Destroy();
|
|
|
|
|
externalImage = nullptr;
|
|
|
|
@ -1012,7 +1011,7 @@ TEST_P(D3D12SharedHandleUsageTests, SRGBReinterpretation) {
|
|
|
|
|
|
|
|
|
|
wgpu::Texture texture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
|
|
|
|
|
// The texture will be reinterpreted as sRGB.
|
|
|
|
|
wgpu::TextureViewDescriptor viewDesc = {};
|
|
|
|
@ -1068,13 +1067,13 @@ class D3D12SharedHandleMultithreadTests : public D3D12SharedHandleUsageTests {
|
|
|
|
|
TEST_P(D3D12SharedHandleMultithreadTests, DestroyDeviceBeforeImageNoDeadLock) {
|
|
|
|
|
wgpu::Texture texture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture,
|
|
|
|
|
&externalImage);
|
|
|
|
|
|
|
|
|
|
ASSERT_NE(texture.Get(), nullptr);
|
|
|
|
|
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
externalImage->EndAccess(texture.Get(), &signalFence);
|
|
|
|
|
EXPECT_TRUE(externalImage->IsValid());
|
|
|
|
|
|
|
|
|
@ -1088,7 +1087,7 @@ TEST_P(D3D12SharedHandleMultithreadTests, DestroyDeviceBeforeImageNoDeadLock) {
|
|
|
|
|
TEST_P(D3D12SharedHandleMultithreadTests, DestroyDeviceAndUseImageInParallel) {
|
|
|
|
|
wgpu::Texture texture;
|
|
|
|
|
ComPtr<ID3D11Texture2D> d3d11Texture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture,
|
|
|
|
|
&externalImage);
|
|
|
|
|
|
|
|
|
@ -1096,7 +1095,7 @@ TEST_P(D3D12SharedHandleMultithreadTests, DestroyDeviceAndUseImageInParallel) {
|
|
|
|
|
EXPECT_TRUE(externalImage->IsValid());
|
|
|
|
|
|
|
|
|
|
std::thread thread1([&] {
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence;
|
|
|
|
|
externalImage->EndAccess(texture.Get(), &signalFence);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -1130,11 +1129,11 @@ TEST_P(D3D12SharedHandleMultithreadTests, ClearInD3D12ReadbackInD3D11_TwoThreads
|
|
|
|
|
CreateSharedD3D11Texture(baseD3dDescriptor, &d3d11Texture, &d3d11Fence, &sharedHandle,
|
|
|
|
|
&fenceSharedHandle);
|
|
|
|
|
|
|
|
|
|
dawn::native::d3d12::ExternalImageDXGIFenceDescriptor d3d12SignalFence;
|
|
|
|
|
dawn::native::d3d::ExternalImageDXGIFenceDescriptor d3d12SignalFence;
|
|
|
|
|
|
|
|
|
|
std::thread d3d12Thread([=, &d3d12SignalFence] {
|
|
|
|
|
wgpu::Texture dawnTexture;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d12::ExternalImageDXGI> externalImage;
|
|
|
|
|
std::unique_ptr<dawn::native::d3d::ExternalImageDXGI> externalImage;
|
|
|
|
|
WaitAndWrapD3D11Texture(baseDawnDescriptor, sharedHandle, fenceSharedHandle,
|
|
|
|
|
/*fenceWaitValue=*/kD3D11FenceSignalValue, &dawnTexture,
|
|
|
|
|
&externalImage, /*isInitialized=*/true);
|
|
|
|
|