Vulkan updates

This commit is contained in:
Jack Andersen 2016-02-22 16:33:59 -10:00
parent 57e2535393
commit ac2f2ba446
16 changed files with 201 additions and 139 deletions

View File

@ -5,6 +5,7 @@
#include <boo/graphicsdev/GL.hpp>
#include <boo/graphicsdev/D3D.hpp>
#include <boo/graphicsdev/Metal.hpp>
#include <boo/graphicsdev/Vulkan.hpp>
#include "FontCache.hpp"
@ -49,8 +50,12 @@ public:
void init(boo::GLDataFactory* factory, FontCache* fcache);
#if _WIN32
void init(boo::ID3DDataFactory* factory, FontCache* fcache);
#elif BOO_HAS_METAL
#endif
#if BOO_HAS_METAL
void init(boo::MetalDataFactory* factory, FontCache* fcache);
#endif
#if BOO_HAS_VULKAN
void init(boo::VulkanDataFactory* factory, FontCache* fcache);
#endif
};

View File

@ -11,6 +11,7 @@
#include <boo/graphicsdev/GL.hpp>
#include <boo/graphicsdev/D3D.hpp>
#include <boo/graphicsdev/Metal.hpp>
#include <boo/graphicsdev/Vulkan.hpp>
namespace Specter
{
@ -160,8 +161,12 @@ public:
void init(boo::GLDataFactory* factory, const IThemeData& theme);
#if _WIN32
void init(boo::ID3DDataFactory* factory, const IThemeData& theme);
#elif BOO_HAS_METAL
#endif
#if BOO_HAS_METAL
void init(boo::MetalDataFactory* factory, const IThemeData& theme);
#endif
#if BOO_HAS_VULKAN
void init(boo::VulkanDataFactory* factory, const IThemeData& theme);
#endif
};

View File

@ -602,7 +602,6 @@ void Button::draw(boo::IGraphicsCommandQueue* gfxQ)
{
View::draw(gfxQ);
gfxQ->setShaderDataBinding(m_vertsBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
if (m_style == Style::Block)
{
gfxQ->draw(0, 28);

View File

@ -32,7 +32,6 @@ void IconView::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub
void IconView::draw(boo::IGraphicsCommandQueue* gfxQ)
{
gfxQ->setShaderDataBinding(m_vertexBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
gfxQ->draw(0, 4);
}

View File

@ -279,11 +279,9 @@ void Menu::draw(boo::IGraphicsCommandQueue* gfxQ)
{
View::draw(gfxQ);
gfxQ->setShaderDataBinding(m_vertsBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
gfxQ->draw(0, 4);
m_scroll.m_view->draw(gfxQ);
gfxQ->setShaderDataBinding(m_vertsBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
gfxQ->draw(4, 4);
m_headText->draw(gfxQ);
}

View File

@ -476,7 +476,6 @@ void ModalWindow::draw(boo::IGraphicsCommandQueue* gfxQ)
return;
gfxQ->setShaderDataBinding(m_vertsBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
gfxQ->draw(0, 22);
gfxQ->draw(22, 16);

View File

@ -636,7 +636,6 @@ void RootView::SplitMenuSystem::draw(boo::IGraphicsCommandQueue* gfxQ)
if (m_phase == Phase::Inactive)
return;
gfxQ->setShaderDataBinding(m_vertsBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
if (m_phase == Phase::InteractiveJoin)
gfxQ->draw(0, 28);
else

View File

@ -300,7 +300,6 @@ void ScrollView::draw(boo::IGraphicsCommandQueue* gfxQ)
if (m_style == Style::ThinIndicator && m_drawInd)
{
gfxQ->setShaderDataBinding(m_vertsBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
gfxQ->draw(0, 4);
}
else if (m_style == Style::SideButtons && m_drawSideButtons)

View File

@ -343,7 +343,6 @@ void Space::draw(boo::IGraphicsCommandQueue* gfxQ)
void Space::CornerView::draw(boo::IGraphicsCommandQueue* gfxQ)
{
gfxQ->setShaderDataBinding(m_vertexBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
gfxQ->draw(0, 34);
}

View File

@ -832,7 +832,6 @@ void Table::draw(boo::IGraphicsCommandQueue* gfxQ)
void Table::RowsView::draw(boo::IGraphicsCommandQueue* gfxQ)
{
gfxQ->setShaderDataBinding(m_vertsBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
gfxQ->setScissor(m_scissorRect);
gfxQ->draw(1, m_visibleRows * m_t.m_columns * 6 - 2);
@ -860,7 +859,6 @@ void Table::RowsView::draw(boo::IGraphicsCommandQueue* gfxQ)
if (m_t.m_header)
{
gfxQ->setShaderDataBinding(m_t.m_vertsBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
gfxQ->setScissor(rootView().subRect());
gfxQ->draw(1, m_t.m_columns * 6 - 2);
for (ViewChild<std::unique_ptr<CellView>>& hv : m_t.m_headerViews)

View File

@ -895,7 +895,6 @@ void TextField::draw(boo::IGraphicsCommandQueue* gfxQ)
{
View::draw(gfxQ);
gfxQ->setShaderDataBinding(m_vertsBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
gfxQ->draw(0, 28);
if (m_active)
{

View File

@ -9,72 +9,72 @@ namespace Specter
{
static LogVisor::LogModule Log("Specter::TextView");
static const char* GLSLVS =
"#version 330\n"
"layout(location=0) in vec3 posIn[4];\n"
"layout(location=4) in mat4 mvMtx;\n"
"layout(location=8) in vec3 uvIn[4];\n"
"layout(location=12) in vec4 colorIn;\n"
SPECTER_VIEW_VERT_BLOCK_GLSL
"struct VertToFrag\n"
"{\n"
" vec3 uv;\n"
" vec4 color;\n"
"};\n"
"out VertToFrag vtf;\n"
"void main()\n"
"{\n"
" vtf.uv = uvIn[gl_VertexID];\n"
" vtf.color = colorIn * mulColor;\n"
" gl_Position = mv * mvMtx * vec4(posIn[gl_VertexID], 1.0);\n"
"}\n";
static const char* GLSLFSReg =
"#version 330\n"
"uniform sampler2DArray fontTex;\n"
"struct VertToFrag\n"
"{\n"
" vec3 uv;\n"
" vec4 color;\n"
"};\n"
"in VertToFrag vtf;\n"
"layout(location=0) out vec4 colorOut;\n"
"void main()\n"
"{\n"
" colorOut = vtf.color;\n"
" colorOut.a *= texture(fontTex, vtf.uv).r;\n"
"}\n";
static const char* GLSLFSSubpixel =
"#version 330\n"
"uniform sampler2DArray fontTex;\n"
"struct VertToFrag\n"
"{\n"
" vec3 uv;\n"
" vec4 color;\n"
"};\n"
"in VertToFrag vtf;\n"
"layout(location=0, index=0) out vec4 colorOut;\n"
"layout(location=0, index=1) out vec4 blendOut;\n"
"void main()\n"
"{\n"
" colorOut = vtf.color;\n"
" blendOut = colorOut.a * texture(fontTex, vtf.uv);\n"
"}\n";
void TextView::Resources::init(boo::GLDataFactory* factory, FontCache* fcache)
{
m_fcache = fcache;
static const char* VS =
"#version 330\n"
"layout(location=0) in vec3 posIn[4];\n"
"layout(location=4) in mat4 mvMtx;\n"
"layout(location=8) in vec3 uvIn[4];\n"
"layout(location=12) in vec4 colorIn;\n"
SPECTER_VIEW_VERT_BLOCK_GLSL
"struct VertToFrag\n"
"{\n"
" vec3 uv;\n"
" vec4 color;\n"
"};\n"
"out VertToFrag vtf;\n"
"void main()\n"
"{\n"
" vtf.uv = uvIn[gl_VertexID];\n"
" vtf.color = colorIn * mulColor;\n"
" gl_Position = mv * mvMtx * vec4(posIn[gl_VertexID], 1.0);\n"
"}\n";
static const char* FSReg =
"#version 330\n"
"uniform sampler2DArray fontTex;\n"
"struct VertToFrag\n"
"{\n"
" vec3 uv;\n"
" vec4 color;\n"
"};\n"
"in VertToFrag vtf;\n"
"layout(location=0) out vec4 colorOut;\n"
"void main()\n"
"{\n"
" colorOut = vtf.color;\n"
" colorOut.a *= texture(fontTex, vtf.uv).r;\n"
"}\n";
static const char* FSSubpixel =
"#version 330\n"
"uniform sampler2DArray fontTex;\n"
"struct VertToFrag\n"
"{\n"
" vec3 uv;\n"
" vec4 color;\n"
"};\n"
"in VertToFrag vtf;\n"
"layout(location=0, index=0) out vec4 colorOut;\n"
"layout(location=0, index=1) out vec4 blendOut;\n"
"void main()\n"
"{\n"
" colorOut = vtf.color;\n"
" blendOut = colorOut.a * texture(fontTex, vtf.uv);\n"
"}\n";
static const char* BlockNames[] = {"SpecterViewBlock"};
m_regular =
factory->newShaderPipeline(VS, FSReg, 1, "fontTex", 1, BlockNames,
factory->newShaderPipeline(GLSLVS, GLSLFSReg, 1, "fontTex", 1, BlockNames,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
false, false, false);
m_subpixel =
factory->newShaderPipeline(VS, FSSubpixel, 1, "fontTex", 1, BlockNames,
factory->newShaderPipeline(GLSLVS, GLSLFSSubpixel, 1, "fontTex", 1, BlockNames,
boo::BlendFactor::SrcColor1, boo::BlendFactor::InvSrcColor1,
false, false, false);
}
@ -181,7 +181,8 @@ void TextView::Resources::init(boo::ID3DDataFactory* factory, FontCache* fcache)
false, false, false);
}
#elif BOO_HAS_METAL
#endif
#if BOO_HAS_METAL
void TextView::Resources::init(boo::MetalDataFactory* factory, FontCache* fcache)
{
@ -257,6 +258,37 @@ void TextView::Resources::init(boo::MetalDataFactory* factory, FontCache* fcache
false, false, false);
}
#endif
#if BOO_HAS_VULKAN
void TextView::Resources::init(boo::VulkanDataFactory* factory, FontCache* fcache)
{
m_fcache = fcache;
boo::VertexElementDescriptor vdescs[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
{nullptr, nullptr, boo::VertexSemantic::ModelView | boo::VertexSemantic::Instanced, 0},
{nullptr, nullptr, boo::VertexSemantic::ModelView | boo::VertexSemantic::Instanced, 1},
{nullptr, nullptr, boo::VertexSemantic::ModelView | boo::VertexSemantic::Instanced, 2},
{nullptr, nullptr, boo::VertexSemantic::ModelView | boo::VertexSemantic::Instanced, 3},
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3},
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced}
};
m_vtxFmt = factory->newVertexFormat(13, vdescs);
m_regular =
factory->newShaderPipeline(GLSLVS, GLSLFSReg, m_vtxFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
false, false, false);
}
#endif
TextView::TextView(ViewResources& res, View& parentView, const FontAtlas& font, Alignment align, size_t capacity)
@ -501,7 +533,6 @@ void TextView::draw(boo::IGraphicsCommandQueue* gfxQ)
m_valid = true;
}
gfxQ->setShaderDataBinding(m_shaderBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
gfxQ->drawInstances(0, 4, m_glyphs.size());
}
}

View File

@ -168,7 +168,6 @@ void Toolbar::draw(boo::IGraphicsCommandQueue* gfxQ)
{
View::draw(gfxQ);
gfxQ->setShaderDataBinding(m_vertsBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
gfxQ->draw(0, 10);
for (std::vector<ViewChild<View*>>& u : m_children)

View File

@ -111,7 +111,6 @@ void Tooltip::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
void Tooltip::draw(boo::IGraphicsCommandQueue* gfxQ)
{
gfxQ->setShaderDataBinding(m_vertsBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
gfxQ->draw(0, 16);
for (int i=0 ; i<4 ; ++i)

View File

@ -6,77 +6,77 @@ namespace Specter
{
static LogVisor::LogModule Log("Specter::View");
static const char* GLSLSolidVS =
"#version 330\n"
"layout(location=0) in vec3 posIn;\n"
"layout(location=1) in vec4 colorIn;\n"
SPECTER_VIEW_VERT_BLOCK_GLSL
"struct VertToFrag\n"
"{\n"
" vec4 color;\n"
"};\n"
"out VertToFrag vtf;\n"
"void main()\n"
"{\n"
" vtf.color = colorIn * mulColor;\n"
" gl_Position = mv * vec4(posIn, 1.0);\n"
"}\n";
static const char* GLSLSolidFS =
"#version 330\n"
"struct VertToFrag\n"
"{\n"
" vec4 color;\n"
"};\n"
"in VertToFrag vtf;\n"
"layout(location=0) out vec4 colorOut;\n"
"void main()\n"
"{\n"
" colorOut = vtf.color;\n"
"}\n";
static const char* GLSLTexVS =
"#version 330\n"
"layout(location=0) in vec3 posIn;\n"
"layout(location=1) in vec2 uvIn;\n"
SPECTER_VIEW_VERT_BLOCK_GLSL
"struct VertToFrag\n"
"{\n"
" vec4 color;\n"
" vec2 uv;\n"
"};\n"
"out VertToFrag vtf;\n"
"void main()\n"
"{\n"
" vtf.uv = uvIn;\n"
" vtf.color = mulColor;\n"
" gl_Position = mv * vec4(posIn, 1.0);\n"
"}\n";
static const char* GLSLTexFS =
"#version 330\n"
"struct VertToFrag\n"
"{\n"
" vec4 color;\n"
" vec2 uv;\n"
"};\n"
"in VertToFrag vtf;\n"
"uniform sampler2D tex;\n"
"layout(location=0) out vec4 colorOut;\n"
"void main()\n"
"{\n"
" colorOut = texture(tex, vtf.uv) * vtf.color;\n"
"}\n";
void View::Resources::init(boo::GLDataFactory* factory, const IThemeData& theme)
{
static const char* SolidVS =
"#version 330\n"
"layout(location=0) in vec3 posIn;\n"
"layout(location=1) in vec4 colorIn;\n"
SPECTER_VIEW_VERT_BLOCK_GLSL
"struct VertToFrag\n"
"{\n"
" vec4 color;\n"
"};\n"
"out VertToFrag vtf;\n"
"void main()\n"
"{\n"
" vtf.color = colorIn * mulColor;\n"
" gl_Position = mv * vec4(posIn, 1.0);\n"
"}\n";
static const char* SolidFS =
"#version 330\n"
"struct VertToFrag\n"
"{\n"
" vec4 color;\n"
"};\n"
"in VertToFrag vtf;\n"
"layout(location=0) out vec4 colorOut;\n"
"void main()\n"
"{\n"
" colorOut = vtf.color;\n"
"}\n";
static const char* TexVS =
"#version 330\n"
"layout(location=0) in vec3 posIn;\n"
"layout(location=1) in vec2 uvIn;\n"
SPECTER_VIEW_VERT_BLOCK_GLSL
"struct VertToFrag\n"
"{\n"
" vec4 color;\n"
" vec2 uv;\n"
"};\n"
"out VertToFrag vtf;\n"
"void main()\n"
"{\n"
" vtf.uv = uvIn;\n"
" vtf.color = mulColor;\n"
" gl_Position = mv * vec4(posIn, 1.0);\n"
"}\n";
static const char* TexFS =
"#version 330\n"
"struct VertToFrag\n"
"{\n"
" vec4 color;\n"
" vec2 uv;\n"
"};\n"
"in VertToFrag vtf;\n"
"uniform sampler2D tex;\n"
"layout(location=0) out vec4 colorOut;\n"
"void main()\n"
"{\n"
" colorOut = texture(tex, vtf.uv) * vtf.color;\n"
"}\n";
static const char* BlockNames[] = {"SpecterViewBlock"};
m_solidShader = factory->newShaderPipeline(SolidVS, SolidFS, 0, nullptr, 1, BlockNames,
m_solidShader = factory->newShaderPipeline(GLSLSolidVS, GLSLSolidFS, 0, nullptr, 1, BlockNames,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
false, false, false);
m_texShader = factory->newShaderPipeline(TexVS, TexFS, 1, "tex", 1, BlockNames,
m_texShader = factory->newShaderPipeline(GLSLTexVS, GLSLTexFS, 1, "tex", 1, BlockNames,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
false, false, false);
}
@ -181,7 +181,8 @@ void View::Resources::init(boo::ID3DDataFactory* factory, const IThemeData& them
false, false, false);
}
#elif BOO_HAS_METAL
#endif
#if BOO_HAS_METAL
void View::Resources::init(boo::MetalDataFactory* factory, const IThemeData& theme)
{
@ -282,6 +283,34 @@ void View::Resources::init(boo::MetalDataFactory* factory, const IThemeData& the
false, false, false);
}
#endif
#if BOO_HAS_VULKAN
void View::Resources::init(boo::VulkanDataFactory* factory, const IThemeData& theme)
{
boo::VertexElementDescriptor solidvdescs[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
{nullptr, nullptr, boo::VertexSemantic::Color}
};
m_solidVtxFmt = factory->newVertexFormat(2, solidvdescs);
m_solidShader = factory->newShaderPipeline(GLSLSolidVS, GLSLSolidFS, m_solidVtxFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
false, false, false);
boo::VertexElementDescriptor texvdescs[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
m_texVtxFmt = factory->newVertexFormat(2, texvdescs);
m_texShader = factory->newShaderPipeline(GLSLTexVS, GLSLTexFS, m_texVtxFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
false, false, false);
}
#endif
void View::buildResources(ViewResources& res)
@ -337,7 +366,6 @@ void View::resized(const ViewBlock& vb, const boo::SWindowRect& sub)
void View::draw(boo::IGraphicsCommandQueue* gfxQ)
{
gfxQ->setShaderDataBinding(m_bgVertsBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
gfxQ->draw(0, 4);
}

View File

@ -25,10 +25,16 @@ void ViewResources::init(boo::IGraphicsDataFactory* factory, FontCache* fcache,
case boo::IGraphicsDataFactory::Platform::D3D12:
init<boo::ID3DDataFactory>(static_cast<boo::ID3DDataFactory*>(factory), *theme, fcache);
break;
#elif BOO_HAS_METAL
#endif
#if BOO_HAS_METAL
case boo::IGraphicsDataFactory::Platform::Metal:
init<boo::MetalDataFactory>(static_cast<boo::MetalDataFactory*>(factory), *theme, fcache);
break;
#endif
#if BOO_HAS_VULKAN
case boo::IGraphicsDataFactory::Platform::Vulkan:
init<boo::VulkanDataFactory>(static_cast<boo::VulkanDataFactory*>(factory), *theme, fcache);
break;
#endif
default:
Log.report(LogVisor::FatalError, _S("unable to init view system for %s"), factory->platformName());