mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-05 16:25:10 +01:00
Implement non-indexed quad conversion support in new GPU
Uses memory::Buffer directly to allow for cleaner recreation and allow for removing host-only buffers from Buffer in the future.
This commit is contained in:
parent
d42814bdc1
commit
01a5e95ce1
@ -3,6 +3,7 @@
|
|||||||
// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
||||||
|
|
||||||
#include <gpu/interconnect/command_executor.h>
|
#include <gpu/interconnect/command_executor.h>
|
||||||
|
#include <gpu/interconnect/conversion/quads.h>
|
||||||
#include <vulkan/vulkan_structs.hpp>
|
#include <vulkan/vulkan_structs.hpp>
|
||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
#include "maxwell_3d.h"
|
#include "maxwell_3d.h"
|
||||||
@ -27,6 +28,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
activeState.MarkAllDirty();
|
activeState.MarkAllDirty();
|
||||||
constantBuffers.MarkAllDirty();
|
constantBuffers.MarkAllDirty();
|
||||||
samplers.MarkAllDirty();
|
samplers.MarkAllDirty();
|
||||||
|
quadConversionBufferAttached = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
executor.AddPipelineChangeCallback([this] {
|
executor.AddPipelineChangeCallback([this] {
|
||||||
@ -34,6 +36,24 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vk::DeviceSize Maxwell3D::UpdateQuadConversionBuffer(u32 count, u32 firstVertex) {
|
||||||
|
vk::DeviceSize offset{conversion::quads::GetRequiredBufferSize(firstVertex, sizeof(u32))};
|
||||||
|
vk::DeviceSize size{conversion::quads::GetRequiredBufferSize(count, sizeof(u32)) + offset};
|
||||||
|
|
||||||
|
if (!quadConversionBuffer || quadConversionBuffer->size_bytes() < size) {
|
||||||
|
quadConversionBuffer = std::make_shared<memory::Buffer>(ctx.gpu.memory.AllocateBuffer(util::AlignUp(size, PAGE_SIZE)));
|
||||||
|
conversion::quads::GenerateQuadListConversionBuffer(quadConversionBuffer->cast<u32>().data(), firstVertex + count);
|
||||||
|
quadConversionBufferAttached = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!quadConversionBufferAttached) {
|
||||||
|
ctx.executor.AttachDependency(quadConversionBuffer);
|
||||||
|
quadConversionBufferAttached = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
vk::Rect2D Maxwell3D::GetClearScissor() {
|
vk::Rect2D Maxwell3D::GetClearScissor() {
|
||||||
const auto &clearSurfaceControl{clearEngineRegisters.clearSurfaceControl};
|
const auto &clearSurfaceControl{clearEngineRegisters.clearSurfaceControl};
|
||||||
|
|
||||||
@ -173,6 +193,18 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
|
|
||||||
Pipeline *oldPipeline{activeState.GetPipeline()};
|
Pipeline *oldPipeline{activeState.GetPipeline()};
|
||||||
activeState.Update(ctx, builder, indexed, topology, count);
|
activeState.Update(ctx, builder, indexed, topology, count);
|
||||||
|
if (directState.inputAssembly.NeedsQuadConversion()) {
|
||||||
|
count = conversion::quads::GetIndexCount(count);
|
||||||
|
first = 0;
|
||||||
|
|
||||||
|
if (!indexed) {
|
||||||
|
// Use an index buffer to emulate quad lists with a triangle list input topology
|
||||||
|
vk::DeviceSize offset{UpdateQuadConversionBuffer(count, first)};
|
||||||
|
builder.SetIndexBuffer(BufferBinding{quadConversionBuffer->vkBuffer, offset}, vk::IndexType::eUint32);
|
||||||
|
indexed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Pipeline *pipeline{activeState.GetPipeline()};
|
Pipeline *pipeline{activeState.GetPipeline()};
|
||||||
|
|
||||||
auto *descUpdateInfo{[&]() -> DescriptorUpdateInfo * {
|
auto *descUpdateInfo{[&]() -> DescriptorUpdateInfo * {
|
||||||
|
@ -42,9 +42,13 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
ClearEngineRegisters clearEngineRegisters;
|
ClearEngineRegisters clearEngineRegisters;
|
||||||
ConstantBuffers constantBuffers;
|
ConstantBuffers constantBuffers;
|
||||||
Samplers samplers;
|
Samplers samplers;
|
||||||
|
std::shared_ptr<memory::Buffer> quadConversionBuffer{};
|
||||||
|
bool quadConversionBufferAttached{};
|
||||||
|
|
||||||
DescriptorAllocator::ActiveDescriptorSet *activeDescriptorSet{};
|
DescriptorAllocator::ActiveDescriptorSet *activeDescriptorSet{};
|
||||||
|
|
||||||
|
size_t UpdateQuadConversionBuffer(u32 count, u32 firstVertex);
|
||||||
|
|
||||||
vk::Rect2D GetClearScissor();
|
vk::Rect2D GetClearScissor();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user