1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 18:53:28 +01:00

rsx: Refactor program texture state handling to be persistent across shader swaps

This commit is contained in:
kd-11 2021-05-13 00:56:01 +03:00 committed by kd-11
parent 11bace8804
commit c5a06dab0a
45 changed files with 337 additions and 179 deletions

View File

@ -359,7 +359,7 @@ void GLGSRender::bind_texture_env()
{
view->bind();
if (current_fragment_program.redirected_textures & (1 << i))
if (current_fragment_program.texture_state.redirected_textures & (1 << i))
{
_SelectTexture(GL_STENCIL_MIRRORS_START + i);
@ -373,7 +373,7 @@ void GLGSRender::bind_texture_env()
auto target = gl::get_target(current_fragment_program.get_texture_dimension(i));
glBindTexture(target, m_null_textures[target]->id());
if (current_fragment_program.redirected_textures & (1 << i))
if (current_fragment_program.texture_state.redirected_textures & (1 << i))
{
_SelectTexture(GL_STENCIL_MIRRORS_START + i);
glBindTexture(target, m_null_textures[target]->id());

View File

@ -4,7 +4,7 @@
#include "Emu/system_config.h"
#include "GLCommonDecompiler.h"
#include "../GCM.h"
#include "../Common/GLSLCommon.h"
#include "../Program/GLSLCommon.h"
std::string GLFragmentDecompilerThread::getFloatTypeName(usz elementCount)
{

View File

@ -1,7 +1,6 @@
#pragma once
#include "../Common/FragmentProgramDecompiler.h"
#include "../Common/GLSLTypes.h"
#include "Emu/RSX/RSXFragmentProgram.h"
#include "../Program/FragmentProgramDecompiler.h"
#include "../Program/GLSLTypes.h"
#include "GLHelpers.h"
namespace glsl

View File

@ -6,7 +6,7 @@
#include "Emu/Memory/vm_locking.h"
#include "Emu/RSX/rsx_methods.h"
#include "../Common/program_state_cache2.hpp"
#include "../Program/program_state_cache2.hpp"
u64 GLGSRender::get_cycles()
{
@ -647,7 +647,7 @@ bool GLGSRender::load_program()
get_current_vertex_program(vs_sampler_state);
current_vertex_program.skip_vertex_input_check = true; //not needed for us since decoding is done server side
current_fragment_program.unnormalized_coords = 0; //unused
current_fragment_program.texture_state.unnormalized_coords = 0; //unused
}
else if (m_program)
{
@ -801,8 +801,7 @@ void GLGSRender::load_program_env()
{
// Fragment texture parameters
auto mapping = m_texture_parameters_buffer->alloc_from_heap(256, m_uniform_buffer_offset_align);
auto buf = static_cast<u8*>(mapping.first);
fill_fragment_texture_parameters(buf, current_fragment_program);
current_fragment_program.texture_params.write_to(mapping.first, current_fp_metadata.referenced_textures_mask);
m_texture_parameters_buffer->bind_range(GL_FRAGMENT_TEXTURE_PARAMS_BIND_SLOT, mapping.second, 256);
}
@ -848,7 +847,7 @@ void GLGSRender::load_program_env()
// Control mask
const auto control_masks = reinterpret_cast<u32*>(fp_buf);
control_masks[0] = rsx::method_registers.shader_control();
control_masks[1] = current_fragment_program.texture_dimensions;
control_masks[1] = current_fragment_program.texture_state.texture_dimensions;
// Bind textures
m_shader_interpreter.update_fragment_textures(fs_sampler_state, current_fp_metadata.referenced_textures_mask, reinterpret_cast<u32*>(fp_buf + 16));

View File

@ -10,7 +10,7 @@
#include "GLExecutionState.h"
#include "../GCM.h"
#include "../Common/TextureUtils.h"
#include "../Common/GLSLTypes.h"
#include "../Program/GLSLTypes.h"
#include "Emu/system_config.h"
#include "Utilities/mutex.h"

View File

@ -3,7 +3,7 @@
#include "GLFragmentProgram.h"
#include "GLHelpers.h"
#include "GLPipelineCompiler.h"
#include "../Common/ProgramStateCache.h"
#include "../Program/ProgramStateCache.h"
#include "../rsx_utils.h"
struct GLTraits

View File

@ -4,8 +4,8 @@
#include "GLVertexProgram.h"
#include "GLFragmentProgram.h"
#include "../rsx_methods.h"
#include "../Common/ShaderInterpreter.h"
#include "../Common/GLSLCommon.h"
#include "../Program/ShaderInterpreter.h"
#include "../Program/GLSLCommon.h"
namespace gl
{

View File

@ -1,6 +1,6 @@
#pragma once
#include "GLHelpers.h"
#include "../Common/ProgramStateCache.h"
#include "../Program/ProgramStateCache.h"
#include "../Common/TextureUtils.h"
#include <unordered_map>

View File

@ -4,7 +4,7 @@
#include "Emu/System.h"
#include "GLCommonDecompiler.h"
#include "../Common/GLSLCommon.h"
#include "../Program/GLSLCommon.h"
#include <algorithm>

View File

@ -1,6 +1,5 @@
#pragma once
#include "../Common/VertexProgramDecompiler.h"
#include "Emu/RSX/RSXVertexProgram.h"
#include "../Program/VertexProgramDecompiler.h"
#include "GLHelpers.h"
#include <unordered_map>

View File

@ -1,7 +1,7 @@
#include "stdafx.h"
#include "CgBinaryProgram.h"
#include "Emu/RSX/RSXFragmentProgram.h"
#include "RSXFragmentProgram.h"
#include <algorithm>

View File

@ -2,7 +2,7 @@
#include "CgBinaryProgram.h"
#include "Emu/System.h"
#include "Emu/RSX/RSXVertexProgram.h"
#include "RSXVertexProgram.h"
void CgBinaryDisasm::AddScaCodeDisasm(const std::string& code)
{

View File

@ -971,7 +971,7 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode)
if (type != rsx::texture_dimension_extended::texture_dimension_3d)
{
if (m_prog.shadow_textures & ref_mask)
if (m_prog.texture_state.shadow_textures & ref_mask)
{
properties.shadow_sampler_mask |= ref_mask;
select = 4;
@ -980,7 +980,7 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode)
else
{
properties.common_access_sampler_mask |= ref_mask;
if (m_prog.redirected_textures & ref_mask)
if (m_prog.texture_state.redirected_textures & ref_mask)
{
properties.redirected_sampler_mask |= ref_mask;
select = 5;
@ -1064,8 +1064,8 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode)
{
AddTex();
if (m_prog.redirected_textures & (1 << dst.tex_num) ||
m_prog.shadow_textures & (1 << dst.tex_num))
if (m_prog.texture_state.redirected_textures & (1 << dst.tex_num) ||
m_prog.texture_state.shadow_textures & (1 << dst.tex_num))
{
// Doesn't make sense to sample with derivates for these types
rsx_log.error("[Unimplemented warning] TXD operation performed on shadow/redirected texture!");

View File

@ -1,6 +1,6 @@
#pragma once
#include "ShaderParam.h"
#include "Emu/RSX/RSXFragmentProgram.h"
#include "RSXFragmentProgram.h"
#include <sstream>
// Helper for GPR occupancy tracking

View File

@ -252,7 +252,7 @@ usz vertex_program_storage_hash::operator()(const RSXVertexProgram &program) con
{
usz hash = vertex_program_utils::get_vertex_program_ucode_hash(program);
hash ^= program.output_mask;
hash ^= program.texture_dimensions;
hash ^= program.texture_state.texture_dimensions;
return hash;
}
@ -260,7 +260,7 @@ bool vertex_program_compare::operator()(const RSXVertexProgram &binary1, const R
{
if (binary1.output_mask != binary2.output_mask)
return false;
if (binary1.texture_dimensions != binary2.texture_dimensions)
if (binary1.texture_state != binary2.texture_state)
return false;
if (binary1.data.size() != binary2.data.size())
return false;
@ -451,20 +451,19 @@ usz fragment_program_storage_hash::operator()(const RSXFragmentProgram& program)
{
usz hash = fragment_program_utils::get_fragment_program_ucode_hash(program);
hash ^= program.ctrl;
hash ^= program.texture_dimensions;
hash ^= program.unnormalized_coords;
hash ^= +program.two_sided_lighting;
hash ^= program.shadow_textures;
hash ^= program.redirected_textures;
hash ^= program.texture_state.texture_dimensions;
hash ^= program.texture_state.unnormalized_coords;
hash ^= program.texture_state.shadow_textures;
hash ^= program.texture_state.redirected_textures;
return hash;
}
bool fragment_program_compare::operator()(const RSXFragmentProgram& binary1, const RSXFragmentProgram& binary2) const
{
if (binary1.ctrl != binary2.ctrl || binary1.texture_dimensions != binary2.texture_dimensions || binary1.unnormalized_coords != binary2.unnormalized_coords ||
binary1.two_sided_lighting != binary2.two_sided_lighting ||
binary1.shadow_textures != binary2.shadow_textures || binary1.redirected_textures != binary2.redirected_textures)
if (binary1.ctrl != binary2.ctrl || binary1.texture_state != binary2.texture_state ||
binary1.two_sided_lighting != binary2.two_sided_lighting)
return false;
const void* instBuffer1 = binary1.get_data();

View File

@ -1,7 +1,7 @@
#pragma once
#include "Emu/RSX/RSXFragmentProgram.h"
#include "Emu/RSX/RSXVertexProgram.h"
#include "RSXFragmentProgram.h"
#include "RSXVertexProgram.h"
#include "Utilities/mutex.h"
#include "util/logs.hpp"

View File

@ -1,7 +1,9 @@
#pragma once
#include "gcm_enums.h"
#include "util/types.hpp"
#include "program_util.h"
#include <string>
#include <vector>
enum register_type
{
@ -298,20 +300,17 @@ struct RSXFragmentProgram
u32 ucode_length = 0;
u32 total_length = 0;
u32 ctrl = 0;
u16 unnormalized_coords = 0;
u16 redirected_textures = 0;
u16 shadow_textures = 0;
bool two_sided_lighting = false;
u32 texture_dimensions = 0;
u32 texcoord_control_mask = 0;
float texture_scale[16][4]{};
rsx::fragment_program_texture_state texture_state;
rsx::fragment_program_texture_config texture_params;
bool valid = false;
rsx::texture_dimension_extended get_texture_dimension(u8 id) const
{
return rsx::texture_dimension_extended{static_cast<u8>((texture_dimensions >> (id * 2)) & 0x3)};
return rsx::texture_dimension_extended{static_cast<u8>((texture_state.texture_dimensions >> (id * 2)) & 0x3)};
}
bool texcoord_is_2d(u8 index) const

View File

@ -1,7 +1,6 @@
#pragma once
#include "gcm_enums.h"
#include "util/types.hpp"
#include "program_util.h"
#include <vector>
#include <bitset>
@ -235,8 +234,8 @@ struct RSXVertexProgram
std::vector<u32> data;
std::vector<rsx_vertex_input> rsx_vertex_inputs;
u32 output_mask;
u32 texture_dimensions;
bool skip_vertex_input_check;
rsx::vertex_program_texture_state texture_state;
u32 base_address;
u32 entry;
@ -245,6 +244,6 @@ struct RSXVertexProgram
rsx::texture_dimension_extended get_texture_dimension(u8 id) const
{
return rsx::texture_dimension_extended{static_cast<u8>((texture_dimensions >> (id * 2)) & 0x3)};
return rsx::texture_dimension_extended{static_cast<u8>((texture_state.texture_dimensions >> (id * 2)) & 0x3)};
}
};

View File

@ -24,7 +24,7 @@ namespace program_common
static std::string get_vertex_interpreter()
{
const char* s =
#include "Interpreter/VertexInterpreter.glsl"
#include "../Common/Interpreter/VertexInterpreter.glsl"
;
return s;
}
@ -32,7 +32,7 @@ namespace program_common
static std::string get_fragment_interpreter()
{
const char* s =
#include "Interpreter/FragmentInterpreter.glsl"
#include "../Common/Interpreter/FragmentInterpreter.glsl"
;
return s;
}

View File

@ -1,5 +1,5 @@
#pragma once
#include "Emu/RSX/RSXVertexProgram.h"
#include "RSXVertexProgram.h"
#include <vector>
#include <stack>
#include "ShaderParam.h"

View File

@ -0,0 +1,109 @@
#include "stdafx.h"
#include "program_util.h"
namespace rsx
{
// Convert u16 to u32
static u32 duplicate_and_extend(u16 bits)
{
u32 x = bits;
x = (x | (x << 8)) & 0x00FF00FF;
x = (x | (x << 4)) & 0x0F0F0F0F;
x = (x | (x << 2)) & 0x33333333;
x = (x | (x << 1)) & 0x55555555;
return x | (x << 1);
}
void fragment_program_texture_config::masked_transfer(void* dst, const void* src, u16 mask)
{
// Try to optimize for the very common case (first 4 slots used)
switch (mask)
{
case 0:
return;
case 1:
std::memcpy(dst, src, 16); return;
case 3:
std::memcpy(dst, src, 32); return;
case 7:
std::memcpy(dst, src, 48); return;
case 15:
std::memcpy(dst, src, 64); return;
default:
break;
};
const auto start = std::countr_zero(mask);
const auto end = 16 - std::countl_zero(mask);
const auto mem_offset = (start * 16);
const auto mem_size = (end - start) * 16;
std::memcpy(static_cast<u8*>(dst) + mem_offset, reinterpret_cast<const u8*>(src) + mem_offset, mem_size);
}
void fragment_program_texture_config::write_to(void* dst, u16 mask)
{
masked_transfer(dst, slots_, mask);
}
void fragment_program_texture_config::load_from(const void* src, u16 mask)
{
masked_transfer(slots_, src, mask);
}
void fragment_program_texture_state::clear(u32 index)
{
const u16 clear_mask = ~(static_cast<u16>(1 << index));
unnormalized_coords &= clear_mask;
redirected_textures &= clear_mask;
shadow_textures &= clear_mask;
}
void fragment_program_texture_state::import(const fragment_program_texture_state& other, u16 mask)
{
unnormalized_coords = other.unnormalized_coords & mask;
redirected_textures = other.redirected_textures & mask;
shadow_textures = other.shadow_textures & mask;
texture_dimensions = other.texture_dimensions & duplicate_and_extend(mask);
}
void fragment_program_texture_state::set_dimension(texture_dimension_extended type, u32 index)
{
const auto offset = (index * 2);
const auto mask = 3 << offset;
texture_dimensions &= ~mask;
texture_dimensions |= static_cast<u32>(type) << offset;
}
bool fragment_program_texture_state::operator == (const fragment_program_texture_state& other) const
{
return texture_dimensions == other.texture_dimensions &&
redirected_textures == other.redirected_textures &&
shadow_textures == other.shadow_textures &&
unnormalized_coords == other.unnormalized_coords;
}
void vertex_program_texture_state::clear(u32 /*index*/)
{
// Nothing to do yet
}
void vertex_program_texture_state::import(const vertex_program_texture_state& other, u16 mask)
{
texture_dimensions = other.texture_dimensions & duplicate_and_extend(mask);
}
void vertex_program_texture_state::set_dimension(texture_dimension_extended type, u32 index)
{
const auto offset = (index * 2);
const auto mask = 3 << offset;
texture_dimensions &= ~mask;
texture_dimensions |= static_cast<u32>(type) << offset;
}
bool vertex_program_texture_state::operator == (const vertex_program_texture_state& other) const
{
return texture_dimensions == other.texture_dimensions;
}
}

View File

@ -0,0 +1,55 @@
#pragma once
#include "util/types.hpp"
#include "../gcm_enums.h"
#include <concepts>
namespace rsx
{
#pragma pack(push, 1)
struct fragment_program_texture_config
{
struct TIU_slot
{
float scale_x;
float scale_y;
u32 remap;
u32 control;
}
slots_[16]; // QT headers will collide with any variable named 'slots' because reasons
template <std::integral T>
TIU_slot& operator[](T index) { return slots_[index]; }
void write_to(void* dst, u16 mask);
void load_from(const void* src, u16 mask);
static void masked_transfer(void* dst, const void* src, u16 mask);
};
#pragma pack(pop)
struct fragment_program_texture_state
{
u32 texture_dimensions = 0;
u16 unnormalized_coords = 0;
u16 redirected_textures = 0;
u16 shadow_textures = 0;
u16 reserved = 0;
void clear(u32 index);
void import(const fragment_program_texture_state& other, u16 mask);
void set_dimension(texture_dimension_extended type, u32 index);
bool operator == (const fragment_program_texture_state& other) const;
};
struct vertex_program_texture_state
{
u32 texture_dimensions = 0;
void clear(u32 index);
void import(const vertex_program_texture_state& other, u16 mask);
void set_dimension(texture_dimension_extended type, u32 index);
bool operator == (const vertex_program_texture_state& other) const;
};
}

View File

@ -5,7 +5,6 @@
#include "Emu/Cell/timers.hpp"
#include "Common/BufferUtils.h"
#include "Common/GLSLCommon.h"
#include "Common/texture_cache.h"
#include "Common/surface_store.h"
#include "Capture/rsx_capture.h"
@ -16,6 +15,7 @@
#include "Emu/Cell/lv2/sys_time.h"
#include "Emu/Cell/Modules/cellGcmSys.h"
#include "Overlays/overlay_perf_metrics.h"
#include "Program/GLSLCommon.h"
#include "Utilities/date_time.h"
#include "Utilities/span.h"
#include "Utilities/StrUtil.h"
@ -854,19 +854,6 @@ namespace rsx
stream_vector(dst + 4, 0u, fog_mode, std::bit_cast<u32>(wpos_scale), std::bit_cast<u32>(wpos_bias));
}
void thread::fill_fragment_texture_parameters(void* buffer, const RSXFragmentProgram& fragment_program)
{
// Copy only the relevant section
if (current_fp_metadata.referenced_textures_mask)
{
const auto start = std::countr_zero(current_fp_metadata.referenced_textures_mask);
const auto end = 16 - std::countl_zero(current_fp_metadata.referenced_textures_mask);
const auto mem_offset = (start * 16);
const auto mem_size = (end - start) * 16;
memcpy(static_cast<u8*>(buffer) + mem_offset, reinterpret_cast<const u8*>(fragment_program.texture_scale) + mem_offset, mem_size);
}
}
u64 thread::timestamp()
{
const u64 freq = sys_time_get_timebase_frequency();
@ -1571,6 +1558,7 @@ namespace rsx
current_fragment_program.offset = program_offset + current_fp_metadata.program_start_offset;
current_fragment_program.ucode_length = current_fp_metadata.program_ucode_length;
current_fragment_program.total_length = current_fp_metadata.program_ucode_length + current_fp_metadata.program_start_offset;
current_fragment_program.texture_state.import(current_fp_texture_state, current_fp_metadata.referenced_textures_mask);
current_fragment_program.valid = true;
if (!(m_graphics_state & rsx::pipeline_state::fragment_program_state_dirty))
@ -1610,6 +1598,8 @@ namespace rsx
current_vertex_program // [out] Program object
);
current_vertex_program.texture_state.import(current_vp_texture_state, current_vp_metadata.referenced_textures_mask);
if (!(m_graphics_state & rsx::pipeline_state::vertex_program_state_dirty))
{
// Verify current texture state is valid
@ -1653,9 +1643,12 @@ namespace rsx
const auto &tex = rsx::method_registers.vertex_textures[i];
if (tex.enabled() && (current_vp_metadata.referenced_textures_mask & (1 << i)))
{
current_vertex_program.texture_dimensions |= (static_cast<u32>(sampler_descriptors[i]->image_type) << (i << 1));
current_vp_texture_state.clear(i);
current_vp_texture_state.set_dimension(sampler_descriptors[i]->image_type, i);
}
}
current_vertex_program.texture_state.import(current_vp_texture_state, current_vp_metadata.referenced_textures_mask);
}
void thread::analyse_inputs_interleaved(vertex_input_layout& result) const
@ -1835,13 +1828,7 @@ namespace rsx
current_fragment_program.ctrl = rsx::method_registers.shader_control() & (CELL_GCM_SHADER_CONTROL_32_BITS_EXPORTS | CELL_GCM_SHADER_CONTROL_DEPTH_EXPORT);
current_fragment_program.texcoord_control_mask = rsx::method_registers.texcoord_control_mask();
current_fragment_program.texture_dimensions = 0;
current_fragment_program.unnormalized_coords = 0;
current_fragment_program.two_sided_lighting = rsx::method_registers.two_side_light_en();
current_fragment_program.redirected_textures = 0;
current_fragment_program.shadow_textures = 0;
memset(current_fragment_program.texture_scale, 0, sizeof(current_fragment_program.texture_scale));
if (method_registers.current_draw_clause.primitive == primitive_type::points &&
method_registers.point_sprite_enabled())
@ -1857,14 +1844,15 @@ namespace rsx
auto &tex = rsx::method_registers.fragment_textures[i];
if (tex.enabled())
{
current_fragment_program.texture_scale[i][0] = sampler_descriptors[i]->scale_x;
current_fragment_program.texture_scale[i][1] = sampler_descriptors[i]->scale_y;
current_fragment_program.texture_scale[i][2] = std::bit_cast<f32>(tex.remap());
current_fragment_program.texture_params[i].scale_x = sampler_descriptors[i]->scale_x;
current_fragment_program.texture_params[i].scale_y = sampler_descriptors[i]->scale_y;
current_fragment_program.texture_params[i].remap = tex.remap();
m_graphics_state |= rsx::pipeline_state::fragment_texture_state_dirty;
u32 texture_control = 0;
current_fragment_program.texture_dimensions |= (static_cast<u32>(sampler_descriptors[i]->image_type) << (i << 1));
current_fp_texture_state.clear(i);
current_fp_texture_state.set_dimension(sampler_descriptors[i]->image_type, i);
if (tex.alpha_kill_enabled())
{
@ -1877,7 +1865,7 @@ namespace rsx
const u32 format = raw_format & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN);
if (raw_format & CELL_GCM_TEXTURE_UN)
current_fragment_program.unnormalized_coords |= (1 << i);
current_fp_texture_state.unnormalized_coords |= (1 << i);
if (sampler_descriptors[i]->format_class != RSX_FORMAT_CLASS_COLOR)
{
@ -1897,7 +1885,7 @@ namespace rsx
case CELL_GCM_TEXTURE_D8R8G8B8:
{
// Emulate bitcast in shader
current_fragment_program.redirected_textures |= (1 << i);
current_fp_texture_state.redirected_textures |= (1 << i);
const auto float_en = (sampler_descriptors[i]->format_class == RSX_FORMAT_CLASS_DEPTH24_FLOAT_X8_PACK32)? 1 : 0;
texture_control |= (float_en << texture_control_bits::DEPTH_FLOAT);
break;
@ -1918,7 +1906,7 @@ namespace rsx
compare_mode < rsx::comparison_function::always &&
compare_mode > rsx::comparison_function::never)
{
current_fragment_program.shadow_textures |= (1 << i);
current_fp_texture_state.shadow_textures |= (1 << i);
}
break;
}
@ -1995,10 +1983,13 @@ namespace rsx
#ifdef __APPLE__
texture_control |= (sampler_descriptors[i]->encoded_component_map() << 16);
#endif
current_fragment_program.texture_scale[i][3] = std::bit_cast<f32>(texture_control);
current_fragment_program.texture_params[i].control = texture_control;
}
}
// Update texture configuration
current_fragment_program.texture_state.import(current_fp_texture_state, current_fp_metadata.referenced_textures_mask);
//Sanity checks
if (current_fragment_program.ctrl & CELL_GCM_SHADER_CONTROL_DEPTH_EXPORT)
{

View File

@ -11,10 +11,10 @@
#include "rsx_cache.h"
#include "RSXFIFO.h"
#include "RSXOffload.h"
#include "RSXVertexProgram.h"
#include "RSXFragmentProgram.h"
#include "rsx_utils.h"
#include "Common/texture_cache_types.h"
#include "Program/RSXVertexProgram.h"
#include "Program/RSXFragmentProgram.h"
#include "Utilities/Thread.h"
#include "Utilities/geometry.h"
@ -739,6 +739,9 @@ namespace rsx
RSXVertexProgram current_vertex_program = {};
RSXFragmentProgram current_fragment_program = {};
vertex_program_texture_state current_vp_texture_state = {};
fragment_program_texture_state current_fp_texture_state = {};
// Runs shader prefetch and resolves pipeline status flags
void analyse_current_rsx_pipeline();
@ -911,11 +914,6 @@ namespace rsx
*/
void fill_fragment_state_buffer(void* buffer, const RSXFragmentProgram& fragment_program);
/**
* Fill buffer with fragment texture parameter constants (texture matrix)
*/
void fill_fragment_texture_parameters(void* buffer, const RSXFragmentProgram& fragment_program);
/**
* Notify that a section of memory has been mapped
* If there is a notify_memory_unmapped request on this range yet to be handled,

View File

@ -1,5 +1,5 @@
#pragma once
#include "../Common/GLSLTypes.h"
#include "../Program/GLSLTypes.h"
namespace vk
{

View File

@ -441,7 +441,7 @@ void VKGSRender::bind_texture_env()
::glsl::program_domain::glsl_fragment_program,
m_current_frame->descriptor_set);
if (current_fragment_program.redirected_textures & (1 << i))
if (current_fragment_program.texture_state.redirected_textures & (1 << i))
{
// Stencil mirror required
auto root_image = static_cast<vk::viewable_image*>(view->image());
@ -473,7 +473,7 @@ void VKGSRender::bind_texture_env()
::glsl::program_domain::glsl_fragment_program,
m_current_frame->descriptor_set);
if (current_fragment_program.redirected_textures & (1 << i))
if (current_fragment_program.texture_state.redirected_textures & (1 << i))
{
m_program->bind_uniform({ vk::null_sampler(), vk::null_image_view(*m_current_command_buffer, view_type)->value, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL },
i,

View File

@ -4,7 +4,7 @@
#include "VKHelpers.h"
#include "vkutils/device.h"
#include "Emu/system_config.h"
#include "../Common/GLSLCommon.h"
#include "../Program/GLSLCommon.h"
#include "../GCM.h"
std::string VKFragmentDecompilerThread::getFloatTypeName(usz elementCount)

View File

@ -1,7 +1,6 @@
#pragma once
#include "../Common/FragmentProgramDecompiler.h"
#include "../Common/GLSLTypes.h"
#include "Emu/RSX/RSXFragmentProgram.h"
#include "../Program/FragmentProgramDecompiler.h"
#include "../Program/GLSLTypes.h"
#include "VulkanAPI.h"
#include "VKProgramPipeline.h"
#include "vkutils/pipeline_binding_table.h"

View File

@ -17,7 +17,7 @@
#include "Emu/RSX/rsx_methods.h"
#include "Emu/Memory/vm_locking.h"
#include "../Common/program_state_cache2.hpp"
#include "../Program/program_state_cache2.hpp"
#include "util/asm.hpp"
@ -1655,7 +1655,7 @@ bool VKGSRender::load_program()
// Load current program from buffer
vertex_program.skip_vertex_input_check = true;
fragment_program.unnormalized_coords = 0;
fragment_program.texture_state.unnormalized_coords = 0;
m_program = m_prog_buffer->get_graphics_pipeline(vertex_program, fragment_program, properties,
shadermode != shader_mode::recompiler, true, pipeline_layout);
@ -1791,7 +1791,7 @@ void VKGSRender::load_program_env()
auto mem = m_fragment_texture_params_ring_info.alloc<256>(256);
auto buf = m_fragment_texture_params_ring_info.map(mem, 256);
fill_fragment_texture_parameters(buf, current_fragment_program);
current_fragment_program.texture_params.write_to(buf, current_fp_metadata.referenced_textures_mask);
m_fragment_texture_params_ring_info.unmap();
m_fragment_texture_params_buffer_info = { m_fragment_texture_params_ring_info.heap->value, mem, 256 };
}
@ -1841,7 +1841,7 @@ void VKGSRender::load_program_env()
// Control mask
const auto control_masks = reinterpret_cast<u32*>(fp_buf);
control_masks[0] = rsx::method_registers.shader_control();
control_masks[1] = current_fragment_program.texture_dimensions;
control_masks[1] = current_fragment_program.texture_state.texture_dimensions;
std::memcpy(fp_buf + 16, current_fragment_program.get_data(), current_fragment_program.ucode_length);
m_fragment_instructions_buffer.unmap();

View File

@ -1,9 +1,9 @@
#pragma once
#include "VKVertexProgram.h"
#include "VKFragmentProgram.h"
#include "../Common/ProgramStateCache.h"
#include "VKRenderPass.h"
#include "VKPipelineCompiler.h"
#include "../Program/ProgramStateCache.h"
#include "util/fnv_hash.hpp"

View File

@ -2,7 +2,7 @@
#include "VulkanAPI.h"
#include "VKCommonDecompiler.h"
#include "../Common/GLSLTypes.h"
#include "../Program/GLSLTypes.h"
#include <string>
#include <vector>

View File

@ -4,8 +4,8 @@
#include "VKFragmentProgram.h"
#include "VKGSRender.h"
#include "../Common/GLSLCommon.h"
#include "../Common/ShaderInterpreter.h"
#include "../Program/GLSLCommon.h"
#include "../Program/ShaderInterpreter.h"
#include "../rsx_methods.h"
namespace vk

View File

@ -4,7 +4,7 @@
#include "VKCommonDecompiler.h"
#include "VKHelpers.h"
#include "vkutils/device.h"
#include "../Common/GLSLCommon.h"
#include "../Program/GLSLCommon.h"
std::string VKVertexDecompilerThread::getFloatTypeName(usz elementCount)

View File

@ -1,6 +1,5 @@
#pragma once
#include "../Common/VertexProgramDecompiler.h"
#include "Emu/RSX/RSXVertexProgram.h"
#include "../Program/VertexProgramDecompiler.h"
#include "Utilities/Thread.h"
#include "VulkanAPI.h"
#include "VKProgramPipeline.h"

View File

@ -2,7 +2,7 @@
#include "Utilities/File.h"
#include "Utilities/lockless.h"
#include "Utilities/Thread.h"
#include "Common/ProgramStateCache.h"
#include "Program/ProgramStateCache.h"
#include "Emu/System.h"
#include "Emu/cache_utils.hpp"
#include "Common/texture_cache_checker.h"
@ -358,7 +358,7 @@ namespace rsx
pipeline = data.pipeline_properties;
vp.output_mask = data.vp_ctrl;
vp.texture_dimensions = data.vp_texture_dimensions;
vp.texture_state.texture_dimensions = data.vp_texture_dimensions;
vp.base_address = data.vp_base_address;
vp.entry = data.vp_entry;
@ -377,12 +377,12 @@ namespace rsx
}
fp.ctrl = data.fp_ctrl;
fp.texture_dimensions = data.fp_texture_dimensions;
fp.texture_state.texture_dimensions = data.fp_texture_dimensions;
fp.texture_state.unnormalized_coords = data.fp_unnormalized_coords;
fp.texture_state.shadow_textures = data.fp_shadow_textures;
fp.texture_state.redirected_textures = data.fp_redirected_textures;
fp.texcoord_control_mask = data.fp_texcoord_control;
fp.unnormalized_coords = data.fp_unnormalized_coords;
fp.two_sided_lighting = !!(data.fp_lighting_flags & 0x1);
fp.shadow_textures = data.fp_shadow_textures;
fp.redirected_textures = data.fp_redirected_textures;
return result;
}
@ -396,7 +396,7 @@ namespace rsx
data_block.pipeline_storage_hash = m_storage.get_hash(pipeline);
data_block.vp_ctrl = vp.output_mask;
data_block.vp_texture_dimensions = vp.texture_dimensions;
data_block.vp_texture_dimensions = vp.texture_state.texture_dimensions;
data_block.vp_base_address = vp.base_address;
data_block.vp_entry = vp.entry;
@ -421,12 +421,12 @@ namespace rsx
}
data_block.fp_ctrl = fp.ctrl;
data_block.fp_texture_dimensions = fp.texture_dimensions;
data_block.fp_texture_dimensions = fp.texture_state.texture_dimensions;
data_block.fp_texcoord_control = fp.texcoord_control_mask;
data_block.fp_unnormalized_coords = fp.unnormalized_coords;
data_block.fp_unnormalized_coords = fp.texture_state.unnormalized_coords;
data_block.fp_lighting_flags = u16(fp.two_sided_lighting);
data_block.fp_shadow_textures = fp.shadow_textures;
data_block.fp_redirected_textures = fp.redirected_textures;
data_block.fp_shadow_textures = fp.texture_state.shadow_textures;
data_block.fp_redirected_textures = fp.texture_state.redirected_textures;
return data_block;
}

View File

@ -77,6 +77,8 @@
<ClCompile Include="Emu\RSX\Overlays\overlay_utils.cpp" />
<ClCompile Include="Emu\RSX\Overlays\Shaders\shader_loading_dialog.cpp" />
<ClCompile Include="Emu\RSX\Overlays\Shaders\shader_loading_dialog_native.cpp" />
<ClCompile Include="Emu\RSX\Program\ProgramStateCache.cpp" />
<ClCompile Include="Emu\RSX\Program\program_util.cpp" />
<ClCompile Include="Emu\RSX\RSXDisAsm.cpp" />
<ClCompile Include="Emu\system_config_types.cpp" />
<ClCompile Include="Emu\perf_meter.cpp" />
@ -335,15 +337,14 @@
<ClCompile Include="Emu\Io\usb_device.cpp" />
<ClCompile Include="Emu\RSX\Capture\rsx_capture.cpp" />
<ClCompile Include="Emu\RSX\Capture\rsx_replay.cpp" />
<ClCompile Include="Emu\RSX\CgBinaryFragmentProgram.cpp" />
<ClCompile Include="Emu\RSX\CgBinaryVertexProgram.cpp" />
<ClCompile Include="Emu\RSX\Program\CgBinaryFragmentProgram.cpp" />
<ClCompile Include="Emu\RSX\Program\CgBinaryVertexProgram.cpp" />
<ClCompile Include="Emu\RSX\Common\BufferUtils.cpp" />
<ClCompile Include="Emu\RSX\Common\FragmentProgramDecompiler.cpp" />
<ClCompile Include="Emu\RSX\Common\GLSLCommon.cpp" />
<ClCompile Include="Emu\RSX\Common\ProgramStateCache.cpp" />
<ClCompile Include="Emu\RSX\Program\FragmentProgramDecompiler.cpp" />
<ClCompile Include="Emu\RSX\Program\GLSLCommon.cpp" />
<ClCompile Include="Emu\RSX\Common\surface_store.cpp" />
<ClCompile Include="Emu\RSX\Common\TextureUtils.cpp" />
<ClCompile Include="Emu\RSX\Common\VertexProgramDecompiler.cpp" />
<ClCompile Include="Emu\RSX\Program\VertexProgramDecompiler.cpp" />
<ClCompile Include="Emu\RSX\gcm_printing.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
@ -457,7 +458,10 @@
<ClInclude Include="Emu\NP\np_structs_extra.h" />
<ClInclude Include="Emu\NP\rpcn_client.h" />
<ClInclude Include="Emu\NP\rpcn_config.h" />
<ClInclude Include="Emu\RSX\Common\ShaderInterpreter.h" />
<ClInclude Include="Emu\RSX\Program\GLSLTypes.h" />
<ClInclude Include="Emu\RSX\Program\ProgramStateCache.h" />
<ClInclude Include="Emu\RSX\Program\program_util.h" />
<ClInclude Include="Emu\RSX\Program\ShaderInterpreter.h" />
<ClInclude Include="Emu\RSX\Common\texture_cache_helpers.h" />
<ClInclude Include="Emu\RSX\Common\texture_cache_types.h" />
<ClInclude Include="Emu\RSX\display.h" />
@ -682,7 +686,7 @@
<ClInclude Include="Emu\RSX\Capture\rsx_capture.h" />
<ClInclude Include="Emu\RSX\Capture\rsx_replay.h" />
<ClInclude Include="Emu\RSX\Capture\rsx_trace.h" />
<ClInclude Include="Emu\RSX\Common\GLSLCommon.h" />
<ClInclude Include="Emu\RSX\Program\GLSLCommon.h" />
<ClInclude Include="Emu\RSX\Common\surface_utils.h" />
<ClInclude Include="Emu\RSX\Common\TextGlyphs.h" />
<ClInclude Include="Emu\RSX\Common\texture_cache.h" />
@ -708,23 +712,22 @@
<ClInclude Include="Emu\Io\Null\NullMouseHandler.h" />
<ClInclude Include="Emu\Io\Null\NullPadHandler.h" />
<ClInclude Include="Emu\Io\PadHandler.h" />
<ClInclude Include="Emu\RSX\CgBinaryProgram.h" />
<ClInclude Include="Emu\RSX\Program\CgBinaryProgram.h" />
<ClInclude Include="Emu\RSX\Common\BufferUtils.h" />
<ClInclude Include="Emu\RSX\Common\FragmentProgramDecompiler.h" />
<ClInclude Include="Emu\RSX\Common\ProgramStateCache.h" />
<ClInclude Include="Emu\RSX\Common\program_state_cache2.hpp" />
<ClInclude Include="Emu\RSX\Program\FragmentProgramDecompiler.h" />
<ClInclude Include="Emu\RSX\Program\program_state_cache2.hpp" />
<ClInclude Include="Emu\RSX\Common\ring_buffer_helper.h" />
<ClInclude Include="Emu\RSX\Common\ShaderParam.h" />
<ClInclude Include="Emu\RSX\Program\ShaderParam.h" />
<ClInclude Include="Emu\RSX\Common\surface_store.h" />
<ClInclude Include="Emu\RSX\Common\TextureUtils.h" />
<ClInclude Include="Emu\RSX\Common\VertexProgramDecompiler.h" />
<ClInclude Include="Emu\RSX\Program\VertexProgramDecompiler.h" />
<ClInclude Include="Emu\RSX\GCM.h" />
<ClInclude Include="Emu\RSX\GSRender.h" />
<ClInclude Include="Emu\RSX\Null\NullGSRender.h" />
<ClInclude Include="Emu\RSX\RSXFragmentProgram.h" />
<ClInclude Include="Emu\RSX\Program\RSXFragmentProgram.h" />
<ClInclude Include="Emu\RSX\RSXTexture.h" />
<ClInclude Include="Emu\RSX\RSXThread.h" />
<ClInclude Include="Emu\RSX\RSXVertexProgram.h" />
<ClInclude Include="Emu\RSX\Program\RSXVertexProgram.h" />
<ClInclude Include="Emu\Memory\vm.h" />
<ClInclude Include="Emu\Memory\vm_ptr.h" />
<ClInclude Include="Emu\Memory\vm_ref.h" />

View File

@ -76,6 +76,9 @@
<Filter Include="Emu\Audio\Pulse">
<UniqueIdentifier>{84c0e40e-efb6-4cfd-b2f5-13c720b09105}</UniqueIdentifier>
</Filter>
<Filter Include="Emu\GPU\RSX\Program">
<UniqueIdentifier>{d055ca32-157a-4d8c-895e-29509858fcb0}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Crypto\aes.cpp">
@ -150,9 +153,6 @@
<ClCompile Include="Emu\RSX\RSXThread.cpp">
<Filter>Emu\GPU\RSX</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\CgBinaryFragmentProgram.cpp">
<Filter>Emu\GPU\RSX</Filter>
</ClCompile>
<ClCompile Include="..\Utilities\rXml.cpp">
<Filter>Utilities</Filter>
</ClCompile>
@ -162,9 +162,6 @@
<ClCompile Include="..\Utilities\Thread.cpp">
<Filter>Utilities</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\CgBinaryVertexProgram.cpp">
<Filter>Emu\GPU\RSX</Filter>
</ClCompile>
<ClCompile Include="Emu\Cell\PPUInterpreter.cpp">
<Filter>Emu\Cell</Filter>
</ClCompile>
@ -174,12 +171,6 @@
<ClCompile Include="..\Utilities\File.cpp">
<Filter>Utilities</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\Common\FragmentProgramDecompiler.cpp">
<Filter>Emu\GPU\RSX\Common</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\Common\VertexProgramDecompiler.cpp">
<Filter>Emu\GPU\RSX\Common</Filter>
</ClCompile>
<ClCompile Include="util\vm_native.cpp">
<Filter>Utilities</Filter>
</ClCompile>
@ -198,9 +189,6 @@
<ClCompile Include="Emu\RSX\Common\BufferUtils.cpp">
<Filter>Emu\GPU\RSX\Common</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\Common\GLSLCommon.cpp">
<Filter>Emu\GPU\RSX\Common</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\Null\NullGSRender.cpp">
<Filter>Emu\GPU\RSX\Null</Filter>
</ClCompile>
@ -210,9 +198,6 @@
<ClCompile Include="Emu\RSX\rsx_methods.cpp">
<Filter>Emu\GPU\RSX</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\Common\ProgramStateCache.cpp">
<Filter>Emu\GPU\RSX\Common</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\Common\surface_store.cpp">
<Filter>Emu\GPU\RSX\Common</Filter>
</ClCompile>
@ -990,6 +975,24 @@
<ClCompile Include="stdafx.cpp">
<Filter>Emu</Filter>
</ClCompile>
<ClCompile Include="stb_image.cpp" />
<ClCompile Include="Emu\RSX\Program\FragmentProgramDecompiler.cpp">
<Filter>Emu\GPU\RSX\Program</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\Program\GLSLCommon.cpp">
<Filter>Emu\GPU\RSX\Program</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\Program\VertexProgramDecompiler.cpp">
<Filter>Emu\GPU\RSX\Program</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\Program\CgBinaryFragmentProgram.cpp" />
<ClCompile Include="Emu\RSX\Program\CgBinaryVertexProgram.cpp" />
<ClCompile Include="Emu\RSX\Program\ProgramStateCache.cpp">
<Filter>Emu\GPU\RSX\Program</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\Program\program_util.cpp">
<Filter>Emu\GPU\RSX\Program</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Crypto\aes.h">
@ -1106,8 +1109,8 @@
<ClInclude Include="Emu\RSX\GSRender.h">
<Filter>Emu\GPU\RSX</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\RSXFragmentProgram.h">
<Filter>Emu\GPU\RSX</Filter>
<ClInclude Include="Emu\RSX\Program\RSXFragmentProgram.h">
<Filter>Emu\GPU\RSX\Program</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\RSXTexture.h">
<Filter>Emu\GPU\RSX</Filter>
@ -1115,11 +1118,11 @@
<ClInclude Include="Emu\RSX\RSXThread.h">
<Filter>Emu\GPU\RSX</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\CgBinaryProgram.h">
<Filter>Emu\GPU\RSX</Filter>
<ClInclude Include="Emu\RSX\Program\CgBinaryProgram.h">
<Filter>Emu\GPU\RSX\Program</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\RSXVertexProgram.h">
<Filter>Emu\GPU\RSX</Filter>
<ClInclude Include="Emu\RSX\Program\RSXVertexProgram.h">
<Filter>Emu\GPU\RSX\Program</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\GCM.h">
<Filter>Emu\GPU\RSX</Filter>
@ -1163,21 +1166,6 @@
<ClInclude Include="..\Utilities\File.h">
<Filter>Utilities</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Common\ProgramStateCache.h">
<Filter>Emu\GPU\RSX\Common</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Common\program_state_cache2.hpp">
<Filter>Emu\GPU\RSX\Common</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Common\FragmentProgramDecompiler.h">
<Filter>Emu\GPU\RSX\Common</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Common\ShaderParam.h">
<Filter>Emu\GPU\RSX\Common</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Common\VertexProgramDecompiler.h">
<Filter>Emu\GPU\RSX\Common</Filter>
</ClInclude>
<ClInclude Include="Emu\Cell\Common.h">
<Filter>Emu\Cell</Filter>
</ClInclude>
@ -1634,9 +1622,6 @@
<ClInclude Include="util\sysinfo.hpp">
<Filter>Utilities</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Common\GLSLCommon.h">
<Filter>Emu\GPU\RSX\Common</Filter>
</ClInclude>
<ClInclude Include="util\fnv_hash.hpp">
<Filter>Utilities</Filter>
</ClInclude>
@ -1859,9 +1844,6 @@
<ClInclude Include="util\cpu_stats.hpp">
<Filter>Utilities</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Common\ShaderInterpreter.h">
<Filter>Emu\GPU\RSX\Common</Filter>
</ClInclude>
<ClInclude Include="Emu\Audio\FAudio\FAudioBackend.h">
<Filter>Emu\Audio\FAudio</Filter>
</ClInclude>
@ -1940,6 +1922,34 @@
<ClInclude Include="Emu\Cell\timers.hpp">
<Filter>Emu</Filter>
</ClInclude>
<ClInclude Include="..\3rdparty\stblib\include\stb_image.h" />
<ClInclude Include="Emu\RSX\Program\FragmentProgramDecompiler.h">
<Filter>Emu\GPU\RSX\Program</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Program\GLSLCommon.h">
<Filter>Emu\GPU\RSX\Program</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Program\program_state_cache2.hpp">
<Filter>Emu\GPU\RSX\Program</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Program\program_util.h">
<Filter>Emu\GPU\RSX\Program</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Program\ShaderInterpreter.h">
<Filter>Emu\GPU\RSX\Program</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Program\ShaderParam.h">
<Filter>Emu\GPU\RSX\Program</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Program\VertexProgramDecompiler.h">
<Filter>Emu\GPU\RSX\Program</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Program\GLSLTypes.h">
<Filter>Emu\GPU\RSX\Program</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Program\ProgramStateCache.h">
<Filter>Emu\GPU\RSX\Program</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="Emu\RSX\Common\Interpreter\FragmentInterpreter.glsl">

View File

@ -9,7 +9,7 @@
#include <QFontDatabase>
#include <QMimeData>
#include "Emu/RSX/CgBinaryProgram.h"
#include "Emu/RSX/Program/CgBinaryProgram.h"
LOG_CHANNEL(gui_log, "GUI");