| 1 | #pragma once |
|---|---|
| 2 | |
| 3 | #include "common/aglResBinaryShaderProgram.h" |
| 4 | #include "common/aglResShaderBinary.h" |
| 5 | #include "common/aglResShaderProgram.h" |
| 6 | |
| 7 | namespace agl { |
| 8 | |
| 9 | struct ResBinaryShaderArchiveData { |
| 10 | union { |
| 11 | char mSignature[4]; |
| 12 | u32 mSigWord; |
| 13 | }; |
| 14 | u32 mVersion; |
| 15 | u32 mFileSize; |
| 16 | u32 mEndian; |
| 17 | u32 mResolved; |
| 18 | u32 mNameLen; |
| 19 | // char mName[]; |
| 20 | |
| 21 | public: |
| 22 | static u32 getVersion(); |
| 23 | static u32 getSignature(); |
| 24 | static const char* getExtension(); |
| 25 | |
| 26 | private: |
| 27 | static const u32 cVersion = 8; |
| 28 | static const u32 cSignature = 0x53484142; // SHAB |
| 29 | static const u32 cEndianCheckBit = 0x01000001; |
| 30 | |
| 31 | friend class ResCommon<ResBinaryShaderArchiveData>; |
| 32 | friend class ResBinaryShaderArchive; |
| 33 | }; |
| 34 | static_assert(sizeof(ResBinaryShaderArchiveData) == 0x18, |
| 35 | "agl::ResBinaryShaderArchiveData size mismatch"); |
| 36 | |
| 37 | class ResBinaryShaderArchive : public ResCommon<ResBinaryShaderArchiveData> { |
| 38 | AGL_RES_FILE_HEADER() |
| 39 | |
| 40 | public: |
| 41 | using ResCommon::ResCommon; |
| 42 | |
| 43 | const char* getName() const { |
| 44 | const DataType* const data = ptr(); |
| 45 | return (const char*)(data + 1); |
| 46 | } |
| 47 | |
| 48 | ResShaderBinaryArray getResShaderBinaryArray() const { |
| 49 | const DataType* const data = ptr(); |
| 50 | return (const ResShaderBinaryArrayData*)((uintptr_t)(data + 1) + data->mNameLen); |
| 51 | } |
| 52 | |
| 53 | s32 getResShaderBinaryNum() const { return getResShaderBinaryArray().getNum(); } |
| 54 | |
| 55 | ResBinaryShaderProgramArray getResBinaryShaderProgramArray() const { |
| 56 | const ResShaderBinaryArrayData* const data = getResShaderBinaryArray().ptr(); |
| 57 | return (const ResBinaryShaderProgramArrayData*)((uintptr_t)data + data->mSize); |
| 58 | } |
| 59 | |
| 60 | s32 getResBinaryShaderProgramNum() const { return getResBinaryShaderProgramArray().getNum(); } |
| 61 | |
| 62 | bool setUp(bool le_resolve_pointers); |
| 63 | }; |
| 64 | |
| 65 | } // namespace agl |
| 66 |