Add DepthStencilStateDesc

This commit is contained in:
Henrik Rydgård committed 2016-12-27 11:59:06 +01:00
1 parent f86b9f7900
commit c7c541f926
7 files changed
+80 -73

No files matched your search

+2 -2
View File
@@ -42,7 +42,7 @@ FormatBuffer fb;
FormatBuffer depthbuf;
u32 clut[4096];
static Draw::Thin3DVertexFormat *vformat = nullptr;
static Draw::InputLayout *vformat = nullptr;
static Draw::DepthStencilState *depth = nullptr;
static Draw::RasterState *rasterNoCull = nullptr;
static Draw::BlendState *blendstateOff = nullptr;
@@ -67,7 +67,7 @@ SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Draw::DrawContext *_thin3D)
vdata = thin3d->CreateBuffer(24 * 4, BufferUsageFlag::DYNAMIC | BufferUsageFlag::VERTEXDATA);
idata = thin3d->CreateBuffer(sizeof(int) * 6, BufferUsageFlag::DYNAMIC | BufferUsageFlag::INDEXDATA);
depth = thin3d->CreateDepthStencilState(false, false, Comparison::LESS);
depth = thin3d->CreateDepthStencilState({ false, false, Comparison::LESS });
blendstateOff = thin3d->CreateBlendState({ false });
samplerNearest = thin3d->CreateSamplerState({ TextureFilter::NEAREST, TextureFilter::NEAREST, TextureFilter::NEAREST });
samplerLinear = thin3d->CreateSamplerState({ TextureFilter::LINEAR, TextureFilter::LINEAR, TextureFilter::LINEAR });
+1 -1
View File
@@ -159,7 +159,7 @@ private:
Draw::DrawContext *t3d_;
Draw::Buffer *vbuf_;
Draw::Thin3DVertexFormat *vformat_;
Draw::InputLayout *vformat_;
Draw::ShaderSet *shaderSet_;
Vertex *verts_;
+15 -8
View File
@@ -31,7 +31,7 @@ namespace Draw {
// Useful in UBOs
typedef int bool32;
enum BlendOp : int {
enum class BlendOp : int {
ADD,
SUBTRACT,
REV_SUBTRACT,
@@ -39,7 +39,7 @@ enum BlendOp : int {
MAX,
};
enum Comparison : int {
enum class Comparison : int {
NEVER,
LESS,
EQUAL,
@@ -282,7 +282,7 @@ struct VertexComponent {
uint8_t offset;
};
class Thin3DVertexFormat : public RefCountedObject {
class InputLayout : public RefCountedObject {
public:
virtual bool RequiresBuffer() = 0;
};
@@ -320,6 +320,13 @@ enum class ShaderLanguage {
HLSL_D3D11,
};
struct DepthStencilStateDesc {
bool depthTestEnabled;
bool depthWriteEnabled;
Comparison depthCompare;
// Ignore stencil
};
struct BlendStateDesc {
bool enabled;
BlendFactor srcCol;
@@ -364,13 +371,13 @@ public:
virtual std::vector<std::string> GetFeatureList() { return std::vector<std::string>(); }
virtual DepthStencilState *CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare) = 0;
virtual DepthStencilState *CreateDepthStencilState(const DepthStencilStateDesc &desc) = 0;
virtual BlendState *CreateBlendState(const BlendStateDesc &desc) = 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 InputLayout *CreateVertexFormat(const std::vector<VertexComponent> &components, int stride, Shader *vshader) = 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;
@@ -404,9 +411,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, 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;
virtual void Draw(Primitive prim, ShaderSet *pipeline, InputLayout *format, Buffer *vdata, int vertexCount, int offset) = 0;
virtual void DrawIndexed(Primitive prim, ShaderSet *pipeline, InputLayout *format, Buffer *vdata, Buffer *idata, int vertexCount, int offset) = 0;
virtual void DrawUP(Primitive prim, ShaderSet *pipeline, InputLayout *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) {
+20 -20
View File
@@ -229,7 +229,7 @@ private:
};
class Thin3DDX9VertexFormat : public Thin3DVertexFormat {
class Thin3DDX9VertexFormat : public InputLayout {
public:
Thin3DDX9VertexFormat(LPDIRECT3DDEVICE9 device, const std::vector<VertexComponent> &components, int stride);
~Thin3DDX9VertexFormat() {
@@ -452,13 +452,13 @@ public:
Thin3DDX9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, IDirect3DDevice9 *device, IDirect3DDevice9Ex *deviceEx);
~Thin3DDX9Context();
DepthStencilState *CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare);
DepthStencilState *CreateDepthStencilState(const DepthStencilStateDesc &desc);
BlendState *CreateBlendState(const BlendStateDesc &desc) 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;
InputLayout *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;
@@ -490,9 +490,9 @@ public:
void SetScissorRect(int left, int top, int width, int height);
void SetViewports(int count, Viewport *viewports);
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 Draw(Primitive prim, ShaderSet *pipeline, InputLayout *format, Buffer *vdata, int vertexCount, int offset) override;
void DrawIndexed(Primitive prim, ShaderSet *pipeline, InputLayout *format, Buffer *vdata, Buffer *idata, int vertexCount, int offset) override;
void DrawUP(Primitive prim, ShaderSet *shaderSet, InputLayout *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 {
@@ -553,15 +553,15 @@ ShaderSet *Thin3DDX9Context::CreateShaderSet(Shader *vshader, Shader *fshader) {
return shaderSet;
}
DepthStencilState *Thin3DDX9Context::CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare) {
DepthStencilState *Thin3DDX9Context::CreateDepthStencilState(const DepthStencilStateDesc &desc) {
Thin3DDX9DepthStencilState *ds = new Thin3DDX9DepthStencilState();
ds->depthCompare = compareToD3D9[depthCompare];
ds->depthTestEnabled = depthTestEnabled;
ds->depthWriteEnabled = depthWriteEnabled;
ds->depthTestEnabled = desc.depthTestEnabled;
ds->depthWriteEnabled = desc.depthWriteEnabled;
ds->depthCompare = compareToD3D9[(int)desc.depthCompare];
return ds;
}
Thin3DVertexFormat *Thin3DDX9Context::CreateVertexFormat(const std::vector<VertexComponent> &components, int stride, Shader *vshader) {
InputLayout *Thin3DDX9Context::CreateVertexFormat(const std::vector<VertexComponent> &components, int stride, Shader *vshader) {
Thin3DDX9VertexFormat *fmt = new Thin3DDX9VertexFormat(device_, components, stride);
return fmt;
}
@@ -569,12 +569,12 @@ Thin3DVertexFormat *Thin3DDX9Context::CreateVertexFormat(const std::vector<Verte
BlendState *Thin3DDX9Context::CreateBlendState(const BlendStateDesc &desc) {
Thin3DDX9BlendState *bs = new Thin3DDX9BlendState();
bs->enabled = desc.enabled;
bs->eqCol = blendEqToD3D9[desc.eqCol];
bs->srcCol = blendFactorToD3D9[desc.srcCol];
bs->dstCol = blendFactorToD3D9[desc.dstCol];
bs->eqAlpha = blendEqToD3D9[desc.eqAlpha];
bs->srcAlpha = blendFactorToD3D9[desc.srcAlpha];
bs->dstAlpha = blendFactorToD3D9[desc.dstAlpha];
bs->eqCol = blendEqToD3D9[(int)desc.eqCol];
bs->srcCol = blendFactorToD3D9[(int)desc.srcCol];
bs->dstCol = blendFactorToD3D9[(int)desc.dstCol];
bs->eqAlpha = blendEqToD3D9[(int)desc.eqAlpha];
bs->srcAlpha = blendFactorToD3D9[(int)desc.srcAlpha];
bs->dstAlpha = blendFactorToD3D9[(int)desc.dstAlpha];
// Ignore logic ops, we don't support them in D3D9
return bs;
}
@@ -696,7 +696,7 @@ void Thin3DDX9ShaderSet::Apply(LPDIRECT3DDEVICE9 device) {
pshader->Apply(device);
}
void Thin3DDX9Context::Draw(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, Buffer *vdata, int vertexCount, int offset) {
void Thin3DDX9Context::Draw(Primitive prim, ShaderSet *shaderSet, InputLayout *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);
@@ -707,7 +707,7 @@ void Thin3DDX9Context::Draw(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFo
device_->DrawPrimitive(primToD3D9[(int)prim], offset, vertexCount / 3);
}
void Thin3DDX9Context::DrawIndexed(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, Buffer *vdata, Buffer *idata, int vertexCount, int offset) {
void Thin3DDX9Context::DrawIndexed(Primitive prim, ShaderSet *shaderSet, InputLayout *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);
@@ -720,7 +720,7 @@ void Thin3DDX9Context::DrawIndexed(Primitive prim, ShaderSet *shaderSet, Thin3DV
device_->DrawIndexedPrimitive(primToD3D9[(int)prim], 0, 0, vertexCount, 0, vertexCount / PrimCountDivisor(prim));
}
void Thin3DDX9Context::DrawUP(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, const void *vdata, int vertexCount) {
void Thin3DDX9Context::DrawUP(Primitive prim, ShaderSet *shaderSet, InputLayout *format, const void *vdata, int vertexCount) {
Thin3DDX9VertexFormat *fmt = static_cast<Thin3DDX9VertexFormat *>(format);
Thin3DDX9ShaderSet *ss = static_cast<Thin3DDX9ShaderSet*>(shaderSet);
+20 -20
View File
@@ -310,7 +310,7 @@ bool Thin3DGLShader::Compile(const char *source) {
return ok_;
}
class Thin3DGLVertexFormat : public Thin3DVertexFormat, GfxResourceHolder {
class Thin3DGLVertexFormat : public InputLayout, GfxResourceHolder {
public:
~Thin3DGLVertexFormat();
@@ -384,13 +384,13 @@ public:
Thin3DGLContext();
virtual ~Thin3DGLContext();
DepthStencilState *CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare) override;
DepthStencilState *CreateDepthStencilState(const DepthStencilStateDesc &desc) override;
BlendState *CreateBlendState(const BlendStateDesc &desc) 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;
InputLayout *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;
@@ -460,9 +460,9 @@ public:
void BindTextures(int start, int count, Texture **textures) override;
// TODO: Add more sophisticated draws.
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 Draw(Primitive prim, ShaderSet *shaderSet, InputLayout *format, Buffer *vdata, int vertexCount, int offset) override;
void DrawIndexed(Primitive prim, ShaderSet *shaderSet, InputLayout *format, Buffer *vdata, Buffer *idata, int vertexCount, int offset) override;
void DrawUP(Primitive prim, ShaderSet *shaderSet, InputLayout *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 {
@@ -512,7 +512,7 @@ Thin3DGLContext::~Thin3DGLContext() {
samplerStates_.clear();
}
Thin3DVertexFormat *Thin3DGLContext::CreateVertexFormat(const std::vector<VertexComponent> &components, int stride, Shader *vshader) {
InputLayout *Thin3DGLContext::CreateVertexFormat(const std::vector<VertexComponent> &components, int stride, Shader *vshader) {
Thin3DGLVertexFormat *fmt = new Thin3DGLVertexFormat();
fmt->components_ = components;
fmt->stride_ = stride;
@@ -719,23 +719,23 @@ void Thin3DGLVertexFormat::GLRestore() {
Compile();
}
DepthStencilState *Thin3DGLContext::CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare) {
DepthStencilState *Thin3DGLContext::CreateDepthStencilState(const DepthStencilStateDesc &desc) {
Thin3DGLDepthStencilState *ds = new Thin3DGLDepthStencilState();
ds->depthTestEnabled = depthTestEnabled;
ds->depthWriteEnabled = depthWriteEnabled;
ds->depthComp = compToGL[depthCompare];
ds->depthTestEnabled = desc.depthTestEnabled;
ds->depthWriteEnabled = desc.depthWriteEnabled;
ds->depthComp = compToGL[(int)desc.depthCompare];
return ds;
}
BlendState *Thin3DGLContext::CreateBlendState(const BlendStateDesc &desc) {
Thin3DGLBlendState *bs = new Thin3DGLBlendState();
bs->enabled = desc.enabled;
bs->eqCol = blendEqToGL[desc.eqCol];
bs->srcCol = blendFactorToGL[desc.srcCol];
bs->dstCol = blendFactorToGL[desc.dstCol];
bs->eqAlpha = blendEqToGL[desc.eqAlpha];
bs->srcAlpha = blendFactorToGL[desc.srcAlpha];
bs->dstAlpha = blendFactorToGL[desc.dstAlpha];
bs->eqCol = blendEqToGL[(int)desc.eqCol];
bs->srcCol = blendFactorToGL[(int)desc.srcCol];
bs->dstCol = blendFactorToGL[(int)desc.dstCol];
bs->eqAlpha = blendEqToGL[(int)desc.eqAlpha];
bs->srcAlpha = blendFactorToGL[(int)desc.srcAlpha];
bs->dstAlpha = blendFactorToGL[(int)desc.dstAlpha];
#ifndef USING_GLES2
bs->logicEnabled = desc.logicEnabled;
bs->logicOp = logicOpToGL[(int)desc.logicOp];
@@ -919,7 +919,7 @@ void Thin3DGLShaderSet::Unapply() {
glUseProgram(0);
}
void Thin3DGLContext::Draw(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, Buffer *vdata, int vertexCount, int offset) {
void Thin3DGLContext::Draw(Primitive prim, ShaderSet *shaderSet, InputLayout *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);
@@ -934,7 +934,7 @@ void Thin3DGLContext::Draw(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFor
fmt->Unapply();
}
void Thin3DGLContext::DrawIndexed(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, Buffer *vdata, Buffer *idata, int vertexCount, int offset) {
void Thin3DGLContext::DrawIndexed(Primitive prim, ShaderSet *shaderSet, InputLayout *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);
@@ -952,7 +952,7 @@ void Thin3DGLContext::DrawIndexed(Primitive prim, ShaderSet *shaderSet, Thin3DVe
fmt->Unapply();
}
void Thin3DGLContext::DrawUP(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, const void *vdata, int vertexCount) {
void Thin3DGLContext::DrawUP(Primitive prim, ShaderSet *shaderSet, InputLayout *format, const void *vdata, int vertexCount) {
Thin3DGLShaderSet *ss = static_cast<Thin3DGLShaderSet *>(shaderSet);
Thin3DGLVertexFormat *fmt = static_cast<Thin3DGLVertexFormat *>(format);
+20 -20
View File
@@ -281,7 +281,7 @@ inline VkFormat ConvertVertexDataTypeToVk(DataFormat type) {
}
}
class Thin3DVKVertexFormat : public Thin3DVertexFormat {
class Thin3DVKVertexFormat : public InputLayout {
public:
void ToVulkan(VkPipelineVertexInputStateCreateInfo *info, VkVertexInputAttributeDescription *attrDescs, VkVertexInputBindingDescription *bindDescs) {
memset(info, 0, sizeof(*info));
@@ -390,11 +390,11 @@ public:
Thin3DVKContext(VulkanContext *vulkan);
virtual ~Thin3DVKContext();
DepthStencilState *CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare) override;
DepthStencilState *CreateDepthStencilState(const DepthStencilStateDesc &desc) override;
BlendState *CreateBlendState(const BlendStateDesc &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;
InputLayout *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;
@@ -435,9 +435,9 @@ public:
void SetSamplerStates(int start, int count, SamplerState **state) override;
// TODO: Add more sophisticated draws.
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 Draw(Primitive prim, ShaderSet *shaderSet, InputLayout *format, Buffer *vdata, int vertexCount, int offset) override;
void DrawIndexed(Primitive prim, ShaderSet *shaderSet, InputLayout *format, Buffer *vdata, Buffer *idata, int vertexCount, int offset) override;
void DrawUP(Primitive prim, ShaderSet *shaderSet, InputLayout *format, const void *vdata, int vertexCount) override;
void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal) override;
@@ -953,7 +953,7 @@ void Thin3DVKContext::DirtyDynamicState() {
viewportDirty_ = true;
}
Thin3DVertexFormat *Thin3DVKContext::CreateVertexFormat(const std::vector<VertexComponent> &components, int stride, Shader *vshader) {
InputLayout *Thin3DVKContext::CreateVertexFormat(const std::vector<VertexComponent> &components, int stride, Shader *vshader) {
Thin3DVKVertexFormat *fmt = new Thin3DVKVertexFormat();
fmt->components_ = components;
fmt->stride_ = stride;
@@ -985,23 +985,23 @@ void Thin3DVKTexture::Finalize(int zim_flags) {
// TODO
}
DepthStencilState *Thin3DVKContext::CreateDepthStencilState(bool depthTestEnabled, bool depthWriteEnabled, Comparison depthCompare) {
DepthStencilState *Thin3DVKContext::CreateDepthStencilState(const DepthStencilStateDesc &desc) {
Thin3DVKDepthStencilState *ds = new Thin3DVKDepthStencilState();
ds->depthTestEnabled = depthTestEnabled;
ds->depthWriteEnabled = depthWriteEnabled;
ds->depthComp = compToVK[depthCompare];
ds->depthTestEnabled = desc.depthTestEnabled;
ds->depthWriteEnabled = desc.depthWriteEnabled;
ds->depthComp = compToVK[(int)desc.depthCompare];
return ds;
}
BlendState *Thin3DVKContext::CreateBlendState(const BlendStateDesc &desc) {
Thin3DVKBlendState *bs = new Thin3DVKBlendState();
bs->blendEnabled = desc.enabled;
bs->eqCol = blendEqToGL[desc.eqCol];
bs->srcCol = blendFactorToVk[desc.srcCol];
bs->dstColor = blendFactorToVk[desc.dstCol];
bs->eqAlpha = blendEqToGL[desc.eqAlpha];
bs->srcAlpha = blendFactorToVk[desc.srcAlpha];
bs->dstAlpha = blendFactorToVk[desc.dstAlpha];
bs->eqCol = blendEqToGL[(int)desc.eqCol];
bs->srcCol = blendFactorToVk[(int)desc.srcCol];
bs->dstColor = blendFactorToVk[(int)desc.dstCol];
bs->eqAlpha = blendEqToGL[(int)desc.eqAlpha];
bs->srcAlpha = blendFactorToVk[(int)desc.srcAlpha];
bs->dstAlpha = blendFactorToVk[(int)desc.dstAlpha];
bs->logicEnabled = desc.logicEnabled;
bs->logicOp = logicOpToVK[(int)desc.logicOp];
return bs;
@@ -1091,7 +1091,7 @@ inline VkPrimitiveTopology PrimToVK(Primitive prim) {
}
}
void Thin3DVKContext::Draw(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, Buffer *vdata, int vertexCount, int offset) {
void Thin3DVKContext::Draw(Primitive prim, ShaderSet *shaderSet, InputLayout *format, Buffer *vdata, int vertexCount, int offset) {
ApplyDynamicState();
curPrim_ = PrimToVK(prim);
@@ -1114,7 +1114,7 @@ void Thin3DVKContext::Draw(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFor
vkCmdDraw(cmd_, vertexCount, 1, offset, 0);
}
void Thin3DVKContext::DrawIndexed(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, Buffer *vdata, Buffer *idata, int vertexCount, int offset) {
void Thin3DVKContext::DrawIndexed(Primitive prim, ShaderSet *shaderSet, InputLayout *format, Buffer *vdata, Buffer *idata, int vertexCount, int offset) {
ApplyDynamicState();
curPrim_ = PrimToVK(prim);
@@ -1143,7 +1143,7 @@ void Thin3DVKContext::DrawIndexed(Primitive prim, ShaderSet *shaderSet, Thin3DVe
vkCmdDrawIndexed(cmd_, vertexCount, 1, 0, offset, 0);
}
void Thin3DVKContext::DrawUP(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, const void *vdata, int vertexCount) {
void Thin3DVKContext::DrawUP(Primitive prim, ShaderSet *shaderSet, InputLayout *format, const void *vdata, int vertexCount) {
ApplyDynamicState();
curPrim_ = PrimToVK(prim);
+2 -2
View File
@@ -27,8 +27,8 @@ void UIContext::Init(Draw::DrawContext *thin3d, Draw::ShaderSet *uishader, Draw:
using namespace Draw;
thin3d_ = thin3d;
blendNormal_ = thin3d_->CreateBlendState({ true, BlendFactor::SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA });
sampler_ = thin3d_->CreateSamplerState({ TextureFilter::LINEAR, TextureFilter::LINEAR,TextureFilter::LINEAR });
depth_ = thin3d_->CreateDepthStencilState(false, false, Comparison::LESS);
sampler_ = thin3d_->CreateSamplerState({ TextureFilter::LINEAR, TextureFilter::LINEAR, TextureFilter::LINEAR });
depth_ = thin3d_->CreateDepthStencilState({ false, false, Comparison::LESS });
T3DRasterStateDesc desc;
desc.cull = CullMode::NONE;
desc.facing = Facing::CCW;