2020-12-05 13:08:24 +01:00
|
|
|
#pragma once
|
2019-05-11 10:58:45 +02:00
|
|
|
|
|
|
|
|
#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
|
|
|
|
2020-12-22 16:04:08 +01:00
|
|
|
#include <unordered_map>
|
|
|
|
|
|
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;
|
|
|
|
|
};
|
|
|
|
|
|
2020-09-06 17:17:08 +02:00
|
|
|
struct image_memory_requirements
|
|
|
|
|
{
|
|
|
|
|
u64 image_size_in_texels;
|
|
|
|
|
u64 image_size_in_bytes;
|
|
|
|
|
u64 memory_required;
|
|
|
|
|
};
|
|
|
|
|
|
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
|
|
|
|
2022-01-25 19:53:53 +01:00
|
|
|
bool formats_are_bitcast_compatible(const texture* texture1, const texture* texture2);
|
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
|
|
|
|
2020-09-06 17:17:08 +02:00
|
|
|
void* copy_image_to_buffer(const pixel_buffer_layout& pack_info, const gl::texture* src, gl::buffer* dst,
|
|
|
|
|
const int src_level, const coord3u& src_region, image_memory_requirements* mem_info);
|
|
|
|
|
|
|
|
|
|
void copy_buffer_to_image(const pixel_buffer_layout& unpack_info, gl::buffer* src, gl::texture* dst,
|
|
|
|
|
const void* src_offset, const int dst_level, const coord3u& dst_region, image_memory_requirements* mem_info);
|
|
|
|
|
|
|
|
|
|
void upload_texture(texture* dst, u32 gcm_format, bool is_swizzled, 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
|
|
|
|
2021-06-05 16:27:03 +02:00
|
|
|
namespace debug
|
|
|
|
|
{
|
|
|
|
|
extern std::unique_ptr<texture> g_vis_texture;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-12 00:05:05 +02:00
|
|
|
extern buffer g_typeless_transfer_buffer;
|
2017-03-29 21:27:29 +02:00
|
|
|
}
|