GPU: ShaderCreateInfo: Add convenience ResourceString

This will improve readability of shader resource generation
code.
This commit is contained in:
Clément Foucault
2025-09-27 11:04:08 +02:00
parent 412b5b3b3f
commit ef8319aaee

View File

@@ -718,6 +718,36 @@ struct ShaderCreateInfo {
GeneratedSourceList generated_sources;
/* Same as StringRefNull but with a few extra member functions. */
struct ResourceString : public StringRefNull {
constexpr ResourceString() : StringRefNull() {}
constexpr ResourceString(const char *str, int64_t size) : StringRefNull(str, size) {}
ResourceString(std::nullptr_t) = delete;
constexpr ResourceString(const char *str) : StringRefNull(str) {}
ResourceString(const std::string &str) : StringRefNull(str) {}
ResourceString(const StringRefNull &str) : StringRefNull(str) {}
int64_t array_offset() const
{
return this->find_first_of("[");
}
bool is_array() const
{
return array_offset() != -1;
}
StringRef str_no_array() const
{
return StringRef(this->c_str(), this->array_offset());
}
StringRef str_only_array() const
{
return this->substr(this->array_offset());
}
};
# define TEST_EQUAL(a, b, _member) \
if (!((a)._member == (b)._member)) { \
return false; \
@@ -822,7 +852,7 @@ struct ShaderCreateInfo {
struct SharedVariable {
Type type;
StringRefNull name;
ResourceString name;
};
Vector<SharedVariable, 0> shared_variables_;
@@ -842,13 +872,13 @@ struct ShaderCreateInfo {
struct UniformBuf {
StringRefNull type_name;
StringRefNull name;
ResourceString name;
};
struct StorageBuf {
Qualifier qualifiers;
StringRefNull type_name;
StringRefNull name;
ResourceString name;
};
struct Resource {
@@ -937,7 +967,7 @@ struct ShaderCreateInfo {
struct PushConst {
Type type;
StringRefNull name;
ResourceString name;
int array_size;
bool operator==(const PushConst &b) const