mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Remove Thin3D prefix on more things
This commit is contained in:
parent
463251908b
commit
9b439e4c43
22 changed files with 216 additions and 216 deletions
|
@ -43,13 +43,13 @@ FormatBuffer depthbuf;
|
|||
u32 clut[4096];
|
||||
|
||||
static Draw::Thin3DVertexFormat *vformat = nullptr;
|
||||
static Draw::Thin3DDepthStencilState *depth = nullptr;
|
||||
static Draw::Thin3DRasterState *rasterNoCull = nullptr;
|
||||
static Draw::DepthStencilState *depth = nullptr;
|
||||
static Draw::RasterState *rasterNoCull = nullptr;
|
||||
static Draw::BlendState *blendstateOff = nullptr;
|
||||
static Draw::Thin3DSamplerState *samplerNearest = nullptr;
|
||||
static Draw::Thin3DSamplerState *samplerLinear = nullptr;
|
||||
static Draw::Thin3DBuffer *vdata = nullptr;
|
||||
static Draw::Thin3DBuffer *idata = nullptr;
|
||||
static Draw::SamplerState *samplerNearest = nullptr;
|
||||
static Draw::SamplerState *samplerLinear = nullptr;
|
||||
static Draw::Buffer *vdata = nullptr;
|
||||
static Draw::Buffer *idata = nullptr;
|
||||
|
||||
SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Draw::Thin3DContext *_thin3D)
|
||||
: gfxCtx_(gfxCtx), thin3d(_thin3D)
|
||||
|
@ -57,12 +57,12 @@ SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Draw::Thin3DContext *_thin3D)
|
|||
using namespace Draw;
|
||||
fbTex = thin3d->CreateTexture(LINEAR2D, DataFormat::R8A8G8B8_UNORM, 480, 272, 1, 1);
|
||||
|
||||
std::vector<Thin3DVertexComponent> components;
|
||||
components.push_back(Thin3DVertexComponent("Position", SEM_POSITION, DataFormat::FLOATx3, 0));
|
||||
components.push_back(Thin3DVertexComponent("TexCoord0", SEM_TEXCOORD0, DataFormat::FLOATx2, 12));
|
||||
components.push_back(Thin3DVertexComponent("Color0", SEM_COLOR0, DataFormat::UNORM8x4, 20));
|
||||
std::vector<VertexComponent> components;
|
||||
components.push_back(VertexComponent("Position", SEM_POSITION, DataFormat::FLOATx3, 0));
|
||||
components.push_back(VertexComponent("TexCoord0", SEM_TEXCOORD0, DataFormat::FLOATx2, 12));
|
||||
components.push_back(VertexComponent("Color0", SEM_COLOR0, DataFormat::UNORM8x4, 20));
|
||||
|
||||
Thin3DShader *vshader = thin3d->GetVshaderPreset(VS_TEXTURE_COLOR_2D);
|
||||
Shader *vshader = thin3d->GetVshaderPreset(VS_TEXTURE_COLOR_2D);
|
||||
vformat = thin3d->CreateVertexFormat(components, 24, vshader);
|
||||
|
||||
vdata = thin3d->CreateBuffer(24 * 4, BufferUsageFlag::DYNAMIC | BufferUsageFlag::VERTEXDATA);
|
||||
|
@ -135,7 +135,7 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) {
|
|||
Viewport viewport = {0.0f, 0.0f, dstwidth, dstheight, 0.0f, 1.0f};
|
||||
thin3d->SetViewports(1, &viewport);
|
||||
thin3d->SetBlendState(blendstateOff);
|
||||
Thin3DSamplerState *sampler;
|
||||
SamplerState *sampler;
|
||||
if (g_Config.iBufFilter == SCALE_NEAREST) {
|
||||
sampler = samplerNearest;
|
||||
} else {
|
||||
|
@ -232,7 +232,7 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) {
|
|||
idata->SetData((const uint8_t *)indexes, sizeof(indexes));
|
||||
|
||||
thin3d->BindTexture(0, fbTex);
|
||||
Thin3DShaderSet *texColor = thin3d->GetShaderSetPreset(SS_TEXTURE_COLOR_2D);
|
||||
ShaderSet *texColor = thin3d->GetShaderSetPreset(SS_TEXTURE_COLOR_2D);
|
||||
|
||||
static const float identity4x4[16] = {
|
||||
1.0f, 0.0f, 0.0f, 0.0f,
|
||||
|
|
|
@ -47,7 +47,7 @@ typedef struct {
|
|||
class ShaderManager;
|
||||
namespace Draw {
|
||||
class Thin3DContext;
|
||||
class Thin3DTexture;
|
||||
class Texture;
|
||||
}
|
||||
|
||||
class SoftGPU : public GPUCommon {
|
||||
|
@ -107,7 +107,7 @@ private:
|
|||
GEBufferFormat displayFormat_;
|
||||
|
||||
GraphicsContext *gfxCtx_;
|
||||
Draw::Thin3DTexture *fbTex;
|
||||
Draw::Texture *fbTex;
|
||||
Draw::Thin3DContext *thin3d;
|
||||
std::vector<u32> fbTexBuffer;
|
||||
};
|
||||
|
|
|
@ -781,7 +781,7 @@ again:
|
|||
return info;
|
||||
}
|
||||
|
||||
void GameInfoCache::SetupTexture(GameInfo *info, std::string &textureData, Draw::Thin3DContext *thin3d, Draw::Thin3DTexture *&tex, double &loadTime) {
|
||||
void GameInfoCache::SetupTexture(GameInfo *info, std::string &textureData, Draw::Thin3DContext *thin3d, Draw::Texture *&tex, double &loadTime) {
|
||||
using namespace Draw;
|
||||
if (textureData.size()) {
|
||||
if (!tex) {
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
namespace Draw {
|
||||
class Thin3DContext;
|
||||
class Thin3DTexture;
|
||||
class Texture;
|
||||
}
|
||||
class PrioritizedWorkQueue;
|
||||
|
||||
|
@ -142,11 +142,11 @@ public:
|
|||
|
||||
// Pre read the data, create a texture the next time (GL thread..)
|
||||
std::string iconTextureData;
|
||||
Draw::Thin3DTexture *iconTexture;
|
||||
Draw::Texture *iconTexture;
|
||||
std::string pic0TextureData;
|
||||
Draw::Thin3DTexture *pic0Texture;
|
||||
Draw::Texture *pic0Texture;
|
||||
std::string pic1TextureData;
|
||||
Draw::Thin3DTexture *pic1Texture;
|
||||
Draw::Texture *pic1Texture;
|
||||
|
||||
std::string sndFileData;
|
||||
|
||||
|
@ -202,7 +202,7 @@ public:
|
|||
private:
|
||||
void Init();
|
||||
void Shutdown();
|
||||
void SetupTexture(GameInfo *info, std::string &textureData, Draw::Thin3DContext *thin3d, Draw::Thin3DTexture *&tex, double &loadTime);
|
||||
void SetupTexture(GameInfo *info, std::string &textureData, Draw::Thin3DContext *thin3d, Draw::Texture *&tex, double &loadTime);
|
||||
|
||||
// Maps ISO path to info.
|
||||
std::map<std::string, GameInfo *> info_;
|
||||
|
|
|
@ -174,7 +174,7 @@ private:
|
|||
|
||||
void GameButton::Draw(UIContext &dc) {
|
||||
GameInfo *ginfo = g_gameInfoCache->GetInfo(dc.GetThin3DContext(), gamePath_, 0);
|
||||
Draw::Thin3DTexture *texture = 0;
|
||||
Draw::Texture *texture = 0;
|
||||
u32 color = 0, shadowColor = 0;
|
||||
using namespace UI;
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ static UI::Theme ui_theme;
|
|||
#include "android/android-ndk-profiler/prof.h"
|
||||
#endif
|
||||
|
||||
Draw::Thin3DTexture *uiTexture;
|
||||
Draw::Texture *uiTexture;
|
||||
|
||||
ScreenManager *screenManager;
|
||||
std::string config_filename;
|
||||
|
|
|
@ -95,7 +95,7 @@ private:
|
|||
uint32_t color_;
|
||||
UI::ImageSizeMode sizeMode_;
|
||||
|
||||
Draw::Thin3DTexture *texture_;
|
||||
Draw::Texture *texture_;
|
||||
bool textureFailed_;
|
||||
bool textureAutoGen_;
|
||||
float fixedSizeW_;
|
||||
|
|
|
@ -154,7 +154,7 @@ static std::string CleanSaveString(std::string str) {
|
|||
|
||||
void SavedataButton::Draw(UIContext &dc) {
|
||||
GameInfo *ginfo = g_gameInfoCache->GetInfo(dc.GetThin3DContext(), savePath_, GAMEINFO_WANTSIZE);
|
||||
Draw::Thin3DTexture *texture = 0;
|
||||
Draw::Texture *texture = 0;
|
||||
u32 color = 0, shadowColor = 0;
|
||||
using namespace UI;
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ private:
|
|||
std::shared_ptr<http::Download> download_;
|
||||
|
||||
std::string textureData_;
|
||||
Draw::Thin3DTexture *texture_;
|
||||
Draw::Texture *texture_;
|
||||
bool textureFailed_;
|
||||
float fixedSizeW_;
|
||||
float fixedSizeH_;
|
||||
|
|
|
@ -41,12 +41,12 @@ void DrawBuffer::Init(Draw::Thin3DContext *t3d) {
|
|||
t3d_ = t3d;
|
||||
inited_ = true;
|
||||
|
||||
std::vector<Thin3DVertexComponent> components;
|
||||
components.push_back(Thin3DVertexComponent("Position", SEM_POSITION, DataFormat::FLOATx3, 0));
|
||||
components.push_back(Thin3DVertexComponent("TexCoord0", SEM_TEXCOORD0, DataFormat::FLOATx2, 12));
|
||||
components.push_back(Thin3DVertexComponent("Color0", SEM_COLOR0, DataFormat::UNORM8x4, 20));
|
||||
std::vector<VertexComponent> components;
|
||||
components.push_back(VertexComponent("Position", SEM_POSITION, DataFormat::FLOATx3, 0));
|
||||
components.push_back(VertexComponent("TexCoord0", SEM_TEXCOORD0, DataFormat::FLOATx2, 12));
|
||||
components.push_back(VertexComponent("Color0", SEM_COLOR0, DataFormat::UNORM8x4, 20));
|
||||
|
||||
Thin3DShader *vshader = t3d_->GetVshaderPreset(VS_TEXTURE_COLOR_2D);
|
||||
Shader *vshader = t3d_->GetVshaderPreset(VS_TEXTURE_COLOR_2D);
|
||||
|
||||
vformat_ = t3d_->CreateVertexFormat(components, 24, vshader);
|
||||
if (vformat_->RequiresBuffer()) {
|
||||
|
@ -65,7 +65,7 @@ void DrawBuffer::Shutdown() {
|
|||
inited_ = false;
|
||||
}
|
||||
|
||||
void DrawBuffer::Begin(Draw::Thin3DShaderSet *program, DrawBufferPrimitiveMode dbmode) {
|
||||
void DrawBuffer::Begin(Draw::ShaderSet *program, DrawBufferPrimitiveMode dbmode) {
|
||||
shaderSet_ = program;
|
||||
count_ = 0;
|
||||
mode_ = dbmode;
|
||||
|
|
|
@ -43,7 +43,7 @@ enum {
|
|||
};
|
||||
|
||||
namespace Draw {
|
||||
class Thin3DShaderSet;
|
||||
class ShaderSet;
|
||||
}
|
||||
|
||||
enum DrawBufferPrimitiveMode {
|
||||
|
@ -63,7 +63,7 @@ public:
|
|||
DrawBuffer();
|
||||
~DrawBuffer();
|
||||
|
||||
void Begin(Draw::Thin3DShaderSet *shaders, DrawBufferPrimitiveMode mode = DBMODE_NORMAL);
|
||||
void Begin(Draw::ShaderSet *shaders, DrawBufferPrimitiveMode mode = DBMODE_NORMAL);
|
||||
void End();
|
||||
|
||||
// TODO: Enforce these. Now Init is autocalled and shutdown not called.
|
||||
|
@ -158,9 +158,9 @@ private:
|
|||
Matrix4x4 drawMatrix_;
|
||||
|
||||
Draw::Thin3DContext *t3d_;
|
||||
Draw::Thin3DBuffer *vbuf_;
|
||||
Draw::Buffer *vbuf_;
|
||||
Draw::Thin3DVertexFormat *vformat_;
|
||||
Draw::Thin3DShaderSet *shaderSet_;
|
||||
Draw::ShaderSet *shaderSet_;
|
||||
|
||||
Vertex *verts_;
|
||||
int count_;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
namespace Draw {
|
||||
class Thin3DContext;
|
||||
class Thin3DTexture;
|
||||
class Texture;
|
||||
}
|
||||
|
||||
#ifdef USING_QT_UI
|
||||
|
@ -23,7 +23,7 @@ namespace Draw {
|
|||
#endif
|
||||
|
||||
struct TextStringEntry {
|
||||
Draw::Thin3DTexture *texture;
|
||||
Draw::Texture *texture;
|
||||
int width;
|
||||
int height;
|
||||
int bmWidth;
|
||||
|
|
|
@ -244,7 +244,7 @@ static bool LoadTextureLevels(const uint8_t *data, size_t size, ImageFileType ty
|
|||
return *num_levels > 0;
|
||||
}
|
||||
|
||||
bool Thin3DTexture::LoadFromFileData(const uint8_t *data, size_t dataSize, ImageFileType type) {
|
||||
bool Texture::LoadFromFileData(const uint8_t *data, size_t dataSize, ImageFileType type) {
|
||||
int width[16], height[16];
|
||||
uint8_t *image[16] = { nullptr };
|
||||
|
||||
|
@ -275,7 +275,7 @@ bool Thin3DTexture::LoadFromFileData(const uint8_t *data, size_t dataSize, Image
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Thin3DTexture::LoadFromFile(const std::string &filename, ImageFileType type) {
|
||||
bool Texture::LoadFromFile(const std::string &filename, ImageFileType type) {
|
||||
filename_ = "";
|
||||
size_t fileSize;
|
||||
uint8_t *buffer = VFSReadFile(filename.c_str(), &fileSize);
|
||||
|
@ -292,8 +292,8 @@ bool Thin3DTexture::LoadFromFile(const std::string &filename, ImageFileType type
|
|||
return retval;
|
||||
}
|
||||
|
||||
Thin3DTexture *Thin3DContext::CreateTextureFromFile(const char *filename, ImageFileType type) {
|
||||
Thin3DTexture *tex = CreateTexture();
|
||||
Texture *Thin3DContext::CreateTextureFromFile(const char *filename, ImageFileType type) {
|
||||
Texture *tex = CreateTexture();
|
||||
if (!tex->LoadFromFile(filename, type)) {
|
||||
tex->Release();
|
||||
return NULL;
|
||||
|
@ -302,7 +302,7 @@ Thin3DTexture *Thin3DContext::CreateTextureFromFile(const char *filename, ImageF
|
|||
}
|
||||
|
||||
// TODO: Remove the code duplication between this and LoadFromFileData
|
||||
Thin3DTexture *Thin3DContext::CreateTextureFromFileData(const uint8_t *data, int size, ImageFileType type) {
|
||||
Texture *Thin3DContext::CreateTextureFromFileData(const uint8_t *data, int size, ImageFileType type) {
|
||||
int width[16], height[16];
|
||||
int num_levels = 0;
|
||||
int zim_flags = 0;
|
||||
|
@ -313,7 +313,7 @@ Thin3DTexture *Thin3DContext::CreateTextureFromFileData(const uint8_t *data, int
|
|||
return NULL;
|
||||
}
|
||||
|
||||
Thin3DTexture *tex = CreateTexture(LINEAR2D, fmt, width[0], height[0], 1, num_levels);
|
||||
Texture *tex = CreateTexture(LINEAR2D, fmt, width[0], height[0], 1, num_levels);
|
||||
for (int i = 0; i < num_levels; i++) {
|
||||
tex->SetImageData(0, 0, 0, width[i], height[i], 1, i, width[i] * 4, image[i]);
|
||||
free(image[i]);
|
||||
|
|
|
@ -128,20 +128,20 @@ enum class Primitive {
|
|||
TRIANGLE_STRIP_ADJ,
|
||||
};
|
||||
|
||||
enum T3DVertexShaderPreset : int {
|
||||
enum VertexShaderPreset : int {
|
||||
VS_COLOR_2D,
|
||||
VS_TEXTURE_COLOR_2D,
|
||||
VS_MAX_PRESET,
|
||||
};
|
||||
|
||||
enum T3DFragmentShaderPreset : int {
|
||||
enum FragmentShaderPreset : int {
|
||||
FS_COLOR_2D,
|
||||
FS_TEXTURE_COLOR_2D,
|
||||
FS_MAX_PRESET,
|
||||
};
|
||||
|
||||
// Predefined full shader setups.
|
||||
enum T3DShaderSetPreset : int {
|
||||
enum ShaderSetPreset : int {
|
||||
SS_COLOR_2D,
|
||||
SS_TEXTURE_COLOR_2D,
|
||||
SS_MAX_PRESET,
|
||||
|
@ -235,21 +235,21 @@ class BlendState : public Thin3DObject {
|
|||
public:
|
||||
};
|
||||
|
||||
class Thin3DSamplerState : public Thin3DObject {
|
||||
class SamplerState : public Thin3DObject {
|
||||
public:
|
||||
};
|
||||
|
||||
class Thin3DDepthStencilState : public Thin3DObject {
|
||||
class DepthStencilState : public Thin3DObject {
|
||||
public:
|
||||
};
|
||||
|
||||
class Thin3DBuffer : public Thin3DObject {
|
||||
class Buffer : public Thin3DObject {
|
||||
public:
|
||||
virtual void SetData(const uint8_t *data, size_t size) = 0;
|
||||
virtual void SubData(const uint8_t *data, size_t offset, size_t size) = 0;
|
||||
};
|
||||
|
||||
class Thin3DTexture : public Thin3DObject {
|
||||
class Texture : public Thin3DObject {
|
||||
public:
|
||||
bool LoadFromFile(const std::string &filename, ImageFileType type = ImageFileType::DETECT);
|
||||
bool LoadFromFileData(const uint8_t *data, size_t dataSize, ImageFileType type = ImageFileType::DETECT);
|
||||
|
@ -267,9 +267,9 @@ protected:
|
|||
int width_, height_, depth_;
|
||||
};
|
||||
|
||||
struct Thin3DVertexComponent {
|
||||
Thin3DVertexComponent() : name(nullptr), type(DataFormat::UNKNOWN), semantic(255), offset(255) {}
|
||||
Thin3DVertexComponent(const char *name, Semantic semantic, DataFormat dataType, uint8_t offset) {
|
||||
struct VertexComponent {
|
||||
VertexComponent() : name(nullptr), type(DataFormat::UNKNOWN), semantic(255), offset(255) {}
|
||||
VertexComponent(const char *name, Semantic semantic, DataFormat dataType, uint8_t offset) {
|
||||
this->name = name;
|
||||
this->semantic = semantic;
|
||||
this->type = dataType;
|
||||
|
@ -286,18 +286,18 @@ public:
|
|||
virtual bool RequiresBuffer() = 0;
|
||||
};
|
||||
|
||||
class Thin3DShader : public Thin3DObject {
|
||||
class Shader : public Thin3DObject {
|
||||
public:
|
||||
};
|
||||
|
||||
class Thin3DShaderSet : public Thin3DObject {
|
||||
class ShaderSet : public Thin3DObject {
|
||||
public:
|
||||
// TODO: Make some faster way of doing these. Support uniform buffers (and fake them on GL 2.0?)
|
||||
virtual void SetVector(const char *name, float *value, int n) = 0;
|
||||
virtual void SetMatrix4x4(const char *name, const float value[16]) = 0;
|
||||
};
|
||||
|
||||
class Thin3DRasterState : public Thin3DObject {
|
||||
class RasterState : public Thin3DObject {
|
||||
public:
|
||||
};
|
||||
|
||||
|
@ -332,7 +332,7 @@ struct BlendStateDesc {
|
|||
// int colorMask;
|
||||
};
|
||||
|
||||
struct T3DSamplerStateDesc {
|
||||
struct SamplerStateDesc {
|
||||
TextureFilter magFilt;
|
||||
TextureFilter minFilt;
|
||||
TextureFilter mipFilt;
|
||||
|
@ -363,37 +363,37 @@ public:
|
|||
|
||||
virtual std::vector<std::string> GetFeatureList() { return std::vector<std::string>(); }
|
||||
|
||||
virtual Thin3DDepthStencilState *CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare) = 0;
|
||||
virtual DepthStencilState *CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare) = 0;
|
||||
virtual BlendState *CreateBlendState(const BlendStateDesc &desc) = 0;
|
||||
virtual Thin3DSamplerState *CreateSamplerState(const T3DSamplerStateDesc &desc) = 0;
|
||||
virtual Thin3DRasterState *CreateRasterState(const T3DRasterStateDesc &desc) = 0;
|
||||
virtual Thin3DBuffer *CreateBuffer(size_t size, uint32_t usageFlags) = 0;
|
||||
virtual Thin3DShaderSet *CreateShaderSet(Thin3DShader *vshader, Thin3DShader *fshader) = 0;
|
||||
virtual Thin3DVertexFormat *CreateVertexFormat(const std::vector<Thin3DVertexComponent> &components, int stride, Thin3DShader *vshader) = 0;
|
||||
virtual SamplerState *CreateSamplerState(const SamplerStateDesc &desc) = 0;
|
||||
virtual RasterState *CreateRasterState(const T3DRasterStateDesc &desc) = 0;
|
||||
virtual Buffer *CreateBuffer(size_t size, uint32_t usageFlags) = 0;
|
||||
virtual ShaderSet *CreateShaderSet(Shader *vshader, Shader *fshader) = 0;
|
||||
virtual Thin3DVertexFormat *CreateVertexFormat(const std::vector<VertexComponent> &components, int stride, Shader *vshader) = 0;
|
||||
|
||||
virtual Thin3DTexture *CreateTexture() = 0; // To be later filled in by ->LoadFromFile or similar.
|
||||
virtual Thin3DTexture *CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) = 0;
|
||||
virtual Texture *CreateTexture() = 0; // To be later filled in by ->LoadFromFile or similar.
|
||||
virtual Texture *CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) = 0;
|
||||
|
||||
// Common Thin3D function, uses CreateTexture
|
||||
Thin3DTexture *CreateTextureFromFile(const char *filename, ImageFileType fileType);
|
||||
Thin3DTexture *CreateTextureFromFileData(const uint8_t *data, int size, ImageFileType fileType);
|
||||
Texture *CreateTextureFromFile(const char *filename, ImageFileType fileType);
|
||||
Texture *CreateTextureFromFileData(const uint8_t *data, int size, ImageFileType fileType);
|
||||
|
||||
// Note that these DO NOT AddRef so you must not ->Release presets unless you manually AddRef them.
|
||||
Thin3DShader *GetVshaderPreset(T3DVertexShaderPreset preset) { return fsPresets_[preset]; }
|
||||
Thin3DShader *GetFshaderPreset(T3DFragmentShaderPreset preset) { return vsPresets_[preset]; }
|
||||
Thin3DShaderSet *GetShaderSetPreset(T3DShaderSetPreset preset) { return ssPresets_[preset]; }
|
||||
Shader *GetVshaderPreset(VertexShaderPreset preset) { return fsPresets_[preset]; }
|
||||
Shader *GetFshaderPreset(FragmentShaderPreset preset) { return vsPresets_[preset]; }
|
||||
ShaderSet *GetShaderSetPreset(ShaderSetPreset preset) { return ssPresets_[preset]; }
|
||||
|
||||
// The implementation makes the choice of which shader code to use.
|
||||
virtual Thin3DShader *CreateShader(ShaderStage stage, const char *glsl_source, const char *hlsl_source, const char *vulkan_source) = 0;
|
||||
virtual Shader *CreateShader(ShaderStage stage, const char *glsl_source, const char *hlsl_source, const char *vulkan_source) = 0;
|
||||
|
||||
// Bound state objects. Too cumbersome to add them all as parameters to Draw.
|
||||
virtual void SetBlendState(BlendState *state) = 0;
|
||||
virtual void SetSamplerStates(int start, int count, Thin3DSamplerState **state) = 0;
|
||||
virtual void SetDepthStencilState(Thin3DDepthStencilState *state) = 0;
|
||||
virtual void SetRasterState(Thin3DRasterState *state) = 0;
|
||||
virtual void SetSamplerStates(int start, int count, SamplerState **state) = 0;
|
||||
virtual void SetDepthStencilState(DepthStencilState *state) = 0;
|
||||
virtual void SetRasterState(RasterState *state) = 0;
|
||||
|
||||
virtual void BindTextures(int start, int count, Thin3DTexture **textures) = 0;
|
||||
void BindTexture(int stage, Thin3DTexture *texture) {
|
||||
virtual void BindTextures(int start, int count, Texture **textures) = 0;
|
||||
void BindTexture(int stage, Texture *texture) {
|
||||
BindTextures(stage, 1, &texture);
|
||||
} // from sampler 0 and upwards
|
||||
|
||||
|
@ -403,9 +403,9 @@ public:
|
|||
virtual void SetViewports(int count, Viewport *viewports) = 0;
|
||||
|
||||
// TODO: Add more sophisticated draws with buffer offsets, and multidraws.
|
||||
virtual void Draw(Primitive prim, Thin3DShaderSet *pipeline, Thin3DVertexFormat *format, Thin3DBuffer *vdata, int vertexCount, int offset) = 0;
|
||||
virtual void DrawIndexed(Primitive prim, Thin3DShaderSet *pipeline, Thin3DVertexFormat *format, Thin3DBuffer *vdata, Thin3DBuffer *idata, int vertexCount, int offset) = 0;
|
||||
virtual void DrawUP(Primitive prim, Thin3DShaderSet *pipeline, Thin3DVertexFormat *format, const void *vdata, int vertexCount) = 0;
|
||||
virtual void Draw(Primitive prim, ShaderSet *pipeline, Thin3DVertexFormat *format, Buffer *vdata, int vertexCount, int offset) = 0;
|
||||
virtual void DrawIndexed(Primitive prim, ShaderSet *pipeline, Thin3DVertexFormat *format, Buffer *vdata, Buffer *idata, int vertexCount, int offset) = 0;
|
||||
virtual void DrawUP(Primitive prim, ShaderSet *pipeline, Thin3DVertexFormat *format, const void *vdata, int vertexCount) = 0;
|
||||
|
||||
// Render pass management. Default implementations here.
|
||||
virtual void Begin(bool clear, uint32_t colorval, float depthVal, int stencilVal) {
|
||||
|
@ -426,9 +426,9 @@ public:
|
|||
protected:
|
||||
void CreatePresets();
|
||||
|
||||
Thin3DShader *vsPresets_[VS_MAX_PRESET];
|
||||
Thin3DShader *fsPresets_[FS_MAX_PRESET];
|
||||
Thin3DShaderSet *ssPresets_[SS_MAX_PRESET];
|
||||
Shader *vsPresets_[VS_MAX_PRESET];
|
||||
Shader *fsPresets_[FS_MAX_PRESET];
|
||||
ShaderSet *ssPresets_[SS_MAX_PRESET];
|
||||
|
||||
int targetWidth_;
|
||||
int targetHeight_;
|
||||
|
|
|
@ -90,7 +90,7 @@ inline int PrimCountDivisor(Primitive prim) {
|
|||
}
|
||||
}
|
||||
|
||||
class Thin3DDX9DepthStencilState : public Thin3DDepthStencilState {
|
||||
class Thin3DDX9DepthStencilState : public DepthStencilState {
|
||||
public:
|
||||
BOOL depthTestEnabled;
|
||||
BOOL depthWriteEnabled;
|
||||
|
@ -104,7 +104,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
class Thin3DDX9RasterState : public Thin3DRasterState {
|
||||
class Thin3DDX9RasterState : public RasterState {
|
||||
public:
|
||||
DWORD cullMode;
|
||||
|
||||
|
@ -133,7 +133,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class Thin3DDX9SamplerState : public Thin3DSamplerState {
|
||||
class Thin3DDX9SamplerState : public SamplerState {
|
||||
public:
|
||||
D3DTEXTUREADDRESS wrapS, wrapT;
|
||||
D3DTEXTUREFILTERTYPE magFilt, minFilt, mipFilt;
|
||||
|
@ -147,7 +147,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class Thin3DDX9Buffer : public Thin3DBuffer {
|
||||
class Thin3DDX9Buffer : public Buffer {
|
||||
public:
|
||||
Thin3DDX9Buffer(LPDIRECT3DDEVICE9 device, size_t size, uint32_t flags) : vbuffer_(nullptr), ibuffer_(nullptr), maxSize_(size) {
|
||||
if (flags & BufferUsageFlag::INDEXDATA) {
|
||||
|
@ -227,7 +227,7 @@ private:
|
|||
|
||||
class Thin3DDX9VertexFormat : public Thin3DVertexFormat {
|
||||
public:
|
||||
Thin3DDX9VertexFormat(LPDIRECT3DDEVICE9 device, const std::vector<Thin3DVertexComponent> &components, int stride);
|
||||
Thin3DDX9VertexFormat(LPDIRECT3DDEVICE9 device, const std::vector<VertexComponent> &components, int stride);
|
||||
~Thin3DDX9VertexFormat() {
|
||||
if (decl_) {
|
||||
decl_->Release();
|
||||
|
@ -245,7 +245,7 @@ private:
|
|||
int stride_;
|
||||
};
|
||||
|
||||
class Thin3DDX9Shader : public Thin3DShader {
|
||||
class Thin3DDX9Shader : public Shader {
|
||||
public:
|
||||
Thin3DDX9Shader(ShaderStage stage) : stage_(stage), vshader_(NULL), pshader_(NULL), constantTable_(NULL) {}
|
||||
~Thin3DDX9Shader() {
|
||||
|
@ -274,7 +274,7 @@ private:
|
|||
LPD3DXCONSTANTTABLE constantTable_;
|
||||
};
|
||||
|
||||
class Thin3DDX9ShaderSet : public Thin3DShaderSet {
|
||||
class Thin3DDX9ShaderSet : public ShaderSet {
|
||||
public:
|
||||
Thin3DDX9ShaderSet(LPDIRECT3DDEVICE9 device) : device_(device) {}
|
||||
Thin3DDX9Shader *vshader;
|
||||
|
@ -286,7 +286,7 @@ private:
|
|||
LPDIRECT3DDEVICE9 device_;
|
||||
};
|
||||
|
||||
class Thin3DDX9Texture : public Thin3DTexture {
|
||||
class Thin3DDX9Texture : public Texture {
|
||||
public:
|
||||
Thin3DDX9Texture(LPDIRECT3DDEVICE9 device, LPDIRECT3DDEVICE9EX deviceEx) : device_(device), deviceEx_(deviceEx), type_(TextureType::UNKNOWN), fmt_(D3DFMT_UNKNOWN), tex_(NULL), volTex_(NULL), cubeTex_(NULL) {
|
||||
}
|
||||
|
@ -448,47 +448,47 @@ public:
|
|||
Thin3DDX9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, IDirect3DDevice9 *device, IDirect3DDevice9Ex *deviceEx);
|
||||
~Thin3DDX9Context();
|
||||
|
||||
Thin3DDepthStencilState *CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare);
|
||||
DepthStencilState *CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare);
|
||||
BlendState *CreateBlendState(const BlendStateDesc &desc) override;
|
||||
Thin3DSamplerState *CreateSamplerState(const T3DSamplerStateDesc &desc) override;
|
||||
Thin3DRasterState *CreateRasterState(const T3DRasterStateDesc &desc) override;
|
||||
Thin3DBuffer *CreateBuffer(size_t size, uint32_t usageFlags) override;
|
||||
Thin3DShaderSet *CreateShaderSet(Thin3DShader *vshader, Thin3DShader *fshader) override;
|
||||
Thin3DVertexFormat *CreateVertexFormat(const std::vector<Thin3DVertexComponent> &components, int stride, Thin3DShader *vshader) override;
|
||||
Thin3DTexture *CreateTexture() override;
|
||||
Thin3DTexture *CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) override;
|
||||
Thin3DShader *CreateShader(ShaderStage stage, const char *glsl_source, const char *hlsl_source, const char *vulkan_source) override;
|
||||
SamplerState *CreateSamplerState(const SamplerStateDesc &desc) override;
|
||||
RasterState *CreateRasterState(const T3DRasterStateDesc &desc) override;
|
||||
Buffer *CreateBuffer(size_t size, uint32_t usageFlags) override;
|
||||
ShaderSet *CreateShaderSet(Shader *vshader, Shader *fshader) override;
|
||||
Thin3DVertexFormat *CreateVertexFormat(const std::vector<VertexComponent> &components, int stride, Shader *vshader) override;
|
||||
Texture *CreateTexture() override;
|
||||
Texture *CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) override;
|
||||
Shader *CreateShader(ShaderStage stage, const char *glsl_source, const char *hlsl_source, const char *vulkan_source) override;
|
||||
|
||||
// Bound state objects. Too cumbersome to add them all as parameters to Draw.
|
||||
void SetBlendState(BlendState *state) {
|
||||
Thin3DDX9BlendState *bs = static_cast<Thin3DDX9BlendState *>(state);
|
||||
bs->Apply(device_);
|
||||
}
|
||||
void SetSamplerStates(int start, int count, Thin3DSamplerState **states) {
|
||||
void SetSamplerStates(int start, int count, SamplerState **states) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
Thin3DDX9SamplerState *s = static_cast<Thin3DDX9SamplerState *>(states[start + i]);
|
||||
s->Apply(device_, start + i);
|
||||
}
|
||||
}
|
||||
void SetDepthStencilState(Thin3DDepthStencilState *state) {
|
||||
void SetDepthStencilState(DepthStencilState *state) {
|
||||
Thin3DDX9DepthStencilState *bs = static_cast<Thin3DDX9DepthStencilState *>(state);
|
||||
bs->Apply(device_);
|
||||
}
|
||||
void SetRasterState(Thin3DRasterState *state) {
|
||||
void SetRasterState(RasterState *state) {
|
||||
Thin3DDX9RasterState *bs = static_cast<Thin3DDX9RasterState *>(state);
|
||||
bs->Apply(device_);
|
||||
}
|
||||
|
||||
void BindTextures(int start, int count, Thin3DTexture **textures);
|
||||
void BindTextures(int start, int count, Texture **textures);
|
||||
|
||||
// Raster state
|
||||
void SetScissorEnabled(bool enable);
|
||||
void SetScissorRect(int left, int top, int width, int height);
|
||||
void SetViewports(int count, Viewport *viewports);
|
||||
|
||||
void Draw(Primitive prim, Thin3DShaderSet *pipeline, Thin3DVertexFormat *format, Thin3DBuffer *vdata, int vertexCount, int offset) override;
|
||||
void DrawIndexed(Primitive prim, Thin3DShaderSet *pipeline, Thin3DVertexFormat *format, Thin3DBuffer *vdata, Thin3DBuffer *idata, int vertexCount, int offset) override;
|
||||
void DrawUP(Primitive prim, Thin3DShaderSet *shaderSet, Thin3DVertexFormat *format, const void *vdata, int vertexCount) override;
|
||||
void Draw(Primitive prim, ShaderSet *pipeline, Thin3DVertexFormat *format, Buffer *vdata, int vertexCount, int offset) override;
|
||||
void DrawIndexed(Primitive prim, ShaderSet *pipeline, Thin3DVertexFormat *format, Buffer *vdata, Buffer *idata, int vertexCount, int offset) override;
|
||||
void DrawUP(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, const void *vdata, int vertexCount) override;
|
||||
void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal);
|
||||
|
||||
std::string GetInfoString(InfoField info) const override {
|
||||
|
@ -528,7 +528,7 @@ Thin3DDX9Context::Thin3DDX9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int ada
|
|||
Thin3DDX9Context::~Thin3DDX9Context() {
|
||||
}
|
||||
|
||||
Thin3DShader *Thin3DDX9Context::CreateShader(ShaderStage stage, const char *glsl_source, const char *hlsl_source, const char *vulkan_source) {
|
||||
Shader *Thin3DDX9Context::CreateShader(ShaderStage stage, const char *glsl_source, const char *hlsl_source, const char *vulkan_source) {
|
||||
Thin3DDX9Shader *shader = new Thin3DDX9Shader(stage);
|
||||
if (shader->Compile(device_, hlsl_source)) {
|
||||
return shader;
|
||||
|
@ -538,7 +538,7 @@ Thin3DShader *Thin3DDX9Context::CreateShader(ShaderStage stage, const char *glsl
|
|||
}
|
||||
}
|
||||
|
||||
Thin3DShaderSet *Thin3DDX9Context::CreateShaderSet(Thin3DShader *vshader, Thin3DShader *fshader) {
|
||||
ShaderSet *Thin3DDX9Context::CreateShaderSet(Shader *vshader, Shader *fshader) {
|
||||
if (!vshader || !fshader) {
|
||||
ELOG("ShaderSet requires both a valid vertex and a fragment shader: %p %p", vshader, fshader);
|
||||
return NULL;
|
||||
|
@ -549,7 +549,7 @@ Thin3DShaderSet *Thin3DDX9Context::CreateShaderSet(Thin3DShader *vshader, Thin3D
|
|||
return shaderSet;
|
||||
}
|
||||
|
||||
Thin3DDepthStencilState *Thin3DDX9Context::CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare) {
|
||||
DepthStencilState *Thin3DDX9Context::CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare) {
|
||||
Thin3DDX9DepthStencilState *ds = new Thin3DDX9DepthStencilState();
|
||||
ds->depthCompare = compareToD3D9[depthCompare];
|
||||
ds->depthTestEnabled = depthTestEnabled;
|
||||
|
@ -557,7 +557,7 @@ Thin3DDepthStencilState *Thin3DDX9Context::CreateDepthStencilState(bool depthTes
|
|||
return ds;
|
||||
}
|
||||
|
||||
Thin3DVertexFormat *Thin3DDX9Context::CreateVertexFormat(const std::vector<Thin3DVertexComponent> &components, int stride, Thin3DShader *vshader) {
|
||||
Thin3DVertexFormat *Thin3DDX9Context::CreateVertexFormat(const std::vector<VertexComponent> &components, int stride, Shader *vshader) {
|
||||
Thin3DDX9VertexFormat *fmt = new Thin3DDX9VertexFormat(device_, components, stride);
|
||||
return fmt;
|
||||
}
|
||||
|
@ -575,7 +575,7 @@ BlendState *Thin3DDX9Context::CreateBlendState(const BlendStateDesc &desc) {
|
|||
return bs;
|
||||
}
|
||||
|
||||
Thin3DSamplerState *Thin3DDX9Context::CreateSamplerState(const T3DSamplerStateDesc &desc) {
|
||||
SamplerState *Thin3DDX9Context::CreateSamplerState(const SamplerStateDesc &desc) {
|
||||
Thin3DDX9SamplerState *samps = new Thin3DDX9SamplerState();
|
||||
samps->wrapS = texWrapToD3D9[(int)desc.wrapS];
|
||||
samps->wrapT = texWrapToD3D9[(int)desc.wrapT];
|
||||
|
@ -585,7 +585,7 @@ Thin3DSamplerState *Thin3DDX9Context::CreateSamplerState(const T3DSamplerStateDe
|
|||
return samps;
|
||||
}
|
||||
|
||||
Thin3DRasterState *Thin3DDX9Context::CreateRasterState(const T3DRasterStateDesc &desc) {
|
||||
RasterState *Thin3DDX9Context::CreateRasterState(const T3DRasterStateDesc &desc) {
|
||||
Thin3DDX9RasterState *rs = new Thin3DDX9RasterState();
|
||||
rs->cullMode = D3DCULL_NONE;
|
||||
if (desc.cull == CullMode::NONE) {
|
||||
|
@ -606,17 +606,17 @@ Thin3DRasterState *Thin3DDX9Context::CreateRasterState(const T3DRasterStateDesc
|
|||
return rs;
|
||||
}
|
||||
|
||||
Thin3DTexture *Thin3DDX9Context::CreateTexture() {
|
||||
Texture *Thin3DDX9Context::CreateTexture() {
|
||||
Thin3DDX9Texture *tex = new Thin3DDX9Texture(device_, deviceEx_);
|
||||
return tex;
|
||||
}
|
||||
|
||||
Thin3DTexture *Thin3DDX9Context::CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) {
|
||||
Texture *Thin3DDX9Context::CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) {
|
||||
Thin3DDX9Texture *tex = new Thin3DDX9Texture(device_, deviceEx_, type, format, width, height, depth, mipLevels);
|
||||
return tex;
|
||||
}
|
||||
|
||||
void Thin3DDX9Context::BindTextures(int start, int count, Thin3DTexture **textures) {
|
||||
void Thin3DDX9Context::BindTextures(int start, int count, Texture **textures) {
|
||||
for (int i = start; i < start + count; i++) {
|
||||
Thin3DDX9Texture *tex = static_cast<Thin3DDX9Texture *>(textures[i - start]);
|
||||
tex->SetToSampler(device_, i);
|
||||
|
@ -661,7 +661,7 @@ static int VertexDataTypeToD3DType(DataFormat type) {
|
|||
}
|
||||
}
|
||||
|
||||
Thin3DDX9VertexFormat::Thin3DDX9VertexFormat(LPDIRECT3DDEVICE9 device, const std::vector<Thin3DVertexComponent> &components, int stride) : decl_(NULL) {
|
||||
Thin3DDX9VertexFormat::Thin3DDX9VertexFormat(LPDIRECT3DDEVICE9 device, const std::vector<VertexComponent> &components, int stride) : decl_(NULL) {
|
||||
D3DVERTEXELEMENT9 *elements = new D3DVERTEXELEMENT9[components.size() + 1];
|
||||
size_t i;
|
||||
for (i = 0; i < components.size(); i++) {
|
||||
|
@ -683,7 +683,7 @@ Thin3DDX9VertexFormat::Thin3DDX9VertexFormat(LPDIRECT3DDEVICE9 device, const std
|
|||
stride_ = stride;
|
||||
}
|
||||
|
||||
Thin3DBuffer *Thin3DDX9Context::CreateBuffer(size_t size, uint32_t usageFlags) {
|
||||
Buffer *Thin3DDX9Context::CreateBuffer(size_t size, uint32_t usageFlags) {
|
||||
return new Thin3DDX9Buffer(device_, size, usageFlags);
|
||||
}
|
||||
|
||||
|
@ -692,7 +692,7 @@ void Thin3DDX9ShaderSet::Apply(LPDIRECT3DDEVICE9 device) {
|
|||
pshader->Apply(device);
|
||||
}
|
||||
|
||||
void Thin3DDX9Context::Draw(Primitive prim, Thin3DShaderSet *shaderSet, Thin3DVertexFormat *format, Thin3DBuffer *vdata, int vertexCount, int offset) {
|
||||
void Thin3DDX9Context::Draw(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, Buffer *vdata, int vertexCount, int offset) {
|
||||
Thin3DDX9Buffer *vbuf = static_cast<Thin3DDX9Buffer *>(vdata);
|
||||
Thin3DDX9VertexFormat *fmt = static_cast<Thin3DDX9VertexFormat *>(format);
|
||||
Thin3DDX9ShaderSet *ss = static_cast<Thin3DDX9ShaderSet*>(shaderSet);
|
||||
|
@ -703,7 +703,7 @@ void Thin3DDX9Context::Draw(Primitive prim, Thin3DShaderSet *shaderSet, Thin3DVe
|
|||
device_->DrawPrimitive(PrimToD3D9(prim), offset, vertexCount / 3);
|
||||
}
|
||||
|
||||
void Thin3DDX9Context::DrawIndexed(Primitive prim, Thin3DShaderSet *shaderSet, Thin3DVertexFormat *format, Thin3DBuffer *vdata, Thin3DBuffer *idata, int vertexCount, int offset) {
|
||||
void Thin3DDX9Context::DrawIndexed(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, Buffer *vdata, Buffer *idata, int vertexCount, int offset) {
|
||||
Thin3DDX9Buffer *vbuf = static_cast<Thin3DDX9Buffer *>(vdata);
|
||||
Thin3DDX9Buffer *ibuf = static_cast<Thin3DDX9Buffer *>(idata);
|
||||
Thin3DDX9VertexFormat *fmt = static_cast<Thin3DDX9VertexFormat *>(format);
|
||||
|
@ -716,7 +716,7 @@ void Thin3DDX9Context::DrawIndexed(Primitive prim, Thin3DShaderSet *shaderSet, T
|
|||
device_->DrawIndexedPrimitive(PrimToD3D9(prim), 0, 0, vertexCount, 0, vertexCount / PrimCountDivisor(prim));
|
||||
}
|
||||
|
||||
void Thin3DDX9Context::DrawUP(Primitive prim, Thin3DShaderSet *shaderSet, Thin3DVertexFormat *format, const void *vdata, int vertexCount) {
|
||||
void Thin3DDX9Context::DrawUP(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, const void *vdata, int vertexCount) {
|
||||
Thin3DDX9VertexFormat *fmt = static_cast<Thin3DDX9VertexFormat *>(format);
|
||||
Thin3DDX9ShaderSet *ss = static_cast<Thin3DDX9ShaderSet*>(shaderSet);
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class Thin3DGLSamplerState : public Thin3DSamplerState {
|
||||
class Thin3DGLSamplerState : public SamplerState {
|
||||
public:
|
||||
GLint wrapS;
|
||||
GLint wrapT;
|
||||
|
@ -169,7 +169,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class Thin3DGLDepthStencilState : public Thin3DDepthStencilState {
|
||||
class Thin3DGLDepthStencilState : public DepthStencilState {
|
||||
public:
|
||||
bool depthTestEnabled;
|
||||
bool depthWriteEnabled;
|
||||
|
@ -188,7 +188,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class Thin3DGLRasterState : public Thin3DRasterState {
|
||||
class Thin3DGLRasterState : public RasterState {
|
||||
public:
|
||||
void Apply() {
|
||||
if (!cullEnable) {
|
||||
|
@ -205,7 +205,7 @@ public:
|
|||
GLenum frontFace;
|
||||
};
|
||||
|
||||
class Thin3DGLBuffer : public Thin3DBuffer, GfxResourceHolder {
|
||||
class Thin3DGLBuffer : public Buffer, GfxResourceHolder {
|
||||
public:
|
||||
Thin3DGLBuffer(size_t size, uint32_t flags) {
|
||||
glGenBuffers(1, &buffer_);
|
||||
|
@ -262,7 +262,7 @@ private:
|
|||
|
||||
// Not registering this as a resource holder, instead ShaderSet is registered. It will
|
||||
// invoke Compile again to recreate the shader then link them together.
|
||||
class Thin3DGLShader : public Thin3DShader {
|
||||
class Thin3DGLShader : public Shader {
|
||||
public:
|
||||
Thin3DGLShader(ShaderStage stage) : shader_(0), type_(0) {
|
||||
type_ = stage == ShaderStage::FRAGMENT ? GL_FRAGMENT_SHADER : GL_VERTEX_SHADER;
|
||||
|
@ -331,7 +331,7 @@ public:
|
|||
return id_ != 0;
|
||||
}
|
||||
|
||||
std::vector<Thin3DVertexComponent> components_;
|
||||
std::vector<VertexComponent> components_;
|
||||
int semanticsMask_; // Fast way to check what semantics to enable/disable.
|
||||
int stride_;
|
||||
GLuint id_;
|
||||
|
@ -345,7 +345,7 @@ struct UniformInfo {
|
|||
|
||||
// TODO: Fold BlendState into this? Seems likely to be right for DX12 etc.
|
||||
// TODO: Add Uniform Buffer support.
|
||||
class Thin3DGLShaderSet : public Thin3DShaderSet, GfxResourceHolder {
|
||||
class Thin3DGLShaderSet : public ShaderSet, GfxResourceHolder {
|
||||
public:
|
||||
Thin3DGLShaderSet() {
|
||||
program_ = 0;
|
||||
|
@ -392,15 +392,15 @@ public:
|
|||
Thin3DGLContext();
|
||||
virtual ~Thin3DGLContext();
|
||||
|
||||
Thin3DDepthStencilState *CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare) override;
|
||||
DepthStencilState *CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare) override;
|
||||
BlendState *CreateBlendState(const BlendStateDesc &desc) override;
|
||||
Thin3DSamplerState *CreateSamplerState(const T3DSamplerStateDesc &desc) override;
|
||||
Thin3DRasterState *CreateRasterState(const T3DRasterStateDesc &desc) override;
|
||||
Thin3DBuffer *CreateBuffer(size_t size, uint32_t usageFlags) override;
|
||||
Thin3DShaderSet *CreateShaderSet(Thin3DShader *vshader, Thin3DShader *fshader) override;
|
||||
Thin3DVertexFormat *CreateVertexFormat(const std::vector<Thin3DVertexComponent> &components, int stride, Thin3DShader *vshader) override;
|
||||
Thin3DTexture *CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) override;
|
||||
Thin3DTexture *CreateTexture() override;
|
||||
SamplerState *CreateSamplerState(const SamplerStateDesc &desc) override;
|
||||
RasterState *CreateRasterState(const T3DRasterStateDesc &desc) override;
|
||||
Buffer *CreateBuffer(size_t size, uint32_t usageFlags) override;
|
||||
ShaderSet *CreateShaderSet(Shader *vshader, Shader *fshader) override;
|
||||
Thin3DVertexFormat *CreateVertexFormat(const std::vector<VertexComponent> &components, int stride, Shader *vshader) override;
|
||||
Texture *CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) override;
|
||||
Texture *CreateTexture() override;
|
||||
|
||||
// Bound state objects
|
||||
void SetBlendState(BlendState *state) override {
|
||||
|
@ -408,7 +408,7 @@ public:
|
|||
s->Apply();
|
||||
}
|
||||
|
||||
void SetSamplerStates(int start, int count, Thin3DSamplerState **states) override {
|
||||
void SetSamplerStates(int start, int count, SamplerState **states) override {
|
||||
if (samplerStates_.size() < (size_t)(start + count)) {
|
||||
samplerStates_.resize(start + count);
|
||||
}
|
||||
|
@ -431,17 +431,17 @@ public:
|
|||
}
|
||||
|
||||
// Bound state objects
|
||||
void SetDepthStencilState(Thin3DDepthStencilState *state) override {
|
||||
void SetDepthStencilState(DepthStencilState *state) override {
|
||||
Thin3DGLDepthStencilState *s = static_cast<Thin3DGLDepthStencilState *>(state);
|
||||
s->Apply();
|
||||
}
|
||||
|
||||
void SetRasterState(Thin3DRasterState *state) override {
|
||||
void SetRasterState(RasterState *state) override {
|
||||
Thin3DGLRasterState *rs = static_cast<Thin3DGLRasterState *>(state);
|
||||
rs->Apply();
|
||||
}
|
||||
|
||||
Thin3DShader *CreateShader(ShaderStage stage, const char *glsl_source, const char *hlsl_source, const char *vulkan_source) override;
|
||||
Shader *CreateShader(ShaderStage stage, const char *glsl_source, const char *hlsl_source, const char *vulkan_source) override;
|
||||
|
||||
void SetScissorEnabled(bool enable) override {
|
||||
if (enable) {
|
||||
|
@ -465,12 +465,12 @@ public:
|
|||
#endif
|
||||
}
|
||||
|
||||
void BindTextures(int start, int count, Thin3DTexture **textures) override;
|
||||
void BindTextures(int start, int count, Texture **textures) override;
|
||||
|
||||
// TODO: Add more sophisticated draws.
|
||||
void Draw(Primitive prim, Thin3DShaderSet *shaderSet, Thin3DVertexFormat *format, Thin3DBuffer *vdata, int vertexCount, int offset) override;
|
||||
void DrawIndexed(Primitive prim, Thin3DShaderSet *shaderSet, Thin3DVertexFormat *format, Thin3DBuffer *vdata, Thin3DBuffer *idata, int vertexCount, int offset) override;
|
||||
void DrawUP(Primitive prim, Thin3DShaderSet *shaderSet, Thin3DVertexFormat *format, const void *vdata, int vertexCount) override;
|
||||
void Draw(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, Buffer *vdata, int vertexCount, int offset) override;
|
||||
void DrawIndexed(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, Buffer *vdata, Buffer *idata, int vertexCount, int offset) override;
|
||||
void DrawUP(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, const void *vdata, int vertexCount) override;
|
||||
void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal) override;
|
||||
|
||||
std::string GetInfoString(InfoField info) const override {
|
||||
|
@ -520,7 +520,7 @@ Thin3DGLContext::~Thin3DGLContext() {
|
|||
samplerStates_.clear();
|
||||
}
|
||||
|
||||
Thin3DVertexFormat *Thin3DGLContext::CreateVertexFormat(const std::vector<Thin3DVertexComponent> &components, int stride, Thin3DShader *vshader) {
|
||||
Thin3DVertexFormat *Thin3DGLContext::CreateVertexFormat(const std::vector<VertexComponent> &components, int stride, Shader *vshader) {
|
||||
Thin3DGLVertexFormat *fmt = new Thin3DGLVertexFormat();
|
||||
fmt->components_ = components;
|
||||
fmt->stride_ = stride;
|
||||
|
@ -544,7 +544,7 @@ GLuint TypeToTarget(TextureType type) {
|
|||
}
|
||||
}
|
||||
|
||||
class Thin3DGLTexture : public Thin3DTexture, GfxResourceHolder {
|
||||
class Thin3DGLTexture : public Texture, GfxResourceHolder {
|
||||
public:
|
||||
Thin3DGLTexture() : tex_(0), target_(0) {
|
||||
generatedMips_ = false;
|
||||
|
@ -634,11 +634,11 @@ private:
|
|||
bool canWrap_;
|
||||
};
|
||||
|
||||
Thin3DTexture *Thin3DGLContext::CreateTexture() {
|
||||
Texture *Thin3DGLContext::CreateTexture() {
|
||||
return new Thin3DGLTexture();
|
||||
}
|
||||
|
||||
Thin3DTexture *Thin3DGLContext::CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) {
|
||||
Texture *Thin3DGLContext::CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) {
|
||||
return new Thin3DGLTexture(type, format, width, height, depth, mipLevels);
|
||||
}
|
||||
|
||||
|
@ -727,7 +727,7 @@ void Thin3DGLVertexFormat::GLRestore() {
|
|||
Compile();
|
||||
}
|
||||
|
||||
Thin3DDepthStencilState *Thin3DGLContext::CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare) {
|
||||
DepthStencilState *Thin3DGLContext::CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare) {
|
||||
Thin3DGLDepthStencilState *ds = new Thin3DGLDepthStencilState();
|
||||
ds->depthTestEnabled = depthTestEnabled;
|
||||
ds->depthWriteEnabled = depthWriteEnabled;
|
||||
|
@ -751,7 +751,7 @@ BlendState *Thin3DGLContext::CreateBlendState(const BlendStateDesc &desc) {
|
|||
return bs;
|
||||
}
|
||||
|
||||
Thin3DSamplerState *Thin3DGLContext::CreateSamplerState(const T3DSamplerStateDesc &desc) {
|
||||
SamplerState *Thin3DGLContext::CreateSamplerState(const SamplerStateDesc &desc) {
|
||||
Thin3DGLSamplerState *samps = new Thin3DGLSamplerState();
|
||||
samps->wrapS = texWrapToGL[(int)desc.wrapS];
|
||||
samps->wrapT = texWrapToGL[(int)desc.wrapT];
|
||||
|
@ -761,7 +761,7 @@ Thin3DSamplerState *Thin3DGLContext::CreateSamplerState(const T3DSamplerStateDes
|
|||
return samps;
|
||||
}
|
||||
|
||||
Thin3DRasterState *Thin3DGLContext::CreateRasterState(const T3DRasterStateDesc &desc) {
|
||||
RasterState *Thin3DGLContext::CreateRasterState(const T3DRasterStateDesc &desc) {
|
||||
Thin3DGLRasterState *rs = new Thin3DGLRasterState();
|
||||
if (desc.cull == CullMode::NONE) {
|
||||
rs->cullEnable = GL_FALSE;
|
||||
|
@ -790,11 +790,11 @@ Thin3DRasterState *Thin3DGLContext::CreateRasterState(const T3DRasterStateDesc &
|
|||
return rs;
|
||||
}
|
||||
|
||||
Thin3DBuffer *Thin3DGLContext::CreateBuffer(size_t size, uint32_t usageFlags) {
|
||||
Buffer *Thin3DGLContext::CreateBuffer(size_t size, uint32_t usageFlags) {
|
||||
return new Thin3DGLBuffer(size, usageFlags);
|
||||
}
|
||||
|
||||
Thin3DShaderSet *Thin3DGLContext::CreateShaderSet(Thin3DShader *vshader, Thin3DShader *fshader) {
|
||||
ShaderSet *Thin3DGLContext::CreateShaderSet(Shader *vshader, Shader *fshader) {
|
||||
if (!vshader || !fshader) {
|
||||
ELOG("ShaderSet requires both a valid vertex and a fragment shader: %p %p", vshader, fshader);
|
||||
return NULL;
|
||||
|
@ -812,7 +812,7 @@ Thin3DShaderSet *Thin3DGLContext::CreateShaderSet(Thin3DShader *vshader, Thin3DS
|
|||
}
|
||||
}
|
||||
|
||||
void Thin3DGLContext::BindTextures(int start, int count, Thin3DTexture **textures) {
|
||||
void Thin3DGLContext::BindTextures(int start, int count, Texture **textures) {
|
||||
for (int i = start; i < start + count; i++) {
|
||||
Thin3DGLTexture *glTex = static_cast<Thin3DGLTexture *>(textures[i]);
|
||||
glActiveTexture(GL_TEXTURE0 + i);
|
||||
|
@ -826,7 +826,7 @@ void Thin3DGLContext::BindTextures(int start, int count, Thin3DTexture **texture
|
|||
}
|
||||
|
||||
|
||||
Thin3DShader *Thin3DGLContext::CreateShader(ShaderStage stage, const char *glsl_source, const char *hlsl_source, const char *vulkan_source) {
|
||||
Shader *Thin3DGLContext::CreateShader(ShaderStage stage, const char *glsl_source, const char *hlsl_source, const char *vulkan_source) {
|
||||
Thin3DGLShader *shader = new Thin3DGLShader(stage);
|
||||
if (shader->Compile(glsl_source)) {
|
||||
return shader;
|
||||
|
@ -927,7 +927,7 @@ void Thin3DGLShaderSet::Unapply() {
|
|||
glUseProgram(0);
|
||||
}
|
||||
|
||||
void Thin3DGLContext::Draw(Primitive prim, Thin3DShaderSet *shaderSet, Thin3DVertexFormat *format, Thin3DBuffer *vdata, int vertexCount, int offset) {
|
||||
void Thin3DGLContext::Draw(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, Buffer *vdata, int vertexCount, int offset) {
|
||||
Thin3DGLShaderSet *ss = static_cast<Thin3DGLShaderSet *>(shaderSet);
|
||||
Thin3DGLBuffer *vbuf = static_cast<Thin3DGLBuffer *>(vdata);
|
||||
Thin3DGLVertexFormat *fmt = static_cast<Thin3DGLVertexFormat *>(format);
|
||||
|
@ -942,7 +942,7 @@ void Thin3DGLContext::Draw(Primitive prim, Thin3DShaderSet *shaderSet, Thin3DVer
|
|||
fmt->Unapply();
|
||||
}
|
||||
|
||||
void Thin3DGLContext::DrawIndexed(Primitive prim, Thin3DShaderSet *shaderSet, Thin3DVertexFormat *format, Thin3DBuffer *vdata, Thin3DBuffer *idata, int vertexCount, int offset) {
|
||||
void Thin3DGLContext::DrawIndexed(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, Buffer *vdata, Buffer *idata, int vertexCount, int offset) {
|
||||
Thin3DGLShaderSet *ss = static_cast<Thin3DGLShaderSet *>(shaderSet);
|
||||
Thin3DGLBuffer *vbuf = static_cast<Thin3DGLBuffer *>(vdata);
|
||||
Thin3DGLBuffer *ibuf = static_cast<Thin3DGLBuffer *>(idata);
|
||||
|
@ -960,7 +960,7 @@ void Thin3DGLContext::DrawIndexed(Primitive prim, Thin3DShaderSet *shaderSet, Th
|
|||
fmt->Unapply();
|
||||
}
|
||||
|
||||
void Thin3DGLContext::DrawUP(Primitive prim, Thin3DShaderSet *shaderSet, Thin3DVertexFormat *format, const void *vdata, int vertexCount) {
|
||||
void Thin3DGLContext::DrawUP(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, const void *vdata, int vertexCount) {
|
||||
Thin3DGLShaderSet *ss = static_cast<Thin3DGLShaderSet *>(shaderSet);
|
||||
Thin3DGLVertexFormat *fmt = static_cast<Thin3DGLVertexFormat *>(format);
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class Thin3DVKDepthStencilState : public Thin3DDepthStencilState {
|
||||
class Thin3DVKDepthStencilState : public DepthStencilState {
|
||||
public:
|
||||
bool depthTestEnabled;
|
||||
bool depthWriteEnabled;
|
||||
|
@ -163,7 +163,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class Thin3DVKRasterState : public Thin3DRasterState {
|
||||
class Thin3DVKRasterState : public RasterState {
|
||||
public:
|
||||
Thin3DVKRasterState(VulkanContext *vulkan, const T3DRasterStateDesc &desc) {
|
||||
cullFace = desc.cull;
|
||||
|
@ -189,7 +189,7 @@ public:
|
|||
|
||||
// Very simplistic buffer that will simply copy its contents into our "pushbuffer" when it's time to draw,
|
||||
// to avoid synchronization issues.
|
||||
class Thin3DVKBuffer : public Thin3DBuffer {
|
||||
class Thin3DVKBuffer : public Buffer {
|
||||
public:
|
||||
Thin3DVKBuffer(size_t size, uint32_t flags) : dataSize_(size) {
|
||||
data_ = new uint8_t[size];
|
||||
|
@ -221,7 +221,7 @@ private:
|
|||
|
||||
// Not registering this as a resource holder, instead ShaderSet is registered. It will
|
||||
// invoke Compile again to recreate the shader then link them together.
|
||||
class Thin3DVKShader : public Thin3DShader {
|
||||
class Thin3DVKShader : public Shader {
|
||||
public:
|
||||
Thin3DVKShader(ShaderStage stage) : module_(VK_NULL_HANDLE), ok_(false) {
|
||||
stage_ = stage == ShaderStage::FRAGMENT ? VK_SHADER_STAGE_FRAGMENT_BIT : VK_SHADER_STAGE_VERTEX_BIT;
|
||||
|
@ -307,11 +307,11 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
std::vector<Thin3DVertexComponent> components_;
|
||||
std::vector<VertexComponent> components_;
|
||||
int stride_;
|
||||
};
|
||||
|
||||
class Thin3DVKShaderSet : public Thin3DShaderSet {
|
||||
class Thin3DVKShaderSet : public ShaderSet {
|
||||
public:
|
||||
Thin3DVKShaderSet() {
|
||||
// HACK! Hardcoded
|
||||
|
@ -390,15 +390,15 @@ public:
|
|||
Thin3DVKContext(VulkanContext *vulkan);
|
||||
virtual ~Thin3DVKContext();
|
||||
|
||||
Thin3DDepthStencilState *CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare) override;
|
||||
DepthStencilState *CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare) override;
|
||||
BlendState *CreateBlendState(const BlendStateDesc &desc) override;
|
||||
Thin3DBuffer *CreateBuffer(size_t size, uint32_t usageFlags) override;
|
||||
Thin3DShaderSet *CreateShaderSet(Thin3DShader *vshader, Thin3DShader *fshader) override;
|
||||
Thin3DVertexFormat *CreateVertexFormat(const std::vector<Thin3DVertexComponent> &components, int stride, Thin3DShader *vshader) override;
|
||||
Thin3DSamplerState *CreateSamplerState(const T3DSamplerStateDesc &desc) override;
|
||||
Thin3DRasterState *CreateRasterState(const T3DRasterStateDesc &desc) override;
|
||||
Thin3DTexture *CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) override;
|
||||
Thin3DTexture *CreateTexture() override;
|
||||
Buffer *CreateBuffer(size_t size, uint32_t usageFlags) override;
|
||||
ShaderSet *CreateShaderSet(Shader *vshader, Shader *fshader) override;
|
||||
Thin3DVertexFormat *CreateVertexFormat(const std::vector<VertexComponent> &components, int stride, Shader *vshader) override;
|
||||
SamplerState *CreateSamplerState(const SamplerStateDesc &desc) override;
|
||||
RasterState *CreateRasterState(const T3DRasterStateDesc &desc) override;
|
||||
Texture *CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) override;
|
||||
Texture *CreateTexture() override;
|
||||
|
||||
// Bound state objects
|
||||
void SetBlendState(BlendState *state) override {
|
||||
|
@ -407,19 +407,19 @@ public:
|
|||
}
|
||||
|
||||
// Bound state objects
|
||||
void SetDepthStencilState(Thin3DDepthStencilState *state) override {
|
||||
void SetDepthStencilState(DepthStencilState *state) override {
|
||||
Thin3DVKDepthStencilState *s = static_cast<Thin3DVKDepthStencilState *>(state);
|
||||
curDepthStencilState_ = s;
|
||||
}
|
||||
|
||||
// Bound state objects
|
||||
void SetRasterState(Thin3DRasterState *state) override {
|
||||
void SetRasterState(RasterState *state) override {
|
||||
Thin3DVKRasterState *s = static_cast<Thin3DVKRasterState *>(state);
|
||||
curRasterState_ = s;
|
||||
}
|
||||
|
||||
// The implementation makes the choice of which shader code to use.
|
||||
Thin3DShader *CreateShader(ShaderStage stage, const char *glsl_source, const char *hlsl_source, const char *vulkan_source) override;
|
||||
Shader *CreateShader(ShaderStage stage, const char *glsl_source, const char *hlsl_source, const char *vulkan_source) override;
|
||||
|
||||
void SetScissorEnabled(bool enable) override {
|
||||
scissorEnabled_ = enable;
|
||||
|
@ -430,14 +430,14 @@ public:
|
|||
|
||||
void SetViewports(int count, Viewport *viewports) override;
|
||||
|
||||
void BindTextures(int start, int count, Thin3DTexture **textures) override;
|
||||
void BindTextures(int start, int count, Texture **textures) override;
|
||||
|
||||
void SetSamplerStates(int start, int count, Thin3DSamplerState **state) override;
|
||||
void SetSamplerStates(int start, int count, SamplerState **state) override;
|
||||
|
||||
// TODO: Add more sophisticated draws.
|
||||
void Draw(Primitive prim, Thin3DShaderSet *shaderSet, Thin3DVertexFormat *format, Thin3DBuffer *vdata, int vertexCount, int offset) override;
|
||||
void DrawIndexed(Primitive prim, Thin3DShaderSet *shaderSet, Thin3DVertexFormat *format, Thin3DBuffer *vdata, Thin3DBuffer *idata, int vertexCount, int offset) override;
|
||||
void DrawUP(Primitive prim, Thin3DShaderSet *shaderSet, Thin3DVertexFormat *format, const void *vdata, int vertexCount) override;
|
||||
void Draw(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, Buffer *vdata, int vertexCount, int offset) override;
|
||||
void DrawIndexed(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, Buffer *vdata, Buffer *idata, int vertexCount, int offset) override;
|
||||
void DrawUP(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, const void *vdata, int vertexCount) override;
|
||||
|
||||
void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal) override;
|
||||
|
||||
|
@ -532,9 +532,9 @@ VkFormat FormatToVulkan(DataFormat fmt, int *bpp) {
|
|||
}
|
||||
}
|
||||
|
||||
class Thin3DVKSamplerState : public Thin3DSamplerState {
|
||||
class Thin3DVKSamplerState : public SamplerState {
|
||||
public:
|
||||
Thin3DVKSamplerState(VulkanContext *vulkan, const T3DSamplerStateDesc &desc) : vulkan_(vulkan) {
|
||||
Thin3DVKSamplerState(VulkanContext *vulkan, const SamplerStateDesc &desc) : vulkan_(vulkan) {
|
||||
VkSamplerCreateInfo s = { VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO };
|
||||
s.addressModeU = desc.wrapS == TextureAddressMode::REPEAT ? VK_SAMPLER_ADDRESS_MODE_REPEAT : VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
||||
s.addressModeV = desc.wrapT == TextureAddressMode::REPEAT ? VK_SAMPLER_ADDRESS_MODE_REPEAT : VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
||||
|
@ -557,15 +557,15 @@ private:
|
|||
VkSampler sampler_;
|
||||
};
|
||||
|
||||
Thin3DSamplerState *Thin3DVKContext::CreateSamplerState(const T3DSamplerStateDesc &desc) {
|
||||
SamplerState *Thin3DVKContext::CreateSamplerState(const SamplerStateDesc &desc) {
|
||||
return new Thin3DVKSamplerState(vulkan_, desc);
|
||||
}
|
||||
|
||||
Thin3DRasterState *Thin3DVKContext::CreateRasterState(const T3DRasterStateDesc &desc) {
|
||||
RasterState *Thin3DVKContext::CreateRasterState(const T3DRasterStateDesc &desc) {
|
||||
return new Thin3DVKRasterState(vulkan_, desc);
|
||||
}
|
||||
|
||||
void Thin3DVKContext::SetSamplerStates(int start, int count, Thin3DSamplerState **state) {
|
||||
void Thin3DVKContext::SetSamplerStates(int start, int count, SamplerState **state) {
|
||||
for (int i = start; i < start + count; i++) {
|
||||
boundSamplers_[i] = (Thin3DVKSamplerState *)state[i];
|
||||
}
|
||||
|
@ -578,7 +578,7 @@ enum class TextureState {
|
|||
PENDING_DESTRUCTION,
|
||||
};
|
||||
|
||||
class Thin3DVKTexture : public Thin3DTexture {
|
||||
class Thin3DVKTexture : public Texture {
|
||||
public:
|
||||
Thin3DVKTexture(VulkanContext *vulkan) : vulkan_(vulkan), vkTex_(nullptr) {
|
||||
}
|
||||
|
@ -953,18 +953,18 @@ void Thin3DVKContext::DirtyDynamicState() {
|
|||
viewportDirty_ = true;
|
||||
}
|
||||
|
||||
Thin3DVertexFormat *Thin3DVKContext::CreateVertexFormat(const std::vector<Thin3DVertexComponent> &components, int stride, Thin3DShader *vshader) {
|
||||
Thin3DVertexFormat *Thin3DVKContext::CreateVertexFormat(const std::vector<VertexComponent> &components, int stride, Shader *vshader) {
|
||||
Thin3DVKVertexFormat *fmt = new Thin3DVKVertexFormat();
|
||||
fmt->components_ = components;
|
||||
fmt->stride_ = stride;
|
||||
return fmt;
|
||||
}
|
||||
|
||||
Thin3DTexture *Thin3DVKContext::CreateTexture() {
|
||||
Texture *Thin3DVKContext::CreateTexture() {
|
||||
return new Thin3DVKTexture(vulkan_);
|
||||
}
|
||||
|
||||
Thin3DTexture *Thin3DVKContext::CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) {
|
||||
Texture *Thin3DVKContext::CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) {
|
||||
return new Thin3DVKTexture(vulkan_, type, format, width, height, depth, mipLevels);
|
||||
}
|
||||
|
||||
|
@ -985,7 +985,7 @@ void Thin3DVKTexture::Finalize(int zim_flags) {
|
|||
// TODO
|
||||
}
|
||||
|
||||
Thin3DDepthStencilState *Thin3DVKContext::CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare) {
|
||||
DepthStencilState *Thin3DVKContext::CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare) {
|
||||
Thin3DVKDepthStencilState *ds = new Thin3DVKDepthStencilState();
|
||||
ds->depthTestEnabled = depthTestEnabled;
|
||||
ds->depthWriteEnabled = depthWriteEnabled;
|
||||
|
@ -1007,11 +1007,11 @@ BlendState *Thin3DVKContext::CreateBlendState(const BlendStateDesc &desc) {
|
|||
return bs;
|
||||
}
|
||||
|
||||
Thin3DBuffer *Thin3DVKContext::CreateBuffer(size_t size, uint32_t usageFlags) {
|
||||
Buffer *Thin3DVKContext::CreateBuffer(size_t size, uint32_t usageFlags) {
|
||||
return new Thin3DVKBuffer(size, usageFlags);
|
||||
}
|
||||
|
||||
Thin3DShaderSet *Thin3DVKContext::CreateShaderSet(Thin3DShader *vshader, Thin3DShader *fshader) {
|
||||
ShaderSet *Thin3DVKContext::CreateShaderSet(Shader *vshader, Shader *fshader) {
|
||||
if (!vshader || !fshader) {
|
||||
ELOG("ShaderSet requires both a valid vertex and a fragment shader: %p %p", vshader, fshader);
|
||||
return NULL;
|
||||
|
@ -1029,13 +1029,13 @@ Thin3DShaderSet *Thin3DVKContext::CreateShaderSet(Thin3DShader *vshader, Thin3DS
|
|||
}
|
||||
}
|
||||
|
||||
void Thin3DVKContext::BindTextures(int start, int count, Thin3DTexture **textures) {
|
||||
void Thin3DVKContext::BindTextures(int start, int count, Texture **textures) {
|
||||
for (int i = start; i < start + count; i++) {
|
||||
boundTextures_[i] = static_cast<Thin3DVKTexture *>(textures[i]);
|
||||
}
|
||||
}
|
||||
|
||||
Thin3DShader *Thin3DVKContext::CreateShader(ShaderStage stage, const char *glsl_source, const char *hlsl_source, const char *vulkan_source) {
|
||||
Shader *Thin3DVKContext::CreateShader(ShaderStage stage, const char *glsl_source, const char *hlsl_source, const char *vulkan_source) {
|
||||
Thin3DVKShader *shader = new Thin3DVKShader(stage);
|
||||
if (shader->Compile(vulkan_, vulkan_source)) {
|
||||
return shader;
|
||||
|
@ -1091,7 +1091,7 @@ inline VkPrimitiveTopology PrimToVK(Primitive prim) {
|
|||
}
|
||||
}
|
||||
|
||||
void Thin3DVKContext::Draw(Primitive prim, Thin3DShaderSet *shaderSet, Thin3DVertexFormat *format, Thin3DBuffer *vdata, int vertexCount, int offset) {
|
||||
void Thin3DVKContext::Draw(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, Buffer *vdata, int vertexCount, int offset) {
|
||||
ApplyDynamicState();
|
||||
|
||||
curPrim_ = PrimToVK(prim);
|
||||
|
@ -1114,7 +1114,7 @@ void Thin3DVKContext::Draw(Primitive prim, Thin3DShaderSet *shaderSet, Thin3DVer
|
|||
vkCmdDraw(cmd_, vertexCount, 1, offset, 0);
|
||||
}
|
||||
|
||||
void Thin3DVKContext::DrawIndexed(Primitive prim, Thin3DShaderSet *shaderSet, Thin3DVertexFormat *format, Thin3DBuffer *vdata, Thin3DBuffer *idata, int vertexCount, int offset) {
|
||||
void Thin3DVKContext::DrawIndexed(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, Buffer *vdata, Buffer *idata, int vertexCount, int offset) {
|
||||
ApplyDynamicState();
|
||||
|
||||
curPrim_ = PrimToVK(prim);
|
||||
|
@ -1143,7 +1143,7 @@ void Thin3DVKContext::DrawIndexed(Primitive prim, Thin3DShaderSet *shaderSet, Th
|
|||
vkCmdDrawIndexed(cmd_, vertexCount, 1, 0, offset, 0);
|
||||
}
|
||||
|
||||
void Thin3DVKContext::DrawUP(Primitive prim, Thin3DShaderSet *shaderSet, Thin3DVertexFormat *format, const void *vdata, int vertexCount) {
|
||||
void Thin3DVKContext::DrawUP(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, const void *vdata, int vertexCount) {
|
||||
ApplyDynamicState();
|
||||
|
||||
curPrim_ = PrimToVK(prim);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
DrawBuffer ui_draw2d;
|
||||
DrawBuffer ui_draw2d_front;
|
||||
|
||||
void UIBegin(Draw::Thin3DShaderSet *shaderSet) {
|
||||
void UIBegin(Draw::ShaderSet *shaderSet) {
|
||||
ui_draw2d.Begin(shaderSet);
|
||||
ui_draw2d_front.Begin(shaderSet);
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ private:
|
|||
|
||||
|
||||
// Call at start of frame
|
||||
void UIBegin(Draw::Thin3DShaderSet *shaderSet);
|
||||
void UIBegin(Draw::ShaderSet *shaderSet);
|
||||
|
||||
// Call at end of frame.
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ UIContext::~UIContext() {
|
|||
blendNormal_->Release();
|
||||
}
|
||||
|
||||
void UIContext::Init(Draw::Thin3DContext *thin3d, Draw::Thin3DShaderSet *uishader, Draw::Thin3DShaderSet *uishadernotex, Draw::Thin3DTexture *uitexture, DrawBuffer *uidrawbuffer, DrawBuffer *uidrawbufferTop) {
|
||||
void UIContext::Init(Draw::Thin3DContext *thin3d, Draw::ShaderSet *uishader, Draw::ShaderSet *uishadernotex, Draw::Texture *uitexture, DrawBuffer *uidrawbuffer, DrawBuffer *uidrawbufferTop) {
|
||||
using namespace Draw;
|
||||
thin3d_ = thin3d;
|
||||
blendNormal_ = thin3d_->CreateBlendState({ true, BlendFactor::SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA });
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
|
||||
namespace Draw {
|
||||
class Thin3DContext;
|
||||
class Thin3DShaderSet;
|
||||
class Thin3DDepthStencilState;
|
||||
class Thin3DTexture;
|
||||
class ShaderSet;
|
||||
class DepthStencilState;
|
||||
class Texture;
|
||||
class BlendState;
|
||||
class Thin3DSamplerState;
|
||||
class Thin3DRasterState;
|
||||
class SamplerState;
|
||||
class RasterState;
|
||||
}
|
||||
|
||||
class Texture;
|
||||
|
@ -36,7 +36,7 @@ public:
|
|||
UIContext();
|
||||
~UIContext();
|
||||
|
||||
void Init(Draw::Thin3DContext *thin3d, Draw::Thin3DShaderSet *uiShaderTex, Draw::Thin3DShaderSet *uiShaderNoTex, Draw::Thin3DTexture *uitexture, DrawBuffer *uidrawbuffer, DrawBuffer *uidrawbufferTop);
|
||||
void Init(Draw::Thin3DContext *thin3d, Draw::ShaderSet *uiShaderTex, Draw::ShaderSet *uiShaderNoTex, Draw::Texture *uitexture, DrawBuffer *uidrawbuffer, DrawBuffer *uidrawbufferTop);
|
||||
|
||||
void Begin();
|
||||
void BeginNoTex();
|
||||
|
@ -86,13 +86,13 @@ private:
|
|||
TextDrawer *textDrawer_;
|
||||
|
||||
Draw::Thin3DContext *thin3D_;
|
||||
Draw::Thin3DDepthStencilState *depth_;
|
||||
Draw::Thin3DSamplerState *sampler_;
|
||||
Draw::Thin3DRasterState *rasterNoCull_;
|
||||
Draw::DepthStencilState *depth_;
|
||||
Draw::SamplerState *sampler_;
|
||||
Draw::RasterState *rasterNoCull_;
|
||||
Draw::BlendState *blendNormal_;
|
||||
Draw::Thin3DShaderSet *uishader_;
|
||||
Draw::Thin3DShaderSet *uishadernotex_;
|
||||
Draw::Thin3DTexture *uitexture_;
|
||||
Draw::ShaderSet *uishader_;
|
||||
Draw::ShaderSet *uishadernotex_;
|
||||
Draw::Texture *uitexture_;
|
||||
|
||||
DrawBuffer *uidrawbuffer_;
|
||||
DrawBuffer *uidrawbufferTop_;
|
||||
|
|
|
@ -35,7 +35,7 @@ class Texture;
|
|||
class UIContext;
|
||||
|
||||
namespace Draw {
|
||||
class Thin3DTexture;
|
||||
class Texture;
|
||||
}
|
||||
|
||||
|
||||
|
@ -827,17 +827,17 @@ private:
|
|||
// of the view.
|
||||
class Thin3DTextureView : public InertView {
|
||||
public:
|
||||
Thin3DTextureView(Draw::Thin3DTexture *texture, ImageSizeMode sizeMode, LayoutParams *layoutParams = 0)
|
||||
Thin3DTextureView(Draw::Texture *texture, ImageSizeMode sizeMode, LayoutParams *layoutParams = 0)
|
||||
: InertView(layoutParams), texture_(texture), color_(0xFFFFFFFF), sizeMode_(sizeMode) {}
|
||||
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
||||
void Draw(UIContext &dc) override;
|
||||
|
||||
void SetTexture(Draw::Thin3DTexture *texture) { texture_ = texture; }
|
||||
void SetTexture(Draw::Texture *texture) { texture_ = texture; }
|
||||
void SetColor(uint32_t color) { color_ = color; }
|
||||
|
||||
private:
|
||||
Draw::Thin3DTexture *texture_;
|
||||
Draw::Texture *texture_;
|
||||
uint32_t color_;
|
||||
ImageSizeMode sizeMode_;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue