2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:29:41 +00:00
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-02-21 13:53:26 +00:00
|
|
|
// Fast image conversion using OpenGL shaders.
|
|
|
|
|
2017-02-01 04:29:29 +00:00
|
|
|
#include "VideoBackends/OGL/TextureConverter.h"
|
|
|
|
|
2014-06-03 05:08:54 +00:00
|
|
|
#include <string>
|
|
|
|
|
2017-02-01 15:56:13 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Common/FileUtil.h"
|
2017-02-01 15:56:13 +00:00
|
|
|
#include "Common/Logging/Log.h"
|
2017-02-01 04:29:29 +00:00
|
|
|
#include "Common/MsgHandler.h"
|
2014-06-03 05:08:54 +00:00
|
|
|
#include "Common/StringUtil.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
|
|
|
|
#include "Core/HW/Memmap.h"
|
|
|
|
|
|
|
|
#include "VideoBackends/OGL/FramebufferManager.h"
|
|
|
|
#include "VideoBackends/OGL/ProgramShaderCache.h"
|
|
|
|
#include "VideoBackends/OGL/Render.h"
|
2015-05-28 22:53:07 +00:00
|
|
|
#include "VideoBackends/OGL/SamplerCache.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoBackends/OGL/TextureCache.h"
|
|
|
|
|
|
|
|
#include "VideoCommon/ImageWrite.h"
|
|
|
|
#include "VideoCommon/TextureConversionShader.h"
|
2016-07-21 23:04:57 +00:00
|
|
|
#include "VideoCommon/VideoCommon.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/VideoConfig.h"
|
|
|
|
|
2011-01-29 20:16:51 +00:00
|
|
|
namespace OGL
|
|
|
|
{
|
2008-12-08 05:25:12 +00:00
|
|
|
namespace TextureConverter
|
|
|
|
{
|
2010-10-19 22:24:27 +00:00
|
|
|
using OGL::TextureCache;
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
static GLuint s_texConvFrameBuffer[2] = {0, 0};
|
|
|
|
static GLuint s_srcTexture = 0; // for decoding from RAM
|
|
|
|
static GLuint s_dstTexture = 0; // for encoding to RAM
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2015-01-26 07:32:32 +00:00
|
|
|
const int renderBufferWidth = EFB_WIDTH * 4;
|
2008-12-08 05:25:12 +00:00
|
|
|
const int renderBufferHeight = 1024;
|
|
|
|
|
2013-02-13 12:12:19 +00:00
|
|
|
static SHADER s_rgbToYuyvProgram;
|
2013-11-25 12:03:35 +00:00
|
|
|
static int s_rgbToYuyvUniform_loc;
|
|
|
|
|
2013-02-13 12:12:19 +00:00
|
|
|
static SHADER s_yuyvToRgbProgram;
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2017-04-04 13:55:36 +00:00
|
|
|
struct EncodingProgram
|
|
|
|
{
|
|
|
|
SHADER program;
|
|
|
|
GLint copy_position_uniform;
|
|
|
|
};
|
|
|
|
static std::map<EFBCopyFormat, EncodingProgram> s_encoding_programs;
|
2009-01-11 22:25:57 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
static GLuint s_PBO = 0; // for readback with different strides
|
2013-11-26 19:05:49 +00:00
|
|
|
|
2014-05-03 21:24:42 +00:00
|
|
|
static void CreatePrograms()
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
/* TODO: Accuracy Improvements
|
|
|
|
*
|
|
|
|
* This shader doesn't really match what the GameCube does internally in the
|
|
|
|
* copy pipeline.
|
|
|
|
* 1. It uses OpenGL's built in filtering when yscaling, someone could work
|
|
|
|
* out how the copypipeline does it's filtering and implement it correctly
|
|
|
|
* in this shader.
|
|
|
|
* 2. Deflickering isn't implemented, a futher filtering over 3 lines.
|
|
|
|
* Isn't really needed on non-interlaced monitors (and would lower quality;
|
|
|
|
* But hey, accuracy!)
|
|
|
|
* 3. Flipper's YUYV conversion implements a 3 pixel horizontal blur on the
|
|
|
|
* UV channels, centering the U channel on the Left pixel and the V channel
|
|
|
|
* on the Right pixel.
|
|
|
|
* The current implementation Centers both UV channels at the same place
|
|
|
|
* inbetween the two Pixels, and only blurs over these two pixels.
|
|
|
|
*/
|
|
|
|
// Output is BGRA because that is slightly faster than RGBA.
|
|
|
|
const char* VProgramRgbToYuyv =
|
|
|
|
"out vec2 uv0;\n"
|
|
|
|
"uniform vec4 copy_position;\n" // left, top, right, bottom
|
|
|
|
"SAMPLER_BINDING(9) uniform sampler2DArray samp9;\n"
|
|
|
|
"void main()\n"
|
|
|
|
"{\n"
|
|
|
|
" vec2 rawpos = vec2(gl_VertexID&1, gl_VertexID&2);\n"
|
|
|
|
" gl_Position = vec4(rawpos*2.0-1.0, 0.0, 1.0);\n"
|
|
|
|
" uv0 = mix(copy_position.xy, copy_position.zw, rawpos) / vec2(textureSize(samp9, 0).xy);\n"
|
|
|
|
"}\n";
|
|
|
|
const char* FProgramRgbToYuyv =
|
|
|
|
"SAMPLER_BINDING(9) uniform sampler2DArray samp9;\n"
|
|
|
|
"in vec2 uv0;\n"
|
|
|
|
"out vec4 ocol0;\n"
|
|
|
|
"void main()\n"
|
|
|
|
"{\n"
|
|
|
|
" vec3 c0 = texture(samp9, vec3(uv0 - dFdx(uv0) * 0.25, 0.0)).rgb;\n"
|
|
|
|
" vec3 c1 = texture(samp9, vec3(uv0 + dFdx(uv0) * 0.25, 0.0)).rgb;\n"
|
|
|
|
" vec3 c01 = (c0 + c1) * 0.5;\n"
|
|
|
|
" vec3 y_const = vec3(0.257,0.504,0.098);\n"
|
|
|
|
" vec3 u_const = vec3(-0.148,-0.291,0.439);\n"
|
|
|
|
" vec3 v_const = vec3(0.439,-0.368,-0.071);\n"
|
|
|
|
" vec4 const3 = vec4(0.0625,0.5,0.0625,0.5);\n"
|
|
|
|
" ocol0 = vec4(dot(c1,y_const),dot(c01,u_const),dot(c0,y_const),dot(c01, v_const)) + "
|
|
|
|
"const3;\n"
|
|
|
|
"}\n";
|
|
|
|
ProgramShaderCache::CompileShader(s_rgbToYuyvProgram, VProgramRgbToYuyv, FProgramRgbToYuyv);
|
|
|
|
s_rgbToYuyvUniform_loc = glGetUniformLocation(s_rgbToYuyvProgram.glprogid, "copy_position");
|
|
|
|
|
|
|
|
/* TODO: Accuracy Improvements
|
|
|
|
*
|
|
|
|
* The YVYU to RGB conversion here matches the RGB to YUYV done above, but
|
|
|
|
* if a game modifies or adds images to the XFB then it should be using the
|
|
|
|
* same algorithm as the flipper, and could result in slight color inaccuracies
|
|
|
|
* when run back through this shader.
|
|
|
|
*/
|
|
|
|
const char* VProgramYuyvToRgb = "void main()\n"
|
|
|
|
"{\n"
|
|
|
|
" vec2 rawpos = vec2(gl_VertexID&1, gl_VertexID&2);\n"
|
|
|
|
" gl_Position = vec4(rawpos*2.0-1.0, 0.0, 1.0);\n"
|
|
|
|
"}\n";
|
|
|
|
const char* FProgramYuyvToRgb = "SAMPLER_BINDING(9) uniform sampler2D samp9;\n"
|
|
|
|
"in vec2 uv0;\n"
|
|
|
|
"out vec4 ocol0;\n"
|
|
|
|
"void main()\n"
|
|
|
|
"{\n"
|
|
|
|
" ivec2 uv = ivec2(gl_FragCoord.xy);\n"
|
|
|
|
// We switch top/bottom here. TODO: move this to screen blit.
|
|
|
|
" ivec2 ts = textureSize(samp9, 0);\n"
|
|
|
|
" vec4 c0 = texelFetch(samp9, ivec2(uv.x>>1, ts.y-uv.y-1), 0);\n"
|
|
|
|
" float y = mix(c0.r, c0.b, (uv.x & 1) == 1);\n"
|
|
|
|
" float yComp = 1.164 * (y - 0.0625);\n"
|
|
|
|
" float uComp = c0.g - 0.5;\n"
|
|
|
|
" float vComp = c0.a - 0.5;\n"
|
|
|
|
" ocol0 = vec4(yComp + (1.596 * vComp),\n"
|
|
|
|
" yComp - (0.813 * vComp) - (0.391 * uComp),\n"
|
|
|
|
" yComp + (2.018 * uComp),\n"
|
|
|
|
" 1.0);\n"
|
|
|
|
"}\n";
|
|
|
|
ProgramShaderCache::CompileShader(s_yuyvToRgbProgram, VProgramYuyvToRgb, FProgramYuyvToRgb);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2017-04-04 13:55:36 +00:00
|
|
|
static EncodingProgram& GetOrCreateEncodingShader(const EFBCopyFormat& format)
|
2009-01-11 22:25:57 +00:00
|
|
|
{
|
2017-04-04 13:55:36 +00:00
|
|
|
auto iter = s_encoding_programs.find(format);
|
|
|
|
if (iter != s_encoding_programs.end())
|
|
|
|
return iter->second;
|
2009-01-11 22:25:57 +00:00
|
|
|
|
2017-04-04 13:55:36 +00:00
|
|
|
const char* shader = TextureConversionShader::GenerateEncodingShader(format, APIType::OpenGL);
|
2009-01-11 22:25:57 +00:00
|
|
|
|
|
|
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
2017-04-04 13:55:36 +00:00
|
|
|
if (g_ActiveConfig.iLog & CONF_SAVESHADERS && shader)
|
|
|
|
{
|
|
|
|
static int counter = 0;
|
|
|
|
std::string filename =
|
|
|
|
StringFromFormat("%senc_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), counter++);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2017-04-04 13:55:36 +00:00
|
|
|
SaveData(filename, shader);
|
|
|
|
}
|
2009-01-11 22:25:57 +00:00
|
|
|
#endif
|
|
|
|
|
2017-04-04 13:55:36 +00:00
|
|
|
const char* VProgram = "void main()\n"
|
|
|
|
"{\n"
|
|
|
|
" vec2 rawpos = vec2(gl_VertexID&1, gl_VertexID&2);\n"
|
|
|
|
" gl_Position = vec4(rawpos*2.0-1.0, 0.0, 1.0);\n"
|
|
|
|
"}\n";
|
2013-11-25 14:01:18 +00:00
|
|
|
|
2017-04-04 13:55:36 +00:00
|
|
|
EncodingProgram program;
|
|
|
|
if (!ProgramShaderCache::CompileShader(program.program, VProgram, shader))
|
|
|
|
PanicAlert("Failed to compile texture encoding shader.");
|
2014-01-05 08:52:26 +00:00
|
|
|
|
2017-04-04 13:55:36 +00:00
|
|
|
program.copy_position_uniform = glGetUniformLocation(program.program.glprogid, "position");
|
|
|
|
return s_encoding_programs.emplace(format, program).first->second;
|
2009-01-11 22:25:57 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
void Init()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
glGenFramebuffers(2, s_texConvFrameBuffer);
|
2013-08-20 13:11:03 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
glActiveTexture(GL_TEXTURE9);
|
|
|
|
glGenTextures(1, &s_srcTexture);
|
|
|
|
glBindTexture(GL_TEXTURE_2D, s_srcTexture);
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
2014-03-29 10:05:44 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
glGenTextures(1, &s_dstTexture);
|
|
|
|
glBindTexture(GL_TEXTURE_2D, s_dstTexture);
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, renderBufferWidth, renderBufferHeight, 0, GL_RGBA,
|
|
|
|
GL_UNSIGNED_BYTE, nullptr);
|
2014-03-29 10:05:44 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
FramebufferManager::SetFramebuffer(s_texConvFrameBuffer[0]);
|
|
|
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, s_dstTexture, 0);
|
|
|
|
FramebufferManager::SetFramebuffer(0);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
glGenBuffers(1, &s_PBO);
|
2013-11-26 19:05:49 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
CreatePrograms();
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Shutdown()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
glDeleteTextures(1, &s_srcTexture);
|
|
|
|
glDeleteTextures(1, &s_dstTexture);
|
|
|
|
glDeleteBuffers(1, &s_PBO);
|
|
|
|
glDeleteFramebuffers(2, s_texConvFrameBuffer);
|
|
|
|
|
|
|
|
s_rgbToYuyvProgram.Destroy();
|
|
|
|
s_yuyvToRgbProgram.Destroy();
|
|
|
|
|
2017-04-04 13:55:36 +00:00
|
|
|
for (auto& program : s_encoding_programs)
|
|
|
|
program.second.program.Destroy();
|
|
|
|
s_encoding_programs.clear();
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
s_srcTexture = 0;
|
|
|
|
s_dstTexture = 0;
|
|
|
|
s_PBO = 0;
|
|
|
|
s_texConvFrameBuffer[0] = 0;
|
|
|
|
s_texConvFrameBuffer[1] = 0;
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2015-07-07 13:09:25 +00:00
|
|
|
// dst_line_size, writeStride in bytes
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
static void EncodeToRamUsingShader(GLuint srcTexture, u8* destAddr, u32 dst_line_size,
|
|
|
|
u32 dstHeight, u32 writeStride, bool linearFilter)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
// switch to texture converter frame buffer
|
|
|
|
// attach render buffer as color destination
|
|
|
|
FramebufferManager::SetFramebuffer(s_texConvFrameBuffer[0]);
|
|
|
|
|
|
|
|
OpenGL_BindAttributelessVAO();
|
|
|
|
|
|
|
|
// set source texture
|
|
|
|
glActiveTexture(GL_TEXTURE9);
|
|
|
|
glBindTexture(GL_TEXTURE_2D_ARRAY, srcTexture);
|
|
|
|
|
2016-09-06 23:17:32 +00:00
|
|
|
// We also linear filtering for both box filtering and downsampling higher resolutions to 1x
|
|
|
|
// TODO: This only produces perfect downsampling for 1.5x and 2x IR, other resolution will
|
|
|
|
// need more complex down filtering to average all pixels and produce the correct result.
|
|
|
|
// Also, box filtering won't be correct for anything other than 1x IR
|
|
|
|
if (linearFilter || g_ActiveConfig.iEFBScale != SCALE_1X)
|
2016-06-24 08:43:46 +00:00
|
|
|
g_sampler_cache->BindLinearSampler(9);
|
|
|
|
else
|
|
|
|
g_sampler_cache->BindNearestSampler(9);
|
|
|
|
|
|
|
|
glViewport(0, 0, (GLsizei)(dst_line_size / 4), (GLsizei)dstHeight);
|
|
|
|
|
|
|
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
|
|
|
|
|
|
int dstSize = dst_line_size * dstHeight;
|
|
|
|
|
2016-12-09 08:14:16 +00:00
|
|
|
// When the dst_line_size and writeStride are the same, we could use glReadPixels directly to RAM.
|
|
|
|
// But instead we always copy the data via a PBO, because macOS inexplicably prefers this (most
|
|
|
|
// noticeably in the Super Mario Sunshine transition).
|
|
|
|
glBindBuffer(GL_PIXEL_PACK_BUFFER, s_PBO);
|
|
|
|
glBufferData(GL_PIXEL_PACK_BUFFER, dstSize, nullptr, GL_STREAM_READ);
|
|
|
|
glReadPixels(0, 0, (GLsizei)(dst_line_size / 4), (GLsizei)dstHeight, GL_BGRA, GL_UNSIGNED_BYTE,
|
|
|
|
nullptr);
|
|
|
|
u8* pbo = (u8*)glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0, dstSize, GL_MAP_READ_BIT);
|
|
|
|
|
|
|
|
if (dst_line_size == writeStride)
|
|
|
|
{
|
|
|
|
memcpy(destAddr, pbo, dst_line_size * dstHeight);
|
|
|
|
}
|
|
|
|
else
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
|
|
|
for (size_t i = 0; i < dstHeight; ++i)
|
|
|
|
{
|
|
|
|
memcpy(destAddr, pbo, dst_line_size);
|
|
|
|
pbo += dst_line_size;
|
|
|
|
destAddr += writeStride;
|
|
|
|
}
|
|
|
|
}
|
2016-12-09 08:14:16 +00:00
|
|
|
|
|
|
|
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
|
|
|
|
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2017-04-04 13:55:36 +00:00
|
|
|
void EncodeToRamFromTexture(u8* dest_ptr, const EFBCopyFormat& format, u32 native_width,
|
|
|
|
u32 bytes_per_row, u32 num_blocks_y, u32 memory_stride,
|
|
|
|
bool is_depth_copy, const EFBRectangle& src_rect, bool scale_by_half)
|
2010-07-12 19:30:25 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
g_renderer->ResetAPIState();
|
2015-10-29 07:45:17 +00:00
|
|
|
|
2017-04-04 13:55:36 +00:00
|
|
|
EncodingProgram& texconv_shader = GetOrCreateEncodingShader(format);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2017-04-04 13:55:36 +00:00
|
|
|
texconv_shader.program.Bind();
|
|
|
|
glUniform4i(texconv_shader.copy_position_uniform, src_rect.left, src_rect.top, native_width,
|
|
|
|
scale_by_half ? 2 : 1);
|
2010-12-20 17:06:39 +00:00
|
|
|
|
2017-04-04 13:55:36 +00:00
|
|
|
const GLuint read_texture = is_depth_copy ?
|
|
|
|
FramebufferManager::ResolveAndGetDepthTarget(src_rect) :
|
|
|
|
FramebufferManager::ResolveAndGetRenderTarget(src_rect);
|
2015-10-29 07:45:17 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
EncodeToRamUsingShader(read_texture, dest_ptr, bytes_per_row, num_blocks_y, memory_stride,
|
2017-04-04 13:55:36 +00:00
|
|
|
scale_by_half && !is_depth_copy);
|
2015-10-29 07:45:17 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
FramebufferManager::SetFramebuffer(0);
|
|
|
|
g_renderer->RestoreAPIState();
|
2009-01-11 22:25:57 +00:00
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
void EncodeToRamYUYV(GLuint srcTexture, const TargetRectangle& sourceRc, u8* destAddr, u32 dstWidth,
|
|
|
|
u32 dstStride, u32 dstHeight)
|
2009-01-11 22:25:57 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
g_renderer->ResetAPIState();
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
s_rgbToYuyvProgram.Bind();
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
glUniform4f(s_rgbToYuyvUniform_loc, static_cast<float>(sourceRc.left),
|
|
|
|
static_cast<float>(sourceRc.top), static_cast<float>(sourceRc.right),
|
|
|
|
static_cast<float>(sourceRc.bottom));
|
2013-11-25 14:01:18 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
// We enable linear filtering, because the GameCube does filtering in the vertical direction when
|
|
|
|
// yscale is enabled.
|
|
|
|
// Otherwise we get jaggies when a game uses yscaling (most PAL games)
|
|
|
|
EncodeToRamUsingShader(srcTexture, destAddr, dstWidth * 2, dstHeight, dstStride, true);
|
|
|
|
FramebufferManager::SetFramebuffer(0);
|
|
|
|
TextureCache::DisableStage(0);
|
|
|
|
g_renderer->RestoreAPIState();
|
2009-01-11 22:25:57 +00:00
|
|
|
}
|
|
|
|
|
2009-02-28 19:02:37 +00:00
|
|
|
// Should be scale free.
|
2013-08-20 13:11:03 +00:00
|
|
|
void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, GLuint destTexture)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
u8* srcAddr = Memory::GetPointer(xfbAddr);
|
|
|
|
if (!srcAddr)
|
|
|
|
{
|
|
|
|
WARN_LOG(VIDEO, "Tried to decode from invalid memory address");
|
|
|
|
return;
|
|
|
|
}
|
2009-06-29 07:30:48 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
g_renderer->ResetAPIState(); // reset any game specific settings
|
2010-09-30 15:24:34 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
OpenGL_BindAttributelessVAO();
|
2014-12-11 17:42:49 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
// switch to texture converter frame buffer
|
|
|
|
// attach destTexture as color destination
|
|
|
|
FramebufferManager::SetFramebuffer(s_texConvFrameBuffer[1]);
|
|
|
|
FramebufferManager::FramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_ARRAY,
|
|
|
|
destTexture, 0);
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
// activate source texture
|
|
|
|
// set srcAddr as data for source texture
|
|
|
|
glActiveTexture(GL_TEXTURE9);
|
|
|
|
glBindTexture(GL_TEXTURE_2D, s_srcTexture);
|
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, srcWidth / 2, srcHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
|
|
|
|
srcAddr);
|
|
|
|
g_sampler_cache->BindNearestSampler(9);
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
glViewport(0, 0, srcWidth, srcHeight);
|
|
|
|
s_yuyvToRgbProgram.Bind();
|
2011-07-15 02:17:14 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
FramebufferManager::SetFramebuffer(0);
|
2009-06-26 08:57:53 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
g_renderer->RestoreAPIState();
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-02-21 13:53:26 +00:00
|
|
|
} // namespace
|
2011-01-29 20:16:51 +00:00
|
|
|
|
2011-01-29 22:48:33 +00:00
|
|
|
} // namespace OGL
|