mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 13:31:27 +12:00
rsx: Implement stencil mirror views
- Implements a mirror view of D24S8 data that accesses the stencil components. Finishes the implementation of TEX2D_DEPTH_RGBA as the stencil component was previously missing from the reconstructed data - Add a few missing destructors Image classes are inherited a lot and I forgot to make the dtors virtual
This commit is contained in:
parent
696b91cb9b
commit
4b79ef1ad9
19 changed files with 401 additions and 156 deletions
|
@ -1,6 +1,8 @@
|
|||
#include "stdafx.h"
|
||||
#include "VKHelpers.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace vk
|
||||
{
|
||||
namespace glsl
|
||||
|
@ -10,10 +12,16 @@ namespace vk
|
|||
program::program(VkDevice dev, VkPipeline p, const std::vector<program_input> &vertex_input, const std::vector<program_input>& fragment_inputs)
|
||||
: m_device(dev), pipeline(p)
|
||||
{
|
||||
linked = false;
|
||||
|
||||
load_uniforms(program_domain::glsl_vertex_program, vertex_input);
|
||||
load_uniforms(program_domain::glsl_vertex_program, fragment_inputs);
|
||||
attribute_location_mask = 0;
|
||||
vertex_attributes_mask = 0;
|
||||
|
||||
fs_texture_bindings.fill(~0u);
|
||||
fs_texture_mirror_bindings.fill(~0u);
|
||||
vs_texture_bindings.fill(~0u);
|
||||
}
|
||||
|
||||
program::~program()
|
||||
|
@ -23,6 +31,8 @@ namespace vk
|
|||
|
||||
program& program::load_uniforms(program_domain domain, const std::vector<program_input>& inputs)
|
||||
{
|
||||
verify("Cannot change uniforms in already linked program!" HERE), !linked;
|
||||
|
||||
for (auto &item : inputs)
|
||||
{
|
||||
uniforms[item.type].push_back(item);
|
||||
|
@ -31,6 +41,46 @@ namespace vk
|
|||
return *this;
|
||||
}
|
||||
|
||||
program& program::link()
|
||||
{
|
||||
// Preprocess texture bindings
|
||||
// Link step is only useful for rasterizer programs, compute programs do not need this
|
||||
for (const auto &uniform : uniforms[program_input_type::input_type_texture])
|
||||
{
|
||||
if (const auto name_start = uniform.name.find("tex"); name_start != std::string::npos)
|
||||
{
|
||||
const auto name_end = uniform.name.find("_stencil");
|
||||
const auto index_start = name_start + 3; // Skip 'tex' part
|
||||
const auto index_length = (name_end != std::string::npos) ? name_end - index_start : name_end;
|
||||
const auto index_part = uniform.name.substr(index_start, index_length);
|
||||
const auto index = std::stoi(index_part);
|
||||
|
||||
if (name_start == 0)
|
||||
{
|
||||
// Fragment texture (tex...)
|
||||
if (name_end == std::string::npos)
|
||||
{
|
||||
// Normal texture
|
||||
fs_texture_bindings[index] = uniform.location;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Stencil mirror
|
||||
fs_texture_mirror_bindings[index] = uniform.location;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Vertex texture (vtex...)
|
||||
vs_texture_bindings[index] = uniform.location;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
linked = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool program::has_uniform(program_input_type type, const std::string &uniform_name)
|
||||
{
|
||||
for (const auto &uniform : uniforms[type])
|
||||
|
@ -71,6 +121,44 @@ namespace vk
|
|||
LOG_NOTICE(RSX, "texture not found in program: %s", uniform_name.c_str());
|
||||
}
|
||||
|
||||
void program::bind_uniform(const VkDescriptorImageInfo & image_descriptor, int texture_unit, ::glsl::program_domain domain, VkDescriptorSet &descriptor_set, bool is_stencil_mirror)
|
||||
{
|
||||
verify("Unsupported program domain" HERE, domain != ::glsl::program_domain::glsl_compute_program);
|
||||
|
||||
u32 binding;
|
||||
if (domain == ::glsl::program_domain::glsl_fragment_program)
|
||||
{
|
||||
binding = (is_stencil_mirror) ? fs_texture_mirror_bindings[texture_unit] : fs_texture_bindings[texture_unit];
|
||||
}
|
||||
else
|
||||
{
|
||||
binding = vs_texture_bindings[texture_unit];
|
||||
}
|
||||
|
||||
if (binding != ~0u)
|
||||
{
|
||||
const VkWriteDescriptorSet descriptor_writer =
|
||||
{
|
||||
VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, // sType
|
||||
nullptr, // pNext
|
||||
descriptor_set, // dstSet
|
||||
binding, // dstBinding
|
||||
0, // dstArrayElement
|
||||
1, // descriptorCount
|
||||
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, // descriptorType
|
||||
&image_descriptor, // pImageInfo
|
||||
nullptr, // pBufferInfo
|
||||
nullptr // pTexelBufferView
|
||||
};
|
||||
|
||||
vkUpdateDescriptorSets(m_device, 1, &descriptor_writer, 0, nullptr);
|
||||
attribute_location_mask |= (1ull << binding);
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_NOTICE(RSX, "texture not found in program: %stex%u", (domain == ::glsl::program_domain::glsl_vertex_program)? "v" : "", texture_unit);
|
||||
}
|
||||
|
||||
void program::bind_uniform(const VkDescriptorBufferInfo &buffer_descriptor, uint32_t binding_point, VkDescriptorSet &descriptor_set)
|
||||
{
|
||||
bind_buffer(buffer_descriptor, binding_point, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, descriptor_set);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue