Skip to content

Commit

Permalink
Remove/disable old swrenderer model rendering code
Browse files Browse the repository at this point in the history
  • Loading branch information
dpjudas committed Dec 1, 2019
1 parent 3059b8f commit 4a4b791
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 216 deletions.
4 changes: 2 additions & 2 deletions src/rendering/polyrenderer/drawers/poly_draw_args.h
Expand Up @@ -67,7 +67,7 @@ struct PolyLight
class PolyDrawArgs
{
public:
void SetClipPlane(int index, const PolyClipPlane &plane) { mClipPlane[index] = plane; }
//void SetClipPlane(int index, const PolyClipPlane &plane) { mClipPlane[index] = plane; }
void SetTexture(const uint8_t *texels, int width, int height);
void SetTexture(FSoftwareTexture *texture, FRenderStyle style);
void SetTexture(FSoftwareTexture *texture, uint32_t translationID, FRenderStyle style);
Expand All @@ -86,7 +86,7 @@ class PolyDrawArgs
void SetLights(PolyLight *lights, int numLights) { mLights = lights; mNumLights = numLights; }
void SetDynLightColor(uint32_t color) { mDynLightColor = color; }

const PolyClipPlane &ClipPlane(int index) const { return mClipPlane[index]; }
//const PolyClipPlane &ClipPlane(int index) const { return mClipPlane[index]; }

bool WriteColor() const { return mWriteColor; }

Expand Down
68 changes: 0 additions & 68 deletions src/rendering/polyrenderer/drawers/poly_triangle.cpp
Expand Up @@ -73,31 +73,6 @@ void PolyTriangleDrawer::SetInputAssembly(const DrawerCommandQueuePtr &queue, Po
queue->Push<PolySetInputAssemblyCommand>(input);
}

void PolyTriangleDrawer::SetTransform(const DrawerCommandQueuePtr &queue, const Mat4f *objectToClip, const Mat4f *objectToWorld)
{
queue->Push<PolySetTransformCommand>(objectToClip, objectToWorld);
}

void PolyTriangleDrawer::SetCullCCW(const DrawerCommandQueuePtr &queue, bool ccw)
{
queue->Push<PolySetCullCCWCommand>(ccw);
}

void PolyTriangleDrawer::SetTwoSided(const DrawerCommandQueuePtr &queue, bool twosided)
{
queue->Push<PolySetTwoSidedCommand>(twosided);
}

void PolyTriangleDrawer::SetWeaponScene(const DrawerCommandQueuePtr &queue, bool enable)
{
queue->Push<PolySetWeaponSceneCommand>(enable);
}

void PolyTriangleDrawer::SetModelVertexShader(const DrawerCommandQueuePtr &queue, int frame1, int frame2, float interpolationFactor)
{
queue->Push<PolySetModelVertexShaderCommand>(frame1, frame2, interpolationFactor);
}

void PolyTriangleDrawer::SetVertexBuffer(const DrawerCommandQueuePtr &queue, const void *vertices)
{
queue->Push<PolySetVertexBufferCommand>(vertices);
Expand All @@ -113,11 +88,6 @@ void PolyTriangleDrawer::SetLightBuffer(const DrawerCommandQueuePtr& queue, cons
queue->Push<PolySetLightBufferCommand>(lights);
}

void PolyTriangleDrawer::PushDrawArgs(const DrawerCommandQueuePtr &queue, const PolyDrawArgs &args)
{
queue->Push<PolyPushDrawArgsCommand>(args);
}

void PolyTriangleDrawer::SetDepthClamp(const DrawerCommandQueuePtr &queue, bool on)
{
queue->Push<PolySetDepthClampCommand>(on);
Expand Down Expand Up @@ -287,17 +257,6 @@ void PolyTriangleThreadData::UpdateClip()
clip.bottom = MIN(MIN(viewport_y + viewport_height, scissor.bottom), dest_height);
}

void PolyTriangleThreadData::SetTransform(const Mat4f *newObjectToClip, const Mat4f *newObjectToWorld)
{
swVertexShader.objectToClip = newObjectToClip;
swVertexShader.objectToWorld = newObjectToWorld;
}

void PolyTriangleThreadData::PushDrawArgs(const PolyDrawArgs &args)
{
drawargs = args;
}

void PolyTriangleThreadData::PushStreamData(const StreamData &data, const PolyPushConstants &constants)
{
mainVertexShader.Data = data;
Expand Down Expand Up @@ -595,33 +554,6 @@ ShadedTriVertex PolyTriangleThreadData::ShadeVertex(int index)
return mainVertexShader;
}

void PolySWInputAssembly::Load(PolyTriangleThreadData *thread, const void *vertices, int index)
{
if (thread->modelFrame1 == -1)
{
thread->swVertexShader.v1 = static_cast<const TriVertex*>(vertices)[index];
}
else
{
const FModelVertex &v1 = static_cast<const FModelVertex*>(vertices)[thread->modelFrame1 + index];
const FModelVertex &v2 = static_cast<const FModelVertex*>(vertices)[thread->modelFrame2 + index];

thread->swVertexShader.v1.x = v1.x;
thread->swVertexShader.v1.y = v1.y;
thread->swVertexShader.v1.z = v1.z;
thread->swVertexShader.v1.w = 1.0f;
thread->swVertexShader.v1.u = v1.u;
thread->swVertexShader.v1.v = v1.v;

thread->swVertexShader.v2.x = v2.x;
thread->swVertexShader.v2.y = v2.y;
thread->swVertexShader.v2.z = v2.z;
thread->swVertexShader.v2.w = 1.0f;
thread->swVertexShader.v2.u = v2.u;
thread->swVertexShader.v2.v = v2.v;
}
}

bool PolyTriangleThreadData::IsDegenerate(const ShadedTriVertex *const* vert)
{
// A degenerate triangle has a zero cross product for two of its sides.
Expand Down
86 changes: 0 additions & 86 deletions src/rendering/polyrenderer/drawers/poly_triangle.h
Expand Up @@ -66,14 +66,6 @@ class PolyTriangleDrawer
static void Draw(const DrawerCommandQueuePtr &queue, int index, int vcount, PolyDrawMode mode = PolyDrawMode::Triangles);
static void DrawIndexed(const DrawerCommandQueuePtr &queue, int index, int count, PolyDrawMode mode = PolyDrawMode::Triangles);
static bool IsBgra();

// Old softpoly/swrenderer interface
static void SetCullCCW(const DrawerCommandQueuePtr &queue, bool ccw);
static void SetTwoSided(const DrawerCommandQueuePtr &queue, bool twosided);
static void SetWeaponScene(const DrawerCommandQueuePtr &queue, bool enable);
static void SetModelVertexShader(const DrawerCommandQueuePtr &queue, int frame1, int frame2, float interpolationFactor);
static void SetTransform(const DrawerCommandQueuePtr &queue, const Mat4f *objectToClip, const Mat4f *objectToWorld);
static void PushDrawArgs(const DrawerCommandQueuePtr &queue, const PolyDrawArgs &args);
};

class PolyDepthStencil
Expand Down Expand Up @@ -116,30 +108,20 @@ class PolyInputAssembly
virtual void Load(PolyTriangleThreadData *thread, const void *vertices, int index) = 0;
};

class PolySWInputAssembly : public PolyInputAssembly
{
public:
void Load(PolyTriangleThreadData *thread, const void *vertices, int index) override;
};

class PolyTriangleThreadData
{
public:
PolyTriangleThreadData(int32_t core, int32_t num_cores, int32_t numa_node, int32_t num_numa_nodes, int numa_start_y, int numa_end_y)
: core(core), num_cores(num_cores), numa_node(numa_node), num_numa_nodes(num_numa_nodes), numa_start_y(numa_start_y), numa_end_y(numa_end_y)
{
swVertexShader.drawargs = &drawargs;
}

void ClearDepth(float value);
void ClearStencil(uint8_t value);
void SetViewport(int x, int y, int width, int height, uint8_t *dest, int dest_width, int dest_height, int dest_pitch, bool dest_bgra, PolyDepthStencil *depthstencil);

void SetTransform(const Mat4f *objectToClip, const Mat4f *objectToWorld);
void SetCullCCW(bool value) { ccw = value; }
void SetTwoSided(bool value) { twosided = value; }
void SetWeaponScene(bool value) { depthbias = value ? -1.0f : 0.0f; }
void SetModelVertexShader(int frame1, int frame2, float interpolationFactor) { modelFrame1 = frame1; modelFrame2 = frame2; swVertexShader.modelInterpolationFactor = interpolationFactor; }

void SetInputAssembly(PolyInputAssembly *input) { inputAssembly = input; }
void SetVertexBuffer(const void *data) { vertices = data; }
Expand All @@ -164,7 +146,6 @@ class PolyTriangleThreadData

void UpdateClip();

void PushDrawArgs(const PolyDrawArgs &args);
void PushStreamData(const StreamData &data, const PolyPushConstants &constants);
void PushMatrices(const VSMatrix &modelMatrix, const VSMatrix &normalModelMatrix, const VSMatrix &textureMatrix);

Expand Down Expand Up @@ -249,10 +230,6 @@ class PolyTriangleThreadData

PolyMainVertexShader mainVertexShader;

int modelFrame1 = -1;
int modelFrame2 = -1;
PolySWVertexShader swVertexShader;

private:
ShadedTriVertex ShadeVertex(int index);
void DrawShadedPoint(const ShadedTriVertex *const* vertex);
Expand Down Expand Up @@ -485,59 +462,6 @@ class PolySetInputAssemblyCommand : public PolyDrawerCommand
PolyInputAssembly *input;
};

class PolySetTransformCommand : public PolyDrawerCommand
{
public:
PolySetTransformCommand(const Mat4f *objectToClip, const Mat4f *objectToWorld) : objectToClip(objectToClip), objectToWorld(objectToWorld) { }
void Execute(DrawerThread *thread) override { PolyTriangleThreadData::Get(thread)->SetTransform(objectToClip, objectToWorld); }

private:
const Mat4f *objectToClip;
const Mat4f *objectToWorld;
};

class PolySetCullCCWCommand : public PolyDrawerCommand
{
public:
PolySetCullCCWCommand(bool ccw) : ccw(ccw) { }
void Execute(DrawerThread *thread) override { PolyTriangleThreadData::Get(thread)->SetCullCCW(ccw); }

private:
bool ccw;
};

class PolySetTwoSidedCommand : public PolyDrawerCommand
{
public:
PolySetTwoSidedCommand(bool twosided) : twosided(twosided) { }
void Execute(DrawerThread *thread) override { PolyTriangleThreadData::Get(thread)->SetTwoSided(twosided); }

private:
bool twosided;
};

class PolySetWeaponSceneCommand : public PolyDrawerCommand
{
public:
PolySetWeaponSceneCommand(bool value) : value(value) { }
void Execute(DrawerThread *thread) override { PolyTriangleThreadData::Get(thread)->SetWeaponScene(value); }

private:
bool value;
};

class PolySetModelVertexShaderCommand : public PolyDrawerCommand
{
public:
PolySetModelVertexShaderCommand(int frame1, int frame2, float interpolationFactor) : frame1(frame1), frame2(frame2), interpolationFactor(interpolationFactor) { }
void Execute(DrawerThread *thread) override { PolyTriangleThreadData::Get(thread)->SetModelVertexShader(frame1, frame2, interpolationFactor); }

private:
int frame1;
int frame2;
float interpolationFactor;
};

class PolyClearDepthCommand : public PolyDrawerCommand
{
public:
Expand Down Expand Up @@ -612,16 +536,6 @@ class PolyPushStreamDataCommand : public PolyDrawerCommand
PolyPushConstants constants;
};

class PolyPushDrawArgsCommand : public PolyDrawerCommand
{
public:
PolyPushDrawArgsCommand(const PolyDrawArgs &args) : args(args) { }
void Execute(DrawerThread *thread) override { PolyTriangleThreadData::Get(thread)->PushDrawArgs(args); }

private:
PolyDrawArgs args;
};

class PolyDrawCommand : public PolyDrawerCommand
{
public:
Expand Down
60 changes: 0 additions & 60 deletions src/rendering/polyrenderer/drawers/poly_vertex_shader.h
Expand Up @@ -197,63 +197,3 @@ class PolyMainVertexShader : public ShadedTriVertex
return result;
}
};

class PolySWVertexShader : public ShadedTriVertex
{
public:
// Input
TriVertex v1;
TriVertex v2;

// Uniforms
float modelInterpolationFactor = 0.0f;
const Mat4f *objectToClip = nullptr;
const Mat4f *objectToWorld = nullptr;
PolyDrawArgs *drawargs = nullptr;

void main()
{
Vec4f objpos;

if (modelInterpolationFactor == 0.f)
{
objpos = Vec4f(v1.x, v1.y, v1.z, v1.w);
vTexCoord.X = v1.u;
vTexCoord.Y = v1.v;
}
else
{
float frac = modelInterpolationFactor;
float inv_frac = 1.0f - frac;

objpos = Vec4f(v1.x * inv_frac + v2.x * frac, v1.y * inv_frac + v2.y * frac, v1.z * inv_frac + v2.z * frac, 1.0f);
vTexCoord.X = v1.u;
vTexCoord.Y = v1.v;
}

// Apply transform to get clip coordinates:
gl_Position = (*objectToClip) * objpos;

if (!objectToWorld) // Identity matrix
{
pixelpos = objpos;
}
else
{
pixelpos = (*objectToWorld) * objpos;
}

vColor = drawargs->Color();

vWorldNormal = { drawargs->Normal().X, drawargs->Normal().Y, drawargs->Normal().Z };

// Calculate gl_ClipDistance[i]
for (int i = 0; i < 3; i++)
{
const auto &clipPlane = drawargs->ClipPlane(i);
gl_ClipDistance[i] = objpos.X * clipPlane.A + objpos.Y * clipPlane.B + objpos.Z * clipPlane.C + objpos.W * clipPlane.D;
}
gl_ClipDistance[3] = 1.0f;
gl_ClipDistance[4] = 1.0f;
}
};
6 changes: 6 additions & 0 deletions src/rendering/swrenderer/things/r_model.cpp
Expand Up @@ -74,6 +74,7 @@ namespace swrenderer

void RenderModel::Render(RenderThread *thread, short *cliptop, short *clipbottom, int minZ, int maxZ, Fake3DTranslucent clip3DFloor)
{
#if 0
SWModelRenderer renderer(thread, clip3DFloor, &WorldToClip, MirrorWorldToClip);

renderer.sector = actor->Sector;
Expand All @@ -94,6 +95,7 @@ namespace swrenderer
renderer.AddLights(actor);
renderer.RenderModel(x, y, z, smf, actor, r_viewpoint.TicFrac);
PolyTriangleDrawer::SetModelVertexShader(thread->DrawQueue, -1, -1, 0.0f);
#endif
}

/////////////////////////////////////////////////////////////////////////////
Expand All @@ -116,6 +118,7 @@ namespace swrenderer

void RenderHUDModel(RenderThread *thread, DPSprite *psp, float ofsx, float ofsy)
{
#if 0
SWModelRenderer renderer(thread, Fake3DTranslucent(), &thread->Viewport->WorldToClip, false);

AActor *playermo = players[consoleplayer].camera;
Expand All @@ -141,10 +144,12 @@ namespace swrenderer

renderer.RenderHUDModel(psp, ofsx, ofsy);
PolyTriangleDrawer::SetModelVertexShader(thread->DrawQueue, -1, -1, 0.0f);
#endif
}

/////////////////////////////////////////////////////////////////////////////

#if 0
SWModelRenderer::SWModelRenderer(RenderThread *thread, Fake3DTranslucent clip3DFloor, Mat4f *worldToClip, bool mirrorWorldToClip)
: Thread(thread), Clip3DFloor(clip3DFloor), WorldToClip(worldToClip), MirrorWorldToClip(mirrorWorldToClip)
{
Expand Down Expand Up @@ -431,4 +436,5 @@ namespace swrenderer

PolyTriangleDrawer::SetModelVertexShader(swrenderer->Thread->DrawQueue, frame1, frame2, swrenderer->InterpolationFactor);
}
#endif
}
2 changes: 2 additions & 0 deletions src/rendering/swrenderer/things/r_model.h
Expand Up @@ -53,6 +53,7 @@ namespace swrenderer
bool MirrorWorldToClip;
};

#if 0
class SWModelRenderer : public FModelRenderer
{
public:
Expand Down Expand Up @@ -115,4 +116,5 @@ namespace swrenderer
TArray<FModelVertex> mVertexBuffer;
TArray<unsigned int> mIndexBuffer;
};
#endif
}

0 comments on commit 4a4b791

Please sign in to comment.