2019-05-11 10:58:45 +02:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
#include "OpenGL.h"
|
2016-03-30 18:55:43 +02:00
|
|
|
|
#include "../GCM.h"
|
2017-09-08 16:52:13 +02:00
|
|
|
|
#include "../Common/TextureUtils.h"
|
2018-04-07 17:16:52 +02:00
|
|
|
|
#include "GLHelpers.h"
|
2015-12-21 03:14:56 +01:00
|
|
|
|
|
|
|
|
|
|
namespace rsx
|
|
|
|
|
|
{
|
2016-06-28 11:58:44 +02:00
|
|
|
|
class vertex_texture;
|
2016-09-19 03:25:49 +02:00
|
|
|
|
class fragment_texture;
|
2017-03-29 21:27:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace gl
|
|
|
|
|
|
{
|
2019-10-02 02:47:19 +02:00
|
|
|
|
struct pixel_buffer_layout
|
|
|
|
|
|
{
|
|
|
|
|
|
GLenum format;
|
|
|
|
|
|
GLenum type;
|
|
|
|
|
|
u8 size;
|
|
|
|
|
|
bool swap_bytes;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2018-01-31 17:11:03 +01:00
|
|
|
|
GLenum get_target(rsx::texture_dimension_extended type);
|
2019-06-08 08:22:09 +02:00
|
|
|
|
GLenum get_sized_internal_format(u32 texture_format);
|
2017-03-29 21:27:29 +02:00
|
|
|
|
std::tuple<GLenum, GLenum> get_format_type(u32 texture_format);
|
2019-10-02 02:47:19 +02:00
|
|
|
|
pixel_buffer_layout get_format_type(texture::internal_format format);
|
2017-03-29 21:27:29 +02:00
|
|
|
|
GLenum wrap_mode(rsx::texture_wrap_mode wrap);
|
|
|
|
|
|
float max_aniso(rsx::texture_max_anisotropy aniso);
|
2017-12-07 13:08:11 +01:00
|
|
|
|
std::array<GLenum, 4> get_swizzle_remap(u32 texture_format);
|
2017-03-29 21:27:29 +02:00
|
|
|
|
|
2018-07-17 18:42:51 +02:00
|
|
|
|
viewable_image* create_texture(u32 gcm_format, u16 width, u16 height, u16 depth, u16 mipmaps, rsx::texture_dimension_extended type);
|
2017-09-08 16:52:13 +02:00
|
|
|
|
|
2019-04-05 13:39:43 +02:00
|
|
|
|
bool formats_are_bitcast_compatible(GLenum format1, GLenum format2);
|
2019-10-12 00:05:05 +02:00
|
|
|
|
void copy_typeless(texture* dst, const texture* src, const coord3u& dst_region, const coord3u& src_region);
|
2018-04-07 17:16:52 +02:00
|
|
|
|
void copy_typeless(texture* dst, const texture* src);
|
2019-10-12 00:05:05 +02:00
|
|
|
|
|
2017-09-14 13:37:14 +02:00
|
|
|
|
/**
|
|
|
|
|
|
* is_swizzled - determines whether input bytes are in morton order
|
|
|
|
|
|
* subresources_layout - descriptor of the mipmap levels in memory
|
|
|
|
|
|
* decoded_remap - two vectors, first one contains index to read, e.g if v[0] = 1 then component 0[A] in the texture should read as component 1[R]
|
|
|
|
|
|
* - layout of vector is in A-R-G-B
|
|
|
|
|
|
* - second vector contains overrides to force the value to either 0 or 1 instead of reading from texture
|
|
|
|
|
|
* static_state - set up the texture without consideration for sampler state (useful for vertex textures which have no real sampler state on RSX)
|
|
|
|
|
|
*/
|
2018-12-13 11:23:58 +01:00
|
|
|
|
void upload_texture(GLuint id, u32 gcm_format, u16 width, u16 height, u16 depth, u16 mipmaps, bool is_swizzled, rsx::texture_dimension_extended type,
|
2018-07-17 18:42:51 +02:00
|
|
|
|
const std::vector<rsx_subresource_layout>& subresources_layout);
|
2017-09-08 16:52:13 +02:00
|
|
|
|
|
2017-03-29 21:27:29 +02:00
|
|
|
|
class sampler_state
|
|
|
|
|
|
{
|
|
|
|
|
|
GLuint samplerHandle = 0;
|
2019-06-18 15:49:01 +02:00
|
|
|
|
std::unordered_map<GLenum, GLuint> m_propertiesi;
|
|
|
|
|
|
std::unordered_map<GLenum, GLfloat> m_propertiesf;
|
2017-03-29 21:27:29 +02:00
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
void create()
|
|
|
|
|
|
{
|
|
|
|
|
|
glGenSamplers(1, &samplerHandle);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void remove()
|
|
|
|
|
|
{
|
|
|
|
|
|
glDeleteSamplers(1, &samplerHandle);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-02-04 14:42:43 +01:00
|
|
|
|
void bind(int index) const
|
2017-03-29 21:27:29 +02:00
|
|
|
|
{
|
|
|
|
|
|
glBindSampler(index, samplerHandle);
|
|
|
|
|
|
}
|
2015-12-21 03:14:56 +01:00
|
|
|
|
|
2019-06-18 15:49:01 +02:00
|
|
|
|
void set_parameteri(GLenum pname, GLuint value)
|
|
|
|
|
|
{
|
|
|
|
|
|
auto prop = m_propertiesi.find(pname);
|
|
|
|
|
|
if (prop != m_propertiesi.end() &&
|
|
|
|
|
|
prop->second == value)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_propertiesi[pname] = value;
|
|
|
|
|
|
glSamplerParameteri(samplerHandle, pname, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void set_parameterf(GLenum pname, GLfloat value)
|
|
|
|
|
|
{
|
|
|
|
|
|
auto prop = m_propertiesf.find(pname);
|
|
|
|
|
|
if (prop != m_propertiesf.end() &&
|
|
|
|
|
|
prop->second == value)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_propertiesf[pname] = value;
|
|
|
|
|
|
glSamplerParameterf(samplerHandle, pname, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GLuint get_parameteri(GLenum pname)
|
|
|
|
|
|
{
|
|
|
|
|
|
auto prop = m_propertiesi.find(pname);
|
|
|
|
|
|
return (prop == m_propertiesi.end()) ? 0 : prop->second;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GLfloat get_parameterf(GLenum pname)
|
|
|
|
|
|
{
|
|
|
|
|
|
auto prop = m_propertiesf.find(pname);
|
|
|
|
|
|
return (prop == m_propertiesf.end()) ? 0 : prop->second;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-09 20:31:31 +02:00
|
|
|
|
void apply(const rsx::fragment_texture& tex, const rsx::sampled_image_descriptor_base* sampled_image);
|
|
|
|
|
|
void apply(const rsx::vertex_texture& tex, const rsx::sampled_image_descriptor_base* sampled_image);
|
2018-11-24 13:54:46 +01:00
|
|
|
|
|
2019-02-04 14:42:43 +01:00
|
|
|
|
void apply_defaults(GLenum default_filter = GL_NEAREST);
|
2017-03-29 21:27:29 +02:00
|
|
|
|
};
|
2019-10-12 00:05:05 +02:00
|
|
|
|
|
|
|
|
|
|
extern buffer g_typeless_transfer_buffer;
|
2017-03-29 21:27:29 +02:00
|
|
|
|
}
|