mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-25 00:04:49 +02:00
Remove unnecessary vector from thin3d_gl texture handling.
This commit is contained in:
@@ -301,6 +301,8 @@ enum class Event {
|
||||
PRESENTED,
|
||||
};
|
||||
|
||||
constexpr uint32_t MAX_TEXTURE_SLOTS = 2;
|
||||
|
||||
struct FramebufferDesc {
|
||||
int width;
|
||||
int height;
|
||||
@@ -610,7 +612,7 @@ public:
|
||||
// Binding a zero render target means binding the backbuffer.
|
||||
virtual void BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) = 0;
|
||||
|
||||
// color must be 0, for now.
|
||||
// binding must be < MAX_TEXTURE_SLOTS (0, 1 are okay if it's 2).
|
||||
virtual void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int attachment) = 0;
|
||||
|
||||
// deprecated
|
||||
|
||||
@@ -383,8 +383,8 @@ public:
|
||||
void GetFramebufferDimensions(Framebuffer *fbo, int *w, int *h) override;
|
||||
|
||||
void BindSamplerStates(int start, int count, SamplerState **states) override {
|
||||
if (boundSamplers_.size() < (size_t)(start + count)) {
|
||||
boundSamplers_.resize(start + count);
|
||||
if (start + count >= MAX_TEXTURE_SLOTS) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < count; i++) {
|
||||
int index = i + start;
|
||||
@@ -488,9 +488,8 @@ private:
|
||||
|
||||
GLRenderManager renderManager_;
|
||||
|
||||
std::vector<OpenGLSamplerState *> boundSamplers_;
|
||||
OpenGLTexture *boundTextures_[8]{};
|
||||
int maxTextures_ = 0;
|
||||
OpenGLSamplerState *boundSamplers_[MAX_TEXTURE_SLOTS]{};
|
||||
OpenGLTexture *boundTextures_[MAX_TEXTURE_SLOTS]{};
|
||||
DeviceCaps caps_{};
|
||||
|
||||
// Bound state
|
||||
@@ -604,7 +603,6 @@ OpenGLContext::~OpenGLContext() {
|
||||
for (int i = 0; i < GLRenderManager::MAX_INFLIGHT_FRAMES; i++) {
|
||||
renderManager_.DeletePushBuffer(frameData_[i].push);
|
||||
}
|
||||
boundSamplers_.clear();
|
||||
}
|
||||
|
||||
void OpenGLContext::BeginFrame() {
|
||||
@@ -998,7 +996,9 @@ Pipeline *OpenGLContext::CreateGraphicsPipeline(const PipelineDesc &desc) {
|
||||
}
|
||||
|
||||
void OpenGLContext::BindTextures(int start, int count, Texture **textures) {
|
||||
maxTextures_ = std::max(maxTextures_, start + count);
|
||||
if (start + count >= MAX_TEXTURE_SLOTS) {
|
||||
return;
|
||||
}
|
||||
for (int i = start; i < start + count; i++) {
|
||||
OpenGLTexture *glTex = static_cast<OpenGLTexture *>(textures[i - start]);
|
||||
if (!glTex) {
|
||||
@@ -1012,25 +1012,24 @@ void OpenGLContext::BindTextures(int start, int count, Texture **textures) {
|
||||
}
|
||||
|
||||
void OpenGLContext::ApplySamplers() {
|
||||
for (int i = 0; i < maxTextures_; i++) {
|
||||
if ((int)boundSamplers_.size() > i && boundSamplers_[i]) {
|
||||
const OpenGLSamplerState *samp = boundSamplers_[i];
|
||||
const OpenGLTexture *tex = boundTextures_[i];
|
||||
if (!tex)
|
||||
continue;
|
||||
GLenum wrapS;
|
||||
GLenum wrapT;
|
||||
if (tex->CanWrap()) {
|
||||
wrapS = samp->wrapU;
|
||||
wrapT = samp->wrapV;
|
||||
} else {
|
||||
wrapS = GL_CLAMP_TO_EDGE;
|
||||
wrapT = GL_CLAMP_TO_EDGE;
|
||||
}
|
||||
GLenum magFilt = samp->magFilt;
|
||||
GLenum minFilt = tex->HasMips() ? samp->mipMinFilt : samp->minFilt;
|
||||
renderManager_.SetTextureSampler(i, wrapS, wrapT, magFilt, minFilt, 0.0f);
|
||||
for (int i = 0; i < MAX_TEXTURE_SLOTS; i++) {
|
||||
const OpenGLSamplerState *samp = boundSamplers_[i];
|
||||
const OpenGLTexture *tex = boundTextures_[i];
|
||||
if (!samp || !tex) {
|
||||
continue;
|
||||
}
|
||||
GLenum wrapS;
|
||||
GLenum wrapT;
|
||||
if (tex->CanWrap()) {
|
||||
wrapS = samp->wrapU;
|
||||
wrapT = samp->wrapV;
|
||||
} else {
|
||||
wrapS = GL_CLAMP_TO_EDGE;
|
||||
wrapT = GL_CLAMP_TO_EDGE;
|
||||
}
|
||||
GLenum magFilt = samp->magFilt;
|
||||
GLenum minFilt = tex->HasMips() ? samp->mipMinFilt : samp->minFilt;
|
||||
renderManager_.SetTextureSampler(i, wrapS, wrapT, magFilt, minFilt, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1132,7 +1131,6 @@ void OpenGLContext::DrawUP(const void *vdata, int vertexCount) {
|
||||
size_t offset = frameData.push->Push(vdata, dataSize, &buf);
|
||||
|
||||
ApplySamplers();
|
||||
|
||||
renderManager_.BindVertexBuffer(curPipeline_->inputLayout->inputLayout_, buf, offset);
|
||||
renderManager_.Draw(curPipeline_->prim, 0, vertexCount);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user