Extend some enums with potentially useful values

This commit is contained in:
Henrik Rydgård 2016-12-26 23:51:17 +01:00
parent e4f18dd220
commit 674937a520
10 changed files with 160 additions and 27 deletions

View File

@ -2,6 +2,8 @@
#include "GPU/ge_constants.h"
// TODO: Replace enums and structs with same from thin3d.h, for convenient mapping.
enum StencilValueType {
STENCIL_VALUE_UNIFORM,
STENCIL_VALUE_ZERO,
@ -86,6 +88,8 @@ enum class BlendFactor : uint8_t {
ONE_MINUS_CONSTANT_COLOR,
CONSTANT_ALPHA,
ONE_MINUS_CONSTANT_ALPHA,
SRC1_COLOR,
ONE_MINUS_SRC1_COLOR,
SRC1_ALPHA,
ONE_MINUS_SRC1_ALPHA,
INVALID,

View File

@ -49,6 +49,8 @@ static const D3DBLEND dxBlendFactorLookup[(size_t)BlendFactor::COUNT] = {
#if 0 // TODO: Requires D3D9Ex
D3DBLEND_SRCCOLOR2,
D3DBLEND_INVSRCCOLOR2,
D3DBLEND_SRCCOLOR2,
D3DBLEND_INVSRCCOLOR2,
#else
D3DBLEND_FORCE_DWORD,
D3DBLEND_FORCE_DWORD,

View File

@ -51,6 +51,8 @@ static const GLushort glBlendFactorLookup[(size_t)BlendFactor::COUNT] = {
GL_ONE_MINUS_CONSTANT_COLOR,
GL_CONSTANT_ALPHA,
GL_ONE_MINUS_CONSTANT_ALPHA,
GL_SRC1_COLOR,
GL_ONE_MINUS_SRC1_COLOR,
#if !defined(USING_GLES2) // TODO: Remove when we have better headers
GL_SRC1_ALPHA,
GL_ONE_MINUS_SRC1_ALPHA,

View File

@ -48,6 +48,8 @@ static const VkBlendFactor vkBlendFactorLookup[(size_t)BlendFactor::COUNT] = {
VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR,
VK_BLEND_FACTOR_CONSTANT_ALPHA,
VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA,
VK_BLEND_FACTOR_SRC1_COLOR,
VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR,
VK_BLEND_FACTOR_SRC1_ALPHA,
VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA,
VK_BLEND_FACTOR_MAX_ENUM,

View File

@ -16,7 +16,7 @@ void D3D11Context::SwapBuffers() {
}
Draw::DrawContext *D3D11Context::CreateThin3DContext() {
return Draw::T3DCreateD3D11Context(); // device_, context_);
return Draw::T3DCreateD3D11Context(device_, context_);
}
static void GetRes(HWND hWnd, int &xres, int &yres) {

View File

@ -21,6 +21,8 @@ struct IDirect3DDevice9;
struct IDirect3D9;
struct IDirect3DDevice9Ex;
struct IDirect3D9Ex;
struct ID3D11Device;
struct ID3D11DeviceContext;
#endif
@ -31,14 +33,6 @@ namespace Draw {
// Useful in UBOs
typedef int bool32;
enum class BlendOp : int {
ADD,
SUBTRACT,
REV_SUBTRACT,
MIN,
MAX,
};
enum class Comparison : int {
NEVER,
LESS,
@ -70,18 +64,33 @@ enum class LogicOp : int {
LOGIC_OR_INVERTED,
};
enum BlendFactor : int {
enum class BlendOp : int {
ADD,
SUBTRACT,
REV_SUBTRACT,
MIN,
MAX,
};
enum class BlendFactor : uint8_t {
ZERO,
ONE,
SRC_COLOR,
SRC_ALPHA,
ONE_MINUS_SRC_COLOR,
ONE_MINUS_SRC_ALPHA,
DST_COLOR,
DST_ALPHA,
ONE_MINUS_DST_COLOR,
SRC_ALPHA,
ONE_MINUS_SRC_ALPHA,
DST_ALPHA,
ONE_MINUS_DST_ALPHA,
FIXED_COLOR,
CONSTANT_COLOR,
ONE_MINUS_CONSTANT_COLOR,
CONSTANT_ALPHA,
ONE_MINUS_CONSTANT_ALPHA,
SRC1_COLOR,
ONE_MINUS_SRC1_COLOR,
SRC1_ALPHA,
ONE_MINUS_SRC1_ALPHA,
};
enum class StencilOp {
@ -520,7 +529,6 @@ public:
Clear(0xF, colorval, depthVal, stencilVal);
}
virtual void End() {}
virtual void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal) = 0;
// Necessary to correctly flip scissor rectangles etc for OpenGL.
@ -548,6 +556,6 @@ DrawContext *T3DCreateDX9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapt
#endif
DrawContext *T3DCreateVulkanContext(VulkanContext *context);
DrawContext *T3DCreateD3D11Context();
DrawContext *T3DCreateD3D11Context(ID3D11Device *device, ID3D11DeviceContext *context);
} // namespace Draw

View File

@ -1,9 +1,95 @@
#include "thin3d/thin3d.h"
#include <d3d11.h>
namespace Draw {
DrawContext *T3DCreateD3D11Context() {
return nullptr;
#if 0
class D3D11Pipeline : public Pipeline {
};
class D3D11DrawContext : public DrawContext {
public:
D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *deviceContext);
~D3D11DrawContext();
const DeviceCaps &GetDeviceCaps() const override {
return caps_;
}
DepthStencilState *CreateDepthStencilState(const DepthStencilStateDesc &desc) override;
BlendState *CreateBlendState(const BlendStateDesc &desc) override;
SamplerState *CreateSamplerState(const SamplerStateDesc &desc) override;
RasterState *CreateRasterState(const RasterStateDesc &desc) override;
Buffer *CreateBuffer(size_t size, uint32_t usageFlags) override;
Pipeline *CreateGraphicsPipeline(const PipelineDesc &desc) override;
InputLayout *CreateInputLayout(const InputLayoutDesc &desc) override;
Texture *CreateTexture() override;
Texture *CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) override;
ShaderModule *CreateShaderModule(ShaderStage stage, const char *glsl_source, const char *hlsl_source, const char *vulkan_source) override;
void BindTextures(int start, int count, Texture **textures) override;
void BindSamplerStates(int start, int count, SamplerState **states) override;
void BindPipeline(Pipeline *pipeline) {
curPipeline_ = (D3D11Pipeline *)pipeline;
}
// Raster state
void SetScissorRect(int left, int top, int width, int height) override;
void SetViewports(int count, Viewport *viewports) override;
void Draw(Buffer *vdata, int vertexCount, int offset) override;
void DrawIndexed(Buffer *vdata, Buffer *idata, int vertexCount, int offset) override;
void DrawUP(const void *vdata, int vertexCount) override;
void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal);
std::string GetInfoString(InfoField info) const override {
switch (info) {
case APIVERSION: return "DirectX 11.0";
case VENDORSTRING: return "N/A";
case VENDOR: return "-";
case RENDERER: return "N/A";
case SHADELANGVERSION: return "N/A";
case APINAME: return "Direct3D 11";
default: return "?";
}
}
private:
ID3D11Device *device_;
ID3D11DeviceContext *context_;
D3D11Pipeline *curPipeline_;
DeviceCaps caps_;
};
D3D11DrawContext::D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *context) : device_(device), context_(context) {
}
D3D11DrawContext::~D3D11DrawContext() {
}
void D3D11DrawContext::SetViewports(int count, Viewport *viewports) {
// Intentionally binary compatible
context_->RSSetViewports(count, (D3D11_VIEWPORT *)viewports);
}
void D3D11DrawContext::SetScissorRect(int left, int top, int width, int height) {
D3D11_RECT rc;
rc.left = left;
rc.top = top;
rc.right = left + width;
rc.bottom = top + height;
context_->RSSetScissorRects(1, &rc);
}
#endif
DrawContext *T3DCreateD3D11Context(ID3D11Device *device, ID3D11DeviceContext *context) {
return nullptr; // new D3D11DrawContext(device, context);
}
} // namespace Draw

View File

@ -48,19 +48,28 @@ static const D3DBLEND blendFactorToD3D9[] = {
D3DBLEND_ZERO,
D3DBLEND_ONE,
D3DBLEND_SRCCOLOR,
D3DBLEND_SRCALPHA,
D3DBLEND_INVSRCCOLOR,
D3DBLEND_INVSRCALPHA,
D3DBLEND_DESTCOLOR,
D3DBLEND_DESTALPHA,
D3DBLEND_INVDESTCOLOR,
D3DBLEND_SRCALPHA,
D3DBLEND_INVSRCALPHA,
D3DBLEND_DESTALPHA,
D3DBLEND_INVDESTALPHA,
D3DBLEND_BLENDFACTOR,
D3DBLEND_INVBLENDFACTOR,
D3DBLEND_BLENDFACTOR,
D3DBLEND_INVBLENDFACTOR,
D3DBLEND_ZERO,
D3DBLEND_ZERO,
D3DBLEND_ZERO,
D3DBLEND_ZERO,
};
static const D3DTEXTUREADDRESS texWrapToD3D9[] = {
D3DTADDRESS_WRAP,
D3DTADDRESS_MIRROR,
D3DTADDRESS_CLAMP,
D3DTADDRESS_BORDER,
};
static const D3DTEXTUREFILTERTYPE texFilterToD3D9[] = {

View File

@ -29,25 +29,36 @@ static const unsigned short blendEqToGL[] = {
GL_FUNC_ADD,
GL_FUNC_SUBTRACT,
GL_FUNC_REVERSE_SUBTRACT,
GL_MIN,
GL_MAX,
};
static const unsigned short blendFactorToGL[] = {
GL_ZERO,
GL_ONE,
GL_SRC_COLOR,
GL_SRC_ALPHA,
GL_ONE_MINUS_SRC_COLOR,
GL_ONE_MINUS_SRC_ALPHA,
GL_DST_COLOR,
GL_DST_ALPHA,
GL_ONE_MINUS_DST_COLOR,
GL_SRC_ALPHA,
GL_ONE_MINUS_SRC_ALPHA,
GL_DST_ALPHA,
GL_ONE_MINUS_DST_ALPHA,
GL_CONSTANT_COLOR,
GL_ONE_MINUS_CONSTANT_COLOR,
GL_CONSTANT_ALPHA,
GL_ONE_MINUS_CONSTANT_ALPHA,
GL_SRC1_COLOR,
GL_ONE_MINUS_SRC1_COLOR,
GL_SRC1_ALPHA,
GL_ONE_MINUS_SRC1_ALPHA,
};
static const unsigned short texWrapToGL[] = {
GL_REPEAT,
GL_MIRRORED_REPEAT,
GL_CLAMP_TO_EDGE,
GL_CLAMP_TO_BORDER,
};
static const unsigned short texFilterToGL[] = {

View File

@ -62,20 +62,29 @@ static const VkBlendOp blendEqToVk[] = {
VK_BLEND_OP_ADD,
VK_BLEND_OP_SUBTRACT,
VK_BLEND_OP_REVERSE_SUBTRACT,
VK_BLEND_OP_MIN,
VK_BLEND_OP_MAX,
};
static const VkBlendFactor blendFactorToVk[] = {
VK_BLEND_FACTOR_ZERO,
VK_BLEND_FACTOR_ONE,
VK_BLEND_FACTOR_SRC_COLOR,
VK_BLEND_FACTOR_SRC_ALPHA,
VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR,
VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
VK_BLEND_FACTOR_DST_COLOR,
VK_BLEND_FACTOR_DST_ALPHA,
VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR,
VK_BLEND_FACTOR_SRC_ALPHA,
VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
VK_BLEND_FACTOR_DST_ALPHA,
VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA,
VK_BLEND_FACTOR_CONSTANT_COLOR,
VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR,
VK_BLEND_FACTOR_CONSTANT_ALPHA,
VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA,
VK_BLEND_FACTOR_SRC1_COLOR,
VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR,
VK_BLEND_FACTOR_SRC1_ALPHA,
VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA,
};
static const VkLogicOp logicOpToVK[] = {