mirror of https://github.com/AxioDL/boo.git
Add baseVertex to drawIndexed; add ESpecialKey::Tab
This commit is contained in:
parent
55deba0913
commit
d13fbda0c0
|
@ -116,7 +116,8 @@ enum class ESpecialKey {
|
||||||
Left = 22,
|
Left = 22,
|
||||||
Right = 23,
|
Right = 23,
|
||||||
Up = 24,
|
Up = 24,
|
||||||
Down = 25
|
Down = 25,
|
||||||
|
Tab = 26,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class EModifierKey {
|
enum class EModifierKey {
|
||||||
|
|
|
@ -32,7 +32,7 @@ struct IGraphicsCommandQueue {
|
||||||
virtual void clearTarget(bool render = true, bool depth = true) = 0;
|
virtual void clearTarget(bool render = true, bool depth = true) = 0;
|
||||||
|
|
||||||
virtual void draw(size_t start, size_t count) = 0;
|
virtual void draw(size_t start, size_t count) = 0;
|
||||||
virtual void drawIndexed(size_t start, size_t count) = 0;
|
virtual void drawIndexed(size_t start, size_t count, size_t baseVertex = 0) = 0;
|
||||||
virtual void drawInstances(size_t start, size_t count, size_t instCount, size_t startInst = 0) = 0;
|
virtual void drawInstances(size_t start, size_t count, size_t instCount, size_t startInst = 0) = 0;
|
||||||
virtual void drawInstancesIndexed(size_t start, size_t count, size_t instCount, size_t startInst = 0) = 0;
|
virtual void drawInstancesIndexed(size_t start, size_t count, size_t instCount, size_t startInst = 0) = 0;
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,7 @@ enum class VertexSemantic {
|
||||||
UV4,
|
UV4,
|
||||||
Weight,
|
Weight,
|
||||||
ModelView,
|
ModelView,
|
||||||
|
Position2,
|
||||||
SemanticMask = 0xf,
|
SemanticMask = 0xf,
|
||||||
Instanced = 0x10
|
Instanced = 0x10
|
||||||
};
|
};
|
||||||
|
|
|
@ -499,12 +499,12 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr std::array<size_t, 11> SEMANTIC_SIZE_TABLE{
|
constexpr std::array<size_t, 12> SEMANTIC_SIZE_TABLE{
|
||||||
0, 12, 16, 12, 16, 16, 4, 8, 16, 16, 16,
|
0, 12, 16, 12, 16, 16, 4, 8, 16, 16, 16, 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr std::array<const char*, 11> SEMANTIC_NAME_TABLE{
|
constexpr std::array<const char*, 12> SEMANTIC_NAME_TABLE{
|
||||||
nullptr, "POSITION", "POSITION", "NORMAL", "NORMAL", "COLOR", "COLOR", "UV", "UV", "WEIGHT", "MODELVIEW",
|
nullptr, "POSITION", "POSITION", "NORMAL", "NORMAL", "COLOR", "COLOR", "UV", "UV", "WEIGHT", "MODELVIEW", "POSITION",
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr std::array<DXGI_FORMAT, 11> SEMANTIC_TYPE_TABLE{
|
constexpr std::array<DXGI_FORMAT, 11> SEMANTIC_TYPE_TABLE{
|
||||||
|
@ -1175,7 +1175,9 @@ struct D3D11CommandQueue final : IGraphicsCommandQueue {
|
||||||
|
|
||||||
void draw(size_t start, size_t count) override { m_deferredCtx->Draw(count, start); }
|
void draw(size_t start, size_t count) override { m_deferredCtx->Draw(count, start); }
|
||||||
|
|
||||||
void drawIndexed(size_t start, size_t count) override { m_deferredCtx->DrawIndexed(count, start, 0); }
|
void drawIndexed(size_t start, size_t count, size_t baseVertex) override {
|
||||||
|
m_deferredCtx->DrawIndexed(count, start, baseVertex);
|
||||||
|
}
|
||||||
|
|
||||||
void drawInstances(size_t start, size_t count, size_t instCount, size_t startInst) override {
|
void drawInstances(size_t start, size_t count, size_t instCount, size_t startInst) override {
|
||||||
m_deferredCtx->DrawInstanced(count, instCount, start, startInst);
|
m_deferredCtx->DrawInstanced(count, instCount, start, startInst);
|
||||||
|
|
|
@ -1151,12 +1151,12 @@ ObjToken<IGraphicsBufferD> GLDataFactoryImpl::newPoolBuffer(BufferUse use, size_
|
||||||
return {new GLGraphicsBufferD<BaseGraphicsPool>(pool, use, stride * count)};
|
return {new GLGraphicsBufferD<BaseGraphicsPool>(pool, use, stride * count)};
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr std::array<GLint, 11> SEMANTIC_COUNT_TABLE{
|
constexpr std::array<GLint, 12> SEMANTIC_COUNT_TABLE{
|
||||||
0, 3, 4, 3, 4, 4, 4, 2, 4, 4, 4,
|
0, 3, 4, 3, 4, 4, 4, 2, 4, 4, 4, 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr std::array<size_t, 11> SEMANTIC_SIZE_TABLE{
|
constexpr std::array<size_t, 12> SEMANTIC_SIZE_TABLE{
|
||||||
0, 12, 16, 12, 16, 16, 4, 8, 16, 16, 16,
|
0, 12, 16, 12, 16, 16, 4, 8, 16, 16, 16, 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr std::array<GLenum, 11> SEMANTIC_TYPE_TABLE{
|
constexpr std::array<GLenum, 11> SEMANTIC_TYPE_TABLE{
|
||||||
|
@ -1210,6 +1210,7 @@ struct GLCommandQueue final : IGraphicsCommandQueue {
|
||||||
size_t count;
|
size_t count;
|
||||||
size_t instCount;
|
size_t instCount;
|
||||||
size_t startInst;
|
size_t startInst;
|
||||||
|
size_t baseVertex;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#ifdef BOO_GRAPHICS_DEBUG_GROUPS
|
#ifdef BOO_GRAPHICS_DEBUG_GROUPS
|
||||||
|
@ -1494,6 +1495,10 @@ struct GLCommandQueue final : IGraphicsCommandQueue {
|
||||||
glDrawArrays(currentPrim, cmd.start, cmd.count);
|
glDrawArrays(currentPrim, cmd.start, cmd.count);
|
||||||
break;
|
break;
|
||||||
case Command::Op::DrawIndexed:
|
case Command::Op::DrawIndexed:
|
||||||
|
if (cmd.baseVertex > 0) {
|
||||||
|
Log.report(logvisor::Fatal,
|
||||||
|
FMT_STRING(_SYS_STR("Attempted to render with baseVertex > 0 (currently unsupported in GL)")));
|
||||||
|
}
|
||||||
glDrawElements(currentPrim, cmd.count, GL_UNSIGNED_INT, reinterpret_cast<void*>(cmd.start * 4));
|
glDrawElements(currentPrim, cmd.count, GL_UNSIGNED_INT, reinterpret_cast<void*>(cmd.start * 4));
|
||||||
break;
|
break;
|
||||||
case Command::Op::DrawInstances:
|
case Command::Op::DrawInstances:
|
||||||
|
@ -1738,11 +1743,12 @@ struct GLCommandQueue final : IGraphicsCommandQueue {
|
||||||
cmd.count = count;
|
cmd.count = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawIndexed(size_t start, size_t count) override {
|
void drawIndexed(size_t start, size_t count, size_t baseVertex) override {
|
||||||
std::vector<Command>& cmds = m_cmdBufs[m_fillBuf];
|
std::vector<Command>& cmds = m_cmdBufs[m_fillBuf];
|
||||||
auto& cmd = cmds.emplace_back(Command::Op::DrawIndexed);
|
auto& cmd = cmds.emplace_back(Command::Op::DrawIndexed);
|
||||||
cmd.start = start;
|
cmd.start = start;
|
||||||
cmd.count = count;
|
cmd.count = count;
|
||||||
|
cmd.baseVertex = baseVertex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawInstances(size_t start, size_t count, size_t instCount, size_t startInst) override {
|
void drawInstances(size_t start, size_t count, size_t instCount, size_t startInst) override {
|
||||||
|
|
|
@ -707,7 +707,8 @@ static const size_t SEMANTIC_SIZE_TABLE[] =
|
||||||
8,
|
8,
|
||||||
16,
|
16,
|
||||||
16,
|
16,
|
||||||
16
|
16,
|
||||||
|
8,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const MTLVertexFormat SEMANTIC_TYPE_TABLE[] =
|
static const MTLVertexFormat SEMANTIC_TYPE_TABLE[] =
|
||||||
|
@ -722,7 +723,8 @@ static const MTLVertexFormat SEMANTIC_TYPE_TABLE[] =
|
||||||
MTLVertexFormatFloat2,
|
MTLVertexFormatFloat2,
|
||||||
MTLVertexFormatFloat4,
|
MTLVertexFormatFloat4,
|
||||||
MTLVertexFormatFloat4,
|
MTLVertexFormatFloat4,
|
||||||
MTLVertexFormatFloat4
|
MTLVertexFormatFloat4,
|
||||||
|
MTLVertexFormatFloat2,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MetalVertexFormat {
|
struct MetalVertexFormat {
|
||||||
|
@ -913,7 +915,7 @@ protected:
|
||||||
|
|
||||||
virtual void draw(MetalCommandQueue& q, size_t start, size_t count);
|
virtual void draw(MetalCommandQueue& q, size_t start, size_t count);
|
||||||
|
|
||||||
virtual void drawIndexed(MetalCommandQueue& q, size_t start, size_t count);
|
virtual void drawIndexed(MetalCommandQueue& q, size_t start, size_t count, size_t baseVertex);
|
||||||
|
|
||||||
virtual void drawInstances(MetalCommandQueue& q, size_t start, size_t count, size_t instCount, size_t startInst);
|
virtual void drawInstances(MetalCommandQueue& q, size_t start, size_t count, size_t instCount, size_t startInst);
|
||||||
|
|
||||||
|
@ -1067,7 +1069,7 @@ class MetalTessellationShaderPipeline : public MetalShaderPipeline {
|
||||||
|
|
||||||
void draw(MetalCommandQueue& q, size_t start, size_t count);
|
void draw(MetalCommandQueue& q, size_t start, size_t count);
|
||||||
|
|
||||||
void drawIndexed(MetalCommandQueue& q, size_t start, size_t count);
|
void drawIndexed(MetalCommandQueue& q, size_t start, size_t count, size_t baseVertex);
|
||||||
|
|
||||||
void drawInstances(MetalCommandQueue& q, size_t start, size_t count, size_t instCount, size_t startInst);
|
void drawInstances(MetalCommandQueue& q, size_t start, size_t count, size_t instCount, size_t startInst);
|
||||||
|
|
||||||
|
@ -1475,8 +1477,8 @@ struct MetalCommandQueue : IGraphicsCommandQueue {
|
||||||
m_boundData->m_pipeline.cast<MetalShaderPipeline>()->draw(*this, start, count);
|
m_boundData->m_pipeline.cast<MetalShaderPipeline>()->draw(*this, start, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawIndexed(size_t start, size_t count) {
|
void drawIndexed(size_t start, size_t count, size_t baseVertex) {
|
||||||
m_boundData->m_pipeline.cast<MetalShaderPipeline>()->drawIndexed(*this, start, count);
|
m_boundData->m_pipeline.cast<MetalShaderPipeline>()->drawIndexed(*this, start, count, baseVertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawInstances(size_t start, size_t count, size_t instCount, size_t startInst) {
|
void drawInstances(size_t start, size_t count, size_t instCount, size_t startInst) {
|
||||||
|
@ -1760,14 +1762,14 @@ void MetalShaderPipeline::draw(MetalCommandQueue& q, size_t start, size_t count)
|
||||||
vertexCount:count];
|
vertexCount:count];
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalShaderPipeline::drawIndexed(MetalCommandQueue& q, size_t start, size_t count) {
|
void MetalShaderPipeline::drawIndexed(MetalCommandQueue& q, size_t start, size_t count, size_t baseVertex) {
|
||||||
[q.m_enc drawIndexedPrimitives:m_drawPrim
|
[q.m_enc drawIndexedPrimitives:m_drawPrim
|
||||||
indexCount:count
|
indexCount:count
|
||||||
indexType:MTLIndexTypeUInt32
|
indexType:MTLIndexTypeUInt32
|
||||||
indexBuffer:GetBufferGPUResource(q.m_boundData->m_ibuf, q.m_fillBuf)
|
indexBuffer:GetBufferGPUResource(q.m_boundData->m_ibuf, q.m_fillBuf)
|
||||||
indexBufferOffset:start * 4
|
indexBufferOffset:start * 4
|
||||||
instanceCount:1
|
instanceCount:1
|
||||||
baseVertex:q.m_boundData->m_baseVert
|
baseVertex:q.m_boundData->m_baseVert + baseVertex
|
||||||
baseInstance:0];
|
baseInstance:0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1803,13 +1805,13 @@ patchIndexBufferOffset:0
|
||||||
baseInstance:0];
|
baseInstance:0];
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalTessellationShaderPipeline::drawIndexed(MetalCommandQueue& q, size_t start, size_t count) {
|
void MetalTessellationShaderPipeline::drawIndexed(MetalCommandQueue& q, size_t start, size_t count, size_t baseVertex) {
|
||||||
q.dispatchTessKernel(m_computeState, start, count, m_patchSize);
|
q.dispatchTessKernel(m_computeState, start, count, m_patchSize);
|
||||||
[q.m_enc drawIndexedPatches:m_patchSize
|
[q.m_enc drawIndexedPatches:m_patchSize
|
||||||
patchStart:0
|
patchStart:0
|
||||||
patchCount:count
|
patchCount:count
|
||||||
patchIndexBuffer:nullptr
|
patchIndexBuffer:nullptr
|
||||||
patchIndexBufferOffset:0
|
patchIndexBufferOffset:baseVertex
|
||||||
controlPointIndexBuffer:GetBufferGPUResource(q.m_boundData->m_ibuf, q.m_fillBuf)
|
controlPointIndexBuffer:GetBufferGPUResource(q.m_boundData->m_ibuf, q.m_fillBuf)
|
||||||
controlPointIndexBufferOffset:start * 4
|
controlPointIndexBufferOffset:start * 4
|
||||||
instanceCount:1
|
instanceCount:1
|
||||||
|
|
|
@ -2204,13 +2204,14 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const size_t SEMANTIC_SIZE_TABLE[] = {0, 12, 16, 12, 16, 16, 4, 8, 16, 16, 16};
|
static const size_t SEMANTIC_SIZE_TABLE[] = {0, 12, 16, 12, 16, 16, 4, 8, 16, 16, 16, 8};
|
||||||
|
|
||||||
static const VkFormat SEMANTIC_TYPE_TABLE[] = {
|
static const VkFormat SEMANTIC_TYPE_TABLE[] = {
|
||||||
VK_FORMAT_UNDEFINED, VK_FORMAT_R32G32B32_SFLOAT, VK_FORMAT_R32G32B32A32_SFLOAT,
|
VK_FORMAT_UNDEFINED, VK_FORMAT_R32G32B32_SFLOAT, VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||||
VK_FORMAT_R32G32B32_SFLOAT, VK_FORMAT_R32G32B32A32_SFLOAT, VK_FORMAT_R32G32B32A32_SFLOAT,
|
VK_FORMAT_R32G32B32_SFLOAT, VK_FORMAT_R32G32B32A32_SFLOAT, VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||||
VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R32G32B32A32_SFLOAT,
|
VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||||
VK_FORMAT_R32G32B32A32_SFLOAT, VK_FORMAT_R32G32B32A32_SFLOAT};
|
VK_FORMAT_R32G32B32A32_SFLOAT, VK_FORMAT_R32G32B32A32_SFLOAT, VK_FORMAT_R32G32_SFLOAT,
|
||||||
|
};
|
||||||
|
|
||||||
struct VulkanVertexFormat {
|
struct VulkanVertexFormat {
|
||||||
VkVertexInputBindingDescription m_bindings[2];
|
VkVertexInputBindingDescription m_bindings[2];
|
||||||
|
@ -3167,7 +3168,7 @@ struct VulkanCommandQueue final : IGraphicsCommandQueue {
|
||||||
|
|
||||||
void draw(size_t start, size_t count) { vk::CmdDraw(m_cmdBufs[m_fillBuf], count, 1, start, 0); }
|
void draw(size_t start, size_t count) { vk::CmdDraw(m_cmdBufs[m_fillBuf], count, 1, start, 0); }
|
||||||
|
|
||||||
void drawIndexed(size_t start, size_t count) { vk::CmdDrawIndexed(m_cmdBufs[m_fillBuf], count, 1, start, 0, 0); }
|
void drawIndexed(size_t start, size_t count, size_t baseVertex) { vk::CmdDrawIndexed(m_cmdBufs[m_fillBuf], count, 1, start, baseVertex, 0); }
|
||||||
|
|
||||||
void drawInstances(size_t start, size_t count, size_t instCount, size_t startInst) {
|
void drawInstances(size_t start, size_t count, size_t instCount, size_t startInst) {
|
||||||
vk::CmdDraw(m_cmdBufs[m_fillBuf], count, instCount, start, startInst);
|
vk::CmdDraw(m_cmdBufs[m_fillBuf], count, instCount, start, startInst);
|
||||||
|
|
|
@ -1006,6 +1006,8 @@ static boo::ESpecialKey translateKeycode(short code) {
|
||||||
return boo::ESpecialKey::Up;
|
return boo::ESpecialKey::Up;
|
||||||
case kVK_DownArrow:
|
case kVK_DownArrow:
|
||||||
return boo::ESpecialKey::Down;
|
return boo::ESpecialKey::Down;
|
||||||
|
case kVK_Tab:
|
||||||
|
return boo::ESpecialKey::Tab;
|
||||||
default:
|
default:
|
||||||
return boo::ESpecialKey::None;
|
return boo::ESpecialKey::None;
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,6 +188,8 @@ static uint32_t translateKeysym(CoreWindow ^ window, VirtualKey sym, ESpecialKey
|
||||||
specialSym = ESpecialKey::Up;
|
specialSym = ESpecialKey::Up;
|
||||||
else if (sym == VirtualKey::Down)
|
else if (sym == VirtualKey::Down)
|
||||||
specialSym = ESpecialKey::Down;
|
specialSym = ESpecialKey::Down;
|
||||||
|
else if (sym == VirtualKey::Tab)
|
||||||
|
specialSym = ESpecialKey::Tab;
|
||||||
else if (sym == VirtualKey::Shift)
|
else if (sym == VirtualKey::Shift)
|
||||||
modifierSym = EModifierKey::Shift;
|
modifierSym = EModifierKey::Shift;
|
||||||
else if (sym == VirtualKey::Control)
|
else if (sym == VirtualKey::Control)
|
||||||
|
|
|
@ -578,6 +578,8 @@ static uint32_t translateKeysym(WPARAM sym, UINT scancode, ESpecialKey& specialS
|
||||||
specialSym = ESpecialKey::Up;
|
specialSym = ESpecialKey::Up;
|
||||||
else if (sym == VK_DOWN)
|
else if (sym == VK_DOWN)
|
||||||
specialSym = ESpecialKey::Down;
|
specialSym = ESpecialKey::Down;
|
||||||
|
else if (sym == VK_TAB)
|
||||||
|
specialSym = ESpecialKey::Tab;
|
||||||
else if (sym == VK_SHIFT)
|
else if (sym == VK_SHIFT)
|
||||||
modifierSym = EModifierKey::Shift;
|
modifierSym = EModifierKey::Shift;
|
||||||
else if (sym == VK_CONTROL)
|
else if (sym == VK_CONTROL)
|
||||||
|
|
|
@ -147,6 +147,8 @@ static char translateKeysym(XKeyEvent* ev, ESpecialKey& specialSym, EModifierKey
|
||||||
specialSym = ESpecialKey::Up;
|
specialSym = ESpecialKey::Up;
|
||||||
else if (sym == XK_Down)
|
else if (sym == XK_Down)
|
||||||
specialSym = ESpecialKey::Down;
|
specialSym = ESpecialKey::Down;
|
||||||
|
else if (sym == XK_Tab)
|
||||||
|
specialSym = ESpecialKey::Tab;
|
||||||
else if (sym == XK_Shift_L || sym == XK_Shift_R)
|
else if (sym == XK_Shift_L || sym == XK_Shift_R)
|
||||||
modifierSym = EModifierKey::Shift;
|
modifierSym = EModifierKey::Shift;
|
||||||
else if (sym == XK_Control_L || sym == XK_Control_R)
|
else if (sym == XK_Control_L || sym == XK_Control_R)
|
||||||
|
|
Loading…
Reference in New Issue