more work on initialization

This commit is contained in:
aap 2016-06-25 23:14:18 +02:00
parent a906d58bcb
commit dd901ebfa3
14 changed files with 132 additions and 80 deletions

View File

@ -28,7 +28,7 @@ int32 build = 0xFFFF;
#elif RW_D3D9
int32 platform = PLATFORM_D3D9;
#else
int32 platform = PLATFORM_nil;
int32 platform = PLATFORM_NULL;
#endif
char *debugFile = nil;

View File

@ -586,14 +586,9 @@ copyNativeRaster(void *dst, void *, int32 offset, int32)
return dst;
}
void
registerNativeRaster(void)
static void*
nativeOpen(void*, int32, int32)
{
nativeRasterOffset = Raster::registerPlugin(sizeof(D3dRaster),
0x12340000 | PLATFORM_D3D9,
createNativeRaster,
destroyNativeRaster,
copyNativeRaster);
driver[PLATFORM_D3D8].rasterNativeOffset = nativeRasterOffset;
driver[PLATFORM_D3D8].rasterCreate = rasterCreate;
driver[PLATFORM_D3D8].rasterLock = rasterLock;
@ -609,5 +604,22 @@ registerNativeRaster(void)
driver[PLATFORM_D3D9].rasterFromImage = rasterFromImage;
}
static void*
nativeClose(void*, int32, int32)
{
printf("d3d native close\n");
}
void
registerNativeRaster(void)
{
Engine::registerPlugin(0, ID_RASTERD3D9, nativeOpen, nativeClose);
nativeRasterOffset = Raster::registerPlugin(sizeof(D3dRaster),
ID_RASTERD3D9,
createNativeRaster,
destroyNativeRaster,
copyNativeRaster);
}
}
}

View File

@ -21,6 +21,8 @@ using namespace d3d;
void
initializePlatform(void)
{
if(nativeRasterOffset == 0)
registerNativeRaster();
driver[PLATFORM_D3D8].defaultPipeline = makeDefaultPipeline();
}

View File

@ -28,6 +28,8 @@ using namespace d3d;
void
initializePlatform(void)
{
if(nativeRasterOffset == 0)
registerNativeRaster();
driver[PLATFORM_D3D9].defaultPipeline = makeDefaultPipeline();
}

View File

@ -20,6 +20,7 @@ namespace xbox {
void
initializePlatform(void)
{
registerNativeRaster();
driver[PLATFORM_XBOX].defaultPipeline = makeDefaultPipeline();
}
@ -899,14 +900,9 @@ copyNativeRaster(void *dst, void *, int32 offset, int32)
return dst;
}
void
registerNativeRaster(void)
static void*
nativeOpen(void*, int32, int32)
{
nativeRasterOffset = Raster::registerPlugin(sizeof(XboxRaster),
0x12340000 | PLATFORM_XBOX,
createNativeRaster,
destroyNativeRaster,
copyNativeRaster);
driver[PLATFORM_XBOX].rasterNativeOffset = nativeRasterOffset;
driver[PLATFORM_XBOX].rasterCreate = rasterCreate;
driver[PLATFORM_XBOX].rasterLock = rasterLock;
@ -914,6 +910,23 @@ registerNativeRaster(void)
driver[PLATFORM_XBOX].rasterNumLevels = rasterNumLevels;
}
static void*
nativeClose(void*, int32, int32)
{
printf("xbox native close\n");
}
void
registerNativeRaster(void)
{
Engine::registerPlugin(0, ID_RASTERXBOX, nativeOpen, nativeClose);
nativeRasterOffset = Raster::registerPlugin(sizeof(XboxRaster),
ID_RASTERXBOX,
createNativeRaster,
destroyNativeRaster,
copyNativeRaster);
}
Texture*
readNativeTexture(Stream *stream)
{

View File

@ -25,7 +25,7 @@ PluginList Engine::s_plglist = {sizeof(Engine), sizeof(Engine), nil, nil};
void
Engine::init(void)
{
ObjPipeline *defpipe = new ObjPipeline(PLATFORM_nil);
ObjPipeline *defpipe = new ObjPipeline(PLATFORM_NULL);
for(uint i = 0; i < NUM_PLATFORMS; i++){
driver[i].defaultPipeline = defpipe;
@ -40,10 +40,12 @@ Engine::init(void)
}
Frame::dirtyList.init();
rw::gl3::registerNativeRaster();
rw::ps2::registerNativeRaster();
rw::xbox::registerNativeRaster();
rw::d3d::registerNativeRaster();
ps2::initializePlatform();
xbox::initializePlatform();
d3d8::initializePlatform();
d3d9::initializePlatform();
wdgl::initializePlatform();
gl3::initializePlatform();
}
void
@ -51,13 +53,6 @@ Engine::open(void)
{
rw::engine = (Engine*)malloc(s_plglist.size);
s_plglist.construct(rw::engine);
ps2::initializePlatform();
xbox::initializePlatform();
d3d8::initializePlatform();
d3d9::initializePlatform();
gl3::initializePlatform();
wdgl::initializePlatform();
}
namespace null {

View File

@ -24,10 +24,15 @@ namespace gl3 {
void
initializePlatform(void)
{
registerNativeRaster();
#ifdef RW_OPENGL
driver[PLATFORM_GL3].defaultPipeline = makeDefaultPipeline();
matFXGlobals.pipelines[PLATFORM_GL3] = makeMatFXPipeline();
skinGlobals.pipelines[PLATFORM_GL3] = makeSkinPipeline();
// uniforms need to be registered before any shaders are created
registerBlock("Scene");
registerBlock("Object");
registerUniform("u_matColor");
registerUniform("u_surfaceProps");
#endif
initializeRender();

View File

@ -113,7 +113,7 @@ copyNativeRaster(void *dst, void *, int32 offset, int32)
}
static void*
nativeOpen(void*, int32 offset, int32)
nativeOpen(void*, int32, int32)
{
driver[PLATFORM_GL3].rasterNativeOffset = nativeRasterOffset;
driver[PLATFORM_GL3].rasterCreate = rasterCreate;
@ -124,16 +124,16 @@ nativeOpen(void*, int32 offset, int32)
}
static void*
nativeClose(void*, int32 offset, int32)
nativeClose(void*, int32, int32)
{
printf("native close\n");
printf("gl3 native close\n");
}
void registerNativeRaster(void)
{
Engine::registerPlugin(0, 0x1234, nativeOpen, nativeClose);
Engine::registerPlugin(0, ID_RASTERGL3, nativeOpen, nativeClose);
nativeRasterOffset = Raster::registerPlugin(sizeof(Gl3Raster),
0x12340000 | PLATFORM_GL3,
ID_RASTERGL3,
createNativeRaster,
destroyNativeRaster,
copyNativeRaster);

View File

@ -125,11 +125,6 @@ initializeRender(void)
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
registerBlock("Scene");
registerBlock("Object");
registerUniform("u_matColor");
registerUniform("u_surfaceProps");
glGenBuffers(1, &ubo_scene);
glBindBuffer(GL_UNIFORM_BUFFER, ubo_scene);
glBindBufferBase(GL_UNIFORM_BUFFER, gl3::findBlock("Scene"), ubo_scene);

View File

@ -716,7 +716,7 @@ void
registerNativeRaster(void)
{
nativeRasterOffset = Raster::registerPlugin(sizeof(GlRaster),
0x12340000 | PLATFORM_WDGL,
ID_RASTERWDGL,
createNativeRaster,
destroyNativeRaster,
copyNativeRaster);

View File

@ -15,6 +15,7 @@
#include "d3d/rwd3d8.h"
#include "d3d/rwd3d9.h"
#include "gl/rwwdgl.h"
#include "gl/rwgl3.h"
#define PLUGIN_ID 2
@ -717,21 +718,23 @@ skinRights(void *object, int32, int32, uint32)
void
registerSkinPlugin(void)
{
ObjPipeline *defpipe = new ObjPipeline(PLATFORM_nil);
ObjPipeline *defpipe = new ObjPipeline(PLATFORM_NULL);
defpipe->pluginID = ID_SKIN;
defpipe->pluginData = 1;
for(uint i = 0; i < nelem(skinGlobals.pipelines); i++)
skinGlobals.pipelines[i] = defpipe;
skinGlobals.pipelines[PLATFORM_PS2] =
ps2::makeSkinPipeline();
skinGlobals.pipelines[PLATFORM_WDGL] =
wdgl::makeSkinPipeline();
skinGlobals.pipelines[PLATFORM_XBOX] =
xbox::makeSkinPipeline();
skinGlobals.pipelines[PLATFORM_D3D8] =
d3d8::makeSkinPipeline();
skinGlobals.pipelines[PLATFORM_D3D9] =
d3d9::makeSkinPipeline();
skinGlobals.pipelines[PLATFORM_WDGL] =
wdgl::makeSkinPipeline();
skinGlobals.pipelines[PLATFORM_GL3] =
gl3::makeSkinPipeline();
skinGlobals.offset = Geometry::registerPlugin(sizeof(Skin*), ID_SKIN,
createSkin,
@ -1220,21 +1223,23 @@ MatFX::enableEffects(Atomic *atomic)
void
registerMatFXPlugin(void)
{
ObjPipeline *defpipe = new ObjPipeline(PLATFORM_nil);
ObjPipeline *defpipe = new ObjPipeline(PLATFORM_NULL);
defpipe->pluginID = 0; //ID_MATFX;
defpipe->pluginData = 0;
for(uint i = 0; i < nelem(matFXGlobals.pipelines); i++)
matFXGlobals.pipelines[i] = defpipe;
matFXGlobals.pipelines[PLATFORM_PS2] =
ps2::makeMatFXPipeline();
matFXGlobals.pipelines[PLATFORM_WDGL] =
wdgl::makeMatFXPipeline();
matFXGlobals.pipelines[PLATFORM_XBOX] =
xbox::makeMatFXPipeline();
matFXGlobals.pipelines[PLATFORM_D3D8] =
d3d8::makeMatFXPipeline();
matFXGlobals.pipelines[PLATFORM_D3D9] =
d3d9::makeMatFXPipeline();
matFXGlobals.pipelines[PLATFORM_WDGL] =
wdgl::makeMatFXPipeline();
matFXGlobals.pipelines[PLATFORM_GL3] =
gl3::makeMatFXPipeline();
matFXGlobals.atomicOffset =
Atomic::registerPlugin(sizeof(int32), ID_MATFX,

View File

@ -21,6 +21,7 @@ namespace ps2 {
void
initializePlatform(void)
{
registerNativeRaster();
driver[PLATFORM_PS2].defaultPipeline = makeDefaultPipeline();
}

View File

@ -477,7 +477,7 @@ getSizeMipmap(void*, int32, int32)
}
static void*
nativeOpen(void*, int32 offset, int32)
nativeOpen(void*, int32, int32)
{
driver[PLATFORM_PS2].rasterNativeOffset = nativeRasterOffset;
driver[PLATFORM_PS2].rasterCreate = rasterCreate;
@ -487,19 +487,20 @@ nativeOpen(void*, int32 offset, int32)
}
static void*
nativeClose(void*, int32 offset, int32)
nativeClose(void*, int32, int32)
{
printf("ps2 native close\n");
}
void
registerNativeRaster(void)
{
Engine::registerPlugin(0, ID_RASTERPS2, nativeOpen, nativeClose);
nativeRasterOffset = Raster::registerPlugin(sizeof(Ps2Raster),
0x12340000 | PLATFORM_PS2,
ID_RASTERPS2,
createNativeRaster,
destroyNativeRaster,
copyNativeRaster);
Engine::registerPlugin(0, 0x1234, nativeOpen, nativeClose);
Texture::registerPlugin(0, ID_SKYMIPMAP, nil, nil, nil);
Texture::registerPluginStream(ID_SKYMIPMAP, readMipmap, writeMipmap, getSizeMipmap);

View File

@ -255,7 +255,7 @@ public:
enum Platform
{
PLATFORM_nil = 0,
PLATFORM_NULL = 0,
// D3D7
PLATFORM_GL = 2,
// MAC
@ -276,42 +276,63 @@ enum Platform
FOURCC_PS2 = 0x00325350 // 'PS2\0'
};
#define MAKEPLUGINID(v, id) (((v & 0xFFFFFF) << 8) | (id & 0xFF))
enum VendorID
{
VEND_CORE = 0,
VEND_CRITERIONTK = 1,
VEND_CRITERIONINT = 4,
VEND_CRITERIONWORLD = 5,
// Used for platform-specific stuff like rasters
VEND_PLATFORM = 10,
};
enum PluginID
{
// Core
ID_NAOBJECT = 0x0,
ID_STRUCT = 0x1,
ID_STRING = 0x2,
ID_EXTENSION = 0x3,
ID_CAMERA = 0x5,
ID_TEXTURE = 0x6,
ID_MATERIAL = 0x7,
ID_MATLIST = 0x8,
ID_FRAMELIST = 0xE,
ID_GEOMETRY = 0xF,
ID_CLUMP = 0x10,
ID_LIGHT = 0x12,
ID_ATOMIC = 0x14,
ID_TEXTURENATIVE = 0x15,
ID_TEXDICTIONARY = 0x16,
ID_GEOMETRYLIST = 0x1A,
ID_ANIMANIMATION = 0x1B,
ID_RIGHTTORENDER = 0x1F,
ID_UVANIMDICT = 0x2B,
ID_NAOBJECT = MAKEPLUGINID(VEND_CORE, 0x00),
ID_STRUCT = MAKEPLUGINID(VEND_CORE, 0x01),
ID_STRING = MAKEPLUGINID(VEND_CORE, 0x02),
ID_EXTENSION = MAKEPLUGINID(VEND_CORE, 0x03),
ID_CAMERA = MAKEPLUGINID(VEND_CORE, 0x05),
ID_TEXTURE = MAKEPLUGINID(VEND_CORE, 0x06),
ID_MATERIAL = MAKEPLUGINID(VEND_CORE, 0x07),
ID_MATLIST = MAKEPLUGINID(VEND_CORE, 0x08),
ID_FRAMELIST = MAKEPLUGINID(VEND_CORE, 0x0E),
ID_GEOMETRY = MAKEPLUGINID(VEND_CORE, 0x0F),
ID_CLUMP = MAKEPLUGINID(VEND_CORE, 0x10),
ID_LIGHT = MAKEPLUGINID(VEND_CORE, 0x12),
ID_ATOMIC = MAKEPLUGINID(VEND_CORE, 0x14),
ID_TEXTURENATIVE = MAKEPLUGINID(VEND_CORE, 0x15),
ID_TEXDICTIONARY = MAKEPLUGINID(VEND_CORE, 0x16),
ID_GEOMETRYLIST = MAKEPLUGINID(VEND_CORE, 0x1A),
ID_ANIMANIMATION = MAKEPLUGINID(VEND_CORE, 0x1B),
ID_RIGHTTORENDER = MAKEPLUGINID(VEND_CORE, 0x1F),
ID_UVANIMDICT = MAKEPLUGINID(VEND_CORE, 0x2B),
// Toolkit
ID_SKYMIPMAP = 0x110,
ID_SKIN = 0x116,
ID_HANIMPLUGIN = 0x11E,
ID_MATFX = 0x120,
ID_PDS = 0x131,
ID_ADC = 0x134,
ID_UVANIMATION = 0x135,
ID_SKYMIPMAP = MAKEPLUGINID(VEND_CRITERIONTK, 0x10),
ID_SKIN = MAKEPLUGINID(VEND_CRITERIONTK, 0x16),
ID_HANIMPLUGIN = MAKEPLUGINID(VEND_CRITERIONTK, 0x1E),
ID_MATFX = MAKEPLUGINID(VEND_CRITERIONTK, 0x20),
ID_PDS = MAKEPLUGINID(VEND_CRITERIONTK, 0x31),
ID_ADC = MAKEPLUGINID(VEND_CRITERIONTK, 0x34),
ID_UVANIMATION = MAKEPLUGINID(VEND_CRITERIONTK, 0x35),
// World
ID_MESH = 0x50E,
ID_NATIVEDATA = 0x510,
ID_VERTEXFMT = 0x511,
ID_MESH = MAKEPLUGINID(VEND_CRITERIONWORLD, 0x0E),
ID_NATIVEDATA = MAKEPLUGINID(VEND_CRITERIONWORLD, 0x10),
ID_VERTEXFMT = MAKEPLUGINID(VEND_CRITERIONWORLD, 0x11),
// custom native raster
ID_RASTERGL = MAKEPLUGINID(VEND_PLATFORM, PLATFORM_GL),
ID_RASTERPS2 = MAKEPLUGINID(VEND_PLATFORM, PLATFORM_PS2),
ID_RASTERXBOX = MAKEPLUGINID(VEND_PLATFORM, PLATFORM_XBOX),
ID_RASTERD3D8 = MAKEPLUGINID(VEND_PLATFORM, PLATFORM_D3D8),
ID_RASTERD3D9 = MAKEPLUGINID(VEND_PLATFORM, PLATFORM_D3D9),
ID_RASTERWDGL = MAKEPLUGINID(VEND_PLATFORM, PLATFORM_WDGL),
ID_RASTERGL3 = MAKEPLUGINID(VEND_PLATFORM, PLATFORM_GL3),
};
#define ECODE(c, s) c,