Use 64bit texture handler for pointer later

This commit is contained in:
Benau 2021-04-14 01:05:44 +08:00
parent 65faa029ca
commit c5bbefd476
19 changed files with 32 additions and 36 deletions

View File

@ -193,7 +193,7 @@ public:
const io::SNamedPath& getName() const { return NamedPath; }
//! return open gl texture name
virtual u32 getOpenGLTextureName() const = 0;
virtual u64 getTextureHandler() const = 0;
virtual u32 getTextureSize() const { return 0; }

View File

@ -749,7 +749,7 @@ namespace video
virtual E_DRIVER_TYPE getDriverType() const { return video::EDT_NULL; }
virtual ECOLOR_FORMAT getColorFormat() const { return video::ECF_A1R5G5B5; };
virtual u32 getPitch() const { return 0; }
virtual u32 getOpenGLTextureName() const { return 0; }
virtual u64 getTextureHandler() const { return 0; }
virtual u64 getHandle() { return 0; }
virtual void regenerateMipMapLevels(void* mipmapData=0) {};
core::dimension2d<u32> size;

View File

@ -2840,7 +2840,7 @@ namespace video
setActiveTexture(GL_TEXTURE0 + stage);
if(Driver->CurrentTexture[stage])
glBindTexture(GL_TEXTURE_2D, Driver->CurrentTexture[stage]->getOpenGLTextureName());
glBindTexture(GL_TEXTURE_2D, Driver->CurrentTexture[stage]->getTextureHandler());
Texture[stage] = Driver->CurrentTexture[stage];
}

View File

@ -429,7 +429,7 @@ u32 COGLES2Texture::getPitch() const
//! return open gl texture name
GLuint COGLES2Texture::getOpenGLTextureName() const
u64 COGLES2Texture::getTextureHandler() const
{
return TextureName;
}

View File

@ -83,9 +83,7 @@ public:
virtual u32 getPitch() const;
//! return open gl texture name
virtual u32 getOpenGLTextureName() const;
virtual u64 getHandle() { return 0; }
virtual u64 getTextureHandler() const;
//! return whether this texture has mipmaps
virtual bool hasMipMaps() const;

View File

@ -2646,7 +2646,7 @@ bool COpenGLDriver::setActiveTexture(u32 stage, const video::ITexture* texture)
if (!useCoreContext)
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture->getOpenGLTextureName());
glBindTexture(GL_TEXTURE_2D, texture->getTextureHandler());
}
return true;
}
@ -4536,7 +4536,7 @@ bool COpenGLDriver::setRenderTarget(const core::array<video::IRenderTarget>& tar
// attach texture to FrameBuffer Object on Color [i]
attachment = GL_COLOR_ATTACHMENT0_EXT+i;
if ((i != 0) && (targets[i].RenderTexture != RenderTargetTexture))
extGlFramebufferTexture2D(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_2D, static_cast<COpenGLTexture*>(targets[i].RenderTexture)->getOpenGLTextureName(), 0);
extGlFramebufferTexture2D(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_2D, static_cast<COpenGLTexture*>(targets[i].RenderTexture)->getTextureHandler(), 0);
#endif
MRTs[i]=attachment;
}

View File

@ -603,7 +603,7 @@ u32 COpenGLTexture::getPitch() const
//! return open gl texture name
GLuint COpenGLTexture::getOpenGLTextureName() const
u64 COpenGLTexture::getTextureHandler() const
{
return TextureName;
}

View File

@ -83,9 +83,7 @@ public:
virtual u32 getPitch() const;
//! return open gl texture name
virtual u32 getOpenGLTextureName() const;
virtual u64 getHandle() { return 0; }
virtual u64 getTextureHandler() const;
//! return whether this texture has mipmaps
virtual bool hasMipMaps() const;

View File

@ -235,7 +235,7 @@ void FontDrawer::draw()
glEnableVertexAttribArray(3);
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*)12);
FontDrawerShader::getInstance()->setTextureUnits(
glyph.first->getOpenGLTextureName());
glyph.first->getTextureHandler());
glDrawElements(GL_TRIANGLES, idx_count,
indices_32.empty() ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);

View File

@ -254,7 +254,7 @@ void FontWithFace::insertGlyph(unsigned font_number, unsigned glyph_index)
if (bits->buffer != NULL && !GUIEngine::isNoGraphics())
{
video::ITexture* tex = m_spritebank->getTexture(cur_tex);
glBindTexture(GL_TEXTURE_2D, tex->getOpenGLTextureName());
glBindTexture(GL_TEXTURE_2D, tex->getTextureHandler());
if (bits->pixel_mode == FT_PIXEL_MODE_GRAY)
{
if (CVS->isARBTextureSwizzleUsable() && !useColorGlyphPage())

View File

@ -161,7 +161,7 @@ static void drawTexColoredQuad(const video::ITexture *texture,
ColoredTextureRectShader::getInstance()->use();
glBindVertexArray(ColoredTextureRectShader::getInstance()->m_vao);
ColoredTextureRectShader::getInstance()
->setTextureUnits(texture->getOpenGLTextureName());
->setTextureUnits(texture->getTextureHandler());
ColoredTextureRectShader::getInstance()
->setUniforms(core::vector2df(center_pos_x, center_pos_y),
core::vector2df(width, height),
@ -292,7 +292,7 @@ void draw2DImage(const video::ITexture* texture,
UniformColoredTextureRectShader::getInstance()->use();
glBindVertexArray(SharedGPUObjects::getUI_VAO());
UniformColoredTextureRectShader::getInstance()
->setTextureUnits(texture->getOpenGLTextureName());
->setTextureUnits(texture->getTextureHandler());
UniformColoredTextureRectShader::getInstance()
->setUniforms(core::vector2df(center_pos_x, center_pos_y),
@ -407,7 +407,7 @@ void draw2DImage(const video::ITexture* texture,
}
else
{
drawTexQuad(texture->getOpenGLTextureName(), width, height,
drawTexQuad(texture->getTextureHandler(), width, height,
center_pos_x, center_pos_y, tex_center_pos_x,
tex_center_pos_y, tex_width, tex_height, rotation);
}
@ -454,7 +454,7 @@ void draw2DImageCustomAlpha(const irr::video::ITexture* texture,
TextureRectCustomAlphaShader::getInstance()->use();
glBindVertexArray(SharedGPUObjects::getUI_VAO());
TextureRectCustomAlphaShader::getInstance()->setTextureUnits(texture->getOpenGLTextureName());
TextureRectCustomAlphaShader::getInstance()->setTextureUnits(texture->getTextureHandler());
TextureRectCustomAlphaShader::getInstance()->setUniforms(
core::vector2df(center_pos_x, center_pos_y),
core::vector2df(width, height),
@ -506,7 +506,7 @@ void draw2DVertexPrimitiveList(video::ITexture *tex, const void* vertices,
Primitive2DList::getInstance()->setUniforms(1.0f,
core::vector2df(float(irr_driver->getActualScreenSize().Width),
float(irr_driver->getActualScreenSize().Height)));
Primitive2DList::getInstance()->setTextureUnits(tex->getOpenGLTextureName());
Primitive2DList::getInstance()->setTextureUnits(tex->getTextureHandler());
glDrawElements(GL_TRIANGLE_FAN, primitiveCount, GL_UNSIGNED_SHORT, 0);
glDeleteVertexArrays(1, &tmpvao);

View File

@ -318,7 +318,7 @@ void CPUParticleManager::drawAll()
cur_mat->getShaderName() == "alphablend")
{
ParticleRenderer::getInstance()->setTextureUnits
(cur_mat->getTexture()->getOpenGLTextureName(),
(cur_mat->getTexture()->getTextureHandler(),
CVS->isDeferredEnabled() ?
irr_driver->getDepthStencilTexture() : 0);
ParticleRenderer::getInstance()->setUniforms(flips, billboard);
@ -326,7 +326,7 @@ void CPUParticleManager::drawAll()
else
{
AlphaTestParticleRenderer::getInstance()->setTextureUnits
(cur_mat->getTexture()->getOpenGLTextureName());
(cur_mat->getTexture()->getTextureHandler());
AlphaTestParticleRenderer::getInstance()->setUniforms(flips);
}
glBindVertexArray(m_gl_particles.at(p.second)->m_vao);

View File

@ -383,7 +383,7 @@ public:
setTextureUnits(render_target_bloom_128,
render_target_bloom_256,
render_target_bloom_512,
m_lens_dust_tex->getOpenGLTextureName());
m_lens_dust_tex->getTextureHandler());
drawFullScreenEffect();
} // render
}; // BloomBlendShader
@ -690,7 +690,7 @@ public:
GLuint rtt_mlaa_tmp)
{
use();
setTextureUnits(rtt_mlaa_tmp, area_map->getOpenGLTextureName());
setTextureUnits(rtt_mlaa_tmp, area_map->getTextureHandler());
drawFullScreenEffect(pixel_size);
} // render
@ -750,7 +750,7 @@ PostProcessing::PostProcessing()
"AreaMap33", false);
video::IImage* img = irr_driver->getVideoDriver()->createImageFromFile(areamap);
m_areamap = new STKTexture(img, "AreaMap33");
if (m_areamap->getOpenGLTextureName() == 0)
if (m_areamap->getTextureHandler() == 0)
{
Log::fatal("postprocessing", "Failed to load the areamap");
return;

View File

@ -1146,12 +1146,12 @@ void updateModelMatrix()
(material_id);
texture_names =
{{
textures[0]->getOpenGLTextureName(),
textures[1]->getOpenGLTextureName(),
textures[2]->getOpenGLTextureName(),
textures[3]->getOpenGLTextureName(),
textures[4]->getOpenGLTextureName(),
textures[5]->getOpenGLTextureName()
textures[0]->getTextureHandler(),
textures[1]->getTextureHandler(),
textures[2]->getTextureHandler(),
textures[3]->getTextureHandler(),
textures[4]->getTextureHandler(),
textures[5]->getTextureHandler()
}};
}
g_final_draw_calls[i][dc].second.emplace_back

View File

@ -490,7 +490,7 @@ void SPShaderManager::addPrefilledTexturesToShader(SPShader* s,
s->addCustomPrefilledTextures(std::get<3>(p)/*sampler_type*/,
GL_TEXTURE_2D, std::get<0>(p)/*name_in_shader*/, [pt]()->GLuint
{
return pt->getOpenGLTextureName();
return pt->getTextureHandler();
}, rp);
}
}

View File

@ -181,7 +181,7 @@ public:
// ------------------------------------------------------------------------
std::shared_ptr<video::IImage> getTextureImage() const;
// ------------------------------------------------------------------------
GLuint getOpenGLTextureName() const { return m_texture_name; }
GLuint getTextureHandler() const { return m_texture_name; }
// ------------------------------------------------------------------------
bool initialized() const
{ return m_width.load() != 0 && m_height.load() != 0; }

View File

@ -87,7 +87,7 @@ video::ITexture* STKTexManager::getTexture(const std::string& path,
{
new_texture = new STKTexture(full_path.empty() ? path : full_path,
tc, no_upload);
if (new_texture->getOpenGLTextureName() == 0 && !no_upload)
if (new_texture->getTextureHandler() == 0 && !no_upload)
{
const char* name = new_texture->getName().getPtr();
if (!m_texture_error_message.empty())

View File

@ -101,7 +101,7 @@ public:
// ------------------------------------------------------------------------
virtual void regenerateMipMapLevels(void* mipmap_data = NULL) {}
// ------------------------------------------------------------------------
virtual u32 getOpenGLTextureName() const { return m_texture_name; }
virtual u64 getTextureHandler() const { return m_texture_name; }
// ------------------------------------------------------------------------
virtual unsigned int getTextureSize() const { return m_texture_size; }
// ------------------------------------------------------------------------

View File

@ -71,7 +71,7 @@ void drawAll()
for (auto& p : g_tbs)
{
TBRenderer::getInstance()
->setTextureUnits(p.first->getOpenGLTextureName());
->setTextureUnits(p.first->getTextureHandler());
for (auto* q : p.second)
{
q->draw(p.first);