Add renderer scissor state contract
This commit is contained in:
@@ -131,6 +131,38 @@ pp::foundation::Status validate_viewport(Viewport viewport, Extent2D target_exte
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
pp::foundation::Status validate_scissor(ScissorRect scissor, Extent2D target_extent) noexcept
|
||||
{
|
||||
const auto extent_status = validate_extent(target_extent);
|
||||
if (!extent_status.ok()) {
|
||||
return extent_status;
|
||||
}
|
||||
|
||||
if (!scissor.enabled) {
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
if (scissor.x < 0 || scissor.y < 0) {
|
||||
return pp::foundation::Status::invalid_argument("scissor origin must be non-negative");
|
||||
}
|
||||
|
||||
if (scissor.width == 0 || scissor.height == 0) {
|
||||
return pp::foundation::Status::invalid_argument("scissor size must be greater than zero");
|
||||
}
|
||||
|
||||
const auto x = static_cast<std::uint32_t>(scissor.x);
|
||||
const auto y = static_cast<std::uint32_t>(scissor.y);
|
||||
if (x > target_extent.width || y > target_extent.height) {
|
||||
return pp::foundation::Status::out_of_range("scissor origin is outside the render target");
|
||||
}
|
||||
|
||||
if (scissor.width > target_extent.width - x || scissor.height > target_extent.height - y) {
|
||||
return pp::foundation::Status::out_of_range("scissor exceeds render target bounds");
|
||||
}
|
||||
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
pp::foundation::Status validate_blend_factor(BlendFactor factor) noexcept
|
||||
{
|
||||
switch (factor) {
|
||||
|
||||
Reference in New Issue
Block a user