mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-15 08:06:19 +00:00
Replace reinterpret_cast with FromAPI/ToAPI where possible
This brings more type safety to the code and is marginally more readable. Bug: None Change-Id: I0330a8a8e95cd9b8b531af266acd8fdc50c50460 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71606 Reviewed-by: Brandon Jones <bajones@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org> Auto-Submit: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
9dc3c0bc86
commit
c6d3a840da
@@ -318,7 +318,7 @@ TEST_F(CommandBufferValidationTest, DestroyEncoder) {
|
||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
|
||||
pass.EndPass();
|
||||
reinterpret_cast<dawn_native::CommandEncoder*>(encoder.Get())->Destroy();
|
||||
dawn_native::FromAPI(encoder.Get())->Destroy();
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish(), HasSubstr("Destroyed encoder cannot be finished."));
|
||||
}
|
||||
|
||||
@@ -327,13 +327,13 @@ TEST_F(CommandBufferValidationTest, DestroyEncoder) {
|
||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
|
||||
pass.EndPass();
|
||||
reinterpret_cast<dawn_native::CommandEncoder*>(encoder.Get())->Destroy();
|
||||
dawn_native::FromAPI(encoder.Get())->Destroy();
|
||||
}
|
||||
|
||||
// Destroyed encoder should allow encoding, and emit error on finish.
|
||||
{
|
||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
reinterpret_cast<dawn_native::CommandEncoder*>(encoder.Get())->Destroy();
|
||||
dawn_native::FromAPI(encoder.Get())->Destroy();
|
||||
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
|
||||
pass.EndPass();
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish(), HasSubstr("Destroyed encoder cannot be finished."));
|
||||
@@ -342,7 +342,7 @@ TEST_F(CommandBufferValidationTest, DestroyEncoder) {
|
||||
// Destroyed encoder should allow encoding and shouldn't emit an error if never finished.
|
||||
{
|
||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
reinterpret_cast<dawn_native::CommandEncoder*>(encoder.Get())->Destroy();
|
||||
dawn_native::FromAPI(encoder.Get())->Destroy();
|
||||
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
|
||||
pass.EndPass();
|
||||
}
|
||||
@@ -353,21 +353,21 @@ TEST_F(CommandBufferValidationTest, DestroyEncoder) {
|
||||
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
|
||||
pass.EndPass();
|
||||
encoder.Finish();
|
||||
reinterpret_cast<dawn_native::CommandEncoder*>(encoder.Get())->Destroy();
|
||||
dawn_native::FromAPI(encoder.Get())->Destroy();
|
||||
}
|
||||
|
||||
// Destroying an encoder twice should not emit any errors.
|
||||
{
|
||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
reinterpret_cast<dawn_native::CommandEncoder*>(encoder.Get())->Destroy();
|
||||
reinterpret_cast<dawn_native::CommandEncoder*>(encoder.Get())->Destroy();
|
||||
dawn_native::FromAPI(encoder.Get())->Destroy();
|
||||
dawn_native::FromAPI(encoder.Get())->Destroy();
|
||||
}
|
||||
|
||||
// Destroying an encoder twice and then calling finish should fail.
|
||||
{
|
||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
reinterpret_cast<dawn_native::CommandEncoder*>(encoder.Get())->Destroy();
|
||||
reinterpret_cast<dawn_native::CommandEncoder*>(encoder.Get())->Destroy();
|
||||
dawn_native::FromAPI(encoder.Get())->Destroy();
|
||||
dawn_native::FromAPI(encoder.Get())->Destroy();
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish(), HasSubstr("Destroyed encoder cannot be finished."));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,8 +167,7 @@ TEST_F(ShaderModuleValidationTest, GetCompilationMessages) {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
dawn_native::ShaderModuleBase* shaderModuleBase =
|
||||
reinterpret_cast<dawn_native::ShaderModuleBase*>(shaderModule.Get());
|
||||
dawn_native::ShaderModuleBase* shaderModuleBase = dawn_native::FromAPI(shaderModule.Get());
|
||||
dawn_native::OwnedCompilationMessages* messages = shaderModuleBase->GetCompilationMessages();
|
||||
messages->ClearMessages();
|
||||
messages->AddMessageForTesting("Info Message");
|
||||
|
||||
Reference in New Issue
Block a user