Add renderer sampler state contract
This commit is contained in:
@@ -242,6 +242,60 @@ pp::foundation::Status validate_depth_state(DepthState state) noexcept
|
||||
return validate_compare_op(state.compare);
|
||||
}
|
||||
|
||||
pp::foundation::Status validate_sampler_filter(SamplerFilter filter) noexcept
|
||||
{
|
||||
switch (filter) {
|
||||
case SamplerFilter::nearest:
|
||||
case SamplerFilter::linear:
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
return pp::foundation::Status::invalid_argument("sampler filter is not supported");
|
||||
}
|
||||
|
||||
pp::foundation::Status validate_sampler_address_mode(SamplerAddressMode mode) noexcept
|
||||
{
|
||||
switch (mode) {
|
||||
case SamplerAddressMode::clamp_to_edge:
|
||||
case SamplerAddressMode::repeat:
|
||||
case SamplerAddressMode::mirrored_repeat:
|
||||
case SamplerAddressMode::clamp_to_border:
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
return pp::foundation::Status::invalid_argument("sampler address mode is not supported");
|
||||
}
|
||||
|
||||
pp::foundation::Status validate_sampler_desc(SamplerDesc desc) noexcept
|
||||
{
|
||||
const auto min_filter = validate_sampler_filter(desc.min_filter);
|
||||
if (!min_filter.ok()) {
|
||||
return min_filter;
|
||||
}
|
||||
|
||||
const auto mag_filter = validate_sampler_filter(desc.mag_filter);
|
||||
if (!mag_filter.ok()) {
|
||||
return mag_filter;
|
||||
}
|
||||
|
||||
const auto mip_filter = validate_sampler_filter(desc.mip_filter);
|
||||
if (!mip_filter.ok()) {
|
||||
return mip_filter;
|
||||
}
|
||||
|
||||
const auto address_u = validate_sampler_address_mode(desc.address_u);
|
||||
if (!address_u.ok()) {
|
||||
return address_u;
|
||||
}
|
||||
|
||||
const auto address_v = validate_sampler_address_mode(desc.address_v);
|
||||
if (!address_v.ok()) {
|
||||
return address_v;
|
||||
}
|
||||
|
||||
return validate_sampler_address_mode(desc.address_w);
|
||||
}
|
||||
|
||||
pp::foundation::Status validate_mesh_desc(MeshDesc desc) noexcept
|
||||
{
|
||||
if (desc.vertex_count == 0) {
|
||||
@@ -493,4 +547,32 @@ const char* compare_op_name(CompareOp op) noexcept
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
const char* sampler_filter_name(SamplerFilter filter) noexcept
|
||||
{
|
||||
switch (filter) {
|
||||
case SamplerFilter::nearest:
|
||||
return "nearest";
|
||||
case SamplerFilter::linear:
|
||||
return "linear";
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
const char* sampler_address_mode_name(SamplerAddressMode mode) noexcept
|
||||
{
|
||||
switch (mode) {
|
||||
case SamplerAddressMode::clamp_to_edge:
|
||||
return "clamp_to_edge";
|
||||
case SamplerAddressMode::repeat:
|
||||
return "repeat";
|
||||
case SamplerAddressMode::mirrored_repeat:
|
||||
return "mirrored_repeat";
|
||||
case SamplerAddressMode::clamp_to_border:
|
||||
return "clamp_to_border";
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user