mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-04-10 05:28:56 +02:00
fixup dynarmic, and dont forget push constants
This commit is contained in:
parent
2f0192665e
commit
f289b2b161
3 changed files with 26 additions and 28 deletions
|
|
@ -69,7 +69,7 @@ namespace {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PushConstants {
|
struct BlitPushConstants {
|
||||||
std::array<float, 2> tex_scale;
|
std::array<float, 2> tex_scale;
|
||||||
std::array<float, 2> tex_offset;
|
std::array<float, 2> tex_offset;
|
||||||
};
|
};
|
||||||
|
|
@ -394,13 +394,13 @@ void BindBlitState(vk::CommandBuffer cmdbuf, VkPipelineLayout layout, const Regi
|
||||||
static_cast<float>(src_size.width);
|
static_cast<float>(src_size.width);
|
||||||
const float scale_y = static_cast<float>(src_region.end.y - src_region.start.y) /
|
const float scale_y = static_cast<float>(src_region.end.y - src_region.start.y) /
|
||||||
static_cast<float>(src_size.height);
|
static_cast<float>(src_size.height);
|
||||||
const PushConstants push_constants{
|
const BlitPushConstants push_constants{
|
||||||
.tex_scale = {scale_x, scale_y},
|
.tex_scale = {scale_x, scale_y},
|
||||||
.tex_offset = {static_cast<float>(src_region.start.x) / static_cast<float>(src_size.width),
|
.tex_offset = {static_cast<float>(src_region.start.x) / static_cast<float>(src_size.width),
|
||||||
static_cast<float>(src_region.start.y) /
|
static_cast<float>(src_region.start.y) /
|
||||||
static_cast<float>(src_size.height)},
|
static_cast<float>(src_size.height)},
|
||||||
};
|
};
|
||||||
cmdbuf.PushConstants(layout, VK_SHADER_STAGE_VERTEX_BIT, push_constants);
|
cmdbuf.BlitPushConstants(layout, VK_SHADER_STAGE_VERTEX_BIT, push_constants);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkExtent2D GetConversionExtent(const ImageView& src_image_view) {
|
VkExtent2D GetConversionExtent(const ImageView& src_image_view) {
|
||||||
|
|
@ -507,11 +507,11 @@ BlitImageHelper::BlitImageHelper(const Device& device_, Scheduler& scheduler_,
|
||||||
descriptor_pool.Allocator(*two_textures_set_layout, TEXTURE_DESCRIPTOR_BANK_INFO<2>)},
|
descriptor_pool.Allocator(*two_textures_set_layout, TEXTURE_DESCRIPTOR_BANK_INFO<2>)},
|
||||||
one_texture_pipeline_layout(device.GetLogical().CreatePipelineLayout(PipelineLayoutCreateInfo(
|
one_texture_pipeline_layout(device.GetLogical().CreatePipelineLayout(PipelineLayoutCreateInfo(
|
||||||
one_texture_set_layout.address(),
|
one_texture_set_layout.address(),
|
||||||
PUSH_CONSTANT_RANGE<VK_SHADER_STAGE_VERTEX_BIT, sizeof(PushConstants)>))),
|
PUSH_CONSTANT_RANGE<VK_SHADER_STAGE_VERTEX_BIT, sizeof(BlitPushConstants)>))),
|
||||||
two_textures_pipeline_layout(
|
two_textures_pipeline_layout(
|
||||||
device.GetLogical().CreatePipelineLayout(PipelineLayoutCreateInfo(
|
device.GetLogical().CreatePipelineLayout(PipelineLayoutCreateInfo(
|
||||||
two_textures_set_layout.address(),
|
two_textures_set_layout.address(),
|
||||||
PUSH_CONSTANT_RANGE<VK_SHADER_STAGE_VERTEX_BIT, sizeof(PushConstants)>))),
|
PUSH_CONSTANT_RANGE<VK_SHADER_STAGE_VERTEX_BIT, sizeof(BlitPushConstants)>))),
|
||||||
clear_color_pipeline_layout(device.GetLogical().CreatePipelineLayout(PipelineLayoutCreateInfo(
|
clear_color_pipeline_layout(device.GetLogical().CreatePipelineLayout(PipelineLayoutCreateInfo(
|
||||||
nullptr, PUSH_CONSTANT_RANGE<VK_SHADER_STAGE_FRAGMENT_BIT, sizeof(float) * 4>))),
|
nullptr, PUSH_CONSTANT_RANGE<VK_SHADER_STAGE_FRAGMENT_BIT, sizeof(float) * 4>))),
|
||||||
full_screen_vert(BuildShader(device, FULL_SCREEN_TRIANGLE_VERT_SPV)),
|
full_screen_vert(BuildShader(device, FULL_SCREEN_TRIANGLE_VERT_SPV)),
|
||||||
|
|
@ -709,7 +709,7 @@ void BlitImageHelper::ClearColor(const Framebuffer* dst_framebuffer, u8 color_ma
|
||||||
(color_mask & 0x4) ? 1.0f : 0.0f, (color_mask & 0x8) ? 1.0f : 0.0f};
|
(color_mask & 0x4) ? 1.0f : 0.0f, (color_mask & 0x8) ? 1.0f : 0.0f};
|
||||||
cmdbuf.SetBlendConstants(blend_color.data());
|
cmdbuf.SetBlendConstants(blend_color.data());
|
||||||
BindBlitState(cmdbuf, dst_region);
|
BindBlitState(cmdbuf, dst_region);
|
||||||
cmdbuf.PushConstants(layout, VK_SHADER_STAGE_FRAGMENT_BIT, clear_color);
|
cmdbuf.BlitPushConstants(layout, VK_SHADER_STAGE_FRAGMENT_BIT, clear_color);
|
||||||
cmdbuf.Draw(3, 1, 0, 0);
|
cmdbuf.Draw(3, 1, 0, 0);
|
||||||
});
|
});
|
||||||
scheduler.InvalidateState();
|
scheduler.InvalidateState();
|
||||||
|
|
@ -733,7 +733,7 @@ void BlitImageHelper::ClearDepthStencil(const Framebuffer* dst_framebuffer, bool
|
||||||
cmdbuf.SetBlendConstants(blend_constants.data());
|
cmdbuf.SetBlendConstants(blend_constants.data());
|
||||||
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
||||||
BindBlitState(cmdbuf, dst_region);
|
BindBlitState(cmdbuf, dst_region);
|
||||||
cmdbuf.PushConstants(layout, VK_SHADER_STAGE_FRAGMENT_BIT, clear_depth);
|
cmdbuf.BlitPushConstants(layout, VK_SHADER_STAGE_FRAGMENT_BIT, clear_depth);
|
||||||
cmdbuf.Draw(3, 1, 0, 0);
|
cmdbuf.Draw(3, 1, 0, 0);
|
||||||
});
|
});
|
||||||
scheduler.InvalidateState();
|
scheduler.InvalidateState();
|
||||||
|
|
@ -765,7 +765,7 @@ void BlitImageHelper::Convert(VkPipeline pipeline, const Framebuffer* dst_frameb
|
||||||
.offset = offset,
|
.offset = offset,
|
||||||
.extent = extent,
|
.extent = extent,
|
||||||
};
|
};
|
||||||
const PushConstants push_constants{
|
const BlitPushConstants push_constants{
|
||||||
.tex_scale = {viewport.width, viewport.height},
|
.tex_scale = {viewport.width, viewport.height},
|
||||||
.tex_offset = {0.0f, 0.0f},
|
.tex_offset = {0.0f, 0.0f},
|
||||||
};
|
};
|
||||||
|
|
@ -777,7 +777,7 @@ void BlitImageHelper::Convert(VkPipeline pipeline, const Framebuffer* dst_frameb
|
||||||
nullptr);
|
nullptr);
|
||||||
cmdbuf.SetViewport(0, viewport);
|
cmdbuf.SetViewport(0, viewport);
|
||||||
cmdbuf.SetScissor(0, scissor);
|
cmdbuf.SetScissor(0, scissor);
|
||||||
cmdbuf.PushConstants(layout, VK_SHADER_STAGE_VERTEX_BIT, push_constants);
|
cmdbuf.BlitPushConstants(layout, VK_SHADER_STAGE_VERTEX_BIT, push_constants);
|
||||||
cmdbuf.Draw(3, 1, 0, 0);
|
cmdbuf.Draw(3, 1, 0, 0);
|
||||||
});
|
});
|
||||||
scheduler.InvalidateState();
|
scheduler.InvalidateState();
|
||||||
|
|
@ -811,7 +811,7 @@ void BlitImageHelper::ConvertDepthStencil(VkPipeline pipeline, const Framebuffer
|
||||||
.offset = offset,
|
.offset = offset,
|
||||||
.extent = extent,
|
.extent = extent,
|
||||||
};
|
};
|
||||||
const PushConstants push_constants{
|
const BlitPushConstants push_constants{
|
||||||
.tex_scale = {viewport.width, viewport.height},
|
.tex_scale = {viewport.width, viewport.height},
|
||||||
.tex_offset = {0.0f, 0.0f},
|
.tex_offset = {0.0f, 0.0f},
|
||||||
};
|
};
|
||||||
|
|
@ -823,7 +823,7 @@ void BlitImageHelper::ConvertDepthStencil(VkPipeline pipeline, const Framebuffer
|
||||||
nullptr);
|
nullptr);
|
||||||
cmdbuf.SetViewport(0, viewport);
|
cmdbuf.SetViewport(0, viewport);
|
||||||
cmdbuf.SetScissor(0, scissor);
|
cmdbuf.SetScissor(0, scissor);
|
||||||
cmdbuf.PushConstants(layout, VK_SHADER_STAGE_VERTEX_BIT, push_constants);
|
cmdbuf.BlitPushConstants(layout, VK_SHADER_STAGE_VERTEX_BIT, push_constants);
|
||||||
cmdbuf.Draw(3, 1, 0, 0);
|
cmdbuf.Draw(3, 1, 0, 0);
|
||||||
});
|
});
|
||||||
scheduler.InvalidateState();
|
scheduler.InvalidateState();
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
using namespace FSR;
|
using namespace FSR;
|
||||||
|
|
||||||
using PushConstants = std::array<u32, 4 * 4>;
|
using FsrPushConstants = std::array<u32, 4 * 4>;
|
||||||
|
|
||||||
FSR::FSR(const Device& device, MemoryAllocator& memory_allocator, size_t image_count,
|
FSR::FSR(const Device& device, MemoryAllocator& memory_allocator, size_t image_count,
|
||||||
VkExtent2D extent)
|
VkExtent2D extent)
|
||||||
|
|
@ -96,7 +96,7 @@ void FSR::CreatePipelineLayouts() {
|
||||||
const VkPushConstantRange range{
|
const VkPushConstantRange range{
|
||||||
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT,
|
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||||
.offset = 0,
|
.offset = 0,
|
||||||
.size = sizeof(PushConstants),
|
.size = sizeof(FsrPushConstants),
|
||||||
};
|
};
|
||||||
VkPipelineLayoutCreateInfo ci{
|
VkPipelineLayoutCreateInfo ci{
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
||||||
|
|
@ -168,8 +168,8 @@ VkImageView FSR::Draw(Scheduler& scheduler, size_t image_index, VkImage source_i
|
||||||
const f32 viewport_height = (crop_rect.bottom - crop_rect.top) * input_image_height;
|
const f32 viewport_height = (crop_rect.bottom - crop_rect.top) * input_image_height;
|
||||||
const f32 viewport_y = crop_rect.top * input_image_height;
|
const f32 viewport_y = crop_rect.top * input_image_height;
|
||||||
|
|
||||||
PushConstants easu_con{};
|
FsrPushConstants easu_con{};
|
||||||
PushConstants rcas_con{};
|
FsrPushConstants rcas_con{};
|
||||||
FsrEasuConOffset(easu_con.data() + 0, easu_con.data() + 4, easu_con.data() + 8,
|
FsrEasuConOffset(easu_con.data() + 0, easu_con.data() + 4, easu_con.data() + 8,
|
||||||
easu_con.data() + 12, viewport_width, viewport_height, input_image_width,
|
easu_con.data() + 12, viewport_width, viewport_height, input_image_width,
|
||||||
input_image_height, output_image_width, output_image_height, viewport_x,
|
input_image_height, output_image_width, output_image_height, viewport_x,
|
||||||
|
|
@ -190,7 +190,7 @@ VkImageView FSR::Draw(Scheduler& scheduler, size_t image_index, VkImage source_i
|
||||||
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, easu_pipeline);
|
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, easu_pipeline);
|
||||||
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0,
|
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0,
|
||||||
easu_descriptor_set, {});
|
easu_descriptor_set, {});
|
||||||
cmdbuf.PushConstants(pipeline_layout, VK_SHADER_STAGE_FRAGMENT_BIT, easu_con);
|
cmdbuf.FsrPushConstants(pipeline_layout, VK_SHADER_STAGE_FRAGMENT_BIT, easu_con);
|
||||||
cmdbuf.Draw(3, 1, 0, 0);
|
cmdbuf.Draw(3, 1, 0, 0);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
|
|
||||||
|
|
@ -200,7 +200,7 @@ VkImageView FSR::Draw(Scheduler& scheduler, size_t image_index, VkImage source_i
|
||||||
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, rcas_pipeline);
|
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, rcas_pipeline);
|
||||||
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0,
|
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0,
|
||||||
rcas_descriptor_set, {});
|
rcas_descriptor_set, {});
|
||||||
cmdbuf.PushConstants(pipeline_layout, VK_SHADER_STAGE_FRAGMENT_BIT, rcas_con);
|
cmdbuf.FsrPushConstants(pipeline_layout, VK_SHADER_STAGE_FRAGMENT_BIT, rcas_con);
|
||||||
cmdbuf.Draw(3, 1, 0, 0);
|
cmdbuf.Draw(3, 1, 0, 0);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,6 @@ constexpr std::array<char, 8> MAGIC_NUMBER{'y', 'u', 'z', 'u', 'c', 'a', 'c', 'h
|
||||||
|
|
||||||
constexpr size_t INST_SIZE = sizeof(u64);
|
constexpr size_t INST_SIZE = sizeof(u64);
|
||||||
|
|
||||||
using Maxwell = Tegra::Engines::Maxwell3D::Regs;
|
|
||||||
|
|
||||||
static u64 MakeCbufKey(u32 index, u32 offset) {
|
static u64 MakeCbufKey(u32 index, u32 offset) {
|
||||||
return (static_cast<u64>(index) << 32) | offset;
|
return (static_cast<u64>(index) << 32) | offset;
|
||||||
}
|
}
|
||||||
|
|
@ -286,34 +284,34 @@ Tegra::Texture::TICEntry GenericEnvironment::ReadTextureInfo(GPUVAddr tic_addr,
|
||||||
|
|
||||||
GraphicsEnvironment::GraphicsEnvironment(Tegra::Engines::Maxwell3D& maxwell3d_,
|
GraphicsEnvironment::GraphicsEnvironment(Tegra::Engines::Maxwell3D& maxwell3d_,
|
||||||
Tegra::MemoryManager& gpu_memory_,
|
Tegra::MemoryManager& gpu_memory_,
|
||||||
Maxwell::ShaderType program, GPUVAddr program_base_,
|
Tegra::Engines::Maxwell3D::Regs::ShaderType program, GPUVAddr program_base_,
|
||||||
u32 start_address_)
|
u32 start_address_)
|
||||||
: GenericEnvironment{gpu_memory_, program_base_, start_address_}, maxwell3d{&maxwell3d_} {
|
: GenericEnvironment{gpu_memory_, program_base_, start_address_}, maxwell3d{&maxwell3d_} {
|
||||||
gpu_memory->ReadBlock(program_base + start_address, &sph, sizeof(sph));
|
gpu_memory->ReadBlock(program_base + start_address, &sph, sizeof(sph));
|
||||||
initial_offset = sizeof(sph);
|
initial_offset = sizeof(sph);
|
||||||
gp_passthrough_mask = maxwell3d->regs.post_vtg_shader_attrib_skip_mask;
|
gp_passthrough_mask = maxwell3d->regs.post_vtg_shader_attrib_skip_mask;
|
||||||
switch (program) {
|
switch (program) {
|
||||||
case Maxwell::ShaderType::VertexA:
|
case Tegra::Engines::Maxwell3D::Regs::ShaderType::VertexA:
|
||||||
stage = Shader::Stage::VertexA;
|
stage = Shader::Stage::VertexA;
|
||||||
stage_index = 0;
|
stage_index = 0;
|
||||||
break;
|
break;
|
||||||
case Maxwell::ShaderType::VertexB:
|
case Tegra::Engines::Maxwell3D::Regs::ShaderType::VertexB:
|
||||||
stage = Shader::Stage::VertexB;
|
stage = Shader::Stage::VertexB;
|
||||||
stage_index = 0;
|
stage_index = 0;
|
||||||
break;
|
break;
|
||||||
case Maxwell::ShaderType::TessellationInit:
|
case Tegra::Engines::Maxwell3D::Regs::ShaderType::TessellationInit:
|
||||||
stage = Shader::Stage::TessellationControl;
|
stage = Shader::Stage::TessellationControl;
|
||||||
stage_index = 1;
|
stage_index = 1;
|
||||||
break;
|
break;
|
||||||
case Maxwell::ShaderType::Tessellation:
|
case Tegra::Engines::Maxwell3D::Regs::ShaderType::Tessellation:
|
||||||
stage = Shader::Stage::TessellationEval;
|
stage = Shader::Stage::TessellationEval;
|
||||||
stage_index = 2;
|
stage_index = 2;
|
||||||
break;
|
break;
|
||||||
case Maxwell::ShaderType::Geometry:
|
case Tegra::Engines::Maxwell3D::Regs::ShaderType::Geometry:
|
||||||
stage = Shader::Stage::Geometry;
|
stage = Shader::Stage::Geometry;
|
||||||
stage_index = 3;
|
stage_index = 3;
|
||||||
break;
|
break;
|
||||||
case Maxwell::ShaderType::Pixel:
|
case Tegra::Engines::Maxwell3D::Regs::ShaderType::Pixel:
|
||||||
stage = Shader::Stage::Fragment;
|
stage = Shader::Stage::Fragment;
|
||||||
stage_index = 4;
|
stage_index = 4;
|
||||||
break;
|
break;
|
||||||
|
|
@ -369,7 +367,7 @@ std::optional<Shader::ReplaceConstant> GraphicsEnvironment::GetReplaceConstBuffe
|
||||||
|
|
||||||
Shader::TextureType GraphicsEnvironment::ReadTextureType(u32 handle) {
|
Shader::TextureType GraphicsEnvironment::ReadTextureType(u32 handle) {
|
||||||
const auto& regs{maxwell3d->regs};
|
const auto& regs{maxwell3d->regs};
|
||||||
const bool via_header_index{regs.sampler_binding == Maxwell::SamplerBinding::ViaHeaderBinding};
|
const bool via_header_index{regs.sampler_binding == Tegra::Engines::Maxwell3D::Regs::SamplerBinding::ViaHeaderBinding};
|
||||||
auto entry =
|
auto entry =
|
||||||
ReadTextureInfo(regs.tex_header.Address(), regs.tex_header.limit, via_header_index, handle);
|
ReadTextureInfo(regs.tex_header.Address(), regs.tex_header.limit, via_header_index, handle);
|
||||||
const Shader::TextureType result{ConvertTextureType(entry)};
|
const Shader::TextureType result{ConvertTextureType(entry)};
|
||||||
|
|
@ -379,7 +377,7 @@ Shader::TextureType GraphicsEnvironment::ReadTextureType(u32 handle) {
|
||||||
|
|
||||||
Shader::TexturePixelFormat GraphicsEnvironment::ReadTexturePixelFormat(u32 handle) {
|
Shader::TexturePixelFormat GraphicsEnvironment::ReadTexturePixelFormat(u32 handle) {
|
||||||
const auto& regs{maxwell3d->regs};
|
const auto& regs{maxwell3d->regs};
|
||||||
const bool via_header_index{regs.sampler_binding == Maxwell::SamplerBinding::ViaHeaderBinding};
|
const bool via_header_index{regs.sampler_binding == Tegra::Engines::Maxwell3D::Regs::SamplerBinding::ViaHeaderBinding};
|
||||||
auto entry =
|
auto entry =
|
||||||
ReadTextureInfo(regs.tex_header.Address(), regs.tex_header.limit, via_header_index, handle);
|
ReadTextureInfo(regs.tex_header.Address(), regs.tex_header.limit, via_header_index, handle);
|
||||||
const Shader::TexturePixelFormat result(ConvertTexturePixelFormat(entry));
|
const Shader::TexturePixelFormat result(ConvertTexturePixelFormat(entry));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue