TextureConverter (OGL/D3D9): Kill EncodeToRam because it wasn't used anywhere and it basically does the same as EncodeToRamFromTexture anyway
This commit is contained in:
parent
3b38295cbd
commit
a02df43e6d
|
@ -313,75 +313,6 @@ void EncodeToRamUsingShader(LPDIRECT3DPIXELSHADER9 shader, LPDIRECT3DTEXTURE9 sr
|
||||||
hr = s_texConvReadSurface->UnlockRect();
|
hr = s_texConvReadSurface->UnlockRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle& source)
|
|
||||||
{
|
|
||||||
u32 format = copyfmt;
|
|
||||||
|
|
||||||
if (bFromZBuffer)
|
|
||||||
{
|
|
||||||
format |= _GX_TF_ZTF;
|
|
||||||
if (copyfmt == 11)
|
|
||||||
format = GX_TF_Z16;
|
|
||||||
else if (format < GX_TF_Z8 || format > GX_TF_Z24X8)
|
|
||||||
format |= _GX_TF_CTF;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (copyfmt > GX_TF_RGBA8 || (copyfmt < GX_TF_RGB565 && !bIsIntensityFmt))
|
|
||||||
format |= _GX_TF_CTF;
|
|
||||||
|
|
||||||
LPDIRECT3DPIXELSHADER9 texconv_shader = GetOrCreateEncodingShader(format);
|
|
||||||
if (!texconv_shader)
|
|
||||||
return;
|
|
||||||
|
|
||||||
u8 *dest_ptr = Memory::GetPointer(address);
|
|
||||||
|
|
||||||
LPDIRECT3DTEXTURE9 source_texture = bFromZBuffer ? FramebufferManager::GetEFBDepthTexture() : FramebufferManager::GetEFBColorTexture();
|
|
||||||
int width = (source.right - source.left) >> bScaleByHalf;
|
|
||||||
int height = (source.bottom - source.top) >> bScaleByHalf;
|
|
||||||
|
|
||||||
int size_in_bytes = TexDecoder_GetTextureSizeInBytes(width, height, format);
|
|
||||||
|
|
||||||
// Invalidate any existing texture covering this memory range.
|
|
||||||
// TODO - don't delete the texture if it already exists, just replace the contents.
|
|
||||||
TextureCache::InvalidateRange(address, size_in_bytes);
|
|
||||||
|
|
||||||
u16 blkW = TexDecoder_GetBlockWidthInTexels(format) - 1;
|
|
||||||
u16 blkH = TexDecoder_GetBlockHeightInTexels(format) - 1;
|
|
||||||
u16 samples = TextureConversionShader::GetEncodedSampleCount(format);
|
|
||||||
|
|
||||||
// only copy on cache line boundaries
|
|
||||||
// extra pixels are copied but not displayed in the resulting texture
|
|
||||||
s32 expandedWidth = (width + blkW) & (~blkW);
|
|
||||||
s32 expandedHeight = (height + blkH) & (~blkH);
|
|
||||||
|
|
||||||
float sampleStride = bScaleByHalf ? 2.f : 1.f;
|
|
||||||
TextureConversionShader::SetShaderParameters(
|
|
||||||
(float)expandedWidth,
|
|
||||||
(float)Renderer::EFBToScaledY(expandedHeight), // TODO: Why do we scale this?
|
|
||||||
(float)Renderer::EFBToScaledX(source.left),
|
|
||||||
(float)Renderer::EFBToScaledY(source.top),
|
|
||||||
Renderer::EFBToScaledXf(sampleStride),
|
|
||||||
Renderer::EFBToScaledYf(sampleStride),
|
|
||||||
(float)Renderer::GetTargetWidth(),
|
|
||||||
(float)Renderer::GetTargetHeight());
|
|
||||||
|
|
||||||
TargetRectangle scaledSource;
|
|
||||||
scaledSource.top = 0;
|
|
||||||
scaledSource.bottom = expandedHeight;
|
|
||||||
scaledSource.left = 0;
|
|
||||||
scaledSource.right = expandedWidth / samples;
|
|
||||||
int cacheBytes = 32;
|
|
||||||
if ((format & 0x0f) == 6)
|
|
||||||
cacheBytes = 64;
|
|
||||||
|
|
||||||
int readStride = (expandedWidth * cacheBytes) / TexDecoder_GetBlockWidthInTexels(format);
|
|
||||||
g_renderer->ResetAPIState();
|
|
||||||
EncodeToRamUsingShader(texconv_shader, source_texture, scaledSource, dest_ptr, expandedWidth / samples, expandedHeight, readStride, true, bScaleByHalf > 0,1.0f);
|
|
||||||
D3D::dev->SetRenderTarget(0, FramebufferManager::GetEFBColorRTSurface());
|
|
||||||
D3D::dev->SetDepthStencilSurface(FramebufferManager::GetEFBDepthRTSurface());
|
|
||||||
g_renderer->RestoreAPIState();
|
|
||||||
}
|
|
||||||
|
|
||||||
u64 EncodeToRamFromTexture(u32 address,LPDIRECT3DTEXTURE9 source_texture, u32 SourceW, u32 SourceH, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle& source)
|
u64 EncodeToRamFromTexture(u32 address,LPDIRECT3DTEXTURE9 source_texture, u32 SourceW, u32 SourceH, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle& source)
|
||||||
{
|
{
|
||||||
u32 format = copyfmt;
|
u32 format = copyfmt;
|
||||||
|
|
|
@ -35,9 +35,6 @@ namespace TextureConverter
|
||||||
void Init();
|
void Init();
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt,
|
|
||||||
u32 copyfmt, int bScaleByHalf, const EFBRectangle& source);
|
|
||||||
|
|
||||||
void EncodeToRamYUYV(LPDIRECT3DTEXTURE9 srcTexture, const TargetRectangle& sourceRc,
|
void EncodeToRamYUYV(LPDIRECT3DTEXTURE9 srcTexture, const TargetRectangle& sourceRc,
|
||||||
u8* destAddr, int dstWidth, int dstHeight,float Gamma);
|
u8* destAddr, int dstWidth, int dstHeight,float Gamma);
|
||||||
|
|
||||||
|
|
|
@ -250,77 +250,6 @@ void EncodeToRamUsingShader(FRAGMENTSHADER& shader, GLuint srcTexture, const Tar
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle& source)
|
|
||||||
{
|
|
||||||
u32 format = copyfmt;
|
|
||||||
|
|
||||||
if (bFromZBuffer)
|
|
||||||
{
|
|
||||||
format |= _GX_TF_ZTF;
|
|
||||||
if (copyfmt == 11)
|
|
||||||
format = GX_TF_Z16;
|
|
||||||
else if (format < GX_TF_Z8 || format > GX_TF_Z24X8)
|
|
||||||
format |= _GX_TF_CTF;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (copyfmt > GX_TF_RGBA8 || (copyfmt < GX_TF_RGB565 && !bIsIntensityFmt))
|
|
||||||
format |= _GX_TF_CTF;
|
|
||||||
|
|
||||||
FRAGMENTSHADER& texconv_shader = GetOrCreateEncodingShader(format);
|
|
||||||
if (texconv_shader.glprogid == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
u8 *dest_ptr = Memory::GetPointer(address);
|
|
||||||
|
|
||||||
GLuint source_texture = bFromZBuffer ? FramebufferManager::ResolveAndGetDepthTarget(source) : FramebufferManager::ResolveAndGetRenderTarget(source);
|
|
||||||
|
|
||||||
int width = (source.right - source.left) >> bScaleByHalf;
|
|
||||||
int height = (source.bottom - source.top) >> bScaleByHalf;
|
|
||||||
|
|
||||||
int size_in_bytes = TexDecoder_GetTextureSizeInBytes(width, height, format);
|
|
||||||
|
|
||||||
// Invalidate any existing texture covering this memory range.
|
|
||||||
// TODO - don't delete the texture if it already exists, just replace the contents.
|
|
||||||
TextureCache::InvalidateRange(address, size_in_bytes);
|
|
||||||
|
|
||||||
u16 blkW = TexDecoder_GetBlockWidthInTexels(format) - 1;
|
|
||||||
u16 blkH = TexDecoder_GetBlockHeightInTexels(format) - 1;
|
|
||||||
u16 samples = TextureConversionShader::GetEncodedSampleCount(format);
|
|
||||||
|
|
||||||
// only copy on cache line boundaries
|
|
||||||
// extra pixels are copied but not displayed in the resulting texture
|
|
||||||
s32 expandedWidth = (width + blkW) & (~blkW);
|
|
||||||
s32 expandedHeight = (height + blkH) & (~blkH);
|
|
||||||
|
|
||||||
float sampleStride = bScaleByHalf ? 2.f : 1.f;
|
|
||||||
TextureConversionShader::SetShaderParameters(
|
|
||||||
(float)expandedWidth,
|
|
||||||
(float)Renderer::EFBToScaledY(expandedHeight), // TODO: Why do we scale this?
|
|
||||||
(float)Renderer::EFBToScaledX(source.left),
|
|
||||||
(float)Renderer::EFBToScaledY(EFB_HEIGHT - source.top - expandedHeight),
|
|
||||||
Renderer::EFBToScaledXf(sampleStride),
|
|
||||||
Renderer::EFBToScaledYf(sampleStride));
|
|
||||||
|
|
||||||
TargetRectangle scaledSource;
|
|
||||||
scaledSource.top = 0;
|
|
||||||
scaledSource.bottom = expandedHeight;
|
|
||||||
scaledSource.left = 0;
|
|
||||||
scaledSource.right = expandedWidth / samples;
|
|
||||||
int cacheBytes = 32;
|
|
||||||
if ((format & 0x0f) == 6)
|
|
||||||
cacheBytes = 64;
|
|
||||||
|
|
||||||
int readStride = (expandedWidth * cacheBytes) / TexDecoder_GetBlockWidthInTexels(format);
|
|
||||||
g_renderer->ResetAPIState();
|
|
||||||
EncodeToRamUsingShader(texconv_shader, source_texture, scaledSource, dest_ptr, expandedWidth / samples, expandedHeight, readStride, true, bScaleByHalf > 0);
|
|
||||||
FramebufferManager::SetFramebuffer(0);
|
|
||||||
VertexShaderManager::SetViewportChanged();
|
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
|
|
||||||
TextureCache::DisableStage(0);
|
|
||||||
g_renderer->RestoreAPIState();
|
|
||||||
GL_REPORT_ERRORD();
|
|
||||||
}
|
|
||||||
|
|
||||||
u64 EncodeToRamFromTexture(u32 address,GLuint source_texture, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle& source)
|
u64 EncodeToRamFromTexture(u32 address,GLuint source_texture, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle& source)
|
||||||
{
|
{
|
||||||
u32 format = copyfmt;
|
u32 format = copyfmt;
|
||||||
|
|
|
@ -32,9 +32,6 @@ namespace TextureConverter
|
||||||
void Init();
|
void Init();
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt,
|
|
||||||
u32 copyfmt, int bScaleByHalf, const EFBRectangle& source);
|
|
||||||
|
|
||||||
void EncodeToRamYUYV(GLuint srcTexture, const TargetRectangle& sourceRc,
|
void EncodeToRamYUYV(GLuint srcTexture, const TargetRectangle& sourceRc,
|
||||||
u8* destAddr, int dstWidth, int dstHeight);
|
u8* destAddr, int dstWidth, int dstHeight);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue