Add renderer texture usage contract
This commit is contained in:
@@ -26,6 +26,7 @@ using pp::renderer::DepthState;
|
||||
using pp::renderer::DrawDesc;
|
||||
using pp::renderer::Extent2D;
|
||||
using pp::renderer::frame_capture_byte_size;
|
||||
using pp::renderer::has_texture_usage;
|
||||
using pp::renderer::ICommandContext;
|
||||
using pp::renderer::IMesh;
|
||||
using pp::renderer::IRenderDevice;
|
||||
@@ -53,6 +54,7 @@ using pp::renderer::ShaderProgramDesc;
|
||||
using pp::renderer::ShaderStageSource;
|
||||
using pp::renderer::TextureDesc;
|
||||
using pp::renderer::TextureFormat;
|
||||
using pp::renderer::TextureUsage;
|
||||
using pp::renderer::Viewport;
|
||||
using pp::renderer::max_shader_source_bytes;
|
||||
using pp::renderer::max_shader_uniform_bytes;
|
||||
@@ -85,7 +87,9 @@ using pp::renderer::validate_shader_catalog;
|
||||
using pp::renderer::validate_shader_program_desc;
|
||||
using pp::renderer::validate_shader_uniform_write;
|
||||
using pp::renderer::validate_texture_copy_descs;
|
||||
using pp::renderer::validate_texture_desc;
|
||||
using pp::renderer::validate_texture_slot;
|
||||
using pp::renderer::validate_texture_usage;
|
||||
using pp::renderer::validate_viewport;
|
||||
|
||||
namespace {
|
||||
@@ -95,7 +99,7 @@ public:
|
||||
explicit FakeRenderTarget(TextureDesc desc = TextureDesc {
|
||||
.extent = Extent2D { .width = 64, .height = 32 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.render_target = true,
|
||||
.usage = TextureUsage::render_target | TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
}) noexcept
|
||||
: desc_(desc)
|
||||
{
|
||||
@@ -151,7 +155,7 @@ public:
|
||||
explicit FakeTexture(TextureDesc desc = TextureDesc {
|
||||
.extent = Extent2D { .width = 64, .height = 32 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.render_target = true,
|
||||
.usage = TextureUsage::render_target | TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
}) noexcept
|
||||
: desc_(desc)
|
||||
{
|
||||
@@ -204,6 +208,9 @@ public:
|
||||
if (!render_pass_status.ok()) {
|
||||
return render_pass_status;
|
||||
}
|
||||
if (!has_texture_usage(target.color_desc().usage, TextureUsage::render_target)) {
|
||||
return pp::foundation::Status::invalid_argument("render target texture must allow render_target usage");
|
||||
}
|
||||
in_render_pass = true;
|
||||
last_render_pass_desc = desc;
|
||||
return validate_extent(target.color_desc().extent);
|
||||
@@ -291,6 +298,9 @@ public:
|
||||
if (!slot_status.ok()) {
|
||||
return slot_status;
|
||||
}
|
||||
if (!has_texture_usage(texture.desc().usage, TextureUsage::sampled)) {
|
||||
return pp::foundation::Status::invalid_argument("bound texture must allow sampled usage");
|
||||
}
|
||||
const auto bytes = texture_byte_size(texture.desc());
|
||||
if (!bytes) {
|
||||
return bytes.status();
|
||||
@@ -354,6 +364,9 @@ public:
|
||||
ReadbackRegion region,
|
||||
pp::renderer::IReadbackBuffer& destination) noexcept override
|
||||
{
|
||||
if (!has_texture_usage(texture.desc().usage, TextureUsage::readback_source)) {
|
||||
return pp::foundation::Status::invalid_argument("readback texture must allow readback_source usage");
|
||||
}
|
||||
const auto bytes = readback_byte_size(texture.desc(), region);
|
||||
if (!bytes) {
|
||||
return bytes.status();
|
||||
@@ -370,6 +383,9 @@ public:
|
||||
ReadbackRegion region,
|
||||
std::span<const std::byte> rgba_or_channel_bytes) noexcept override
|
||||
{
|
||||
if (!has_texture_usage(texture.desc().usage, TextureUsage::upload_destination)) {
|
||||
return pp::foundation::Status::invalid_argument("texture upload destination must allow upload_destination usage");
|
||||
}
|
||||
const auto bytes = readback_byte_size(texture.desc(), region);
|
||||
if (!bytes) {
|
||||
return bytes.status();
|
||||
@@ -511,9 +527,9 @@ public:
|
||||
[[nodiscard]] pp::foundation::Result<std::unique_ptr<IRenderTarget>> create_render_target(
|
||||
TextureDesc color_desc) noexcept override
|
||||
{
|
||||
if (!color_desc.render_target) {
|
||||
if (!has_texture_usage(color_desc.usage, TextureUsage::render_target)) {
|
||||
return pp::foundation::Result<std::unique_ptr<IRenderTarget>>::failure(
|
||||
pp::foundation::Status::invalid_argument("render target texture must be flagged as render_target"));
|
||||
pp::foundation::Status::invalid_argument("render target texture must allow render_target usage"));
|
||||
}
|
||||
|
||||
const auto bytes = texture_byte_size(color_desc);
|
||||
@@ -590,6 +606,13 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
constexpr TextureUsage all_texture_usages = TextureUsage::sampled
|
||||
| TextureUsage::render_target
|
||||
| TextureUsage::upload_destination
|
||||
| TextureUsage::readback_source
|
||||
| TextureUsage::copy_source
|
||||
| TextureUsage::copy_destination;
|
||||
|
||||
void computes_texture_sizes(pp::tests::Harness& h)
|
||||
{
|
||||
const auto rgba = texture_byte_size(TextureDesc {
|
||||
@@ -608,6 +631,51 @@ void computes_texture_sizes(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, texture_format_name(TextureFormat::depth24_stencil8) == std::string_view("depth24_stencil8"));
|
||||
}
|
||||
|
||||
void validates_texture_usage_contract(pp::tests::Harness& h)
|
||||
{
|
||||
const TextureDesc sampled_desc {
|
||||
.extent = Extent2D { .width = 4, .height = 4 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.usage = TextureUsage::sampled,
|
||||
};
|
||||
const TextureDesc all_usage_desc {
|
||||
.extent = Extent2D { .width = 4, .height = 4 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.usage = all_texture_usages,
|
||||
};
|
||||
const TextureDesc empty_usage_desc {
|
||||
.extent = Extent2D { .width = 4, .height = 4 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.usage = TextureUsage::none,
|
||||
};
|
||||
const TextureDesc unknown_usage_desc {
|
||||
.extent = Extent2D { .width = 4, .height = 4 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.usage = static_cast<TextureUsage>(1U << 31U),
|
||||
};
|
||||
const TextureDesc unknown_format_desc {
|
||||
.extent = Extent2D { .width = 4, .height = 4 },
|
||||
.format = static_cast<TextureFormat>(255),
|
||||
};
|
||||
|
||||
PP_EXPECT(h, has_texture_usage(all_texture_usages, TextureUsage::render_target));
|
||||
PP_EXPECT(h, !has_texture_usage(TextureUsage::sampled, TextureUsage::render_target));
|
||||
PP_EXPECT(h, validate_texture_usage(TextureUsage::sampled | TextureUsage::copy_source).ok());
|
||||
PP_EXPECT(h, validate_texture_desc(sampled_desc).ok());
|
||||
PP_EXPECT(h, validate_texture_desc(all_usage_desc).ok());
|
||||
|
||||
const auto empty_usage = validate_texture_desc(empty_usage_desc);
|
||||
const auto unknown_usage = validate_texture_desc(unknown_usage_desc);
|
||||
const auto unknown_format = validate_texture_desc(unknown_format_desc);
|
||||
|
||||
PP_EXPECT(h, !empty_usage.ok());
|
||||
PP_EXPECT(h, empty_usage.code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !unknown_usage.ok());
|
||||
PP_EXPECT(h, unknown_usage.code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !unknown_format.ok());
|
||||
PP_EXPECT(h, unknown_format.code == StatusCode::invalid_argument);
|
||||
}
|
||||
|
||||
void rejects_invalid_or_excessive_extents(pp::tests::Harness& h)
|
||||
{
|
||||
const auto zero = validate_extent(Extent2D { .width = 0, .height = 1 });
|
||||
@@ -630,7 +698,7 @@ void validates_readback_bounds(pp::tests::Harness& h)
|
||||
const TextureDesc desc {
|
||||
.extent = Extent2D { .width = 64, .height = 32 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.render_target = true,
|
||||
.usage = TextureUsage::render_target | TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
};
|
||||
|
||||
PP_EXPECT(h, validate_readback_region(desc, ReadbackRegion { .x = 0, .y = 0, .width = 64, .height = 32 }).ok());
|
||||
@@ -653,12 +721,12 @@ void computes_readback_byte_sizes(pp::tests::Harness& h)
|
||||
const TextureDesc rgba_desc {
|
||||
.extent = Extent2D { .width = 64, .height = 32 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.render_target = true,
|
||||
.usage = TextureUsage::render_target | TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
};
|
||||
const TextureDesc r8_desc {
|
||||
.extent = Extent2D { .width = 64, .height = 32 },
|
||||
.format = TextureFormat::r8,
|
||||
.render_target = true,
|
||||
.usage = TextureUsage::render_target | TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
};
|
||||
|
||||
const auto rgba = readback_byte_size(rgba_desc, ReadbackRegion { .x = 4, .y = 2, .width = 8, .height = 3 });
|
||||
@@ -678,12 +746,12 @@ void computes_frame_capture_byte_sizes(pp::tests::Harness& h)
|
||||
const TextureDesc target_desc {
|
||||
.extent = Extent2D { .width = 16, .height = 8 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.render_target = true,
|
||||
.usage = TextureUsage::render_target | TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
};
|
||||
const TextureDesc texture_desc {
|
||||
.extent = Extent2D { .width = 16, .height = 8 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.render_target = false,
|
||||
.usage = TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
};
|
||||
|
||||
const auto capture = frame_capture_byte_size(target_desc);
|
||||
@@ -700,17 +768,17 @@ void validates_blit_contract(pp::tests::Harness& h)
|
||||
const TextureDesc target_desc {
|
||||
.extent = Extent2D { .width = 16, .height = 8 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.render_target = true,
|
||||
.usage = TextureUsage::render_target | TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
};
|
||||
const TextureDesc r8_target_desc {
|
||||
.extent = Extent2D { .width = 16, .height = 8 },
|
||||
.format = TextureFormat::r8,
|
||||
.render_target = true,
|
||||
.usage = TextureUsage::render_target | TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
};
|
||||
const TextureDesc texture_desc {
|
||||
.extent = Extent2D { .width = 16, .height = 8 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.render_target = false,
|
||||
.usage = TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
};
|
||||
|
||||
PP_EXPECT(h, validate_blit_descs(target_desc, target_desc).ok());
|
||||
@@ -1239,12 +1307,12 @@ void render_devices_create_validated_resources(pp::tests::Harness& h)
|
||||
const auto texture = device.create_texture(TextureDesc {
|
||||
.extent = Extent2D { .width = 8, .height = 4 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.render_target = false,
|
||||
.usage = TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
});
|
||||
const auto target = device.create_render_target(TextureDesc {
|
||||
.extent = Extent2D { .width = 8, .height = 4 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.render_target = true,
|
||||
.usage = TextureUsage::render_target | TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
});
|
||||
const auto shader = device.create_shader_program(ShaderProgramDesc {
|
||||
.debug_name = "factory-shader",
|
||||
@@ -1260,9 +1328,9 @@ void render_devices_create_validated_resources(pp::tests::Harness& h)
|
||||
|
||||
PP_EXPECT(h, texture.ok());
|
||||
PP_EXPECT(h, texture.value()->desc().extent.width == 8U);
|
||||
PP_EXPECT(h, !texture.value()->desc().render_target);
|
||||
PP_EXPECT(h, !has_texture_usage(texture.value()->desc().usage, TextureUsage::render_target));
|
||||
PP_EXPECT(h, target.ok());
|
||||
PP_EXPECT(h, target.value()->color_desc().render_target);
|
||||
PP_EXPECT(h, has_texture_usage(target.value()->color_desc().usage, TextureUsage::render_target));
|
||||
PP_EXPECT(h, shader.ok());
|
||||
PP_EXPECT(h, shader.value()->debug_name() == std::string_view("factory-shader"));
|
||||
PP_EXPECT(h, mesh.ok());
|
||||
@@ -1277,7 +1345,7 @@ void render_devices_create_validated_resources(pp::tests::Harness& h)
|
||||
const auto bad_target = device.create_render_target(TextureDesc {
|
||||
.extent = Extent2D { .width = 8, .height = 4 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.render_target = false,
|
||||
.usage = TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
});
|
||||
const auto bad_shader = device.create_shader_program(ShaderProgramDesc {
|
||||
.debug_name = "bad-shader",
|
||||
@@ -1305,7 +1373,7 @@ void recording_renderer_records_shader_uniform_writes(pp::tests::Harness& h)
|
||||
RecordingRenderTarget target(TextureDesc {
|
||||
.extent = Extent2D { .width = 16, .height = 8 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.render_target = true,
|
||||
.usage = TextureUsage::render_target | TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
});
|
||||
RecordingShaderProgram shader("uniform-shader");
|
||||
const std::array<std::byte, 64> uniform_bytes {};
|
||||
@@ -1348,19 +1416,19 @@ void recording_renderer_records_valid_command_sequences(pp::tests::Harness& h)
|
||||
RecordingTexture2D texture(TextureDesc {
|
||||
.extent = Extent2D { .width = 64, .height = 32 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.render_target = true,
|
||||
.usage = TextureUsage::render_target | TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
});
|
||||
RecordingReadbackBuffer readback_buffer(64U * 32U * 4U);
|
||||
const std::array<std::byte, 96> upload_bytes {};
|
||||
RecordingRenderTarget target(TextureDesc {
|
||||
.extent = Extent2D { .width = 64, .height = 32 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.render_target = true,
|
||||
.usage = TextureUsage::render_target | TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
});
|
||||
RecordingRenderTarget blit_target(TextureDesc {
|
||||
.extent = Extent2D { .width = 64, .height = 32 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.render_target = true,
|
||||
.usage = TextureUsage::render_target | TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
});
|
||||
RecordingShaderProgram shader("recorded-shader");
|
||||
RecordingMesh mesh(MeshDesc { .vertex_count = 3, .index_count = 3, .topology = PrimitiveTopology::triangles });
|
||||
@@ -1540,22 +1608,57 @@ void recording_renderer_rejects_invalid_command_order_and_targets(pp::tests::Har
|
||||
RecordingRenderTarget target(TextureDesc {
|
||||
.extent = Extent2D { .width = 32, .height = 16 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.render_target = true,
|
||||
.usage = TextureUsage::render_target | TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
});
|
||||
RecordingRenderTarget non_render_target(TextureDesc {
|
||||
.extent = Extent2D { .width = 32, .height = 16 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.render_target = false,
|
||||
.usage = TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
});
|
||||
RecordingRenderTarget r8_target(TextureDesc {
|
||||
.extent = Extent2D { .width = 32, .height = 16 },
|
||||
.format = TextureFormat::r8,
|
||||
.render_target = true,
|
||||
.usage = TextureUsage::render_target | TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
});
|
||||
RecordingTexture2D texture(TextureDesc {
|
||||
.extent = Extent2D { .width = 32, .height = 16 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.render_target = true,
|
||||
.usage = TextureUsage::render_target | TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
});
|
||||
RecordingTexture2D texture_without_sampled(TextureDesc {
|
||||
.extent = Extent2D { .width = 32, .height = 16 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.usage = TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
});
|
||||
RecordingTexture2D texture_without_upload(TextureDesc {
|
||||
.extent = Extent2D { .width = 32, .height = 16 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.usage = TextureUsage::sampled | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
});
|
||||
RecordingTexture2D texture_without_readback(TextureDesc {
|
||||
.extent = Extent2D { .width = 32, .height = 16 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.usage = TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
});
|
||||
RecordingTexture2D texture_without_copy_source(TextureDesc {
|
||||
.extent = Extent2D { .width = 32, .height = 16 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.usage = TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_destination,
|
||||
});
|
||||
RecordingTexture2D texture_without_copy_destination(TextureDesc {
|
||||
.extent = Extent2D { .width = 32, .height = 16 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.usage = TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source,
|
||||
});
|
||||
RecordingRenderTarget target_without_copy_source(TextureDesc {
|
||||
.extent = Extent2D { .width = 32, .height = 16 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.usage = TextureUsage::render_target | TextureUsage::copy_destination | TextureUsage::readback_source,
|
||||
});
|
||||
RecordingRenderTarget target_without_copy_destination(TextureDesc {
|
||||
.extent = Extent2D { .width = 32, .height = 16 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.usage = TextureUsage::render_target | TextureUsage::copy_source | TextureUsage::readback_source,
|
||||
});
|
||||
RecordingReadbackBuffer small_readback_buffer(3U);
|
||||
RecordingReadbackBuffer full_readback_buffer(32U * 16U * 4U);
|
||||
@@ -1692,6 +1795,11 @@ void recording_renderer_rejects_invalid_command_order_and_targets(pp::tests::Har
|
||||
const auto bind_texture_bad_slot = context.bind_texture(max_texture_slots, texture);
|
||||
PP_EXPECT(h, !bind_texture_bad_slot.ok());
|
||||
PP_EXPECT(h, bind_texture_bad_slot.code == StatusCode::out_of_range);
|
||||
|
||||
const auto bind_texture_without_sampled = context.bind_texture(0, texture_without_sampled);
|
||||
PP_EXPECT(h, !bind_texture_without_sampled.ok());
|
||||
PP_EXPECT(h, bind_texture_without_sampled.code == StatusCode::invalid_argument);
|
||||
|
||||
PP_EXPECT(h, context.bind_texture(0, texture).ok());
|
||||
|
||||
const auto bind_sampler_bad_slot = context.bind_sampler(max_texture_slots, SamplerDesc {});
|
||||
@@ -1759,6 +1867,13 @@ void recording_renderer_rejects_invalid_command_order_and_targets(pp::tests::Har
|
||||
PP_EXPECT(h, !upload_outside_bounds.ok());
|
||||
PP_EXPECT(h, upload_outside_bounds.code == StatusCode::out_of_range);
|
||||
|
||||
const auto upload_without_usage = context.upload_texture(
|
||||
texture_without_upload,
|
||||
ReadbackRegion { .x = 0, .y = 0, .width = 1, .height = 1 },
|
||||
one_pixel_upload);
|
||||
PP_EXPECT(h, !upload_without_usage.ok());
|
||||
PP_EXPECT(h, upload_without_usage.code == StatusCode::invalid_argument);
|
||||
|
||||
const auto copy_mismatched_regions = context.copy_texture(
|
||||
texture,
|
||||
ReadbackRegion { .x = 0, .y = 0, .width = 2, .height = 1 },
|
||||
@@ -1775,6 +1890,22 @@ void recording_renderer_rejects_invalid_command_order_and_targets(pp::tests::Har
|
||||
PP_EXPECT(h, !copy_outside_bounds.ok());
|
||||
PP_EXPECT(h, copy_outside_bounds.code == StatusCode::out_of_range);
|
||||
|
||||
const auto copy_without_source_usage = context.copy_texture(
|
||||
texture_without_copy_source,
|
||||
ReadbackRegion { .x = 0, .y = 0, .width = 1, .height = 1 },
|
||||
texture,
|
||||
ReadbackRegion { .x = 0, .y = 0, .width = 1, .height = 1 });
|
||||
PP_EXPECT(h, !copy_without_source_usage.ok());
|
||||
PP_EXPECT(h, copy_without_source_usage.code == StatusCode::invalid_argument);
|
||||
|
||||
const auto copy_without_destination_usage = context.copy_texture(
|
||||
texture,
|
||||
ReadbackRegion { .x = 0, .y = 0, .width = 1, .height = 1 },
|
||||
texture_without_copy_destination,
|
||||
ReadbackRegion { .x = 0, .y = 0, .width = 1, .height = 1 });
|
||||
PP_EXPECT(h, !copy_without_destination_usage.ok());
|
||||
PP_EXPECT(h, copy_without_destination_usage.code == StatusCode::invalid_argument);
|
||||
|
||||
const auto upload_with_wrong_size = context.upload_texture(
|
||||
texture,
|
||||
ReadbackRegion { .x = 0, .y = 0, .width = 1, .height = 1 },
|
||||
@@ -1782,6 +1913,13 @@ void recording_renderer_rejects_invalid_command_order_and_targets(pp::tests::Har
|
||||
PP_EXPECT(h, !upload_with_wrong_size.ok());
|
||||
PP_EXPECT(h, upload_with_wrong_size.code == StatusCode::invalid_argument);
|
||||
|
||||
const auto read_without_usage = context.read_texture(
|
||||
texture_without_readback,
|
||||
ReadbackRegion { .x = 0, .y = 0, .width = 1, .height = 1 },
|
||||
full_readback_buffer);
|
||||
PP_EXPECT(h, !read_without_usage.ok());
|
||||
PP_EXPECT(h, read_without_usage.code == StatusCode::invalid_argument);
|
||||
|
||||
const auto read_into_small_buffer = context.read_texture(
|
||||
texture,
|
||||
ReadbackRegion { .x = 0, .y = 0, .width = 1, .height = 1 },
|
||||
@@ -1815,6 +1953,24 @@ void recording_renderer_rejects_invalid_command_order_and_targets(pp::tests::Har
|
||||
PP_EXPECT(h, !blit_mismatched_format.ok());
|
||||
PP_EXPECT(h, blit_mismatched_format.code == StatusCode::invalid_argument);
|
||||
|
||||
const auto blit_without_source_usage = context.blit_render_target(
|
||||
target_without_copy_source,
|
||||
ReadbackRegion { .x = 0, .y = 0, .width = 1, .height = 1 },
|
||||
target,
|
||||
ReadbackRegion { .x = 0, .y = 0, .width = 1, .height = 1 },
|
||||
BlitFilter::nearest);
|
||||
PP_EXPECT(h, !blit_without_source_usage.ok());
|
||||
PP_EXPECT(h, blit_without_source_usage.code == StatusCode::invalid_argument);
|
||||
|
||||
const auto blit_without_destination_usage = context.blit_render_target(
|
||||
target,
|
||||
ReadbackRegion { .x = 0, .y = 0, .width = 1, .height = 1 },
|
||||
target_without_copy_destination,
|
||||
ReadbackRegion { .x = 0, .y = 0, .width = 1, .height = 1 },
|
||||
BlitFilter::nearest);
|
||||
PP_EXPECT(h, !blit_without_destination_usage.ok());
|
||||
PP_EXPECT(h, blit_without_destination_usage.code == StatusCode::invalid_argument);
|
||||
|
||||
const auto blit_outside_bounds = context.blit_render_target(
|
||||
target,
|
||||
ReadbackRegion { .x = 31, .y = 15, .width = 2, .height = 1 },
|
||||
@@ -1840,6 +1996,7 @@ int main()
|
||||
{
|
||||
pp::tests::Harness harness;
|
||||
harness.run("computes_texture_sizes", computes_texture_sizes);
|
||||
harness.run("validates_texture_usage_contract", validates_texture_usage_contract);
|
||||
harness.run("rejects_invalid_or_excessive_extents", rejects_invalid_or_excessive_extents);
|
||||
harness.run("validates_readback_bounds", validates_readback_bounds);
|
||||
harness.run("computes_readback_byte_sizes", computes_readback_byte_sizes);
|
||||
|
||||
Reference in New Issue
Block a user