matfx pipeline values

This commit is contained in:
aap 2015-07-13 15:01:31 +02:00
parent d832570142
commit 99bdd4fd23
3 changed files with 41 additions and 17 deletions

View File

@ -30,7 +30,7 @@ main(int argc, char *argv[])
rw::platform = rw::PLATFORM_PS2; rw::platform = rw::PLATFORM_PS2;
rw::Pipeline *defpipe = rw::ps2::makeDefaultPipeline(); rw::Pipeline *defpipe = rw::ps2::makeDefaultPipeline();
rw::Pipeline *skinpipe = rw::ps2::makeSkinPipeline(); // rw::Pipeline *skinpipe = rw::ps2::makeSkinPipeline();
// rw::ps2::dumpPipeline(defpipe); // rw::ps2::dumpPipeline(defpipe);
// rw::ps2::dumpPipeline(skinpipe); // rw::ps2::dumpPipeline(skinpipe);
@ -62,6 +62,7 @@ main(int argc, char *argv[])
c = Clump::streamRead(&in); c = Clump::streamRead(&in);
assert(c != NULL); assert(c != NULL);
printf("%s\n", argv[arg]);
for(int32 i = 0; i < c->numAtomics; i++){ for(int32 i = 0; i < c->numAtomics; i++){
Atomic *a = c->atomicList[i]; Atomic *a = c->atomicList[i];
if(a->pipeline){ if(a->pipeline){
@ -82,6 +83,7 @@ main(int argc, char *argv[])
} }
} }
/*
data = new rw::uint8[256*1024]; data = new rw::uint8[256*1024];
rw::StreamMemory out; rw::StreamMemory out;
out.open(data, 0, 256*1024); out.open(data, 0, 256*1024);
@ -93,6 +95,7 @@ main(int argc, char *argv[])
fclose(cf); fclose(cf);
out.close(); out.close();
delete[] data; delete[] data;
*/
delete c; delete c;

View File

@ -460,7 +460,6 @@ instanceMat(Pipeline *pipe, Geometry *g, InstanceData *inst, Mesh *m)
*p++ = (a->attrib&0xFF004000) *p++ = (a->attrib&0xFF004000)
| 0x8000 | nverts << 16 | i; // UNPACK | 0x8000 | nverts << 16 | i; // UNPACK
// TODO: instance
switch(i){ switch(i){
case 0: case 0:
p = instanceXYZ(p, g, m, idx, nverts); p = instanceXYZ(p, g, m, idx, nverts);
@ -497,8 +496,6 @@ instanceMat(Pipeline *pipe, Geometry *g, InstanceData *inst, Mesh *m)
*/ */
} }
#undef QWC
void void
Pipeline::instance(Atomic *atomic) Pipeline::instance(Atomic *atomic)
{ {
@ -519,6 +516,31 @@ Pipeline::instance(Atomic *atomic)
geometry->geoflags |= Geometry::NATIVE; geometry->geoflags |= Geometry::NATIVE;
} }
void
printVertCounts(InstanceData *inst, int flag)
{
uint32 *d = (uint32*)inst->data;
int stride;
if(inst->arePointersFixed){
d += 4;
while(d[3]&0x60000000){ // skip UNPACKs
stride = d[2]&0xFF;
d += 4 + 4*QWC(attribSize(d[3])*((d[3]>>16)&0xFF));
}
if(d[2] == 0)
printf("ITOP %x %d (%d)\n", *d, stride, flag);
}else{
while((*d&0x70000000) == 0x30000000){
stride = d[2]&0xFF;
d += 8;
}
if((*d&0x70000000) == 0x10000000){
d += (*d&0xFFFF)*4;
printf("ITOP %x %d (%d)\n", *d, stride, flag);
}
}
}
// Only a dummy right now // Only a dummy right now
void void
Pipeline::uninstance(Atomic *atomic) Pipeline::uninstance(Atomic *atomic)
@ -530,17 +552,19 @@ Pipeline::uninstance(Atomic *atomic)
for(uint32 i = 0; i < header->numMeshes; i++){ for(uint32 i = 0; i < header->numMeshes; i++){
Mesh *mesh = &geometry->meshHeader->mesh[i]; Mesh *mesh = &geometry->meshHeader->mesh[i];
InstanceData *instance = &header->instanceMeshes[i]; InstanceData *instance = &header->instanceMeshes[i];
printf("numIndices: %d\n", mesh->numIndices); // printf("numIndices: %d\n", mesh->numIndices);
printDMA(instance); // printDMA(instance);
printVertCounts(instance, geometry->meshHeader->flags);
} }
} }
#undef QWC
void void
Pipeline::setTriBufferSizes(uint32 inputStride, Pipeline::setTriBufferSizes(uint32 inputStride, uint32 stripCount)
uint32 stripCount, uint32 listCount)
{ {
this->inputStride = inputStride; this->inputStride = inputStride;
this->triListCount = listCount/12*12; this->triListCount = stripCount/12*12;
PipeAttribute *a; PipeAttribute *a;
for(uint i = 0; i < nelem(this->attribs); i++){ for(uint i = 0; i < nelem(this->attribs); i++){
a = this->attribs[i]; a = this->attribs[i];
@ -562,7 +586,7 @@ makeDefaultPipeline(void)
pipe->attribs[AT_RGBA] = &attribRGBA; pipe->attribs[AT_RGBA] = &attribRGBA;
pipe->attribs[AT_NORMAL] = &attribNormal; pipe->attribs[AT_NORMAL] = &attribNormal;
uint32 vertCount = Pipeline::getVertCount(VU_Lights, 4, 3, 2); uint32 vertCount = Pipeline::getVertCount(VU_Lights, 4, 3, 2);
pipe->setTriBufferSizes(4, vertCount, vertCount/3); pipe->setTriBufferSizes(4, vertCount);
pipe->vifOffset = pipe->inputStride*vertCount; pipe->vifOffset = pipe->inputStride*vertCount;
return pipe; return pipe;
} }
@ -579,7 +603,7 @@ makeSkinPipeline(void)
pipe->attribs[AT_NORMAL] = &attribNormal; pipe->attribs[AT_NORMAL] = &attribNormal;
pipe->attribs[AT_NORMAL+1] = &attribWeights; pipe->attribs[AT_NORMAL+1] = &attribWeights;
uint32 vertCount = Pipeline::getVertCount(VU_Lights-0x100, 5, 3, 2); uint32 vertCount = Pipeline::getVertCount(VU_Lights-0x100, 5, 3, 2);
pipe->setTriBufferSizes(5, vertCount, vertCount/3); pipe->setTriBufferSizes(5, vertCount);
pipe->vifOffset = pipe->inputStride*vertCount; pipe->vifOffset = pipe->inputStride*vertCount;
return pipe; return pipe;
} }
@ -594,10 +618,8 @@ makeMatFXPipeline(void)
pipe->attribs[AT_UV] = &attribUV; pipe->attribs[AT_UV] = &attribUV;
pipe->attribs[AT_RGBA] = &attribRGBA; pipe->attribs[AT_RGBA] = &attribRGBA;
pipe->attribs[AT_NORMAL] = &attribNormal; pipe->attribs[AT_NORMAL] = &attribNormal;
// TODO: not correct uint32 vertCount = Pipeline::getVertCount(0x3C5, 4, 3, 3);
uint32 vertCount = Pipeline::getVertCount(VU_Lights, 4, 3, 2); pipe->setTriBufferSizes(4, vertCount);
pipe->setTriBufferSizes(4, vertCount, vertCount/3);
pipe->triStripCount = 0x38;
pipe->vifOffset = pipe->inputStride*vertCount; pipe->vifOffset = pipe->inputStride*vertCount;
return pipe; return pipe;
} }

View File

@ -53,8 +53,7 @@ struct Pipeline : rw::Pipeline
virtual void instance(Atomic *atomic); virtual void instance(Atomic *atomic);
virtual void uninstance(Atomic *atomic); virtual void uninstance(Atomic *atomic);
// virtual void render(Atomic *atomic); // virtual void render(Atomic *atomic);
void setTriBufferSizes(uint32 inputStride, void setTriBufferSizes(uint32 inputStride, uint32 stripCount);
uint32 stripCount, uint32 listCount);
}; };
Pipeline *makeDefaultPipeline(void); Pipeline *makeDefaultPipeline(void);