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::Format, engine::ColorTargetCount> colorAttachmentFormats;
for (u32 i{}; i < packedState.GetColorRenderTargetCount(); i++) {
attachmentBlendStates.push_back(packedState.GetAttachmentBlendState(i));
texture::Format format{packedState.GetColorRenderTargetFormat(packedState.ctSelect[i])};
colorAttachmentFormats.push_back(format ? format->vkFormat : vk::Format::eUndefined);
for (u32 i{}; i < engine::ColorTargetCount; i++) {
if (i < packedState.GetColorRenderTargetCount()) {
attachmentBlendStates.push_back(packedState.GetAttachmentBlendState(i));
texture::Format format{packedState.GetColorRenderTargetFormat(packedState.ctSelect[i])};
colorAttachmentFormats.push_back(format ? format->vkFormat : vk::Format::eUndefined);
} else {
colorAttachmentFormats.push_back(vk::Format::eUndefined);
}
}
vk::PipelineColorBlendStateCreateInfo colorBlendState{

View File

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

View File

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