mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-23 05:19:18 +01:00
Commonise maxwell3d state updater
This commit is contained in:
parent
a0b81d54d6
commit
86dab65af4
@ -6,7 +6,7 @@
|
|||||||
#include <gpu/interconnect/command_executor.h>
|
#include <gpu/interconnect/command_executor.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
namespace skyline::gpu::interconnect::maxwell3d {
|
namespace skyline::gpu::interconnect {
|
||||||
/**
|
/**
|
||||||
* @brief Header for a singly-linked state update command
|
* @brief Header for a singly-linked state update command
|
||||||
*/
|
*/
|
||||||
@ -35,17 +35,30 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static constexpr size_t MaxVertexBufferCount{16};
|
||||||
|
|
||||||
struct SetVertexBuffersCmdImpl {
|
struct SetVertexBuffersCmdImpl {
|
||||||
void Record(GPU &gpu, vk::raii::CommandBuffer &commandBuffer) {
|
void Record(GPU &gpu, vk::raii::CommandBuffer &commandBuffer) {
|
||||||
|
if (ext) {
|
||||||
|
commandBuffer.bindVertexBuffers2EXT(firstBinding,
|
||||||
|
span(buffers).subspan(firstBinding, bindingCount),
|
||||||
|
span(offsets).subspan(firstBinding, bindingCount),
|
||||||
|
span(sizes).subspan(firstBinding, bindingCount),
|
||||||
|
span(strides).subspan(firstBinding, bindingCount));
|
||||||
|
} else {
|
||||||
commandBuffer.bindVertexBuffers(firstBinding,
|
commandBuffer.bindVertexBuffers(firstBinding,
|
||||||
span(buffers).subspan(firstBinding, bindingCount),
|
span(buffers).subspan(firstBinding, bindingCount),
|
||||||
span(offsets).subspan(firstBinding, bindingCount));
|
span(offsets).subspan(firstBinding, bindingCount));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ext{};
|
||||||
u32 firstBinding{};
|
u32 firstBinding{};
|
||||||
u32 bindingCount{};
|
u32 bindingCount{};
|
||||||
std::array<vk::Buffer, engine::VertexStreamCount> buffers;
|
std::array<vk::Buffer, MaxVertexBufferCount> buffers;
|
||||||
std::array<vk::DeviceSize, engine::VertexStreamCount> offsets;
|
std::array<vk::DeviceSize, MaxVertexBufferCount> offsets;
|
||||||
|
std::array<vk::DeviceSize, MaxVertexBufferCount> strides;
|
||||||
|
std::array<vk::DeviceSize, MaxVertexBufferCount> sizes;
|
||||||
};
|
};
|
||||||
using SetVertexBuffersCmd = CmdHolder<SetVertexBuffersCmdImpl>;
|
using SetVertexBuffersCmd = CmdHolder<SetVertexBuffersCmdImpl>;
|
||||||
|
|
||||||
@ -54,13 +67,14 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
for (u32 i{base.firstBinding}; i < base.firstBinding + base.bindingCount; i++) {
|
for (u32 i{base.firstBinding}; i < base.firstBinding + base.bindingCount; i++) {
|
||||||
base.buffers[i] = views[i].GetBuffer()->GetBacking();
|
base.buffers[i] = views[i].GetBuffer()->GetBacking();
|
||||||
base.offsets[i] = views[i].GetOffset();
|
base.offsets[i] = views[i].GetOffset();
|
||||||
|
base.sizes[i] = views[i].size;
|
||||||
}
|
}
|
||||||
|
|
||||||
base.Record(gpu, commandBuffer);
|
base.Record(gpu, commandBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetVertexBuffersCmdImpl base{};
|
SetVertexBuffersCmdImpl base{};
|
||||||
std::array<BufferView, engine::VertexStreamCount> views;
|
std::array<BufferView, MaxVertexBufferCount> views;
|
||||||
};
|
};
|
||||||
using SetVertexBuffersDynamicCmd = CmdHolder<SetVertexBuffersDynamicCmdImpl>;
|
using SetVertexBuffersDynamicCmd = CmdHolder<SetVertexBuffersDynamicCmdImpl>;
|
||||||
|
|
||||||
@ -239,10 +253,11 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
|
|
||||||
struct SetPipelineCmdImpl {
|
struct SetPipelineCmdImpl {
|
||||||
void Record(GPU &gpu, vk::raii::CommandBuffer &commandBuffer) {
|
void Record(GPU &gpu, vk::raii::CommandBuffer &commandBuffer) {
|
||||||
commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, pipeline);
|
commandBuffer.bindPipeline(bindPoint, pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
vk::Pipeline pipeline;
|
vk::Pipeline pipeline;
|
||||||
|
vk::PipelineBindPoint bindPoint;
|
||||||
};
|
};
|
||||||
using SetPipelineCmd = CmdHolder<SetPipelineCmdImpl>;
|
using SetPipelineCmd = CmdHolder<SetPipelineCmdImpl>;
|
||||||
|
|
||||||
@ -309,10 +324,11 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
return {head};
|
return {head};
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetVertexBuffer(u32 index, const BufferBinding &binding) {
|
void SetVertexBuffer(u32 index, const BufferBinding &binding, bool ext = false, vk::DeviceSize stride = 0) {
|
||||||
if (index != vertexBatchBindNextBinding || vertexBatchBind->header.record != &SetVertexBuffersCmd::Record) {
|
if (index != vertexBatchBindNextBinding || vertexBatchBind->header.record != &SetVertexBuffersCmd::Record || vertexBatchBind->cmd.base.ext != ext) {
|
||||||
FlushVertexBatchBind();
|
FlushVertexBatchBind();
|
||||||
vertexBatchBind->header.record = &SetVertexBuffersCmd::Record;
|
vertexBatchBind->header.record = &SetVertexBuffersCmd::Record;
|
||||||
|
vertexBatchBind->cmd.base.ext = ext;
|
||||||
vertexBatchBind->cmd.base.firstBinding = index;
|
vertexBatchBind->cmd.base.firstBinding = index;
|
||||||
vertexBatchBindNextBinding = index;
|
vertexBatchBindNextBinding = index;
|
||||||
}
|
}
|
||||||
@ -320,21 +336,25 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
u32 bindingIdx{vertexBatchBindNextBinding++};
|
u32 bindingIdx{vertexBatchBindNextBinding++};
|
||||||
vertexBatchBind->cmd.base.buffers[bindingIdx] = binding.buffer;
|
vertexBatchBind->cmd.base.buffers[bindingIdx] = binding.buffer;
|
||||||
vertexBatchBind->cmd.base.offsets[bindingIdx] = binding.offset;
|
vertexBatchBind->cmd.base.offsets[bindingIdx] = binding.offset;
|
||||||
|
vertexBatchBind->cmd.base.sizes[bindingIdx] = binding.size;
|
||||||
|
vertexBatchBind->cmd.base.strides[bindingIdx] = stride;
|
||||||
vertexBatchBind->cmd.base.bindingCount++;
|
vertexBatchBind->cmd.base.bindingCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetVertexBuffer(u32 index, BufferView view) {
|
void SetVertexBuffer(u32 index, BufferView view, bool ext = false, vk::DeviceSize stride = 0) {
|
||||||
view.GetBuffer()->BlockSequencedCpuBackingWrites();
|
view.GetBuffer()->BlockSequencedCpuBackingWrites();
|
||||||
|
|
||||||
if (index != vertexBatchBindNextBinding || vertexBatchBind->header.record != &SetVertexBuffersDynamicCmd::Record) {
|
if (index != vertexBatchBindNextBinding || vertexBatchBind->header.record != &SetVertexBuffersDynamicCmd::Record || vertexBatchBind->cmd.base.ext != ext) {
|
||||||
FlushVertexBatchBind();
|
FlushVertexBatchBind();
|
||||||
vertexBatchBind->header.record = &SetVertexBuffersDynamicCmd::Record;
|
vertexBatchBind->header.record = &SetVertexBuffersDynamicCmd::Record;
|
||||||
|
vertexBatchBind->cmd.base.ext = ext;
|
||||||
vertexBatchBind->cmd.base.firstBinding = index;
|
vertexBatchBind->cmd.base.firstBinding = index;
|
||||||
vertexBatchBindNextBinding = index;
|
vertexBatchBindNextBinding = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 bindingIdx{vertexBatchBindNextBinding++};
|
u32 bindingIdx{vertexBatchBindNextBinding++};
|
||||||
vertexBatchBind->cmd.views[bindingIdx] = view;
|
vertexBatchBind->cmd.views[bindingIdx] = view;
|
||||||
|
vertexBatchBind->cmd.base.strides[bindingIdx] = stride;
|
||||||
vertexBatchBind->cmd.base.bindingCount++;
|
vertexBatchBind->cmd.base.bindingCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,7 +429,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetBlendConstants(const std::array<float, engine::BlendColorChannelCount> &blendConstants) {
|
void SetBlendConstants(const std::array<float, 4> &blendConstants) {
|
||||||
AppendCmd<SetBlendConstantsCmd>(
|
AppendCmd<SetBlendConstantsCmd>(
|
||||||
{
|
{
|
||||||
.blendConstants = blendConstants,
|
.blendConstants = blendConstants,
|
||||||
@ -443,10 +463,11 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetPipeline(vk::Pipeline pipeline) {
|
void SetPipeline(vk::Pipeline pipeline, vk::PipelineBindPoint bindPoint) {
|
||||||
AppendCmd<SetPipelineCmd>(
|
AppendCmd<SetPipelineCmd>(
|
||||||
{
|
{
|
||||||
.pipeline = pipeline,
|
.pipeline = pipeline,
|
||||||
|
.bindPoint = bindPoint,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -9,8 +9,8 @@
|
|||||||
#include <gpu/buffer_manager.h>
|
#include <gpu/buffer_manager.h>
|
||||||
#include <gpu/interconnect/command_executor.h>
|
#include <gpu/interconnect/command_executor.h>
|
||||||
#include <gpu/interconnect/conversion/quads.h>
|
#include <gpu/interconnect/conversion/quads.h>
|
||||||
|
#include <gpu/interconnect/common/state_updater.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "state_updater.h"
|
|
||||||
#include "active_state.h"
|
#include "active_state.h"
|
||||||
|
|
||||||
namespace skyline::gpu::interconnect::maxwell3d {
|
namespace skyline::gpu::interconnect::maxwell3d {
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
#include <gpu/interconnect/command_executor.h>
|
#include <gpu/interconnect/command_executor.h>
|
||||||
#include <gpu/interconnect/conversion/quads.h>
|
#include <gpu/interconnect/conversion/quads.h>
|
||||||
|
#include <gpu/interconnect/common/state_updater.h>
|
||||||
#include <soc/gm20b/channel.h>
|
#include <soc/gm20b/channel.h>
|
||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
#include "maxwell_3d.h"
|
#include "maxwell_3d.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "state_updater.h"
|
|
||||||
|
|
||||||
namespace skyline::gpu::interconnect::maxwell3d {
|
namespace skyline::gpu::interconnect::maxwell3d {
|
||||||
Maxwell3D::Maxwell3D(GPU &gpu,
|
Maxwell3D::Maxwell3D(GPU &gpu,
|
||||||
|
Loading…
Reference in New Issue
Block a user