mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-16 02:49:17 +01:00
Avoid bitfields for signed enum types in PackedPipelineState
This commit is contained in:
parent
2f2b615780
commit
e71ca05f19
@ -19,7 +19,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
|
|
||||||
void PackedPipelineState::SetVertexBinding(u32 index, engine::VertexStream stream, engine::VertexStreamInstance instance) {
|
void PackedPipelineState::SetVertexBinding(u32 index, engine::VertexStream stream, engine::VertexStreamInstance instance) {
|
||||||
vertexBindings[index].stride = stream.format.stride;
|
vertexBindings[index].stride = stream.format.stride;
|
||||||
vertexBindings[index].inputRate = instance.isInstanced ? vk::VertexInputRate::eInstance : vk::VertexInputRate::eVertex;
|
vertexBindings[index].inputRate = static_cast<u8>(instance.isInstanced ? vk::VertexInputRate::eInstance : vk::VertexInputRate::eVertex);
|
||||||
vertexBindings[index].enable = stream.format.enable;
|
vertexBindings[index].enable = stream.format.enable;
|
||||||
vertexBindings[index].divisor = stream.frequency;
|
vertexBindings[index].divisor = stream.frequency;
|
||||||
}
|
}
|
||||||
@ -33,16 +33,23 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
void PackedPipelineState::SetPolygonMode(engine::PolygonMode mode) {
|
void PackedPipelineState::SetPolygonMode(engine::PolygonMode mode) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case engine::PolygonMode::Fill:
|
case engine::PolygonMode::Fill:
|
||||||
polygonMode = vk::PolygonMode::eFill;
|
polygonMode = static_cast<u8>(vk::PolygonMode::eFill);
|
||||||
|
break;
|
||||||
case engine::PolygonMode::Line:
|
case engine::PolygonMode::Line:
|
||||||
polygonMode = vk::PolygonMode::eLine;
|
polygonMode = static_cast<u8>(vk::PolygonMode::eLine);
|
||||||
|
break;
|
||||||
case engine::PolygonMode::Point:
|
case engine::PolygonMode::Point:
|
||||||
polygonMode = vk::PolygonMode::ePoint;
|
polygonMode = static_cast<u8>(vk::PolygonMode::ePoint);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw exception("Invalid polygon mode: 0x{:X}", static_cast<u32>(mode));
|
throw exception("Invalid polygon mode: 0x{:X}", static_cast<u32>(mode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vk::PolygonMode PackedPipelineState::GetPolygonMode() const {
|
||||||
|
return static_cast<vk::PolygonMode>(polygonMode);
|
||||||
|
}
|
||||||
|
|
||||||
void PackedPipelineState::SetCullMode(bool enable, engine::CullFace mode) {
|
void PackedPipelineState::SetCullMode(bool enable, engine::CullFace mode) {
|
||||||
if (!enable) {
|
if (!enable) {
|
||||||
cullMode = {};
|
cullMode = {};
|
||||||
@ -52,67 +59,82 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
switch (mode) {
|
switch (mode) {
|
||||||
case engine::CullFace::Front:
|
case engine::CullFace::Front:
|
||||||
cullMode = VK_CULL_MODE_FRONT_BIT;
|
cullMode = VK_CULL_MODE_FRONT_BIT;
|
||||||
|
break;
|
||||||
case engine::CullFace::Back:
|
case engine::CullFace::Back:
|
||||||
cullMode = VK_CULL_MODE_BACK_BIT;
|
cullMode = VK_CULL_MODE_BACK_BIT;
|
||||||
|
break;
|
||||||
case engine::CullFace::FrontAndBack:
|
case engine::CullFace::FrontAndBack:
|
||||||
cullMode = VK_CULL_MODE_FRONT_BIT | VK_CULL_MODE_BACK_BIT;
|
cullMode = VK_CULL_MODE_FRONT_BIT | VK_CULL_MODE_BACK_BIT;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw exception("Invalid cull mode: 0x{:X}", static_cast<u32>(mode));
|
throw exception("Invalid cull mode: 0x{:X}", static_cast<u32>(mode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static vk::CompareOp ConvertCompareFunc(engine::CompareFunc func) {
|
static u8 ConvertCompareFunc(engine::CompareFunc func) {
|
||||||
if (func < engine::CompareFunc::D3DNever || func > engine::CompareFunc::OglAlways || (func > engine::CompareFunc::D3DAlways && func < engine::CompareFunc::OglNever))
|
if (func < engine::CompareFunc::D3DNever || func > engine::CompareFunc::OglAlways || (func > engine::CompareFunc::D3DAlways && func < engine::CompareFunc::OglNever))
|
||||||
throw exception("Invalid comparision function: 0x{:X}", static_cast<u32>(func));
|
throw exception("Invalid comparision function: 0x{:X}", static_cast<u32>(func));
|
||||||
|
|
||||||
u32 val{static_cast<u32>(func)};
|
u32 val{static_cast<u32>(func)};
|
||||||
|
|
||||||
// VK CompareOp values match 1:1 with Maxwell with some small maths
|
// VK CompareOp values match 1:1 with Maxwell with some small maths
|
||||||
return static_cast<vk::CompareOp>(func >= engine::CompareFunc::OglNever ? val - 0x200 : val - 1);
|
return static_cast<u8>(func >= engine::CompareFunc::OglNever ? val - 0x200 : val - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackedPipelineState::SetDepthFunc(engine::CompareFunc func) {
|
void PackedPipelineState::SetDepthFunc(engine::CompareFunc func) {
|
||||||
depthFunc = ConvertCompareFunc(func);
|
depthFunc = ConvertCompareFunc(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vk::CompareOp PackedPipelineState::GetDepthFunc() const {
|
||||||
|
return static_cast<vk::CompareOp>(depthFunc);
|
||||||
|
}
|
||||||
|
|
||||||
void PackedPipelineState::SetLogicOp(engine::LogicOp::Func op) {
|
void PackedPipelineState::SetLogicOp(engine::LogicOp::Func op) {
|
||||||
if (op < engine::LogicOp::Func::Clear || op > engine::LogicOp::Func::Set)
|
if (op < engine::LogicOp::Func::Clear || op > engine::LogicOp::Func::Set)
|
||||||
throw exception("Invalid logical operation: 0x{:X}", static_cast<u32>(op));
|
throw exception("Invalid logical operation: 0x{:X}", static_cast<u32>(op));
|
||||||
|
|
||||||
// VK LogicOp values match 1:1 with Maxwell
|
// VK LogicOp values match 1:1 with Maxwell
|
||||||
logicOp = static_cast<vk::LogicOp>(static_cast<u32>(op) - static_cast<u32>(engine::LogicOp::Func::Clear));
|
logicOp = static_cast<u8>(static_cast<u32>(op) - static_cast<u32>(engine::LogicOp::Func::Clear));
|
||||||
}
|
}
|
||||||
|
|
||||||
static vk::StencilOp ConvertStencilOp(engine::StencilOps::Op op) {
|
vk::LogicOp PackedPipelineState::GetLogicOp() const {
|
||||||
switch (op) {
|
return static_cast<vk::LogicOp>(logicOp);
|
||||||
case engine::StencilOps::Op::OglZero:
|
}
|
||||||
case engine::StencilOps::Op::D3DZero:
|
|
||||||
return vk::StencilOp::eZero;
|
static u8 ConvertStencilOp(engine::StencilOps::Op op) {
|
||||||
case engine::StencilOps::Op::D3DKeep:
|
auto conv{[&]() {
|
||||||
case engine::StencilOps::Op::OglKeep:
|
switch (op) {
|
||||||
return vk::StencilOp::eKeep;
|
case engine::StencilOps::Op::OglZero:
|
||||||
case engine::StencilOps::Op::D3DReplace:
|
case engine::StencilOps::Op::D3DZero:
|
||||||
case engine::StencilOps::Op::OglReplace:
|
return vk::StencilOp::eZero;
|
||||||
return vk::StencilOp::eReplace;
|
case engine::StencilOps::Op::D3DKeep:
|
||||||
case engine::StencilOps::Op::D3DIncrSat:
|
case engine::StencilOps::Op::OglKeep:
|
||||||
case engine::StencilOps::Op::OglIncrSat:
|
return vk::StencilOp::eKeep;
|
||||||
return vk::StencilOp::eIncrementAndClamp;
|
case engine::StencilOps::Op::D3DReplace:
|
||||||
case engine::StencilOps::Op::D3DDecrSat:
|
case engine::StencilOps::Op::OglReplace:
|
||||||
case engine::StencilOps::Op::OglDecrSat:
|
return vk::StencilOp::eReplace;
|
||||||
return vk::StencilOp::eDecrementAndClamp;
|
case engine::StencilOps::Op::D3DIncrSat:
|
||||||
case engine::StencilOps::Op::D3DInvert:
|
case engine::StencilOps::Op::OglIncrSat:
|
||||||
case engine::StencilOps::Op::OglInvert:
|
return vk::StencilOp::eIncrementAndClamp;
|
||||||
return vk::StencilOp::eInvert;
|
case engine::StencilOps::Op::D3DDecrSat:
|
||||||
case engine::StencilOps::Op::D3DIncr:
|
case engine::StencilOps::Op::OglDecrSat:
|
||||||
case engine::StencilOps::Op::OglIncr:
|
return vk::StencilOp::eDecrementAndClamp;
|
||||||
return vk::StencilOp::eIncrementAndWrap;
|
case engine::StencilOps::Op::D3DInvert:
|
||||||
case engine::StencilOps::Op::D3DDecr:
|
case engine::StencilOps::Op::OglInvert:
|
||||||
case engine::StencilOps::Op::OglDecr:
|
return vk::StencilOp::eInvert;
|
||||||
return vk::StencilOp::eDecrementAndWrap;
|
case engine::StencilOps::Op::D3DIncr:
|
||||||
default:
|
case engine::StencilOps::Op::OglIncr:
|
||||||
throw exception("Invalid stencil operation: 0x{:X}", static_cast<u32>(op));
|
return vk::StencilOp::eIncrementAndWrap;
|
||||||
}
|
case engine::StencilOps::Op::D3DDecr:
|
||||||
|
case engine::StencilOps::Op::OglDecr:
|
||||||
|
return vk::StencilOp::eDecrementAndWrap;
|
||||||
|
default:
|
||||||
|
throw exception("Invalid stencil operation: 0x{:X}", static_cast<u32>(op));
|
||||||
|
}
|
||||||
|
}};
|
||||||
|
|
||||||
|
return static_cast<u8>(conv());
|
||||||
}
|
}
|
||||||
|
|
||||||
static PackedPipelineState::StencilOps PackStencilOps(engine::StencilOps ops) {
|
static PackedPipelineState::StencilOps PackStencilOps(engine::StencilOps ops) {
|
||||||
@ -136,88 +158,96 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
(write.aEnable ? VK_COLOR_COMPONENT_A_BIT : 0);
|
(write.aEnable ? VK_COLOR_COMPONENT_A_BIT : 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
static vk::BlendOp ConvertBlendOp(engine::BlendOp op) {
|
static u8 ConvertBlendOp(engine::BlendOp op) {
|
||||||
switch (op) {
|
auto conv{[&]() {
|
||||||
case engine::BlendOp::D3DAdd:
|
switch (op) {
|
||||||
case engine::BlendOp::OglFuncAdd:
|
case engine::BlendOp::D3DAdd:
|
||||||
return vk::BlendOp::eAdd;
|
case engine::BlendOp::OglFuncAdd:
|
||||||
case engine::BlendOp::D3DSubtract:
|
return vk::BlendOp::eAdd;
|
||||||
case engine::BlendOp::OglFuncSubtract:
|
case engine::BlendOp::D3DSubtract:
|
||||||
return vk::BlendOp::eSubtract;
|
case engine::BlendOp::OglFuncSubtract:
|
||||||
case engine::BlendOp::D3DRevSubtract:
|
return vk::BlendOp::eSubtract;
|
||||||
case engine::BlendOp::OglFuncReverseSubtract:
|
case engine::BlendOp::D3DRevSubtract:
|
||||||
return vk::BlendOp::eReverseSubtract;
|
case engine::BlendOp::OglFuncReverseSubtract:
|
||||||
case engine::BlendOp::D3DMin:
|
return vk::BlendOp::eReverseSubtract;
|
||||||
case engine::BlendOp::OglMin:
|
case engine::BlendOp::D3DMin:
|
||||||
return vk::BlendOp::eMin;
|
case engine::BlendOp::OglMin:
|
||||||
case engine::BlendOp::D3DMax:
|
return vk::BlendOp::eMin;
|
||||||
case engine::BlendOp::OglMax:
|
case engine::BlendOp::D3DMax:
|
||||||
return vk::BlendOp::eMax;
|
case engine::BlendOp::OglMax:
|
||||||
default:
|
return vk::BlendOp::eMax;
|
||||||
throw exception("Invalid blend operation: 0x{:X}", static_cast<u32>(op));
|
default:
|
||||||
}
|
throw exception("Invalid blend operation: 0x{:X}", static_cast<u32>(op));
|
||||||
|
}
|
||||||
|
}};
|
||||||
|
|
||||||
|
return static_cast<u8>(conv());
|
||||||
}
|
}
|
||||||
|
|
||||||
static vk::BlendFactor ConvertBlendFactor(engine::BlendCoeff coeff) {
|
static u8 ConvertBlendFactor(engine::BlendCoeff coeff) {
|
||||||
switch (coeff) {
|
auto conv{[&]() {
|
||||||
case engine::BlendCoeff::OglZero:
|
switch (coeff) {
|
||||||
case engine::BlendCoeff::D3DZero:
|
case engine::BlendCoeff::OglZero:
|
||||||
return vk::BlendFactor::eZero;
|
case engine::BlendCoeff::D3DZero:
|
||||||
case engine::BlendCoeff::OglOne:
|
return vk::BlendFactor::eZero;
|
||||||
case engine::BlendCoeff::D3DOne:
|
case engine::BlendCoeff::OglOne:
|
||||||
return vk::BlendFactor::eOne;
|
case engine::BlendCoeff::D3DOne:
|
||||||
case engine::BlendCoeff::OglSrcColor:
|
return vk::BlendFactor::eOne;
|
||||||
case engine::BlendCoeff::D3DSrcColor:
|
case engine::BlendCoeff::OglSrcColor:
|
||||||
return vk::BlendFactor::eSrcColor;
|
case engine::BlendCoeff::D3DSrcColor:
|
||||||
case engine::BlendCoeff::OglOneMinusSrcColor:
|
return vk::BlendFactor::eSrcColor;
|
||||||
case engine::BlendCoeff::D3DInvSrcColor:
|
case engine::BlendCoeff::OglOneMinusSrcColor:
|
||||||
return vk::BlendFactor::eOneMinusSrcColor;
|
case engine::BlendCoeff::D3DInvSrcColor:
|
||||||
case engine::BlendCoeff::OglSrcAlpha:
|
return vk::BlendFactor::eOneMinusSrcColor;
|
||||||
case engine::BlendCoeff::D3DSrcAlpha:
|
case engine::BlendCoeff::OglSrcAlpha:
|
||||||
return vk::BlendFactor::eSrcAlpha;
|
case engine::BlendCoeff::D3DSrcAlpha:
|
||||||
case engine::BlendCoeff::OglOneMinusSrcAlpha:
|
return vk::BlendFactor::eSrcAlpha;
|
||||||
case engine::BlendCoeff::D3DInvSrcAlpha:
|
case engine::BlendCoeff::OglOneMinusSrcAlpha:
|
||||||
return vk::BlendFactor::eOneMinusSrcAlpha;
|
case engine::BlendCoeff::D3DInvSrcAlpha:
|
||||||
case engine::BlendCoeff::OglDstAlpha:
|
return vk::BlendFactor::eOneMinusSrcAlpha;
|
||||||
case engine::BlendCoeff::D3DDstAlpha:
|
case engine::BlendCoeff::OglDstAlpha:
|
||||||
return vk::BlendFactor::eDstAlpha;
|
case engine::BlendCoeff::D3DDstAlpha:
|
||||||
case engine::BlendCoeff::OglOneMinusDstAlpha:
|
return vk::BlendFactor::eDstAlpha;
|
||||||
case engine::BlendCoeff::D3DInvDstAlpha:
|
case engine::BlendCoeff::OglOneMinusDstAlpha:
|
||||||
return vk::BlendFactor::eOneMinusDstAlpha;
|
case engine::BlendCoeff::D3DInvDstAlpha:
|
||||||
case engine::BlendCoeff::OglDstColor:
|
return vk::BlendFactor::eOneMinusDstAlpha;
|
||||||
case engine::BlendCoeff::D3DDstColor:
|
case engine::BlendCoeff::OglDstColor:
|
||||||
return vk::BlendFactor::eDstColor;
|
case engine::BlendCoeff::D3DDstColor:
|
||||||
case engine::BlendCoeff::OglOneMinusDstColor:
|
return vk::BlendFactor::eDstColor;
|
||||||
case engine::BlendCoeff::D3DInvDstColor:
|
case engine::BlendCoeff::OglOneMinusDstColor:
|
||||||
return vk::BlendFactor::eOneMinusDstColor;
|
case engine::BlendCoeff::D3DInvDstColor:
|
||||||
case engine::BlendCoeff::OglSrcAlphaSaturate:
|
return vk::BlendFactor::eOneMinusDstColor;
|
||||||
case engine::BlendCoeff::D3DSrcAlphaSaturate:
|
case engine::BlendCoeff::OglSrcAlphaSaturate:
|
||||||
return vk::BlendFactor::eSrcAlphaSaturate;
|
case engine::BlendCoeff::D3DSrcAlphaSaturate:
|
||||||
case engine::BlendCoeff::OglConstantColor:
|
return vk::BlendFactor::eSrcAlphaSaturate;
|
||||||
case engine::BlendCoeff::D3DBlendCoeff:
|
case engine::BlendCoeff::OglConstantColor:
|
||||||
return vk::BlendFactor::eConstantColor;
|
case engine::BlendCoeff::D3DBlendCoeff:
|
||||||
case engine::BlendCoeff::OglOneMinusConstantColor:
|
return vk::BlendFactor::eConstantColor;
|
||||||
case engine::BlendCoeff::D3DInvBlendCoeff:
|
case engine::BlendCoeff::OglOneMinusConstantColor:
|
||||||
return vk::BlendFactor::eOneMinusConstantColor;
|
case engine::BlendCoeff::D3DInvBlendCoeff:
|
||||||
case engine::BlendCoeff::OglConstantAlpha:
|
return vk::BlendFactor::eOneMinusConstantColor;
|
||||||
return vk::BlendFactor::eConstantAlpha;
|
case engine::BlendCoeff::OglConstantAlpha:
|
||||||
case engine::BlendCoeff::OglOneMinusConstantAlpha:
|
return vk::BlendFactor::eConstantAlpha;
|
||||||
return vk::BlendFactor::eOneMinusConstantAlpha;
|
case engine::BlendCoeff::OglOneMinusConstantAlpha:
|
||||||
case engine::BlendCoeff::OglSrc1Color:
|
return vk::BlendFactor::eOneMinusConstantAlpha;
|
||||||
case engine::BlendCoeff::D3DSrc1Color:
|
case engine::BlendCoeff::OglSrc1Color:
|
||||||
return vk::BlendFactor::eSrc1Color;
|
case engine::BlendCoeff::D3DSrc1Color:
|
||||||
case engine::BlendCoeff::OglInvSrc1Color:
|
return vk::BlendFactor::eSrc1Color;
|
||||||
case engine::BlendCoeff::D3DInvSrc1Color:
|
case engine::BlendCoeff::OglInvSrc1Color:
|
||||||
return vk::BlendFactor::eOneMinusSrc1Color;
|
case engine::BlendCoeff::D3DInvSrc1Color:
|
||||||
case engine::BlendCoeff::OglSrc1Alpha:
|
return vk::BlendFactor::eOneMinusSrc1Color;
|
||||||
case engine::BlendCoeff::D3DSrc1Alpha:
|
case engine::BlendCoeff::OglSrc1Alpha:
|
||||||
return vk::BlendFactor::eSrc1Alpha;
|
case engine::BlendCoeff::D3DSrc1Alpha:
|
||||||
case engine::BlendCoeff::OglInvSrc1Alpha:
|
return vk::BlendFactor::eSrc1Alpha;
|
||||||
case engine::BlendCoeff::D3DInvSrc1Alpha:
|
case engine::BlendCoeff::OglInvSrc1Alpha:
|
||||||
return vk::BlendFactor::eOneMinusSrc1Alpha;
|
case engine::BlendCoeff::D3DInvSrc1Alpha:
|
||||||
default:
|
return vk::BlendFactor::eOneMinusSrc1Alpha;
|
||||||
throw exception("Invalid blend coefficient type: 0x{:X}", static_cast<u32>(coeff));
|
default:
|
||||||
}
|
throw exception("Invalid blend coefficient type: 0x{:X}", static_cast<u32>(coeff));
|
||||||
|
}
|
||||||
|
}};
|
||||||
|
|
||||||
|
return static_cast<u8>(conv());
|
||||||
}
|
}
|
||||||
|
|
||||||
static PackedPipelineState::AttachmentBlendState PackAttachmentBlendState(bool enable, engine::CtWrite writeMask, auto blend) {
|
static PackedPipelineState::AttachmentBlendState PackAttachmentBlendState(bool enable, engine::CtWrite writeMask, auto blend) {
|
||||||
@ -244,10 +274,10 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
std::array<vk::StencilOpState, 2> PackedPipelineState::GetStencilOpsState() const {
|
std::array<vk::StencilOpState, 2> PackedPipelineState::GetStencilOpsState() const {
|
||||||
auto convertFaceOps{[](StencilOps ops) {
|
auto convertFaceOps{[](StencilOps ops) {
|
||||||
return vk::StencilOpState{
|
return vk::StencilOpState{
|
||||||
.failOp = ops.fail,
|
.failOp = static_cast<vk::StencilOp>(ops.fail),
|
||||||
.passOp = ops.zPass,
|
.passOp = static_cast<vk::StencilOp>(ops.zPass),
|
||||||
.depthFailOp = ops.zFail,
|
.depthFailOp = static_cast<vk::StencilOp>(ops.zFail),
|
||||||
.compareOp = ops.func,
|
.compareOp = static_cast<vk::CompareOp>(ops.func),
|
||||||
};
|
};
|
||||||
}};
|
}};
|
||||||
|
|
||||||
@ -262,12 +292,12 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
.colorWriteMask = vk::ColorComponentFlags{state.colorWriteMask},
|
.colorWriteMask = vk::ColorComponentFlags{state.colorWriteMask},
|
||||||
.colorBlendOp = state.colorBlendOp,
|
.colorBlendOp = static_cast<vk::BlendOp>(state.colorBlendOp),
|
||||||
.srcColorBlendFactor = state.srcColorBlendFactor,
|
.srcColorBlendFactor = static_cast<vk::BlendFactor>(state.srcColorBlendFactor),
|
||||||
.dstColorBlendFactor = state.dstColorBlendFactor,
|
.dstColorBlendFactor = static_cast<vk::BlendFactor>(state.dstColorBlendFactor),
|
||||||
.alphaBlendOp = state.alphaBlendOp,
|
.alphaBlendOp = static_cast<vk::BlendOp>(state.alphaBlendOp),
|
||||||
.srcAlphaBlendFactor = state.srcAlphaBlendFactor,
|
.srcAlphaBlendFactor = static_cast<vk::BlendFactor>(state.srcAlphaBlendFactor),
|
||||||
.dstAlphaBlendFactor = state.dstAlphaBlendFactor,
|
.dstAlphaBlendFactor = static_cast<vk::BlendFactor>(state.dstAlphaBlendFactor),
|
||||||
.blendEnable = state.blendEnable
|
.blendEnable = state.blendEnable
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,10 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
std::array<u64, engine::PipelineCount> shaderHashes;
|
std::array<u64, engine::PipelineCount> shaderHashes;
|
||||||
|
|
||||||
struct StencilOps {
|
struct StencilOps {
|
||||||
vk::StencilOp zPass : 3;
|
u8 zPass : 3;
|
||||||
vk::StencilOp fail : 3;
|
u8 fail : 3;
|
||||||
vk::StencilOp zFail : 3;
|
u8 zFail : 3;
|
||||||
vk::CompareOp func : 3;
|
u8 func : 3;
|
||||||
// 4 bits left for each stencil side
|
// 4 bits left for each stencil side
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
engine::TessellationParameters::Spacing spacing : 2; //!< Use SetTessellationParameters
|
engine::TessellationParameters::Spacing spacing : 2; //!< Use SetTessellationParameters
|
||||||
engine::TessellationParameters::OutputPrimitives outputPrimitives : 2; //!< Use SetTessellationParameters
|
engine::TessellationParameters::OutputPrimitives outputPrimitives : 2; //!< Use SetTessellationParameters
|
||||||
bool rasterizerDiscardEnable : 1;
|
bool rasterizerDiscardEnable : 1;
|
||||||
vk::PolygonMode polygonMode : 2; //!< Use SetPolygonMode
|
u8 polygonMode : 2; //!< Use {Set,Get}PolygonMode
|
||||||
VkCullModeFlags cullMode : 2; //!< Use SetCullMode
|
VkCullModeFlags cullMode : 2; //!< Use SetCullMode
|
||||||
bool flipYEnable : 1;
|
bool flipYEnable : 1;
|
||||||
bool frontFaceClockwise : 1; //!< With Y flip transformation already applied
|
bool frontFaceClockwise : 1; //!< With Y flip transformation already applied
|
||||||
@ -45,11 +45,11 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
engine::ProvokingVertex::Value provokingVertex : 1;
|
engine::ProvokingVertex::Value provokingVertex : 1;
|
||||||
bool depthTestEnable : 1;
|
bool depthTestEnable : 1;
|
||||||
bool depthWriteEnable : 1;
|
bool depthWriteEnable : 1;
|
||||||
vk::CompareOp depthFunc : 3; //!< Use SetDepthFunc
|
u8 depthFunc : 3; //!< Use {Set,Get}DepthFunc
|
||||||
bool depthBoundsTestEnable : 1;
|
bool depthBoundsTestEnable : 1;
|
||||||
bool stencilTestEnable : 1;
|
bool stencilTestEnable : 1;
|
||||||
bool logicOpEnable : 1;
|
bool logicOpEnable : 1;
|
||||||
vk::LogicOp logicOp : 4; //!< Use SetLogicOp
|
u8 logicOp : 4; //!< Use {Set,Get}LogicOp
|
||||||
u8 bindlessTextureConstantBufferSlotSelect : 5;
|
u8 bindlessTextureConstantBufferSlotSelect : 5;
|
||||||
bool apiMandatedEarlyZ : 1;
|
bool apiMandatedEarlyZ : 1;
|
||||||
bool openGlNdc : 1;
|
bool openGlNdc : 1;
|
||||||
@ -63,22 +63,26 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
|
|
||||||
struct VertexBinding {
|
struct VertexBinding {
|
||||||
u16 stride : 12;
|
u16 stride : 12;
|
||||||
vk::VertexInputRate inputRate : 1;
|
u8 inputRate : 1;
|
||||||
bool enable : 1;
|
bool enable : 1;
|
||||||
u8 _pad_ : 2;
|
u8 _pad_ : 2;
|
||||||
u32 divisor;
|
u32 divisor;
|
||||||
|
|
||||||
|
vk::VertexInputRate GetInputRate() const {
|
||||||
|
return static_cast<vk::VertexInputRate>(inputRate);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::array<VertexBinding, engine::VertexStreamCount> vertexBindings; //!< Use {Set, Get}VertexBinding
|
std::array<VertexBinding, engine::VertexStreamCount> vertexBindings; //!< Use {Set, Get}VertexBinding
|
||||||
|
|
||||||
struct AttachmentBlendState {
|
struct AttachmentBlendState {
|
||||||
VkColorComponentFlags colorWriteMask : 4;
|
VkColorComponentFlags colorWriteMask : 4;
|
||||||
vk::BlendOp colorBlendOp : 3;
|
u8 colorBlendOp : 3;
|
||||||
vk::BlendFactor srcColorBlendFactor : 5;
|
u8 srcColorBlendFactor : 5;
|
||||||
vk::BlendFactor dstColorBlendFactor : 5;
|
u8 dstColorBlendFactor : 5;
|
||||||
vk::BlendOp alphaBlendOp : 3;
|
u8 alphaBlendOp : 3;
|
||||||
vk::BlendFactor srcAlphaBlendFactor : 5;
|
u8 srcAlphaBlendFactor : 5;
|
||||||
vk::BlendFactor dstAlphaBlendFactor : 5;
|
u8 dstAlphaBlendFactor : 5;
|
||||||
bool blendEnable : 1;
|
bool blendEnable : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -94,14 +98,20 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
|
|
||||||
void SetPolygonMode(engine::PolygonMode mode);
|
void SetPolygonMode(engine::PolygonMode mode);
|
||||||
|
|
||||||
|
vk::PolygonMode GetPolygonMode() const;
|
||||||
|
|
||||||
void SetCullMode(bool enable, engine::CullFace mode);
|
void SetCullMode(bool enable, engine::CullFace mode);
|
||||||
|
|
||||||
void SetDepthFunc(engine::CompareFunc func);
|
void SetDepthFunc(engine::CompareFunc func);
|
||||||
|
|
||||||
|
vk::CompareOp GetDepthFunc() const;
|
||||||
|
|
||||||
void SetStencilOps(engine::StencilOps front, engine::StencilOps back);
|
void SetStencilOps(engine::StencilOps front, engine::StencilOps back);
|
||||||
|
|
||||||
void SetLogicOp(engine::LogicOp::Func op);
|
void SetLogicOp(engine::LogicOp::Func op);
|
||||||
|
|
||||||
|
vk::LogicOp GetLogicOp() const;
|
||||||
|
|
||||||
void SetAttachmentBlendState(u32 index, bool enable, engine::CtWrite writeMask, engine::Blend blend);
|
void SetAttachmentBlendState(u32 index, bool enable, engine::CtWrite writeMask, engine::Blend blend);
|
||||||
|
|
||||||
void SetAttachmentBlendState(u32 index, bool enable, engine::CtWrite writeMask, engine::BlendPerTarget blend);
|
void SetAttachmentBlendState(u32 index, bool enable, engine::CtWrite writeMask, engine::BlendPerTarget blend);
|
||||||
|
@ -374,7 +374,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
.inputRate = binding.divisor ? vk::VertexInputRate::eInstance : vk::VertexInputRate::eVertex,
|
.inputRate = binding.divisor ? vk::VertexInputRate::eInstance : vk::VertexInputRate::eVertex,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (binding.inputRate == vk::VertexInputRate::eInstance) {
|
if (binding.GetInputRate() == vk::VertexInputRate::eInstance) {
|
||||||
if (!ctx.gpu.traits.supportsVertexAttributeDivisor) [[unlikely]]
|
if (!ctx.gpu.traits.supportsVertexAttributeDivisor) [[unlikely]]
|
||||||
Logger::Warn("Vertex attribute divisor used on guest without host support");
|
Logger::Warn("Vertex attribute divisor used on guest without host support");
|
||||||
else if (!ctx.gpu.traits.supportsVertexAttributeZeroDivisor && binding.divisor == 0) [[unlikely]]
|
else if (!ctx.gpu.traits.supportsVertexAttributeZeroDivisor && binding.divisor == 0) [[unlikely]]
|
||||||
@ -427,7 +427,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
|
|
||||||
auto &rasterizationCreateInfo{rasterizationState.get<vk::PipelineRasterizationStateCreateInfo>()};
|
auto &rasterizationCreateInfo{rasterizationState.get<vk::PipelineRasterizationStateCreateInfo>()};
|
||||||
rasterizationCreateInfo.rasterizerDiscardEnable = packedState.rasterizerDiscardEnable;
|
rasterizationCreateInfo.rasterizerDiscardEnable = packedState.rasterizerDiscardEnable;
|
||||||
rasterizationCreateInfo.polygonMode = packedState.polygonMode;
|
rasterizationCreateInfo.polygonMode = packedState.GetPolygonMode();
|
||||||
rasterizationCreateInfo.cullMode = vk::CullModeFlags{packedState.cullMode};
|
rasterizationCreateInfo.cullMode = vk::CullModeFlags{packedState.cullMode};
|
||||||
rasterizationCreateInfo.frontFace = packedState.frontFaceClockwise ? vk::FrontFace::eClockwise : vk::FrontFace::eCounterClockwise;
|
rasterizationCreateInfo.frontFace = packedState.frontFaceClockwise ? vk::FrontFace::eClockwise : vk::FrontFace::eCounterClockwise;
|
||||||
rasterizationCreateInfo.depthBiasEnable = packedState.depthBiasEnable;
|
rasterizationCreateInfo.depthBiasEnable = packedState.depthBiasEnable;
|
||||||
@ -440,7 +440,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
vk::PipelineDepthStencilStateCreateInfo depthStencilState{
|
vk::PipelineDepthStencilStateCreateInfo depthStencilState{
|
||||||
.depthTestEnable = packedState.depthTestEnable,
|
.depthTestEnable = packedState.depthTestEnable,
|
||||||
.depthWriteEnable = packedState.depthWriteEnable,
|
.depthWriteEnable = packedState.depthWriteEnable,
|
||||||
.depthCompareOp = packedState.depthFunc,
|
.depthCompareOp = packedState.GetDepthFunc(),
|
||||||
.depthBoundsTestEnable = packedState.depthBoundsTestEnable,
|
.depthBoundsTestEnable = packedState.depthBoundsTestEnable,
|
||||||
.stencilTestEnable = packedState.stencilTestEnable
|
.stencilTestEnable = packedState.stencilTestEnable
|
||||||
};
|
};
|
||||||
@ -453,7 +453,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
|
|
||||||
vk::PipelineColorBlendStateCreateInfo colorBlendState{
|
vk::PipelineColorBlendStateCreateInfo colorBlendState{
|
||||||
.logicOpEnable = packedState.logicOpEnable,
|
.logicOpEnable = packedState.logicOpEnable,
|
||||||
.logicOp = packedState.logicOp,
|
.logicOp = packedState.GetLogicOp(),
|
||||||
.attachmentCount = static_cast<u32>(attachmentBlendStates.size()),
|
.attachmentCount = static_cast<u32>(attachmentBlendStates.size()),
|
||||||
.pAttachments = attachmentBlendStates.data()
|
.pAttachments = attachmentBlendStates.data()
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user