BUILD.gn: enable additional warnings.

Skia uses more warnings than Dawn, enable in Dawn directly so that
rolls of Dawn into Skia don't introduce warnings. These warnings
seem useful anyway.

Bug: chromium:1064305

Change-Id: I13dc776af84151131584a95caeee2cd21ae80fea
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/18964
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Corentin Wallez 2020-04-08 16:04:32 +00:00 committed by Commit Bot service account
parent c08a0d40fc
commit 7119a0278d
28 changed files with 148 additions and 119 deletions

View File

@ -86,6 +86,17 @@ config("dawn_internal") {
# Only internal Dawn targets can use this config, this means only targets in
# this BUILD.gn file.
visibility = [ ":*" ]
# Enable more warnings that were found when using Dawn in other projects
if (is_clang) {
cflags = [
"-Wstrict-prototypes",
"-Winconsistent-missing-destructor-override",
"-Wshadow-field",
"-Wmissing-field-initializers",
"-Wcstring-format-directive",
]
}
}
###############################################################################

View File

@ -79,13 +79,14 @@ namespace dawn_native {
RenderBundleEncoder::RenderBundleEncoder(DeviceBase* device,
const RenderBundleEncoderDescriptor* descriptor)
: RenderEncoderBase(device, &mEncodingContext),
mEncodingContext(device, this),
: RenderEncoderBase(device, &mBundleEncodingContext),
mBundleEncodingContext(device, this),
mAttachmentState(device->GetOrCreateAttachmentState(descriptor)) {
}
RenderBundleEncoder::RenderBundleEncoder(DeviceBase* device, ErrorTag errorTag)
: RenderEncoderBase(device, &mEncodingContext, errorTag), mEncodingContext(device, this) {
: RenderEncoderBase(device, &mBundleEncodingContext, errorTag),
mBundleEncodingContext(device, this) {
}
// static
@ -98,18 +99,19 @@ namespace dawn_native {
}
CommandIterator RenderBundleEncoder::AcquireCommands() {
return mEncodingContext.AcquireCommands();
return mBundleEncodingContext.AcquireCommands();
}
RenderBundleBase* RenderBundleEncoder::Finish(const RenderBundleDescriptor* descriptor) {
PassResourceUsage usages = mUsageTracker.AcquireResourceUsage();
DeviceBase* device = GetDevice();
// Even if mEncodingContext.Finish() validation fails, calling it will mutate the internal
// state of the encoding context. Subsequent calls to encode commands will generate errors.
if (device->ConsumedError(mEncodingContext.Finish()) ||
// Even if mBundleEncodingContext.Finish() validation fails, calling it will mutate the
// internal state of the encoding context. Subsequent calls to encode commands will generate
// errors.
if (device->ConsumedError(mBundleEncodingContext.Finish()) ||
(device->IsValidationEnabled() &&
device->ConsumedError(ValidateFinish(mEncodingContext.GetIterator(), usages)))) {
device->ConsumedError(ValidateFinish(mBundleEncodingContext.GetIterator(), usages)))) {
return RenderBundleBase::MakeError(device);
}

View File

@ -44,7 +44,7 @@ namespace dawn_native {
MaybeError ValidateFinish(CommandIterator* commands, const PassResourceUsage& usages) const;
EncodingContext mEncodingContext;
EncodingContext mBundleEncodingContext;
Ref<AttachmentState> mAttachmentState;
};
} // namespace dawn_native

View File

@ -88,7 +88,8 @@ namespace dawn_native {
"Enable residency management. This allows page-in and page-out of resource heaps in "
"GPU memory. This component improves overcommitted performance by keeping the most "
"recently used resources local to the GPU. Turning this component off can cause "
"allocation failures when application memory exceeds physical device memory."}},
"allocation failures when application memory exceeds physical device memory.",
"https://crbug.com/dawn/193"}},
{Toggle::SkipValidation,
{"skip_validation", "Skip expensive validation of Dawn commands.",
"https://crbug.com/dawn/271"}},
@ -111,18 +112,22 @@ namespace dawn_native {
{Toggle::MetalDisableSamplerCompare,
{"metal_disable_sampler_compare",
"Disables the use of sampler compare on Metal. This is unsupported before A9 "
"processors."}},
"processors.",
"https://crbug.com/dawn/342"}},
{Toggle::DisableBaseVertex,
{"disable_base_vertex",
"Disables the use of non-zero base vertex which is unsupported on some platforms."}},
"Disables the use of non-zero base vertex which is unsupported on some platforms.",
"https://crbug.com/dawn/343"}},
{Toggle::DisableBaseInstance,
{"disable_base_instance",
"Disables the use of non-zero base instance which is unsupported on some "
"platforms."}},
"platforms.",
"https://crbug.com/dawn/343"}},
{Toggle::UseD3D12SmallShaderVisibleHeapForTesting,
{"use_d3d12_small_shader_visible_heap",
"Enable use of a small D3D12 shader visible heap, instead of using a large one by "
"default. This setting is used to test bindgroup encoding."}},
"default. This setting is used to test bindgroup encoding.",
"https://crbug.com/dawn/155"}},
}};
} // anonymous namespace

View File

@ -27,7 +27,7 @@ namespace dawn_native { namespace d3d12 {
class Adapter : public AdapterBase {
public:
Adapter(Backend* backend, ComPtr<IDXGIAdapter3> hardwareAdapter);
virtual ~Adapter() = default;
~Adapter() override = default;
const D3D12DeviceInfo& GetDeviceInfo() const;
IDXGIAdapter3* GetHardwareAdapter() const;

View File

@ -46,7 +46,7 @@ namespace dawn_native { namespace d3d12 {
class Device : public DeviceBase {
public:
static ResultOrError<Device*> Create(Adapter* adapter, const DeviceDescriptor* descriptor);
~Device();
~Device() override;
MaybeError Initialize();

View File

@ -27,7 +27,7 @@ namespace dawn_native { namespace d3d12 {
class StagingBuffer : public StagingBufferBase {
public:
StagingBuffer(size_t size, Device* device);
~StagingBuffer();
~StagingBuffer() override;
ID3D12Resource* GetResource() const;

View File

@ -39,7 +39,7 @@ namespace dawn_native { namespace metal {
static ResultOrError<Device*> Create(AdapterBase* adapter,
id<MTLDevice> mtlDevice,
const DeviceDescriptor* descriptor);
~Device();
~Device() override;
MaybeError Initialize();

View File

@ -190,10 +190,10 @@ namespace dawn_native { namespace metal {
std::string result_str;
DAWN_TRY(CheckSpvcSuccess(result.GetStringOutput(&result_str),
"Unable to get MSL shader text"));
mslSource = [NSString stringWithFormat:@"%s", result_str.c_str()];
mslSource = [[NSString alloc] initWithUTF8String:result_str.c_str()];
} else {
std::string msl = compiler->compile();
mslSource = [NSString stringWithFormat:@"%s", msl.c_str()];
mslSource = [[NSString alloc] initWithUTF8String:msl.c_str()];
}
auto mtlDevice = ToBackend(GetDevice())->GetMTLDevice();
NSError* error = nil;
@ -216,7 +216,7 @@ namespace dawn_native { namespace metal {
functionName = "main0";
}
NSString* name = [NSString stringWithFormat:@"%s", functionName];
NSString* name = [[NSString alloc] initWithUTF8String:functionName];
out->function = [library newFunctionWithName:name];
[library release];
}

View File

@ -26,7 +26,7 @@ namespace dawn_native { namespace metal {
class StagingBuffer : public StagingBufferBase {
public:
StagingBuffer(size_t size, Device* device);
~StagingBuffer();
~StagingBuffer() override;
id<MTLBuffer> GetBufferHandle() const;

View File

@ -84,7 +84,7 @@ namespace dawn_native { namespace null {
class Device : public DeviceBase {
public:
static ResultOrError<Device*> Create(Adapter* adapter, const DeviceDescriptor* descriptor);
~Device();
~Device() override;
MaybeError Initialize();
@ -152,7 +152,7 @@ namespace dawn_native { namespace null {
class Adapter : public AdapterBase {
public:
Adapter(InstanceBase* instance);
virtual ~Adapter();
~Adapter() override;
// Used for the tests that intend to use an adapter without all extensions enabled.
void SetSupportedExtensions(const std::vector<const char*>& requiredExtensions);

View File

@ -37,7 +37,7 @@ namespace dawn_native { namespace opengl {
static ResultOrError<Device*> Create(AdapterBase* adapter,
const DeviceDescriptor* descriptor,
const OpenGLFunctions& functions);
~Device();
~Device() override;
MaybeError Initialize();

View File

@ -27,7 +27,7 @@ namespace dawn_native { namespace vulkan {
class Adapter : public AdapterBase {
public:
Adapter(Backend* backend, VkPhysicalDevice physicalDevice);
virtual ~Adapter() = default;
~Adapter() override = default;
const VulkanDeviceInfo& GetDeviceInfo() const;
VkPhysicalDevice GetPhysicalDevice() const;

View File

@ -44,7 +44,7 @@ namespace dawn_native { namespace vulkan {
class Device : public DeviceBase {
public:
static ResultOrError<Device*> Create(Adapter* adapter, const DeviceDescriptor* descriptor);
~Device();
~Device() override;
MaybeError Initialize();

View File

@ -26,7 +26,7 @@ namespace dawn_native { namespace vulkan {
class StagingBuffer : public StagingBufferBase {
public:
StagingBuffer(size_t size, Device* device);
~StagingBuffer();
~StagingBuffer() override;
VkBuffer GetBufferHandle() const;

View File

@ -60,8 +60,8 @@ namespace dawn_native { namespace vulkan {
}
#ifdef DAWN_PLATFORM_LINUX
ExternalImageDescriptorFD::ExternalImageDescriptorFD(ExternalImageDescriptorType type)
: ExternalImageDescriptor(type) {
ExternalImageDescriptorFD::ExternalImageDescriptorFD(ExternalImageDescriptorType descType)
: ExternalImageDescriptor(descType) {
}
ExternalImageDescriptorOpaqueFD::ExternalImageDescriptorOpaqueFD()

View File

@ -20,8 +20,8 @@
namespace dawn_wire { namespace client {
Device::Device(Client* client, uint32_t refcount, uint32_t id)
: ObjectBase(this, refcount, id), mClient(client) {
Device::Device(Client* client, uint32_t initialRefcount, uint32_t initialId)
: ObjectBase(this, initialRefcount, initialId), mClient(client) {
this->device = this;
}

View File

@ -42,7 +42,7 @@ namespace dawn_wire {
class DAWN_WIRE_EXPORT WireClient : public CommandHandler {
public:
WireClient(const WireClientDescriptor& descriptor);
~WireClient();
~WireClient() override;
static DawnProcTable GetProcs();

View File

@ -38,7 +38,7 @@ namespace dawn_wire {
class DAWN_WIRE_EXPORT WireServer : public CommandHandler {
public:
WireServer(const WireServerDescriptor& descriptor);
~WireServer();
~WireServer() override;
const volatile char* HandleCommands(const volatile char* commands,
size_t size) override final;

View File

@ -132,7 +132,7 @@ void InitDawnEnd2EndTestEnvironment(int argc, char** argv);
class DawnTestEnvironment : public testing::Environment {
public:
DawnTestEnvironment(int argc, char** argv);
~DawnTestEnvironment() = default;
~DawnTestEnvironment() override = default;
static void SetEnvironment(DawnTestEnvironment* env);

View File

@ -35,7 +35,6 @@ protected:
}
wgpu::PipelineLayout MakeBasicPipelineLayout(
wgpu::Device device,
std::vector<wgpu::BindGroupLayout> bindingInitializer) const {
wgpu::PipelineLayoutDescriptor descriptor;
@ -103,7 +102,7 @@ protected:
wgpu::ShaderModule vsModule = MakeSimpleVSModule();
wgpu::ShaderModule fsModule = MakeFSModule(bindingTypes);
wgpu::PipelineLayout pipelineLayout = MakeBasicPipelineLayout(device, bindGroupLayouts);
wgpu::PipelineLayout pipelineLayout = MakeBasicPipelineLayout(bindGroupLayouts);
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.layout = pipelineLayout;

View File

@ -59,37 +59,37 @@ namespace {
mD3d11Device = std::move(d3d11Device);
mD3d11DeviceContext = std::move(d3d11DeviceContext);
dawnDescriptor.dimension = wgpu::TextureDimension::e2D;
dawnDescriptor.format = wgpu::TextureFormat::RGBA8Unorm;
dawnDescriptor.size = {kTestWidth, kTestHeight, 1};
dawnDescriptor.sampleCount = 1;
dawnDescriptor.arrayLayerCount = 1;
dawnDescriptor.mipLevelCount = 1;
dawnDescriptor.usage = wgpu::TextureUsage::Sampled | wgpu::TextureUsage::CopySrc |
wgpu::TextureUsage::OutputAttachment |
wgpu::TextureUsage::CopyDst;
baseDawnDescriptor.dimension = wgpu::TextureDimension::e2D;
baseDawnDescriptor.format = wgpu::TextureFormat::RGBA8Unorm;
baseDawnDescriptor.size = {kTestWidth, kTestHeight, 1};
baseDawnDescriptor.sampleCount = 1;
baseDawnDescriptor.arrayLayerCount = 1;
baseDawnDescriptor.mipLevelCount = 1;
baseDawnDescriptor.usage = wgpu::TextureUsage::Sampled | wgpu::TextureUsage::CopySrc |
wgpu::TextureUsage::OutputAttachment |
wgpu::TextureUsage::CopyDst;
d3dDescriptor.Width = kTestWidth;
d3dDescriptor.Height = kTestHeight;
d3dDescriptor.MipLevels = 1;
d3dDescriptor.ArraySize = 1;
d3dDescriptor.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
d3dDescriptor.SampleDesc.Count = 1;
d3dDescriptor.SampleDesc.Quality = 0;
d3dDescriptor.Usage = D3D11_USAGE_DEFAULT;
d3dDescriptor.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
d3dDescriptor.CPUAccessFlags = 0;
d3dDescriptor.MiscFlags =
baseD3dDescriptor.Width = kTestWidth;
baseD3dDescriptor.Height = kTestHeight;
baseD3dDescriptor.MipLevels = 1;
baseD3dDescriptor.ArraySize = 1;
baseD3dDescriptor.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
baseD3dDescriptor.SampleDesc.Count = 1;
baseD3dDescriptor.SampleDesc.Quality = 0;
baseD3dDescriptor.Usage = D3D11_USAGE_DEFAULT;
baseD3dDescriptor.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
baseD3dDescriptor.CPUAccessFlags = 0;
baseD3dDescriptor.MiscFlags =
D3D11_RESOURCE_MISC_SHARED_NTHANDLE | D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX;
}
protected:
void WrapSharedHandle(const wgpu::TextureDescriptor* dawnDescriptor,
const D3D11_TEXTURE2D_DESC* d3dDescriptor,
void WrapSharedHandle(const wgpu::TextureDescriptor* dawnDesc,
const D3D11_TEXTURE2D_DESC* baseD3dDescriptor,
wgpu::Texture* dawnTexture,
ID3D11Texture2D** d3d11TextureOut) const {
ComPtr<ID3D11Texture2D> d3d11Texture;
HRESULT hr = mD3d11Device->CreateTexture2D(d3dDescriptor, nullptr, &d3d11Texture);
HRESULT hr = mD3d11Device->CreateTexture2D(baseD3dDescriptor, nullptr, &d3d11Texture);
ASSERT_EQ(hr, S_OK);
ComPtr<IDXGIResource1> dxgiResource;
@ -104,7 +104,7 @@ namespace {
dawn_native::d3d12::ExternalImageDescriptorDXGISharedHandle externDesc;
externDesc.cTextureDescriptor =
reinterpret_cast<const WGPUTextureDescriptor*>(dawnDescriptor);
reinterpret_cast<const WGPUTextureDescriptor*>(dawnDesc);
externDesc.sharedHandle = sharedHandle;
externDesc.acquireMutexKey = 0;
WGPUTexture texture = dawn_native::d3d12::WrapSharedHandle(device.Get(), &externDesc);
@ -123,8 +123,8 @@ namespace {
ComPtr<ID3D11Device> mD3d11Device;
ComPtr<ID3D11DeviceContext> mD3d11DeviceContext;
D3D11_TEXTURE2D_DESC d3dDescriptor;
wgpu::TextureDescriptor dawnDescriptor;
D3D11_TEXTURE2D_DESC baseD3dDescriptor;
wgpu::TextureDescriptor baseDawnDescriptor;
};
} // anonymous namespace
@ -140,7 +140,7 @@ TEST_P(D3D12SharedHandleValidation, Success) {
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;
WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture);
WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture);
ASSERT_NE(texture.Get(), nullptr);
}
@ -150,11 +150,12 @@ TEST_P(D3D12SharedHandleValidation, InvalidTextureDescriptor) {
DAWN_SKIP_TEST_IF(UsesWire());
wgpu::ChainedStruct chainedDescriptor;
dawnDescriptor.nextInChain = &chainedDescriptor;
baseDawnDescriptor.nextInChain = &chainedDescriptor;
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;
ASSERT_DEVICE_ERROR(WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture));
ASSERT_DEVICE_ERROR(
WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture));
ASSERT_EQ(texture.Get(), nullptr);
}
@ -162,11 +163,12 @@ TEST_P(D3D12SharedHandleValidation, InvalidTextureDescriptor) {
// Test an error occurs if the descriptor mip level count isn't 1
TEST_P(D3D12SharedHandleValidation, InvalidMipLevelCount) {
DAWN_SKIP_TEST_IF(UsesWire());
dawnDescriptor.mipLevelCount = 2;
baseDawnDescriptor.mipLevelCount = 2;
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;
ASSERT_DEVICE_ERROR(WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture));
ASSERT_DEVICE_ERROR(
WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture));
ASSERT_EQ(texture.Get(), nullptr);
}
@ -174,11 +176,12 @@ TEST_P(D3D12SharedHandleValidation, InvalidMipLevelCount) {
// Test an error occurs if the descriptor array layer count isn't 1
TEST_P(D3D12SharedHandleValidation, InvalidArrayLayerCount) {
DAWN_SKIP_TEST_IF(UsesWire());
dawnDescriptor.arrayLayerCount = 2;
baseDawnDescriptor.arrayLayerCount = 2;
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;
ASSERT_DEVICE_ERROR(WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture));
ASSERT_DEVICE_ERROR(
WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture));
ASSERT_EQ(texture.Get(), nullptr);
}
@ -186,11 +189,12 @@ TEST_P(D3D12SharedHandleValidation, InvalidArrayLayerCount) {
// Test an error occurs if the descriptor sample count isn't 1
TEST_P(D3D12SharedHandleValidation, InvalidSampleCount) {
DAWN_SKIP_TEST_IF(UsesWire());
dawnDescriptor.sampleCount = 4;
baseDawnDescriptor.sampleCount = 4;
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;
ASSERT_DEVICE_ERROR(WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture));
ASSERT_DEVICE_ERROR(
WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture));
ASSERT_EQ(texture.Get(), nullptr);
}
@ -198,11 +202,12 @@ TEST_P(D3D12SharedHandleValidation, InvalidSampleCount) {
// Test an error occurs if the descriptor width doesn't match the texture's
TEST_P(D3D12SharedHandleValidation, InvalidWidth) {
DAWN_SKIP_TEST_IF(UsesWire());
dawnDescriptor.size.width = kTestWidth + 1;
baseDawnDescriptor.size.width = kTestWidth + 1;
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;
ASSERT_DEVICE_ERROR(WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture));
ASSERT_DEVICE_ERROR(
WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture));
ASSERT_EQ(texture.Get(), nullptr);
}
@ -210,11 +215,12 @@ TEST_P(D3D12SharedHandleValidation, InvalidWidth) {
// Test an error occurs if the descriptor height doesn't match the texture's
TEST_P(D3D12SharedHandleValidation, InvalidHeight) {
DAWN_SKIP_TEST_IF(UsesWire());
dawnDescriptor.size.height = kTestHeight + 1;
baseDawnDescriptor.size.height = kTestHeight + 1;
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;
ASSERT_DEVICE_ERROR(WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture));
ASSERT_DEVICE_ERROR(
WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture));
ASSERT_EQ(texture.Get(), nullptr);
}
@ -222,11 +228,12 @@ TEST_P(D3D12SharedHandleValidation, InvalidHeight) {
// Test an error occurs if the descriptor format isn't compatible with the D3D12 Resource
TEST_P(D3D12SharedHandleValidation, InvalidFormat) {
DAWN_SKIP_TEST_IF(UsesWire());
dawnDescriptor.format = wgpu::TextureFormat::R8Unorm;
baseDawnDescriptor.format = wgpu::TextureFormat::R8Unorm;
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;
ASSERT_DEVICE_ERROR(WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture));
ASSERT_DEVICE_ERROR(
WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture));
ASSERT_EQ(texture.Get(), nullptr);
}
@ -234,11 +241,12 @@ TEST_P(D3D12SharedHandleValidation, InvalidFormat) {
// Test an error occurs if the number of D3D mip levels is greater than 1.
TEST_P(D3D12SharedHandleValidation, InvalidNumD3DMipLevels) {
DAWN_SKIP_TEST_IF(UsesWire());
d3dDescriptor.MipLevels = 2;
baseD3dDescriptor.MipLevels = 2;
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;
ASSERT_DEVICE_ERROR(WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture));
ASSERT_DEVICE_ERROR(
WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture));
ASSERT_EQ(texture.Get(), nullptr);
}
@ -246,11 +254,12 @@ TEST_P(D3D12SharedHandleValidation, InvalidNumD3DMipLevels) {
// Test an error occurs if the number of array levels is greater than 1.
TEST_P(D3D12SharedHandleValidation, InvalidD3DArraySize) {
DAWN_SKIP_TEST_IF(UsesWire());
d3dDescriptor.ArraySize = 2;
baseD3dDescriptor.ArraySize = 2;
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;
ASSERT_DEVICE_ERROR(WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture));
ASSERT_DEVICE_ERROR(
WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture));
ASSERT_EQ(texture.Get(), nullptr);
}
@ -416,11 +425,11 @@ TEST_P(D3D12SharedHandleUsageTests, ClearInD3D11CopyAndReadbackInD3D12) {
wgpu::Texture dawnSrcTexture;
ComPtr<ID3D11Texture2D> d3d11Texture;
ComPtr<IDXGIKeyedMutex> dxgiKeyedMutex;
WrapAndClearD3D11Texture(&dawnDescriptor, &d3dDescriptor, &dawnSrcTexture, clearColor,
WrapAndClearD3D11Texture(&baseDawnDescriptor, &baseD3dDescriptor, &dawnSrcTexture, clearColor,
&d3d11Texture, &dxgiKeyedMutex);
// Create a texture on the device and copy the source texture to it.
wgpu::Texture dawnCopyDestTexture = device.CreateTexture(&dawnDescriptor);
wgpu::Texture dawnCopyDestTexture = device.CreateTexture(&baseDawnDescriptor);
SimpleCopyTextureToTexture(dawnSrcTexture, dawnCopyDestTexture);
// Readback the destination texture and ensure it contains the colors we used
@ -439,7 +448,7 @@ TEST_P(D3D12SharedHandleUsageTests, ClearInD3D11ReadbackInD3D12) {
wgpu::Texture dawnTexture;
ComPtr<ID3D11Texture2D> d3d11Texture;
ComPtr<IDXGIKeyedMutex> dxgiKeyedMutex;
WrapAndClearD3D11Texture(&dawnDescriptor, &d3dDescriptor, &dawnTexture, clearColor,
WrapAndClearD3D11Texture(&baseDawnDescriptor, &baseD3dDescriptor, &dawnTexture, clearColor,
&d3d11Texture, &dxgiKeyedMutex);
// Readback the destination texture and ensure it contains the colors we used
@ -459,7 +468,7 @@ TEST_P(D3D12SharedHandleUsageTests, ClearInD3D12ReadbackInD3D11) {
wgpu::Texture dawnTexture;
ComPtr<ID3D11Texture2D> d3d11Texture;
ComPtr<IDXGIKeyedMutex> dxgiKeyedMutex;
WrapAndClearD3D11Texture(&dawnDescriptor, &d3dDescriptor, &dawnTexture, d3d11ClearColor,
WrapAndClearD3D11Texture(&baseDawnDescriptor, &baseD3dDescriptor, &dawnTexture, d3d11ClearColor,
&d3d11Texture, &dxgiKeyedMutex);
const wgpu::Color d3d12ClearColor{0.0f, 0.0f, 1.0f, 1.0f};
@ -484,7 +493,7 @@ TEST_P(D3D12SharedHandleUsageTests, ClearTwiceInD3D12ReadbackInD3D11) {
wgpu::Texture dawnTexture;
ComPtr<ID3D11Texture2D> d3d11Texture;
ComPtr<IDXGIKeyedMutex> dxgiKeyedMutex;
WrapAndClearD3D11Texture(&dawnDescriptor, &d3dDescriptor, &dawnTexture, d3d11ClearColor,
WrapAndClearD3D11Texture(&baseDawnDescriptor, &baseD3dDescriptor, &dawnTexture, d3d11ClearColor,
&d3d11Texture, &dxgiKeyedMutex);
const wgpu::Color d3d12ClearColor1{0.0f, 0.0f, 1.0f, 1.0f};
@ -511,7 +520,7 @@ TEST_P(D3D12SharedHandleUsageTests, UnclearedTextureIsCleared) {
wgpu::Texture dawnTexture;
ComPtr<ID3D11Texture2D> d3d11Texture;
ComPtr<IDXGIKeyedMutex> dxgiKeyedMutex;
WrapAndClearD3D11Texture(&dawnDescriptor, &d3dDescriptor, &dawnTexture, clearColor,
WrapAndClearD3D11Texture(&baseDawnDescriptor, &baseD3dDescriptor, &dawnTexture, clearColor,
&d3d11Texture, &dxgiKeyedMutex, false);
// Readback the destination texture and ensure it contains the colors we used

View File

@ -28,7 +28,7 @@ void InitDawnPerfTestEnvironment(int argc, char** argv);
class DawnPerfTestEnvironment : public DawnTestEnvironment {
public:
DawnPerfTestEnvironment(int argc, char** argv);
~DawnPerfTestEnvironment();
~DawnPerfTestEnvironment() override;
void SetUp() override;
void TearDown() override;

View File

@ -27,7 +27,7 @@
class ValidationTest : public testing::Test {
public:
ValidationTest();
~ValidationTest();
~ValidationTest() override;
wgpu::Device CreateDeviceFromAdapter(dawn_native::Adapter adapter,
const std::vector<const char*>& requiredExtensions);

View File

@ -315,12 +315,12 @@ TEST_F(WireArgumentTests, StructureOfStructureArrayArgument) {
static constexpr int NUM_BINDINGS = 3;
WGPUBindGroupLayoutEntry bindings[NUM_BINDINGS]{
{0, WGPUShaderStage_Vertex, WGPUBindingType_Sampler, false, false,
WGPUTextureViewDimension_2D, WGPUTextureComponentType_Float},
WGPUTextureViewDimension_2D, WGPUTextureComponentType_Float, WGPUTextureFormat_RGBA8Unorm},
{1, WGPUShaderStage_Vertex, WGPUBindingType_SampledTexture, false, false,
WGPUTextureViewDimension_2D, WGPUTextureComponentType_Float},
WGPUTextureViewDimension_2D, WGPUTextureComponentType_Float, WGPUTextureFormat_RGBA8Unorm},
{2, static_cast<WGPUShaderStage>(WGPUShaderStage_Vertex | WGPUShaderStage_Fragment),
WGPUBindingType_UniformBuffer, false, false, WGPUTextureViewDimension_2D,
WGPUTextureComponentType_Float},
WGPUTextureComponentType_Float, WGPUTextureFormat_RGBA8Unorm},
};
WGPUBindGroupLayoutDescriptor bglDescriptor = {};
bglDescriptor.bindingCount = NUM_BINDINGS;

View File

@ -55,8 +55,7 @@ class D3D12DescriptorHeapTests : public DawnTest {
})");
}
utils::BasicRenderPass MakeRenderPass(const wgpu::Device& device,
uint32_t width,
utils::BasicRenderPass MakeRenderPass(uint32_t width,
uint32_t height,
wgpu::TextureFormat format) {
DAWN_ASSERT(width > 0 && height > 0);
@ -291,7 +290,7 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBO) {
dawn_native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting));
utils::BasicRenderPass renderPass =
MakeRenderPass(device, kRTSize, kRTSize, wgpu::TextureFormat::R32Float);
MakeRenderPass(kRTSize, kRTSize, wgpu::TextureFormat::R32Float);
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.vertexStage.module = mSimpleVSModule;

View File

@ -99,7 +99,7 @@ namespace dawn_native { namespace vulkan {
return gbmBo;
}
wgpu::Texture WrapVulkanImage(wgpu::Device device,
wgpu::Texture WrapVulkanImage(wgpu::Device dawnDevice,
const wgpu::TextureDescriptor* textureDescriptor,
int memoryFd,
uint32_t stride,
@ -117,7 +117,7 @@ namespace dawn_native { namespace vulkan {
descriptor.waitFDs = waitFDs;
WGPUTexture texture =
dawn_native::vulkan::WrapVulkanImage(device.Get(), &descriptor);
dawn_native::vulkan::WrapVulkanImage(dawnDevice.Get(), &descriptor);
if (expectValid) {
EXPECT_NE(texture, nullptr) << "Failed to wrap image, are external memory / "
@ -132,8 +132,8 @@ namespace dawn_native { namespace vulkan {
// Exports the signal from a wrapped texture and ignores it
// We have to export the signal before destroying the wrapped texture else it's an
// assertion failure
void IgnoreSignalSemaphore(wgpu::Device device, wgpu::Texture wrappedTexture) {
int fd = dawn_native::vulkan::ExportSignalSemaphoreOpaqueFD(device.Get(),
void IgnoreSignalSemaphore(wgpu::Device dawnDevice, wgpu::Texture wrappedTexture) {
int fd = dawn_native::vulkan::ExportSignalSemaphoreOpaqueFD(dawnDevice.Get(),
wrappedTexture.Get());
ASSERT_NE(fd, -1);
close(fd);
@ -289,7 +289,9 @@ namespace dawn_native { namespace vulkan {
dawn_native::vulkan::Device* secondDeviceVk;
// Clear a texture on a given device
void ClearImage(wgpu::Device device, wgpu::Texture wrappedTexture, wgpu::Color clearColor) {
void ClearImage(wgpu::Device dawnDevice,
wgpu::Texture wrappedTexture,
wgpu::Color clearColor) {
wgpu::TextureView wrappedView = wrappedTexture.CreateView();
// Submit a clear operation
@ -297,19 +299,19 @@ namespace dawn_native { namespace vulkan {
renderPassDescriptor.cColorAttachments[0].clearColor = clearColor;
renderPassDescriptor.cColorAttachments[0].loadOp = wgpu::LoadOp::Clear;
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::CommandEncoder encoder = dawnDevice.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPassDescriptor);
pass.EndPass();
wgpu::CommandBuffer commands = encoder.Finish();
wgpu::Queue queue = device.CreateQueue();
wgpu::Queue queue = dawnDevice.CreateQueue();
queue.Submit(1, &commands);
}
// Submits a 1x1x1 copy from source to destination
void SimpleCopyTextureToTexture(wgpu::Device device,
wgpu::Queue queue,
void SimpleCopyTextureToTexture(wgpu::Device dawnDevice,
wgpu::Queue dawnQueue,
wgpu::Texture source,
wgpu::Texture destination) {
wgpu::TextureCopyView copySrc;
@ -326,11 +328,11 @@ namespace dawn_native { namespace vulkan {
wgpu::Extent3D copySize = {1, 1, 1};
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::CommandEncoder encoder = dawnDevice.CreateCommandEncoder();
encoder.CopyTextureToTexture(&copySrc, &copyDst, &copySize);
wgpu::CommandBuffer commands = encoder.Finish();
queue.Submit(1, &commands);
dawnQueue.Submit(1, &commands);
}
};

View File

@ -152,7 +152,7 @@ namespace dawn_native { namespace vulkan {
}
// Wraps a vulkan image from external memory
wgpu::Texture WrapVulkanImage(wgpu::Device device,
wgpu::Texture WrapVulkanImage(wgpu::Device dawnDevice,
const wgpu::TextureDescriptor* textureDescriptor,
int memoryFd,
VkDeviceSize allocationSize,
@ -170,7 +170,7 @@ namespace dawn_native { namespace vulkan {
descriptor.waitFDs = waitFDs;
WGPUTexture texture =
dawn_native::vulkan::WrapVulkanImage(device.Get(), &descriptor);
dawn_native::vulkan::WrapVulkanImage(dawnDevice.Get(), &descriptor);
if (expectValid) {
EXPECT_NE(texture, nullptr) << "Failed to wrap image, are external memory / "
@ -185,8 +185,8 @@ namespace dawn_native { namespace vulkan {
// Exports the signal from a wrapped texture and ignores it
// We have to export the signal before destroying the wrapped texture else it's an
// assertion failure
void IgnoreSignalSemaphore(wgpu::Device device, wgpu::Texture wrappedTexture) {
int fd = dawn_native::vulkan::ExportSignalSemaphoreOpaqueFD(device.Get(),
void IgnoreSignalSemaphore(wgpu::Device dawnDevice, wgpu::Texture wrappedTexture) {
int fd = dawn_native::vulkan::ExportSignalSemaphoreOpaqueFD(dawnDevice.Get(),
wrappedTexture.Get());
ASSERT_NE(fd, -1);
close(fd);
@ -407,26 +407,28 @@ namespace dawn_native { namespace vulkan {
int defaultFd;
// Clear a texture on a given device
void ClearImage(wgpu::Device device, wgpu::Texture wrappedTexture, wgpu::Color clearColor) {
void ClearImage(wgpu::Device dawnDevice,
wgpu::Texture wrappedTexture,
wgpu::Color clearColor) {
wgpu::TextureView wrappedView = wrappedTexture.CreateView();
// Submit a clear operation
utils::ComboRenderPassDescriptor renderPassDescriptor({wrappedView}, {});
renderPassDescriptor.cColorAttachments[0].clearColor = clearColor;
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::CommandEncoder encoder = dawnDevice.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPassDescriptor);
pass.EndPass();
wgpu::CommandBuffer commands = encoder.Finish();
wgpu::Queue queue = device.CreateQueue();
wgpu::Queue queue = dawnDevice.CreateQueue();
queue.Submit(1, &commands);
}
// Submits a 1x1x1 copy from source to destination
void SimpleCopyTextureToTexture(wgpu::Device device,
wgpu::Queue queue,
void SimpleCopyTextureToTexture(wgpu::Device dawnDevice,
wgpu::Queue dawnQueue,
wgpu::Texture source,
wgpu::Texture destination) {
wgpu::TextureCopyView copySrc;
@ -443,11 +445,11 @@ namespace dawn_native { namespace vulkan {
wgpu::Extent3D copySize = {1, 1, 1};
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::CommandEncoder encoder = dawnDevice.CreateCommandEncoder();
encoder.CopyTextureToTexture(&copySrc, &copyDst, &copySize);
wgpu::CommandBuffer commands = encoder.Finish();
queue.Submit(1, &commands);
dawnQueue.Submit(1, &commands);
}
};