GPUShader: Rename createInfo storage Qualifiers

Using opt-in instead of opt-out to make code easier to read.
Add combined flag enum.
Making restrict an inverse flag option because it is so rare to
use it.
This commit is contained in:
2022-02-01 18:32:47 +01:00
parent 9505af72d4
commit f39ade9e00
3 changed files with 13 additions and 10 deletions

View File

@@ -130,10 +130,13 @@ enum class ImageType {
/* Storage qualifiers. */
enum class Qualifier {
RESTRICT = (1 << 0),
READ_ONLY = (1 << 1),
WRITE_ONLY = (1 << 2),
QUALIFIER_MAX = (WRITE_ONLY << 1) - 1,
/** Restrict flag is set by default. Unless specified otherwise. */
NO_RESTRICT = (1 << 0),
READ = (1 << 1),
WRITE = (1 << 2),
/** Shorthand version of combined flags. */
READ_WRITE = READ | WRITE,
QUALIFIER_MAX = (WRITE << 1) - 1,
};
ENUM_OPERATORS(Qualifier, Qualifier::QUALIFIER_MAX);

View File

@@ -277,15 +277,15 @@ static void print_image_type(std::ostream &os,
static std::ostream &print_qualifier(std::ostream &os, const Qualifier &qualifiers)
{
if ((qualifiers & Qualifier::RESTRICT) == Qualifier::RESTRICT) {
if (bool(qualifiers & Qualifier::NO_RESTRICT) == false) {
os << "restrict ";
}
if ((qualifiers & Qualifier::READ_ONLY) == Qualifier::READ_ONLY) {
os << "readonly ";
}
if ((qualifiers & Qualifier::WRITE_ONLY) == Qualifier::WRITE_ONLY) {
if (bool(qualifiers & Qualifier::READ) == false) {
os << "writeonly ";
}
if (bool(qualifiers & Qualifier::WRITE) == false) {
os << "readonly ";
}
return os;
}