mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-03 03:35:59 +00:00
dawn: Add Device::CreateErrorTexture(desc)
This will be used by Blink to create error textures with correct reflection information exposed to JavaScript. Bug: chromium:1345736 Change-Id: I0bc3a72d602c1bb57dc76e90f4883951f86ef428 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96681 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Shrek Shao <shrekshao@google.com> Commit-Queue: Shrek Shao <shrekshao@google.com> Reviewed-by: Austin Eng <enga@chromium.org> Auto-Submit: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
eb02cd3301
commit
256e026f64
@ -1109,6 +1109,14 @@
|
|||||||
{"name": "descriptor", "type": "texture descriptor", "annotation": "const*"}
|
{"name": "descriptor", "type": "texture descriptor", "annotation": "const*"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "create error texture",
|
||||||
|
"returns": "texture",
|
||||||
|
"tags": ["dawn"],
|
||||||
|
"args": [
|
||||||
|
{"name": "descriptor", "type": "texture descriptor", "annotation": "const*"}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "destroy"
|
"name": "destroy"
|
||||||
},
|
},
|
||||||
|
@ -223,6 +223,7 @@
|
|||||||
"DeviceCreateErrorBuffer",
|
"DeviceCreateErrorBuffer",
|
||||||
"DeviceCreateQuerySet",
|
"DeviceCreateQuerySet",
|
||||||
"DeviceCreateTexture",
|
"DeviceCreateTexture",
|
||||||
|
"DeviceCreateErrorTexture",
|
||||||
"DeviceGetQueue",
|
"DeviceGetQueue",
|
||||||
"DeviceInjectError"
|
"DeviceInjectError"
|
||||||
],
|
],
|
||||||
|
@ -1231,6 +1231,10 @@ ExternalTextureBase* DeviceBase::APICreateErrorExternalTexture() {
|
|||||||
return ExternalTextureBase::MakeError(this);
|
return ExternalTextureBase::MakeError(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextureBase* DeviceBase::APICreateErrorTexture(const TextureDescriptor* desc) {
|
||||||
|
return TextureBase::MakeError(this, desc);
|
||||||
|
}
|
||||||
|
|
||||||
// Other Device API methods
|
// Other Device API methods
|
||||||
|
|
||||||
// Returns true if future ticking is needed.
|
// Returns true if future ticking is needed.
|
||||||
|
@ -266,8 +266,8 @@ class DeviceBase : public RefCountedWithExternalCount {
|
|||||||
|
|
||||||
// For Dawn Wire
|
// For Dawn Wire
|
||||||
BufferBase* APICreateErrorBuffer();
|
BufferBase* APICreateErrorBuffer();
|
||||||
|
|
||||||
ExternalTextureBase* APICreateErrorExternalTexture();
|
ExternalTextureBase* APICreateErrorExternalTexture();
|
||||||
|
TextureBase* APICreateErrorTexture(const TextureDescriptor* desc);
|
||||||
|
|
||||||
QueueBase* APIGetQueue();
|
QueueBase* APIGetQueue();
|
||||||
|
|
||||||
|
@ -945,4 +945,33 @@ TEST_F(TextureValidationTest, CreationParameterReflectionForErrorTextures) {
|
|||||||
CheckTextureMatchesDescriptor(tex, desc);
|
CheckTextureMatchesDescriptor(tex, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test that CreateErrorTexture creates an invalid texture but doesn't produce an error.
|
||||||
|
TEST_F(TextureValidationTest, CreateErrorTexture) {
|
||||||
|
wgpu::TextureDescriptor desc;
|
||||||
|
desc.format = wgpu::TextureFormat::RGBA8Unorm;
|
||||||
|
desc.size = {1, 1, 1};
|
||||||
|
desc.usage = wgpu::TextureUsage::RenderAttachment;
|
||||||
|
|
||||||
|
// Check that the descriptor is valid.
|
||||||
|
device.CreateTexture(&desc);
|
||||||
|
|
||||||
|
// Creating the error texture doesn't produce a validation error.
|
||||||
|
wgpu::Texture tex = device.CreateErrorTexture(&desc);
|
||||||
|
|
||||||
|
// Using the texture, for example to create a view, is an error.
|
||||||
|
ASSERT_DEVICE_ERROR(tex.CreateView());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test that the texture creation parameters are correctly reflected for textures created via
|
||||||
|
// CreateErrorTexture
|
||||||
|
TEST_F(TextureValidationTest, CreationParameterReflectionForCreateErrorTexture) {
|
||||||
|
wgpu::TextureDescriptor desc;
|
||||||
|
desc.format = wgpu::TextureFormat::RGBA8Unorm;
|
||||||
|
desc.size = {1, 1, 1};
|
||||||
|
desc.usage = wgpu::TextureUsage::RenderAttachment;
|
||||||
|
|
||||||
|
wgpu::Texture tex = device.CreateErrorTexture(&desc);
|
||||||
|
CheckTextureMatchesDescriptor(tex, desc);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -212,6 +212,10 @@ WGPUTexture Device::CreateTexture(const WGPUTextureDescriptor* descriptor) {
|
|||||||
return Texture::Create(this, descriptor);
|
return Texture::Create(this, descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WGPUTexture Device::CreateErrorTexture(const WGPUTextureDescriptor* descriptor) {
|
||||||
|
return Texture::CreateError(this, descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
WGPUQueue Device::GetQueue() {
|
WGPUQueue Device::GetQueue() {
|
||||||
// The queue is lazily created because if a Device is created by
|
// The queue is lazily created because if a Device is created by
|
||||||
// Reserve/Inject, we cannot send the GetQueue message until
|
// Reserve/Inject, we cannot send the GetQueue message until
|
||||||
|
@ -52,6 +52,7 @@ class Device final : public ObjectBase {
|
|||||||
void* userdata);
|
void* userdata);
|
||||||
WGPUQuerySet CreateQuerySet(const WGPUQuerySetDescriptor* descriptor);
|
WGPUQuerySet CreateQuerySet(const WGPUQuerySetDescriptor* descriptor);
|
||||||
WGPUTexture CreateTexture(const WGPUTextureDescriptor* descriptor);
|
WGPUTexture CreateTexture(const WGPUTextureDescriptor* descriptor);
|
||||||
|
WGPUTexture CreateErrorTexture(const WGPUTextureDescriptor* descriptor);
|
||||||
|
|
||||||
void HandleError(WGPUErrorType errorType, const char* message);
|
void HandleError(WGPUErrorType errorType, const char* message);
|
||||||
void HandleLogging(WGPULoggingType loggingType, const char* message);
|
void HandleLogging(WGPULoggingType loggingType, const char* message);
|
||||||
|
@ -35,6 +35,22 @@ WGPUTexture Texture::Create(Device* device, const WGPUTextureDescriptor* descrip
|
|||||||
return ToAPI(texture);
|
return ToAPI(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
WGPUTexture Texture::CreateError(Device* device, const WGPUTextureDescriptor* descriptor) {
|
||||||
|
Client* wireClient = device->GetClient();
|
||||||
|
Texture* texture = wireClient->Make<Texture>(descriptor);
|
||||||
|
|
||||||
|
// Send the Device::CreateErrorTexture command without modifications.
|
||||||
|
DeviceCreateErrorTextureCmd cmd;
|
||||||
|
cmd.self = ToAPI(device);
|
||||||
|
cmd.selfId = device->GetWireId();
|
||||||
|
cmd.descriptor = descriptor;
|
||||||
|
cmd.result = texture->GetWireHandle();
|
||||||
|
wireClient->SerializeCommand(cmd);
|
||||||
|
|
||||||
|
return ToAPI(texture);
|
||||||
|
}
|
||||||
|
|
||||||
Texture::Texture(const ObjectBaseParams& params, const WGPUTextureDescriptor* descriptor)
|
Texture::Texture(const ObjectBaseParams& params, const WGPUTextureDescriptor* descriptor)
|
||||||
: ObjectBase(params),
|
: ObjectBase(params),
|
||||||
mSize(descriptor->size),
|
mSize(descriptor->size),
|
||||||
|
@ -26,6 +26,7 @@ class Device;
|
|||||||
class Texture final : public ObjectBase {
|
class Texture final : public ObjectBase {
|
||||||
public:
|
public:
|
||||||
static WGPUTexture Create(Device* device, const WGPUTextureDescriptor* descriptor);
|
static WGPUTexture Create(Device* device, const WGPUTextureDescriptor* descriptor);
|
||||||
|
static WGPUTexture CreateError(Device* device, const WGPUTextureDescriptor* descriptor);
|
||||||
|
|
||||||
Texture(const ObjectBaseParams& params, const WGPUTextureDescriptor* descriptor);
|
Texture(const ObjectBaseParams& params, const WGPUTextureDescriptor* descriptor);
|
||||||
~Texture() override;
|
~Texture() override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user