Validate renderer blit descriptors first
This commit is contained in:
@@ -1132,14 +1132,30 @@ void computes_frame_capture_byte_sizes(pp::tests::Harness& h)
|
||||
.format = TextureFormat::rgba8,
|
||||
.usage = TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
};
|
||||
const TextureDesc unsupported_usage_desc {
|
||||
.extent = Extent2D { .width = 16, .height = 8 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.usage = TextureUsage::render_target | TextureUsage::readback_source | static_cast<TextureUsage>(1U << 31U),
|
||||
};
|
||||
const TextureDesc unknown_format_desc {
|
||||
.extent = Extent2D { .width = 16, .height = 8 },
|
||||
.format = static_cast<TextureFormat>(255),
|
||||
.usage = TextureUsage::render_target | TextureUsage::readback_source,
|
||||
};
|
||||
|
||||
const auto capture = frame_capture_byte_size(target_desc);
|
||||
const auto non_target = frame_capture_byte_size(texture_desc);
|
||||
const auto unsupported_usage = frame_capture_byte_size(unsupported_usage_desc);
|
||||
const auto unknown_format = frame_capture_byte_size(unknown_format_desc);
|
||||
|
||||
PP_EXPECT(h, capture.ok());
|
||||
PP_EXPECT(h, capture.value() == 512U);
|
||||
PP_EXPECT(h, !non_target.ok());
|
||||
PP_EXPECT(h, non_target.status().code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !unsupported_usage.ok());
|
||||
PP_EXPECT(h, unsupported_usage.status().code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !unknown_format.ok());
|
||||
PP_EXPECT(h, unknown_format.status().code == StatusCode::invalid_argument);
|
||||
}
|
||||
|
||||
void validates_blit_contract(pp::tests::Harness& h)
|
||||
@@ -1159,6 +1175,16 @@ void validates_blit_contract(pp::tests::Harness& h)
|
||||
.format = TextureFormat::rgba8,
|
||||
.usage = TextureUsage::sampled | TextureUsage::upload_destination | TextureUsage::readback_source | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
};
|
||||
const TextureDesc unknown_format_target_desc {
|
||||
.extent = Extent2D { .width = 16, .height = 8 },
|
||||
.format = static_cast<TextureFormat>(255),
|
||||
.usage = TextureUsage::render_target | TextureUsage::copy_source | TextureUsage::copy_destination,
|
||||
};
|
||||
const TextureDesc unsupported_usage_target_desc {
|
||||
.extent = Extent2D { .width = 16, .height = 8 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.usage = TextureUsage::render_target | TextureUsage::copy_source | TextureUsage::copy_destination | static_cast<TextureUsage>(1U << 31U),
|
||||
};
|
||||
|
||||
PP_EXPECT(h, validate_blit_descs(target_desc, target_desc).ok());
|
||||
PP_EXPECT(h, validate_blit_filter(BlitFilter::nearest).ok());
|
||||
@@ -1167,12 +1193,18 @@ void validates_blit_contract(pp::tests::Harness& h)
|
||||
|
||||
const auto non_target = validate_blit_descs(texture_desc, target_desc);
|
||||
const auto mismatched_format = validate_blit_descs(target_desc, r8_target_desc);
|
||||
const auto unknown_format = validate_blit_descs(unknown_format_target_desc, unknown_format_target_desc);
|
||||
const auto unsupported_usage = validate_blit_descs(unsupported_usage_target_desc, target_desc);
|
||||
const auto bad_filter = validate_blit_filter(static_cast<BlitFilter>(255));
|
||||
|
||||
PP_EXPECT(h, !non_target.ok());
|
||||
PP_EXPECT(h, non_target.code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !mismatched_format.ok());
|
||||
PP_EXPECT(h, mismatched_format.code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !unknown_format.ok());
|
||||
PP_EXPECT(h, unknown_format.code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !unsupported_usage.ok());
|
||||
PP_EXPECT(h, unsupported_usage.code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !bad_filter.ok());
|
||||
PP_EXPECT(h, bad_filter.code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, blit_filter_name(static_cast<BlitFilter>(255)) == std::string_view("unknown"));
|
||||
|
||||
Reference in New Issue
Block a user