2012-11-01 16:19:01 +01:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
2012-11-04 23:01:49 +01:00
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
2012-11-01 16:19:01 +01:00
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2012-12-25 13:47:59 +01:00
|
|
|
#include "IndexGenerator.h"
|
2012-12-25 13:56:30 +01:00
|
|
|
#include "VertexDecoder.h"
|
2012-12-25 13:47:59 +01:00
|
|
|
|
2012-12-21 16:49:42 +01:00
|
|
|
class LinkedShader;
|
2012-12-25 13:47:59 +01:00
|
|
|
class ShaderManager;
|
2012-12-21 16:49:42 +01:00
|
|
|
struct DecVtxFormat;
|
|
|
|
|
2012-12-25 13:47:59 +01:00
|
|
|
// Handles transform, lighting and drawing.
|
|
|
|
class TransformDrawEngine {
|
|
|
|
public:
|
2012-12-25 15:28:34 +01:00
|
|
|
TransformDrawEngine();
|
2012-12-25 13:47:59 +01:00
|
|
|
~TransformDrawEngine();
|
|
|
|
void SubmitPrim(void *verts, void *inds, int prim, int vertexCount, float *customUV, int forceIndexType, int *bytesRead);
|
|
|
|
void DrawBezier(int ucount, int vcount);
|
|
|
|
void Flush();
|
2012-12-25 15:28:34 +01:00
|
|
|
void SetShaderManager(ShaderManager *shaderManager) {
|
|
|
|
shaderManager_ = shaderManager;
|
|
|
|
}
|
2012-12-25 13:47:59 +01:00
|
|
|
|
|
|
|
private:
|
2012-12-25 13:56:30 +01:00
|
|
|
void SoftwareTransformAndDraw(int prim, u8 *decoded, LinkedShader *program, int vertexCount, void *inds, int indexType, const DecVtxFormat &decVtxFormat, int maxIndex);
|
|
|
|
|
2012-12-25 13:47:59 +01:00
|
|
|
// Vertex collector state
|
|
|
|
IndexGenerator indexGen;
|
|
|
|
int numVerts;
|
|
|
|
|
|
|
|
// Vertex collector buffers
|
2012-12-25 13:56:30 +01:00
|
|
|
VertexDecoder dec;
|
2012-12-25 14:09:22 +01:00
|
|
|
u32 lastVType;
|
2012-12-25 13:56:30 +01:00
|
|
|
u8 *decoded;
|
|
|
|
u16 *decIndex;
|
|
|
|
|
|
|
|
TransformedVertex *transformed;
|
|
|
|
TransformedVertex *transformedExpanded;
|
2012-12-25 14:09:22 +01:00
|
|
|
|
2012-12-25 13:47:59 +01:00
|
|
|
// Other
|
|
|
|
ShaderManager *shaderManager_;
|
|
|
|
};
|
|
|
|
|
|
|
|
// void SoftwareTransformAndDraw(int prim, LinkedShader *program, int vertexCount, void *inds, int indexType, const DecVtxFormat &decVtxFormat, int maxIndex, float *customUV);
|
|
|
|
|
2012-12-21 16:49:42 +01:00
|
|
|
// Only used by SW transform
|
2012-12-25 13:47:59 +01:00
|
|
|
struct Color4 {
|
|
|
|
float r, g, b, a;
|
|
|
|
|
2012-12-21 16:49:42 +01:00
|
|
|
Color4() : r(0), g(0), b(0), a(0) { }
|
|
|
|
Color4(float _r, float _g, float _b, float _a=1.0f)
|
2012-12-25 13:47:59 +01:00
|
|
|
: r(_r), g(_g), b(_b), a(_a) {
|
2012-12-21 16:49:42 +01:00
|
|
|
}
|
|
|
|
Color4(const float in[4]) {r=in[0];g=in[1];b=in[2];a=in[3];}
|
|
|
|
Color4(const float in[3], float alpha) {r=in[0];g=in[1];b=in[2];a=alpha;}
|
|
|
|
|
|
|
|
const float &operator [](int i) const {return *(&r + i);}
|
|
|
|
|
2012-12-25 13:47:59 +01:00
|
|
|
Color4 operator *(float f) const {
|
2012-12-21 16:49:42 +01:00
|
|
|
return Color4(f*r,f*g,f*b,f*a);
|
|
|
|
}
|
2012-12-25 13:47:59 +01:00
|
|
|
Color4 operator *(const Color4 &c) const {
|
2012-12-21 16:49:42 +01:00
|
|
|
return Color4(r*c.r,g*c.g,b*c.b,a*c.a);
|
|
|
|
}
|
2012-12-25 13:47:59 +01:00
|
|
|
Color4 operator +(const Color4 &c) const {
|
2012-12-21 16:49:42 +01:00
|
|
|
return Color4(r+c.r,g+c.g,b+c.b,a+c.a);
|
|
|
|
}
|
2012-12-25 13:47:59 +01:00
|
|
|
void operator +=(const Color4 &c) {
|
2012-12-21 16:49:42 +01:00
|
|
|
r+=c.r;
|
|
|
|
g+=c.g;
|
|
|
|
b+=c.b;
|
|
|
|
a+=c.a;
|
|
|
|
}
|
2012-12-25 13:47:59 +01:00
|
|
|
void GetFromRGB(u32 col) {
|
2012-12-21 16:49:42 +01:00
|
|
|
r = ((col>>16) & 0xff)/255.0f;
|
|
|
|
g = ((col>>8) & 0xff)/255.0f;
|
|
|
|
b = ((col>>0) & 0xff)/255.0f;
|
|
|
|
}
|
2012-12-25 13:47:59 +01:00
|
|
|
void GetFromA(u32 col) {
|
2012-12-21 16:49:42 +01:00
|
|
|
a = (col&0xff)/255.0f;
|
|
|
|
}
|
|
|
|
};
|