mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Draw: Use constants for texture slots.
GL actually had a check for 16 but then an array for 8. This should make it easier to figure out if we ever hit those limits.
This commit is contained in:
parent
17071e7fec
commit
7f8144494e
5 changed files with 14 additions and 9 deletions
|
@ -1331,7 +1331,7 @@ Framebuffer *D3D11DrawContext::CreateFramebuffer(const FramebufferDesc &desc) {
|
|||
|
||||
void D3D11DrawContext::BindTextures(int start, int count, Texture **textures) {
|
||||
// Collect the resource views from the textures.
|
||||
ID3D11ShaderResourceView *views[8];
|
||||
ID3D11ShaderResourceView *views[MAX_BOUND_TEXTURES];
|
||||
_assert_(start + count <= ARRAY_SIZE(views));
|
||||
for (int i = 0; i < count; i++) {
|
||||
D3D11Texture *tex = (D3D11Texture *)textures[i];
|
||||
|
@ -1341,7 +1341,7 @@ void D3D11DrawContext::BindTextures(int start, int count, Texture **textures) {
|
|||
}
|
||||
|
||||
void D3D11DrawContext::BindSamplerStates(int start, int count, SamplerState **states) {
|
||||
ID3D11SamplerState *samplers[8];
|
||||
ID3D11SamplerState *samplers[MAX_BOUND_TEXTURES];
|
||||
_assert_(start + count <= ARRAY_SIZE(samplers));
|
||||
for (int i = 0; i < count; i++) {
|
||||
D3D11SamplerState *samp = (D3D11SamplerState *)states[i];
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "GLRenderManager.h"
|
||||
#include "DataFormatGL.h"
|
||||
|
||||
#define TEXCACHE_NAME_CACHE_SIZE 16
|
||||
static constexpr int TEXCACHE_NAME_CACHE_SIZE = 16;
|
||||
|
||||
#if PPSSPP_PLATFORM(IOS)
|
||||
extern void bindDefaultFBO();
|
||||
|
@ -800,7 +800,7 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last
|
|||
GLuint blendEqColor = (GLuint)-1;
|
||||
GLuint blendEqAlpha = (GLuint)-1;
|
||||
|
||||
GLRTexture *curTex[8]{};
|
||||
GLRTexture *curTex[MAX_GL_TEXTURE_SLOTS]{};
|
||||
|
||||
CHECK_GL_ERROR_IF_DEBUG();
|
||||
auto &commands = step.commands;
|
||||
|
|
|
@ -357,6 +357,7 @@ void GLRenderManager::BindFramebufferAsRenderTarget(GLRFramebuffer *fb, GLRRende
|
|||
|
||||
void GLRenderManager::BindFramebufferAsTexture(GLRFramebuffer *fb, int binding, int aspectBit, int attachment) {
|
||||
_dbg_assert_(curRenderStep_ && curRenderStep_->stepType == GLRStepType::RENDER);
|
||||
_dbg_assert_(binding < MAX_GL_TEXTURE_SLOTS);
|
||||
GLRRenderData data{ GLRRenderCommand::BIND_FB_TEXTURE };
|
||||
data.bind_fb_texture.slot = binding;
|
||||
data.bind_fb_texture.framebuffer = fb;
|
||||
|
|
|
@ -21,6 +21,8 @@ namespace Draw {
|
|||
class DrawContext;
|
||||
}
|
||||
|
||||
constexpr int MAX_GL_TEXTURE_SLOTS = 8;
|
||||
|
||||
class GLRTexture {
|
||||
public:
|
||||
GLRTexture(int width, int height, int numMips);
|
||||
|
@ -571,8 +573,8 @@ public:
|
|||
|
||||
void BindTexture(int slot, GLRTexture *tex) {
|
||||
_dbg_assert_(curRenderStep_ && curRenderStep_->stepType == GLRStepType::RENDER);
|
||||
_dbg_assert_(slot < MAX_GL_TEXTURE_SLOTS);
|
||||
GLRRenderData data{ GLRRenderCommand::BINDTEXTURE };
|
||||
_dbg_assert_(slot < 16);
|
||||
data.texture.slot = slot;
|
||||
data.texture.texture = tex;
|
||||
curRenderStep_->commands.push_back(data);
|
||||
|
@ -824,6 +826,7 @@ public:
|
|||
// Modifies the current texture as per GL specs, not global state.
|
||||
void SetTextureSampler(int slot, GLenum wrapS, GLenum wrapT, GLenum magFilter, GLenum minFilter, float anisotropy) {
|
||||
_dbg_assert_(curRenderStep_ && curRenderStep_->stepType == GLRStepType::RENDER);
|
||||
_dbg_assert_(slot < MAX_GL_TEXTURE_SLOTS);
|
||||
GLRRenderData data{ GLRRenderCommand::TEXTURESAMPLER };
|
||||
data.textureSampler.slot = slot;
|
||||
data.textureSampler.wrapS = wrapS;
|
||||
|
@ -836,6 +839,7 @@ public:
|
|||
|
||||
void SetTextureLod(int slot, float minLod, float maxLod, float lodBias) {
|
||||
_dbg_assert_(curRenderStep_ && curRenderStep_->stepType == GLRStepType::RENDER);
|
||||
_dbg_assert_(slot < MAX_GL_TEXTURE_SLOTS);
|
||||
GLRRenderData data{ GLRRenderCommand::TEXTURELOD};
|
||||
data.textureLod.slot = slot;
|
||||
data.textureLod.minLod = minLod;
|
||||
|
|
|
@ -299,7 +299,7 @@ public:
|
|||
|
||||
// TODO: Optimize by getting the locations first and putting in a custom struct
|
||||
UniformBufferDesc dynamicUniforms;
|
||||
GLint samplerLocs_[8]{};
|
||||
GLint samplerLocs_[MAX_TEXTURE_SLOTS]{};
|
||||
std::vector<GLint> dynamicUniformLocs_;
|
||||
GLRProgram *program_ = nullptr;
|
||||
|
||||
|
@ -1149,13 +1149,13 @@ bool OpenGLPipeline::LinkShaders() {
|
|||
queries.push_back({ &samplerLocs_[0], "sampler0" });
|
||||
queries.push_back({ &samplerLocs_[1], "sampler1" });
|
||||
queries.push_back({ &samplerLocs_[2], "sampler2" });
|
||||
_assert_(queries.size() >= MAX_TEXTURE_SLOTS);
|
||||
for (size_t i = 0; i < dynamicUniforms.uniforms.size(); ++i) {
|
||||
queries.push_back({ &dynamicUniformLocs_[i], dynamicUniforms.uniforms[i].name });
|
||||
}
|
||||
std::vector<GLRProgram::Initializer> initialize;
|
||||
initialize.push_back({ &samplerLocs_[0], 0, 0 });
|
||||
initialize.push_back({ &samplerLocs_[1], 0, 1 });
|
||||
initialize.push_back({ &samplerLocs_[2], 0, 2 });
|
||||
for (int i = 0; i < MAX_TEXTURE_SLOTS; ++i)
|
||||
initialize.push_back({ &samplerLocs_[i], 0, i });
|
||||
program_ = render_->CreateProgram(linkShaders, semantics, queries, initialize, false);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue