| 1 | #pragma once |
|---|---|
| 2 | |
| 3 | #include <prim/seadSafeString.h> |
| 4 | #include "common/aglResCommon.h" |
| 5 | #include "common/aglShaderEnum.h" |
| 6 | |
| 7 | namespace agl { |
| 8 | |
| 9 | struct ResShaderSymbolData { |
| 10 | u32 mSize; |
| 11 | s32 mOffset; |
| 12 | u32 mNameLen; |
| 13 | u32 mIDLen; |
| 14 | u32 mDefaultValueSize; |
| 15 | u32 mVariationNum; |
| 16 | // char mName[]; |
| 17 | }; |
| 18 | static_assert(sizeof(ResShaderSymbolData) == 0x18, "agl::ResShaderSymbolData size mismatch"); |
| 19 | |
| 20 | class ResShaderSymbol : public ResCommon<ResShaderSymbolData> { |
| 21 | public: |
| 22 | using ResCommon::ResCommon; |
| 23 | |
| 24 | const char* getName() const { |
| 25 | const DataType* const data = ptr(); |
| 26 | return (const char*)(data + 1); |
| 27 | } |
| 28 | |
| 29 | const char* getID() const { |
| 30 | const DataType* const data = ptr(); |
| 31 | return (const char*)((uintptr_t)(data + 1) + data->mNameLen); |
| 32 | } |
| 33 | |
| 34 | void* getDefaultValue() const { |
| 35 | const DataType* const data = ptr(); |
| 36 | return (void*)((uintptr_t)(data + 1) + data->mNameLen + data->mIDLen); |
| 37 | } |
| 38 | |
| 39 | const u8* getVariationEnableArray() const { |
| 40 | const DataType* const data = ptr(); |
| 41 | return (const u8*)((uintptr_t)(data + 1) + data->mNameLen + data->mIDLen + |
| 42 | data->mDefaultValueSize); |
| 43 | } |
| 44 | |
| 45 | bool isVariationEnable(s32 index) const { return getVariationEnableArray()[index]; } |
| 46 | }; |
| 47 | |
| 48 | class ResShaderSymbolArray : public ResArray<ResShaderSymbol> { |
| 49 | public: |
| 50 | using ResArray::ResArray; |
| 51 | |
| 52 | ResShaderSymbol searchResShaderSymbolByID(const sead::SafeString& id) const; |
| 53 | }; |
| 54 | |
| 55 | using ResShaderSymbolArrayData = ResShaderSymbolArray::DataType; |
| 56 | static_assert(sizeof(ResShaderSymbolArrayData) == 8, "agl::ResShaderSymbolArrayData size mismatch"); |
| 57 | |
| 58 | } // namespace agl |
| 59 |