Add renderer blend state contract
This commit is contained in:
@@ -131,6 +131,63 @@ pp::foundation::Status validate_viewport(Viewport viewport, Extent2D target_exte
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
pp::foundation::Status validate_blend_factor(BlendFactor factor) noexcept
|
||||
{
|
||||
switch (factor) {
|
||||
case BlendFactor::zero:
|
||||
case BlendFactor::one:
|
||||
case BlendFactor::source_alpha:
|
||||
case BlendFactor::one_minus_source_alpha:
|
||||
case BlendFactor::destination_alpha:
|
||||
case BlendFactor::one_minus_destination_alpha:
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
return pp::foundation::Status::invalid_argument("blend factor is not supported");
|
||||
}
|
||||
|
||||
pp::foundation::Status validate_blend_op(BlendOp op) noexcept
|
||||
{
|
||||
switch (op) {
|
||||
case BlendOp::add:
|
||||
case BlendOp::subtract:
|
||||
case BlendOp::reverse_subtract:
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
return pp::foundation::Status::invalid_argument("blend operation is not supported");
|
||||
}
|
||||
|
||||
pp::foundation::Status validate_blend_state(BlendState state) noexcept
|
||||
{
|
||||
const auto source_color = validate_blend_factor(state.source_color);
|
||||
if (!source_color.ok()) {
|
||||
return source_color;
|
||||
}
|
||||
|
||||
const auto destination_color = validate_blend_factor(state.destination_color);
|
||||
if (!destination_color.ok()) {
|
||||
return destination_color;
|
||||
}
|
||||
|
||||
const auto color_op = validate_blend_op(state.color_op);
|
||||
if (!color_op.ok()) {
|
||||
return color_op;
|
||||
}
|
||||
|
||||
const auto source_alpha = validate_blend_factor(state.source_alpha);
|
||||
if (!source_alpha.ok()) {
|
||||
return source_alpha;
|
||||
}
|
||||
|
||||
const auto destination_alpha = validate_blend_factor(state.destination_alpha);
|
||||
if (!destination_alpha.ok()) {
|
||||
return destination_alpha;
|
||||
}
|
||||
|
||||
return validate_blend_op(state.alpha_op);
|
||||
}
|
||||
|
||||
pp::foundation::Status validate_mesh_desc(MeshDesc desc) noexcept
|
||||
{
|
||||
if (desc.vertex_count == 0) {
|
||||
@@ -324,4 +381,38 @@ const char* blit_filter_name(BlitFilter filter) noexcept
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
const char* blend_factor_name(BlendFactor factor) noexcept
|
||||
{
|
||||
switch (factor) {
|
||||
case BlendFactor::zero:
|
||||
return "zero";
|
||||
case BlendFactor::one:
|
||||
return "one";
|
||||
case BlendFactor::source_alpha:
|
||||
return "source_alpha";
|
||||
case BlendFactor::one_minus_source_alpha:
|
||||
return "one_minus_source_alpha";
|
||||
case BlendFactor::destination_alpha:
|
||||
return "destination_alpha";
|
||||
case BlendFactor::one_minus_destination_alpha:
|
||||
return "one_minus_destination_alpha";
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
const char* blend_op_name(BlendOp op) noexcept
|
||||
{
|
||||
switch (op) {
|
||||
case BlendOp::add:
|
||||
return "add";
|
||||
case BlendOp::subtract:
|
||||
return "subtract";
|
||||
case BlendOp::reverse_subtract:
|
||||
return "reverse_subtract";
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user