mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
More work on GL state leaks. Some things really need a redesign.
This commit is contained in:
parent
ea376ef886
commit
5313fc5b36
7 changed files with 26 additions and 9 deletions
|
@ -107,6 +107,7 @@ void __KernelInit()
|
||||||
ERROR_LOG(SCEKERNEL, "Can't init kernel when kernel is running");
|
ERROR_LOG(SCEKERNEL, "Can't init kernel when kernel is running");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
INFO_LOG(SCEKERNEL, "Initializing kernel...");
|
||||||
|
|
||||||
__KernelTimeInit();
|
__KernelTimeInit();
|
||||||
__InterruptsInit();
|
__InterruptsInit();
|
||||||
|
|
|
@ -1654,7 +1654,7 @@ void __KernelLoadReset() {
|
||||||
bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_string) {
|
bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_string) {
|
||||||
SceKernelLoadExecParam param;
|
SceKernelLoadExecParam param;
|
||||||
|
|
||||||
PSP_SetLoading("Loading game...");
|
PSP_SetLoading("Loading exec...");
|
||||||
|
|
||||||
if (paramPtr)
|
if (paramPtr)
|
||||||
Memory::ReadStruct(paramPtr, ¶m);
|
Memory::ReadStruct(paramPtr, ¶m);
|
||||||
|
|
|
@ -108,9 +108,9 @@ static GPUBackend gpuBackend;
|
||||||
static std::string gpuBackendDevice;
|
static std::string gpuBackendDevice;
|
||||||
|
|
||||||
// Ugly!
|
// Ugly!
|
||||||
static bool pspIsInited = false;
|
static volatile bool pspIsInited = false;
|
||||||
static bool pspIsIniting = false;
|
static volatile bool pspIsIniting = false;
|
||||||
static bool pspIsQuitting = false;
|
static volatile bool pspIsQuitting = false;
|
||||||
|
|
||||||
void ResetUIState() {
|
void ResetUIState() {
|
||||||
globalUIState = UISTATE_MENU;
|
globalUIState = UISTATE_MENU;
|
||||||
|
|
|
@ -314,6 +314,7 @@ void DrawEngineGLES::DoFlush() {
|
||||||
if (lastRenderStepId_ != curRenderStepId) {
|
if (lastRenderStepId_ != curRenderStepId) {
|
||||||
// Dirty everything that has dynamic state that will need re-recording.
|
// Dirty everything that has dynamic state that will need re-recording.
|
||||||
gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_BLEND_STATE | DIRTY_RASTER_STATE);
|
gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_BLEND_STATE | DIRTY_RASTER_STATE);
|
||||||
|
textureCache_->ForgetLastTexture();
|
||||||
lastRenderStepId_ = curRenderStepId;
|
lastRenderStepId_ = curRenderStepId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1090,7 +1090,6 @@ void EmuScreen::CreateViews() {
|
||||||
loadingSpinner->SetTag("LoadingSpinner");
|
loadingSpinner->SetTag("LoadingSpinner");
|
||||||
|
|
||||||
// Don't really need this, and it creates a lot of strings to translate...
|
// Don't really need this, and it creates a lot of strings to translate...
|
||||||
// Maybe just show "Loading game..." only?
|
|
||||||
loadingTextView->SetVisibility(V_GONE);
|
loadingTextView->SetVisibility(V_GONE);
|
||||||
loadingTextView->SetShadow(true);
|
loadingTextView->SetShadow(true);
|
||||||
|
|
||||||
|
|
|
@ -416,6 +416,7 @@ private:
|
||||||
GLuint currentReadHandle_ = 0;
|
GLuint currentReadHandle_ = 0;
|
||||||
|
|
||||||
GLuint AllocTextureName();
|
GLuint AllocTextureName();
|
||||||
|
|
||||||
// Texture name cache. Ripped straight from TextureCacheGLES.
|
// Texture name cache. Ripped straight from TextureCacheGLES.
|
||||||
std::vector<GLuint> nameCache_;
|
std::vector<GLuint> nameCache_;
|
||||||
std::unordered_map<int, std::string> glStrings_;
|
std::unordered_map<int, std::string> glStrings_;
|
||||||
|
|
|
@ -483,14 +483,16 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ApplySamplers();
|
void ApplySamplers();
|
||||||
|
void Unbind();
|
||||||
|
|
||||||
GLRenderManager renderManager_;
|
GLRenderManager renderManager_;
|
||||||
|
|
||||||
OpenGLSamplerState *boundSamplers_[MAX_TEXTURE_SLOTS]{};
|
|
||||||
OpenGLTexture *boundTextures_[MAX_TEXTURE_SLOTS]{};
|
|
||||||
DeviceCaps caps_{};
|
DeviceCaps caps_{};
|
||||||
|
|
||||||
// Bound state
|
// Bound state
|
||||||
|
OpenGLSamplerState *boundSamplers_[MAX_TEXTURE_SLOTS]{};
|
||||||
|
OpenGLTexture *boundTextures_[MAX_TEXTURE_SLOTS]{};
|
||||||
|
|
||||||
OpenGLPipeline *curPipeline_ = nullptr;
|
OpenGLPipeline *curPipeline_ = nullptr;
|
||||||
OpenGLBuffer *curVBuffers_[4]{};
|
OpenGLBuffer *curVBuffers_[4]{};
|
||||||
int curVBufferOffsets_[4]{};
|
int curVBufferOffsets_[4]{};
|
||||||
|
@ -610,10 +612,14 @@ void OpenGLContext::BeginFrame() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLContext::EndFrame() {
|
void OpenGLContext::EndFrame() {
|
||||||
|
Unbind();
|
||||||
|
|
||||||
FrameData &frameData = frameData_[renderManager_.GetCurFrame()];
|
FrameData &frameData = frameData_[renderManager_.GetCurFrame()];
|
||||||
renderManager_.EndPushBuffer(frameData.push); // upload the data!
|
renderManager_.EndPushBuffer(frameData.push); // upload the data!
|
||||||
renderManager_.Finish();
|
renderManager_.Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenGLContext::Unbind() {
|
||||||
// Unbind stuff.
|
// Unbind stuff.
|
||||||
for (auto &texture : boundTextures_) {
|
for (auto &texture : boundTextures_) {
|
||||||
texture = nullptr;
|
texture = nullptr;
|
||||||
|
@ -621,6 +627,9 @@ void OpenGLContext::EndFrame() {
|
||||||
for (auto &sampler : boundSamplers_) {
|
for (auto &sampler : boundSamplers_) {
|
||||||
sampler = nullptr;
|
sampler = nullptr;
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < ARRAY_SIZE(boundTextures_); i++) {
|
||||||
|
renderManager_.BindTexture(i, nullptr);
|
||||||
|
}
|
||||||
curPipeline_ = nullptr;
|
curPipeline_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -679,7 +688,6 @@ private:
|
||||||
|
|
||||||
OpenGLTexture::OpenGLTexture(GLRenderManager *render, const TextureDesc &desc) : render_(render) {
|
OpenGLTexture::OpenGLTexture(GLRenderManager *render, const TextureDesc &desc) : render_(render) {
|
||||||
generatedMips_ = false;
|
generatedMips_ = false;
|
||||||
canWrap_ = true;
|
|
||||||
width_ = desc.width;
|
width_ = desc.width;
|
||||||
height_ = desc.height;
|
height_ = desc.height;
|
||||||
depth_ = desc.depth;
|
depth_ = desc.depth;
|
||||||
|
@ -1022,7 +1030,9 @@ void OpenGLContext::ApplySamplers() {
|
||||||
for (int i = 0; i < MAX_TEXTURE_SLOTS; i++) {
|
for (int i = 0; i < MAX_TEXTURE_SLOTS; i++) {
|
||||||
const OpenGLSamplerState *samp = boundSamplers_[i];
|
const OpenGLSamplerState *samp = boundSamplers_[i];
|
||||||
const OpenGLTexture *tex = boundTextures_[i];
|
const OpenGLTexture *tex = boundTextures_[i];
|
||||||
if (!samp || !tex) {
|
if (tex) {
|
||||||
|
_assert_(samp);
|
||||||
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
GLenum wrapS;
|
GLenum wrapS;
|
||||||
|
@ -1037,6 +1047,8 @@ void OpenGLContext::ApplySamplers() {
|
||||||
GLenum magFilt = samp->magFilt;
|
GLenum magFilt = samp->magFilt;
|
||||||
GLenum minFilt = tex->HasMips() ? samp->mipMinFilt : samp->minFilt;
|
GLenum minFilt = tex->HasMips() ? samp->mipMinFilt : samp->minFilt;
|
||||||
renderManager_.SetTextureSampler(i, wrapS, wrapT, magFilt, minFilt, 0.0f);
|
renderManager_.SetTextureSampler(i, wrapS, wrapT, magFilt, minFilt, 0.0f);
|
||||||
|
// TODO: Improve this to allow mipmaps. We don't care about those right now though for thin3d stuff.
|
||||||
|
renderManager_.SetTextureLod(i, 0.0, 0.0, 0.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1098,6 +1110,9 @@ void OpenGLContext::BindPipeline(Pipeline *pipeline) {
|
||||||
curPipeline_->depthStencil->Apply(&renderManager_, stencilRef_);
|
curPipeline_->depthStencil->Apply(&renderManager_, stencilRef_);
|
||||||
curPipeline_->raster->Apply(&renderManager_);
|
curPipeline_->raster->Apply(&renderManager_);
|
||||||
renderManager_.BindProgram(curPipeline_->program_);
|
renderManager_.BindProgram(curPipeline_->program_);
|
||||||
|
} else {
|
||||||
|
// Wipe bound textures and samplers.
|
||||||
|
Unbind();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue