Pixel Shader Asset: Difference between revisions
Aerosoul94 (talk | contribs) mNo edit summary |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 27: | Line 27: | ||
== Call of Duty 4 & World at War & Modern Warfare 2 == | == Call of Duty 4 & World at War & Modern Warfare 2 == | ||
=== Rendering === | |||
[[MW2_Rendering|Rendering]] | |||
=== Structures === | |||
<source lang="cpp"> | <source lang="cpp"> | ||
struct GfxPixelShaderLoadDef | |||
{ | |||
CgBinaryProgram *ps; // serialized Cg/NV fragment program blob | |||
int size; // byte size of ps payload | |||
}; | |||
struct MaterialPixelShaderProgram | struct MaterialPixelShaderProgram | ||
{ | { | ||
union | |||
{ | |||
// Fastfile/source view, consumed by Load_GfxPixelShaderLoadDef. | |||
struct | |||
{ | |||
CgBinaryProgram *ps; // +0x00 | |||
int size; // +0x04 | |||
char runtime[0x0C]; // +0x08, overwritten/filled by runtime build, size 8 ifndef mw2 | |||
} load; | |||
// Runtime view after EBOOT.elf:00361f38 builds the PS3 fragment program data. | |||
struct | |||
{ | |||
unsigned short *patchTable; // +0x00 | |||
int commandListOffset; // +0x04, offset to copied RSX command dwords | |||
int commandDwordCount; // +0x08 | |||
unsigned short patchTableWords; // +0x0C | |||
unsigned short uploadByteSize; // +0x0E | |||
void *sharedUpload; // +0x10, default fragment upload image | |||
} runtime; | |||
}; | |||
}; | }; | ||
struct MaterialPixelShader | struct MaterialPixelShader | ||
{ | { | ||
const char *name; // +0x00, XString | |||
MaterialPixelShaderProgram prog; // +0x04, total asset size 0x18 | |||
}; | }; | ||
</source> | </source> | ||
MaterialPixelShader is 0x18 bytes on PS3. EBOOT.elf:0x00107578 loads the name, then loads prog at +0x04. MaterialPixelShaderProgram itself is 0x14 bytes; EBOOT.elf:0x000fb128 copies those bytes, aliases the first 8 bytes as GfxPixelShaderLoadDef, and calls the pixel program loader. | |||
ps is not the final RSX-bound shader address. It is the serialized Cg/NV fragment-program blob pointer. When inline, the loader consumes size bytes for that blob, then 0x004c7428 -> 0x00361f38 parses/builds runtime data from it. | |||
At draw time the upload image is still patched. Shader arg kinds 5, 6, and 7 provide code/material/literal pixel constants; 00396e48 uses the runtime patch table to write those float4 values into the upload image, then 004a7bd4 copies it to a draw cache and 003abd08 binds it through RSX method 0x408e4. | |||
== Black Ops == | == Black Ops == | ||
Latest revision as of 18:27, 5 July 2026
Modern Warfare 3 & Ghosts
struct MaterialPixelShaderProgram
{
CgBinaryProgram *ps; // size = size
int size;
const char *data; // size = size2
int size2;
int unknown[2];
};
struct MaterialPixelShader
{
const char *name;
MaterialPixelShaderProgram prog;
};Call of Duty 4 & World at War & Modern Warfare 2
Rendering
Structures
struct GfxPixelShaderLoadDef
{
CgBinaryProgram *ps; // serialized Cg/NV fragment program blob
int size; // byte size of ps payload
};
struct MaterialPixelShaderProgram
{
union
{
// Fastfile/source view, consumed by Load_GfxPixelShaderLoadDef.
struct
{
CgBinaryProgram *ps; // +0x00
int size; // +0x04
char runtime[0x0C]; // +0x08, overwritten/filled by runtime build, size 8 ifndef mw2
} load;
// Runtime view after EBOOT.elf:00361f38 builds the PS3 fragment program data.
struct
{
unsigned short *patchTable; // +0x00
int commandListOffset; // +0x04, offset to copied RSX command dwords
int commandDwordCount; // +0x08
unsigned short patchTableWords; // +0x0C
unsigned short uploadByteSize; // +0x0E
void *sharedUpload; // +0x10, default fragment upload image
} runtime;
};
};
struct MaterialPixelShader
{
const char *name; // +0x00, XString
MaterialPixelShaderProgram prog; // +0x04, total asset size 0x18
};MaterialPixelShader is 0x18 bytes on PS3. EBOOT.elf:0x00107578 loads the name, then loads prog at +0x04. MaterialPixelShaderProgram itself is 0x14 bytes; EBOOT.elf:0x000fb128 copies those bytes, aliases the first 8 bytes as GfxPixelShaderLoadDef, and calls the pixel program loader.
ps is not the final RSX-bound shader address. It is the serialized Cg/NV fragment-program blob pointer. When inline, the loader consumes size bytes for that blob, then 0x004c7428 -> 0x00361f38 parses/builds runtime data from it.
At draw time the upload image is still patched. Shader arg kinds 5, 6, and 7 provide code/material/literal pixel constants; 00396e48 uses the runtime patch table to write those float4 values into the upload image, then 004a7bd4 copies it to a draw cache and 003abd08 binds it through RSX method 0x408e4.
Black Ops
struct MaterialPixelShaderProgram
{
char *data; // size = size << 2
char unknown[2];
unsigned __int16 size;
};
struct MaterialPixelShader
{
const char *name;
MaterialPixelShaderProgram prog;
};Black Ops 2
struct MaterialPixelShaderProgram
{
char *data1; // if flag2 & 0x80: size = (size1 << 4) + 0x10
// else: size = 0
char *data2; // if flag2 & 0x80:
// if flag1 & 0x80: size = size1 + 0x11
// else: size = (size1 << 2) + 0x14
// else: size = 0x10
unsigned __int16 size1;
char flag1;
char flag2;
};
struct MaterialPixelShader
{
const char *name;
MaterialPixelShaderProgram prog;
};