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

View File

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

View File

@ -602,7 +602,6 @@ void Button::draw(boo::IGraphicsCommandQueue* gfxQ)
{ {
View::draw(gfxQ); View::draw(gfxQ);
gfxQ->setShaderDataBinding(m_vertsBinding); gfxQ->setShaderDataBinding(m_vertsBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
if (m_style == Style::Block) if (m_style == Style::Block)
{ {
gfxQ->draw(0, 28); 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) void IconView::draw(boo::IGraphicsCommandQueue* gfxQ)
{ {
gfxQ->setShaderDataBinding(m_vertexBinding); gfxQ->setShaderDataBinding(m_vertexBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
gfxQ->draw(0, 4); gfxQ->draw(0, 4);
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,11 +9,7 @@ namespace Specter
{ {
static LogVisor::LogModule Log("Specter::TextView"); static LogVisor::LogModule Log("Specter::TextView");
void TextView::Resources::init(boo::GLDataFactory* factory, FontCache* fcache) static const char* GLSLVS =
{
m_fcache = fcache;
static const char* VS =
"#version 330\n" "#version 330\n"
"layout(location=0) in vec3 posIn[4];\n" "layout(location=0) in vec3 posIn[4];\n"
"layout(location=4) in mat4 mvMtx;\n" "layout(location=4) in mat4 mvMtx;\n"
@ -33,7 +29,7 @@ void TextView::Resources::init(boo::GLDataFactory* factory, FontCache* fcache)
" gl_Position = mv * mvMtx * vec4(posIn[gl_VertexID], 1.0);\n" " gl_Position = mv * mvMtx * vec4(posIn[gl_VertexID], 1.0);\n"
"}\n"; "}\n";
static const char* FSReg = static const char* GLSLFSReg =
"#version 330\n" "#version 330\n"
"uniform sampler2DArray fontTex;\n" "uniform sampler2DArray fontTex;\n"
"struct VertToFrag\n" "struct VertToFrag\n"
@ -49,7 +45,7 @@ void TextView::Resources::init(boo::GLDataFactory* factory, FontCache* fcache)
" colorOut.a *= texture(fontTex, vtf.uv).r;\n" " colorOut.a *= texture(fontTex, vtf.uv).r;\n"
"}\n"; "}\n";
static const char* FSSubpixel = static const char* GLSLFSSubpixel =
"#version 330\n" "#version 330\n"
"uniform sampler2DArray fontTex;\n" "uniform sampler2DArray fontTex;\n"
"struct VertToFrag\n" "struct VertToFrag\n"
@ -66,15 +62,19 @@ void TextView::Resources::init(boo::GLDataFactory* factory, FontCache* fcache)
" blendOut = colorOut.a * texture(fontTex, vtf.uv);\n" " blendOut = colorOut.a * texture(fontTex, vtf.uv);\n"
"}\n"; "}\n";
void TextView::Resources::init(boo::GLDataFactory* factory, FontCache* fcache)
{
m_fcache = fcache;
static const char* BlockNames[] = {"SpecterViewBlock"}; static const char* BlockNames[] = {"SpecterViewBlock"};
m_regular = m_regular =
factory->newShaderPipeline(VS, FSReg, 1, "fontTex", 1, BlockNames, factory->newShaderPipeline(GLSLVS, GLSLFSReg, 1, "fontTex", 1, BlockNames,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
false, false, false); false, false, false);
m_subpixel = m_subpixel =
factory->newShaderPipeline(VS, FSSubpixel, 1, "fontTex", 1, BlockNames, factory->newShaderPipeline(GLSLVS, GLSLFSSubpixel, 1, "fontTex", 1, BlockNames,
boo::BlendFactor::SrcColor1, boo::BlendFactor::InvSrcColor1, boo::BlendFactor::SrcColor1, boo::BlendFactor::InvSrcColor1,
false, false, false); false, false, false);
} }
@ -181,7 +181,8 @@ void TextView::Resources::init(boo::ID3DDataFactory* factory, FontCache* fcache)
false, false, false); false, false, false);
} }
#elif BOO_HAS_METAL #endif
#if BOO_HAS_METAL
void TextView::Resources::init(boo::MetalDataFactory* factory, FontCache* fcache) 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); 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 #endif
TextView::TextView(ViewResources& res, View& parentView, const FontAtlas& font, Alignment align, size_t capacity) 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; m_valid = true;
} }
gfxQ->setShaderDataBinding(m_shaderBinding); gfxQ->setShaderDataBinding(m_shaderBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
gfxQ->drawInstances(0, 4, m_glyphs.size()); gfxQ->drawInstances(0, 4, m_glyphs.size());
} }
} }

View File

@ -168,7 +168,6 @@ void Toolbar::draw(boo::IGraphicsCommandQueue* gfxQ)
{ {
View::draw(gfxQ); View::draw(gfxQ);
gfxQ->setShaderDataBinding(m_vertsBinding); gfxQ->setShaderDataBinding(m_vertsBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
gfxQ->draw(0, 10); gfxQ->draw(0, 10);
for (std::vector<ViewChild<View*>>& u : m_children) 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) void Tooltip::draw(boo::IGraphicsCommandQueue* gfxQ)
{ {
gfxQ->setShaderDataBinding(m_vertsBinding); gfxQ->setShaderDataBinding(m_vertsBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
gfxQ->draw(0, 16); gfxQ->draw(0, 16);
for (int i=0 ; i<4 ; ++i) for (int i=0 ; i<4 ; ++i)

View File

@ -6,9 +6,7 @@ namespace Specter
{ {
static LogVisor::LogModule Log("Specter::View"); static LogVisor::LogModule Log("Specter::View");
void View::Resources::init(boo::GLDataFactory* factory, const IThemeData& theme) static const char* GLSLSolidVS =
{
static const char* SolidVS =
"#version 330\n" "#version 330\n"
"layout(location=0) in vec3 posIn;\n" "layout(location=0) in vec3 posIn;\n"
"layout(location=1) in vec4 colorIn;\n" "layout(location=1) in vec4 colorIn;\n"
@ -24,7 +22,7 @@ void View::Resources::init(boo::GLDataFactory* factory, const IThemeData& theme)
" gl_Position = mv * vec4(posIn, 1.0);\n" " gl_Position = mv * vec4(posIn, 1.0);\n"
"}\n"; "}\n";
static const char* SolidFS = static const char* GLSLSolidFS =
"#version 330\n" "#version 330\n"
"struct VertToFrag\n" "struct VertToFrag\n"
"{\n" "{\n"
@ -37,7 +35,7 @@ void View::Resources::init(boo::GLDataFactory* factory, const IThemeData& theme)
" colorOut = vtf.color;\n" " colorOut = vtf.color;\n"
"}\n"; "}\n";
static const char* TexVS = static const char* GLSLTexVS =
"#version 330\n" "#version 330\n"
"layout(location=0) in vec3 posIn;\n" "layout(location=0) in vec3 posIn;\n"
"layout(location=1) in vec2 uvIn;\n" "layout(location=1) in vec2 uvIn;\n"
@ -55,7 +53,7 @@ void View::Resources::init(boo::GLDataFactory* factory, const IThemeData& theme)
" gl_Position = mv * vec4(posIn, 1.0);\n" " gl_Position = mv * vec4(posIn, 1.0);\n"
"}\n"; "}\n";
static const char* TexFS = static const char* GLSLTexFS =
"#version 330\n" "#version 330\n"
"struct VertToFrag\n" "struct VertToFrag\n"
"{\n" "{\n"
@ -70,13 +68,15 @@ void View::Resources::init(boo::GLDataFactory* factory, const IThemeData& theme)
" colorOut = texture(tex, vtf.uv) * vtf.color;\n" " colorOut = texture(tex, vtf.uv) * vtf.color;\n"
"}\n"; "}\n";
void View::Resources::init(boo::GLDataFactory* factory, const IThemeData& theme)
{
static const char* BlockNames[] = {"SpecterViewBlock"}; 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, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
false, false, false); 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, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
false, false, false); false, false, false);
} }
@ -181,7 +181,8 @@ void View::Resources::init(boo::ID3DDataFactory* factory, const IThemeData& them
false, false, false); false, false, false);
} }
#elif BOO_HAS_METAL #endif
#if BOO_HAS_METAL
void View::Resources::init(boo::MetalDataFactory* factory, const IThemeData& theme) 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); 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 #endif
void View::buildResources(ViewResources& res) 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) void View::draw(boo::IGraphicsCommandQueue* gfxQ)
{ {
gfxQ->setShaderDataBinding(m_bgVertsBinding); gfxQ->setShaderDataBinding(m_bgVertsBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
gfxQ->draw(0, 4); gfxQ->draw(0, 4);
} }

View File

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