Always populate all colour attachments

This better follow the Vulkan spec, which doesn't mention anything about writes to OOB attachments, only those marked as unused.
This commit is contained in:
Billy Laws 2022-12-27 19:08:40 +00:00
parent 3571737392
commit afef6c5123
3 changed files with 19 additions and 27 deletions

View File

@ -530,10 +530,14 @@ namespace skyline::gpu::interconnect::maxwell3d {
boost::container::static_vector<vk::PipelineColorBlendAttachmentState, engine::ColorTargetCount> attachmentBlendStates; boost::container::static_vector<vk::PipelineColorBlendAttachmentState, engine::ColorTargetCount> attachmentBlendStates;
boost::container::static_vector<vk::Format, engine::ColorTargetCount> colorAttachmentFormats; boost::container::static_vector<vk::Format, engine::ColorTargetCount> colorAttachmentFormats;
for (u32 i{}; i < packedState.GetColorRenderTargetCount(); i++) { for (u32 i{}; i < engine::ColorTargetCount; i++) {
if (i < packedState.GetColorRenderTargetCount()) {
attachmentBlendStates.push_back(packedState.GetAttachmentBlendState(i)); attachmentBlendStates.push_back(packedState.GetAttachmentBlendState(i));
texture::Format format{packedState.GetColorRenderTargetFormat(packedState.ctSelect[i])}; texture::Format format{packedState.GetColorRenderTargetFormat(packedState.ctSelect[i])};
colorAttachmentFormats.push_back(format ? format->vkFormat : vk::Format::eUndefined); colorAttachmentFormats.push_back(format ? format->vkFormat : vk::Format::eUndefined);
} else {
colorAttachmentFormats.push_back(vk::Format::eUndefined);
}
} }
vk::PipelineColorBlendStateCreateInfo colorBlendState{ vk::PipelineColorBlendStateCreateInfo colorBlendState{

View File

@ -300,19 +300,14 @@ namespace skyline::gpu::interconnect::maxwell3d {
packedState.SetLogicOp(engine->logicOp.func); packedState.SetLogicOp(engine->logicOp.func);
for (u32 i{}; i < engine::ColorTargetCount; i++) { for (u32 i{}; i < engine::ColorTargetCount; i++) {
bool rtEnabled{packedState.IsColorRenderTargetEnabled(packedState.ctSelect[i])};
enabledRts.set(i, rtEnabled);
auto ctWrite{[&]() { auto ctWrite{[&]() {
if (!rtEnabled)
return engine::CtWrite{};
if (engine->singleCtWriteControl) if (engine->singleCtWriteControl)
return engine->ctWrites[0]; return engine->ctWrites[0];
else else
return engine->ctWrites[i]; return engine->ctWrites[i];
}()}; }()};
bool enable{engine->blend.enable[i] != 0 && rtEnabled}; bool enable{engine->blend.enable[i] != 0};
if (engine->blendStatePerTargetEnable) if (engine->blendStatePerTargetEnable)
packedState.SetAttachmentBlendState(i, enable, ctWrite, engine->blendPerTargets[i]); packedState.SetAttachmentBlendState(i, enable, ctWrite, engine->blendPerTargets[i]);
@ -321,14 +316,6 @@ namespace skyline::gpu::interconnect::maxwell3d {
} }
} }
bool ColorBlendState::Refresh(PackedPipelineState &packedState) {
for (u32 i{}; i < engine::ColorTargetCount; i++)
if (enabledRts.test(i) != packedState.IsColorRenderTargetEnabled(packedState.ctSelect[i]))
return true;
return false;
}
/* Transform Feedback State */ /* Transform Feedback State */
void TransformFeedbackState::EngineRegisters::DirtyBind(DirtyManager &manager, dirty::Handle handle) const { void TransformFeedbackState::EngineRegisters::DirtyBind(DirtyManager &manager, dirty::Handle handle) const {
manager.Bind(handle, streamOutputEnable, streamOutControls, streamOutLayoutSelect); manager.Bind(handle, streamOutputEnable, streamOutControls, streamOutLayoutSelect);
@ -404,12 +391,16 @@ namespace skyline::gpu::interconnect::maxwell3d {
} }
colorAttachments.clear(); colorAttachments.clear();
for (size_t i{}; i < ctSelect.count; i++) { for (size_t i{}; i < engine::ColorTargetCount; i++) {
if (i < ctSelect.count) {
const auto &view{colorRenderTargets[ctSelect[i]].UpdateGet(ctx, packedState).view.get()}; const auto &view{colorRenderTargets[ctSelect[i]].UpdateGet(ctx, packedState).view.get()};
colorAttachments.push_back(view); colorAttachments.push_back(view);
if (view) if (view)
ctx.executor.AttachTexture(view); ctx.executor.AttachTexture(view);
} else {
colorAttachments.push_back({});
}
} }
depthAttachment = depthRenderTarget.UpdateGet(ctx, packedState).view.get(); depthAttachment = depthRenderTarget.UpdateGet(ctx, packedState).view.get();

View File

@ -212,7 +212,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
void Flush(PackedPipelineState &packedState); void Flush(PackedPipelineState &packedState);
}; };
class ColorBlendState : dirty::RefreshableManualDirty { class ColorBlendState : dirty::ManualDirty {
public: public:
struct EngineRegisters { struct EngineRegisters {
const engine::LogicOp &logicOp; const engine::LogicOp &logicOp;
@ -227,14 +227,11 @@ namespace skyline::gpu::interconnect::maxwell3d {
private: private:
dirty::BoundSubresource<EngineRegisters> engine; dirty::BoundSubresource<EngineRegisters> engine;
std::bitset<engine::ColorTargetCount> enabledRts{};
public: public:
ColorBlendState(dirty::Handle dirtyHandle, DirtyManager &manager, const EngineRegisters &engine); ColorBlendState(dirty::Handle dirtyHandle, DirtyManager &manager, const EngineRegisters &engine);
void Flush(PackedPipelineState &packedState); void Flush(PackedPipelineState &packedState);
bool Refresh(PackedPipelineState &packedState);
}; };
class TransformFeedbackState : dirty::ManualDirty { class TransformFeedbackState : dirty::ManualDirty {