Add renderer texture transition contract
This commit is contained in:
@@ -692,6 +692,78 @@ pp::foundation::Status validate_mipmap_generation_desc(TextureDesc desc) noexcep
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
pp::foundation::Status validate_texture_state(TextureState state) noexcept
|
||||
{
|
||||
switch (state) {
|
||||
case TextureState::undefined:
|
||||
case TextureState::shader_read:
|
||||
case TextureState::render_target:
|
||||
case TextureState::upload_destination:
|
||||
case TextureState::copy_source:
|
||||
case TextureState::copy_destination:
|
||||
case TextureState::readback_source:
|
||||
case TextureState::present:
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
return pp::foundation::Status::invalid_argument("texture state is not supported");
|
||||
}
|
||||
|
||||
pp::foundation::Status validate_texture_transition_desc(
|
||||
TextureDesc desc,
|
||||
TextureState before,
|
||||
TextureState after) noexcept
|
||||
{
|
||||
const auto desc_status = validate_texture_desc(desc);
|
||||
if (!desc_status.ok()) {
|
||||
return desc_status;
|
||||
}
|
||||
|
||||
const auto before_status = validate_texture_state(before);
|
||||
if (!before_status.ok()) {
|
||||
return before_status;
|
||||
}
|
||||
|
||||
const auto after_status = validate_texture_state(after);
|
||||
if (!after_status.ok()) {
|
||||
return after_status;
|
||||
}
|
||||
|
||||
if (before == after) {
|
||||
return pp::foundation::Status::invalid_argument("texture transition must change state");
|
||||
}
|
||||
|
||||
if (after == TextureState::undefined) {
|
||||
return pp::foundation::Status::invalid_argument("texture transition destination must not be undefined");
|
||||
}
|
||||
|
||||
if (after == TextureState::shader_read && !has_texture_usage(desc.usage, TextureUsage::sampled)) {
|
||||
return pp::foundation::Status::invalid_argument("shader-read transition requires sampled usage");
|
||||
}
|
||||
|
||||
if (after == TextureState::render_target && !has_texture_usage(desc.usage, TextureUsage::render_target)) {
|
||||
return pp::foundation::Status::invalid_argument("render-target transition requires render_target usage");
|
||||
}
|
||||
|
||||
if (after == TextureState::upload_destination && !has_texture_usage(desc.usage, TextureUsage::upload_destination)) {
|
||||
return pp::foundation::Status::invalid_argument("upload transition requires upload_destination usage");
|
||||
}
|
||||
|
||||
if (after == TextureState::copy_source && !has_texture_usage(desc.usage, TextureUsage::copy_source)) {
|
||||
return pp::foundation::Status::invalid_argument("copy-source transition requires copy_source usage");
|
||||
}
|
||||
|
||||
if (after == TextureState::copy_destination && !has_texture_usage(desc.usage, TextureUsage::copy_destination)) {
|
||||
return pp::foundation::Status::invalid_argument("copy-destination transition requires copy_destination usage");
|
||||
}
|
||||
|
||||
if (after == TextureState::readback_source && !has_texture_usage(desc.usage, TextureUsage::readback_source)) {
|
||||
return pp::foundation::Status::invalid_argument("readback transition requires readback_source usage");
|
||||
}
|
||||
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
pp::foundation::Status validate_blit_filter(BlitFilter filter) noexcept
|
||||
{
|
||||
switch (filter) {
|
||||
@@ -749,6 +821,30 @@ const char* texture_format_name(TextureFormat format) noexcept
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
const char* texture_state_name(TextureState state) noexcept
|
||||
{
|
||||
switch (state) {
|
||||
case TextureState::undefined:
|
||||
return "undefined";
|
||||
case TextureState::shader_read:
|
||||
return "shader_read";
|
||||
case TextureState::render_target:
|
||||
return "render_target";
|
||||
case TextureState::upload_destination:
|
||||
return "upload_destination";
|
||||
case TextureState::copy_source:
|
||||
return "copy_source";
|
||||
case TextureState::copy_destination:
|
||||
return "copy_destination";
|
||||
case TextureState::readback_source:
|
||||
return "readback_source";
|
||||
case TextureState::present:
|
||||
return "present";
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
const char* primitive_topology_name(PrimitiveTopology topology) noexcept
|
||||
{
|
||||
switch (topology) {
|
||||
|
||||
Reference in New Issue
Block a user