Compare commits

..

1 Commits

Author SHA1 Message Date
GPUCode
20ef8e47e6 host_shaders: Remove dependency on shaderSampledImageArrayDynamicIndexing 2024-01-25 01:06:43 +02:00
8 changed files with 48 additions and 27 deletions

View File

@@ -20,6 +20,18 @@ layout (push_constant, std140) uniform DrawInfo {
layout (set = 0, binding = 0) uniform sampler2D screen_textures[3]; layout (set = 0, binding = 0) uniform sampler2D screen_textures[3];
void main() { // Not all vulkan drivers support shaderSampledImageArrayDynamicIndexing, so index manually.
color = texture(screen_textures[screen_id_l], frag_tex_coord); vec4 GetScreen(int screen_id) {
switch (screen_id) {
case 0:
return texture(screen_textures[0], frag_tex_coord);
case 1:
return texture(screen_textures[1], frag_tex_coord);
case 2:
return texture(screen_textures[2], frag_tex_coord);
}
}
void main() {
color = GetScreen(screen_id_l);
} }

View File

@@ -32,8 +32,20 @@ layout (push_constant, std140) uniform DrawInfo {
layout (set = 0, binding = 0) uniform sampler2D screen_textures[3]; layout (set = 0, binding = 0) uniform sampler2D screen_textures[3];
// Not all vulkan drivers support shaderSampledImageArrayDynamicIndexing, so index manually.
vec4 GetScreen(int screen_id) {
switch (screen_id) {
case 0:
return texture(screen_textures[0], frag_tex_coord);
case 1:
return texture(screen_textures[1], frag_tex_coord);
case 2:
return texture(screen_textures[2], frag_tex_coord);
}
}
void main() { void main() {
vec4 color_tex_l = texture(screen_textures[screen_id_l], frag_tex_coord); vec4 color_tex_l = GetScreen(screen_id_l);
vec4 color_tex_r = texture(screen_textures[screen_id_r], frag_tex_coord); vec4 color_tex_r = GetScreen(screen_id_r);
color = vec4(color_tex_l.rgb*l+color_tex_r.rgb*r, color_tex_l.a); color = vec4(color_tex_l.rgb*l+color_tex_r.rgb*r, color_tex_l.a);
} }

View File

@@ -20,10 +20,22 @@ layout (push_constant, std140) uniform DrawInfo {
layout (set = 0, binding = 0) uniform sampler2D screen_textures[3]; layout (set = 0, binding = 0) uniform sampler2D screen_textures[3];
// Not all vulkan drivers support shaderSampledImageArrayDynamicIndexing, so index manually.
vec4 GetScreen(int screen_id) {
switch (screen_id) {
case 0:
return texture(screen_textures[0], frag_tex_coord);
case 1:
return texture(screen_textures[1], frag_tex_coord);
case 2:
return texture(screen_textures[2], frag_tex_coord);
}
}
void main() { void main() {
float screen_row = o_resolution.x * frag_tex_coord.x; float screen_row = o_resolution.x * frag_tex_coord.x;
if (int(screen_row) % 2 == reverse_interlaced) if (int(screen_row) % 2 == reverse_interlaced)
color = texture(screen_textures[screen_id_l], frag_tex_coord); color = GetScreen(screen_id_l);
else else
color = texture(screen_textures[screen_id_r], frag_tex_coord); color = GetScreen(screen_id_r);
} }

View File

@@ -337,6 +337,7 @@ void GeometryPipeline::Reconfigure() {
// The following assumes that when geometry shader is in use, the shader unit 3 is configured as // The following assumes that when geometry shader is in use, the shader unit 3 is configured as
// a geometry shader unit. // a geometry shader unit.
// TODO: what happens if this is not true? // TODO: what happens if this is not true?
ASSERT(regs.pipeline.gs_unit_exclusive_configuration == 1);
ASSERT(regs.gs.shader_mode == ShaderRegs::ShaderMode::GS); ASSERT(regs.gs.shader_mode == ShaderRegs::ShaderMode::GS);
ASSERT(regs.pipeline.use_gs == PipelineRegs::UseGS::Yes); ASSERT(regs.pipeline.use_gs == PipelineRegs::UseGS::Yes);

View File

@@ -35,7 +35,7 @@ PicaCore::PicaCore(Memory::MemorySystem& memory_, std::shared_ptr<DebugContext>
gs_unit, gs_unit,
gs_setup}, gs_setup},
shader_engine{CreateEngine(Settings::values.use_shader_jit.GetValue())} { shader_engine{CreateEngine(Settings::values.use_shader_jit.GetValue())} {
InitializeRegs(); SetFramebufferDefaults();
const auto submit_vertex = [this](const AttributeBuffer& buffer) { const auto submit_vertex = [this](const AttributeBuffer& buffer) {
const auto add_triangle = [this](const OutputVertex& v0, const OutputVertex& v1, const auto add_triangle = [this](const OutputVertex& v0, const OutputVertex& v1,
@@ -54,7 +54,7 @@ PicaCore::PicaCore(Memory::MemorySystem& memory_, std::shared_ptr<DebugContext>
PicaCore::~PicaCore() = default; PicaCore::~PicaCore() = default;
void PicaCore::InitializeRegs() { void PicaCore::SetFramebufferDefaults() {
auto& framebuffer_top = regs.framebuffer_config[0]; auto& framebuffer_top = regs.framebuffer_config[0];
auto& framebuffer_sub = regs.framebuffer_config[1]; auto& framebuffer_sub = regs.framebuffer_config[1];
@@ -77,11 +77,6 @@ void PicaCore::InitializeRegs() {
framebuffer_sub.stride = 3 * 240; framebuffer_sub.stride = 3 * 240;
framebuffer_sub.color_format.Assign(PixelFormat::RGB8); framebuffer_sub.color_format.Assign(PixelFormat::RGB8);
framebuffer_sub.active_fb = 0; framebuffer_sub.active_fb = 0;
// Tales of Abyss expects this register to have the following default values.
auto& gs = regs.internal.gs;
gs.max_input_attribute_index.Assign(1);
gs.shader_mode.Assign(ShaderRegs::ShaderMode::VS);
} }
void PicaCore::BindRasterizer(VideoCore::RasterizerInterface* rasterizer) { void PicaCore::BindRasterizer(VideoCore::RasterizerInterface* rasterizer) {
@@ -259,13 +254,6 @@ void PicaCore::WriteInternalReg(u32 id, u32 value, u32 mask) {
break; break;
} }
case PICA_REG_INDEX(vs.output_mask):
if (!regs.internal.pipeline.gs_unit_exclusive_configuration &&
regs.internal.pipeline.use_gs == PipelineRegs::UseGS::No) {
regs.internal.gs.output_mask.Assign(value);
}
break;
case PICA_REG_INDEX(vs.bool_uniforms): case PICA_REG_INDEX(vs.bool_uniforms):
vs_setup.WriteUniformBoolReg(regs.internal.vs.bool_uniforms.Value()); vs_setup.WriteUniformBoolReg(regs.internal.vs.bool_uniforms.Value());
if (!regs.internal.pipeline.gs_unit_exclusive_configuration && if (!regs.internal.pipeline.gs_unit_exclusive_configuration &&

View File

@@ -39,7 +39,7 @@ public:
void ProcessCmdList(PAddr list, u32 size); void ProcessCmdList(PAddr list, u32 size);
private: private:
void InitializeRegs(); void SetFramebufferDefaults();
void WriteInternalReg(u32 id, u32 value, u32 mask); void WriteInternalReg(u32 id, u32 value, u32 mask);

View File

@@ -35,7 +35,6 @@ struct ShaderRegs {
union { union {
// Number of input attributes to shader unit - 1 // Number of input attributes to shader unit - 1
u32 input_buffer_config;
BitField<0, 4, u32> max_input_attribute_index; BitField<0, 4, u32> max_input_attribute_index;
BitField<8, 8, u32> input_to_uniform; BitField<8, 8, u32> input_to_uniform;
BitField<24, 8, ShaderMode> shader_mode; BitField<24, 8, ShaderMode> shader_mode;

View File

@@ -341,8 +341,8 @@ static constexpr void MortonCopy(u32 width, u32 height, u32 start_offset, u32 en
*/ */
template <bool decode, PixelFormat format, bool converted = false> template <bool decode, PixelFormat format, bool converted = false>
static constexpr void LinearCopy(std::span<u8> src_buffer, std::span<u8> dst_buffer) { static constexpr void LinearCopy(std::span<u8> src_buffer, std::span<u8> dst_buffer) {
std::size_t src_size = src_buffer.size(); const std::size_t src_size = src_buffer.size();
std::size_t dst_size = dst_buffer.size(); const std::size_t dst_size = dst_buffer.size();
if constexpr (converted) { if constexpr (converted) {
constexpr u32 encoded_bytes_per_pixel = GetFormatBpp(format) / 8; constexpr u32 encoded_bytes_per_pixel = GetFormatBpp(format) / 8;
@@ -352,9 +352,6 @@ static constexpr void LinearCopy(std::span<u8> src_buffer, std::span<u8> dst_buf
constexpr u32 dst_bytes_per_pixel = constexpr u32 dst_bytes_per_pixel =
decode ? decoded_bytes_per_pixel : encoded_bytes_per_pixel; decode ? decoded_bytes_per_pixel : encoded_bytes_per_pixel;
src_size = Common::AlignDown(src_size, src_bytes_per_pixel);
dst_size = Common::AlignDown(dst_size, dst_bytes_per_pixel);
for (std::size_t src_index = 0, dst_index = 0; src_index < src_size && dst_index < dst_size; for (std::size_t src_index = 0, dst_index = 0; src_index < src_size && dst_index < dst_size;
src_index += src_bytes_per_pixel, dst_index += dst_bytes_per_pixel) { src_index += src_bytes_per_pixel, dst_index += dst_bytes_per_pixel) {
const auto src_pixel = src_buffer.subspan(src_index, src_bytes_per_pixel); const auto src_pixel = src_buffer.subspan(src_index, src_bytes_per_pixel);