Skip to content

Commit

Permalink
Remove global num videos hack.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed May 1, 2016
1 parent 99d2935 commit f5b93bc
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 30 deletions.
4 changes: 0 additions & 4 deletions Core/HW/MediaEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ extern "C" {
}
#endif // USE_FFMPEG

int g_iNumVideos = 0;

#ifdef USE_FFMPEG
static AVPixelFormat getSwsFormat(int pspFormat)
{
Expand Down Expand Up @@ -149,12 +147,10 @@ MediaEngine::MediaEngine(): m_pdata(0) {
m_ringbuffersize = 0;
m_mpegheaderReadPos = 0;
m_audioType = PSP_CODEC_AT3PLUS; // in movie, we use only AT3+ audio
g_iNumVideos++;
}

MediaEngine::~MediaEngine() {
closeMedia();
g_iNumVideos--;
}

void MediaEngine::closeMedia() {
Expand Down
15 changes: 8 additions & 7 deletions GPU/Common/TextureCacheCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
// Videos should be updated every few frames, so we forge quickly.
#define VIDEO_DECIMATE_AGE 4

// Ugly.
extern int g_iNumVideos;

TextureCacheCommon::TextureCacheCommon()
: cacheSizeEstimate_(0), nextTexture_(nullptr),
clutLastFormat_(0xFFFFFFFF), clutTotalBytes_(0), clutMaxBytes_(0), clutRenderAddress_(0xFFFFFFFF) {
Expand Down Expand Up @@ -79,7 +76,7 @@ int TextureCacheCommon::AttachedDrawingHeight() {
return 0;
}

void TextureCacheCommon::GetSamplingParams(int &minFilt, int &magFilt, bool &sClamp, bool &tClamp, float &lodBias, u8 maxLevel) {
void TextureCacheCommon::GetSamplingParams(int &minFilt, int &magFilt, bool &sClamp, bool &tClamp, float &lodBias, u8 maxLevel, u32 addr) {
minFilt = gstate.texfilter & 0x7;
magFilt = (gstate.texfilter >> 8) & 1;
sClamp = gstate.isTexCoordClampedS();
Expand All @@ -96,9 +93,12 @@ void TextureCacheCommon::GetSamplingParams(int &minFilt, int &magFilt, bool &sCl
lodBias = (float)(int)(s8)((gstate.texlevel >> 16) & 0xFF) / 16.0f;
}

if (g_Config.iTexFiltering == TEX_FILTER_LINEAR_VIDEO && g_iNumVideos > 0 && (gstate.getTextureDimension(0) & 0xF) >= 9) {
magFilt |= 1;
minFilt |= 1;
if (g_Config.iTexFiltering == TEX_FILTER_LINEAR_VIDEO) {
bool isVideo = videos_.find(addr & 0x3FFFFFFF) != videos_.end();
if (isVideo) {
magFilt |= 1;
minFilt |= 1;
}
}
if (g_Config.iTexFiltering == TEX_FILTER_LINEAR && (!gstate.isColorTestEnabled() || IsColorTestTriviallyTrue())) {
if (!gstate.isAlphaTestEnabled() || IsAlphaTestTriviallyTrue()) {
Expand Down Expand Up @@ -309,6 +309,7 @@ void TextureCacheCommon::NotifyConfigChanged() {
}

void TextureCacheCommon::NotifyVideoUpload(u32 addr, int size, int width, GEBufferFormat fmt) {
addr &= 0x3FFFFFFF;
videos_[addr] = gpuStats.numFlips;
}

Expand Down
2 changes: 1 addition & 1 deletion GPU/Common/TextureCacheCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class TextureCacheCommon {
void *RearrangeBuf(void *inBuf, u32 inRowBytes, u32 outRowBytes, int h, bool allowInPlace = true);

u32 EstimateTexMemoryUsage(const TexCacheEntry *entry);
void GetSamplingParams(int &minFilt, int &magFilt, bool &sClamp, bool &tClamp, float &lodBias, u8 maxLevel);
void GetSamplingParams(int &minFilt, int &magFilt, bool &sClamp, bool &tClamp, float &lodBias, u8 maxLevel, u32 addr);
void UpdateMaxSeenV(bool throughMode);

virtual bool AttachFramebuffer(TexCacheEntry *entry, u32 address, VirtualFramebuffer *framebuffer, u32 texaddrOffset = 0) = 0;
Expand Down
6 changes: 2 additions & 4 deletions GPU/Directx9/TextureCacheDX9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
#include "math/math_util.h"


extern int g_iNumVideos;

namespace DX9 {

#define INVALID_TEX (LPDIRECT3DTEXTURE9)(-1)
Expand Down Expand Up @@ -503,7 +501,7 @@ void TextureCacheDX9::UpdateSamplingParams(TexCacheEntry &entry, bool force) {
bool sClamp;
bool tClamp;
float lodBias;
GetSamplingParams(minFilt, magFilt, sClamp, tClamp, lodBias, entry.maxLevel);
GetSamplingParams(minFilt, magFilt, sClamp, tClamp, lodBias, entry.maxLevel, entry.addr);

if (entry.maxLevel != 0) {
GETexLevelMode mode = gstate.getTexLevelMode();
Expand Down Expand Up @@ -543,7 +541,7 @@ void TextureCacheDX9::SetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHe
bool sClamp;
bool tClamp;
float lodBias;
GetSamplingParams(minFilt, magFilt, sClamp, tClamp, lodBias, 0);
GetSamplingParams(minFilt, magFilt, sClamp, tClamp, lodBias, 0, 0);

dxstate.texMinFilter.set(MinFilt[minFilt]);
dxstate.texMipFilter.set(MipFilt[minFilt]);
Expand Down
2 changes: 0 additions & 2 deletions GPU/GLES/Framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@

// #define DEBUG_READ_PIXELS 1

extern int g_iNumVideos;

static const char tex_fs[] =
#ifdef USING_GLES2
"precision mediump float;\n"
Expand Down
7 changes: 2 additions & 5 deletions GPU/GLES/TextureCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@

#define INVALID_TEX -1

// Hack!
extern int g_iNumVideos;

TextureCache::TextureCache() : secondCacheSizeEstimate_(0), clearCacheNextFrame_(false), lowMemoryMode_(false), clutBuf_(NULL), texelsScaledThisFrame_(0) {
timesInvalidatedAllThisFrame_ = 0;
lastBoundTexture = INVALID_TEX;
Expand Down Expand Up @@ -490,7 +487,7 @@ void TextureCache::UpdateSamplingParams(TexCacheEntry &entry, bool force) {
bool sClamp;
bool tClamp;
float lodBias;
GetSamplingParams(minFilt, magFilt, sClamp, tClamp, lodBias, entry.maxLevel);
GetSamplingParams(minFilt, magFilt, sClamp, tClamp, lodBias, entry.maxLevel, entry.addr);

if (entry.maxLevel != 0) {
if (force || entry.lodBias != lodBias) {
Expand Down Expand Up @@ -544,7 +541,7 @@ void TextureCache::SetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHeigh
bool sClamp;
bool tClamp;
float lodBias;
GetSamplingParams(minFilt, magFilt, sClamp, tClamp, lodBias, 0);
GetSamplingParams(minFilt, magFilt, sClamp, tClamp, lodBias, 0, 0);

minFilt &= 1; // framebuffers can't mipmap.

Expand Down
2 changes: 0 additions & 2 deletions GPU/Vulkan/FramebufferVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@

#include "UI/OnScreenDisplay.h"

extern int g_iNumVideos;

const VkFormat framebufFormat = VK_FORMAT_R8G8B8A8_UNORM;

static const char tex_fs[] = R"(#version 400
Expand Down
7 changes: 2 additions & 5 deletions GPU/Vulkan/TextureCacheVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ static const VkComponentMapping VULKAN_1555_SWIZZLE = { VK_COMPONENT_SWIZZLE_B,
static const VkComponentMapping VULKAN_565_SWIZZLE = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A };
static const VkComponentMapping VULKAN_8888_SWIZZLE = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A };

// Hack!
extern int g_iNumVideos;

SamplerCache::~SamplerCache() {
for (auto iter : cache_) {
vulkan_->Delete().QueueDeleteSampler(iter.second);
Expand Down Expand Up @@ -508,7 +505,7 @@ void TextureCacheVulkan::UpdateSamplingParams(TexCacheEntry &entry, SamplerCache
bool sClamp;
bool tClamp;
float lodBias;
GetSamplingParams(minFilt, magFilt, sClamp, tClamp, lodBias, entry.maxLevel);
GetSamplingParams(minFilt, magFilt, sClamp, tClamp, lodBias, entry.maxLevel, entry.addr);
key.minFilt = minFilt & 1;
key.mipEnable = (minFilt >> 2) & 1;
key.mipFilt = (minFilt >> 1) & 1;
Expand Down Expand Up @@ -549,7 +546,7 @@ void TextureCacheVulkan::SetFramebufferSamplingParams(u16 bufferWidth, u16 buffe
bool sClamp;
bool tClamp;
float lodBias;
GetSamplingParams(minFilt, magFilt, sClamp, tClamp, lodBias, 0);
GetSamplingParams(minFilt, magFilt, sClamp, tClamp, lodBias, 0, 0);

key.minFilt = minFilt & 1;
key.mipFilt = 0;
Expand Down

0 comments on commit f5b93bc

Please sign in to comment.