mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 03:32:55 +00:00
rsx: Add a base class for vertex programs and implement range intersection for constant IDs
This commit is contained in:
parent
cc313bfba1
commit
b0375d9c9a
@ -50,17 +50,14 @@ public:
|
|||||||
void Task();
|
void Task();
|
||||||
};
|
};
|
||||||
|
|
||||||
class GLVertexProgram
|
class GLVertexProgram : public rsx::VertexProgramBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GLVertexProgram();
|
GLVertexProgram();
|
||||||
~GLVertexProgram();
|
~GLVertexProgram();
|
||||||
|
|
||||||
ParamArray parr;
|
ParamArray parr;
|
||||||
u32 id;
|
|
||||||
gl::glsl::shader shader;
|
gl::glsl::shader shader;
|
||||||
std::vector<u16> constant_ids;
|
|
||||||
bool has_indexed_constants;
|
|
||||||
|
|
||||||
void Decompile(const RSXVertexProgram& prog);
|
void Decompile(const RSXVertexProgram& prog);
|
||||||
|
|
||||||
|
@ -139,4 +139,4 @@ public:
|
|||||||
|
|
||||||
VertexProgramDecompiler(const RSXVertexProgram& prog);
|
VertexProgramDecompiler(const RSXVertexProgram& prog);
|
||||||
std::string Decompile();
|
std::string Decompile();
|
||||||
};
|
};
|
||||||
|
@ -109,4 +109,52 @@ namespace rsx
|
|||||||
return texture_dimensions == other.texture_dimensions &&
|
return texture_dimensions == other.texture_dimensions &&
|
||||||
multisampled_textures == other.multisampled_textures;
|
multisampled_textures == other.multisampled_textures;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int VertexProgramBase::TranslateConstantsRange(int first_index, int count) const
|
||||||
|
{
|
||||||
|
// The constant ids should be sorted, so just find the first one and check for continuity
|
||||||
|
int index = -1;
|
||||||
|
int next = first_index;
|
||||||
|
int last = first_index + count - 1;
|
||||||
|
|
||||||
|
// Early rejection test
|
||||||
|
if (constant_ids.empty() || first_index > constant_ids.back() || last < first_index)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < constant_ids.size(); ++i)
|
||||||
|
{
|
||||||
|
if (constant_ids[i] > first_index && index < 0)
|
||||||
|
{
|
||||||
|
// No chance of a match
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (constant_ids[i] == next)
|
||||||
|
{
|
||||||
|
// Index matched
|
||||||
|
if (index < 0)
|
||||||
|
{
|
||||||
|
index = static_cast<int>(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (last == next++)
|
||||||
|
{
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index >= 0)
|
||||||
|
{
|
||||||
|
// Previously matched but no more
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OOB or partial match
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,4 +57,16 @@ namespace rsx
|
|||||||
void set_dimension(texture_dimension_extended type, u32 index);
|
void set_dimension(texture_dimension_extended type, u32 index);
|
||||||
bool operator == (const vertex_program_texture_state& other) const;
|
bool operator == (const vertex_program_texture_state& other) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct VertexProgramBase
|
||||||
|
{
|
||||||
|
u32 id;
|
||||||
|
std::vector<u16> constant_ids;
|
||||||
|
bool has_indexed_constants;
|
||||||
|
|
||||||
|
// Translates an incoming range of constants against our mapping.
|
||||||
|
// If there is no linear mapping available, return -1, otherwise returns the translated index of the first slot
|
||||||
|
// TODO: Move this somewhere else during refactor
|
||||||
|
int TranslateConstantsRange(int first_index, int count) const;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public:
|
|||||||
const std::vector<vk::glsl::program_input>& get_inputs() { return inputs; }
|
const std::vector<vk::glsl::program_input>& get_inputs() { return inputs; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class VKVertexProgram
|
class VKVertexProgram : public rsx::VertexProgramBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VKVertexProgram();
|
VKVertexProgram();
|
||||||
@ -60,11 +60,8 @@ public:
|
|||||||
|
|
||||||
ParamArray parr;
|
ParamArray parr;
|
||||||
VkShaderModule handle = nullptr;
|
VkShaderModule handle = nullptr;
|
||||||
u32 id;
|
|
||||||
vk::glsl::shader shader;
|
vk::glsl::shader shader;
|
||||||
std::vector<vk::glsl::program_input> uniforms;
|
std::vector<vk::glsl::program_input> uniforms;
|
||||||
std::vector<u16> constant_ids;
|
|
||||||
bool has_indexed_constants;
|
|
||||||
|
|
||||||
void Decompile(const RSXVertexProgram& prog);
|
void Decompile(const RSXVertexProgram& prog);
|
||||||
void Compile();
|
void Compile();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user