Skip to content

Commit

Permalink
Main: HardwarePixelBuffer - factor out getNameForRenderTexture
Browse files Browse the repository at this point in the history
and improve naming scheme
  • Loading branch information
paroj committed Aug 23, 2024
1 parent ff3f504 commit 47ffa50
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
2 changes: 2 additions & 0 deletions OgreMain/include/OgreHardwarePixelBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ namespace Ogre {
*/
void _clearSliceRTT(size_t zoffset);
friend class RenderTexture;

String getNameForRenderTexture(const String& parentName) const;
public:
/// Should be called by HardwareBufferManager
HardwarePixelBuffer(uint32 mWidth, uint32 mHeight, uint32 mDepth,
Expand Down
6 changes: 6 additions & 0 deletions OgreMain/src/OgreHardwarePixelBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,10 @@ namespace Ogre
mSliceTRT[zoffset] = NULL;
}


String HardwarePixelBuffer::getNameForRenderTexture(const String& parentName) const
{
// we need to add the pointer value, as the parent texture can have multiple slices or faces
return StringUtil::format("%s:buf%p", parentName.c_str(), this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ namespace Ogre {
mSliceTRT.reserve(mDepth);
for(size_t zoffset=0; zoffset<mDepth; ++zoffset)
{
String name;
name = "rtt/"+StringConverter::toString((size_t)this) + "/" + parentTexture->getName();

String name = getNameForRenderTexture(parentTexture->getName());
RenderTexture *trt = new D3D11RenderTexture(name, this, zoffset, mDevice);
mSliceTRT.push_back(trt);
Root::getSingleton().getRenderSystem()->attachRenderTarget(*trt);
Expand Down
3 changes: 1 addition & 2 deletions RenderSystems/Direct3D9/src/OgreD3D9HardwarePixelBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,8 +985,7 @@ void D3D9HardwarePixelBuffer::updateRenderTexture(bool writeGamma, uint fsaa, co
{
if (mSliceTRT.empty())
{
String name;
name = "rtt/" +Ogre::StringConverter::toString((size_t)this) + "/" + srcName;
String name = getNameForRenderTexture(srcName);

mSliceTRT.push_back(OGRE_NEW D3D9RenderTexture(name, this, writeGamma, fsaa));
Root::getSingleton().getRenderSystem()->attachRenderTarget(*mSliceTRT[0]);
Expand Down
3 changes: 1 addition & 2 deletions RenderSystems/GL/src/OgreGLHardwarePixelBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ GLTextureBuffer::GLTextureBuffer(GLRenderSystem* renderSystem, GLTexture* parent
mSliceTRT.reserve(mDepth);
for(uint32 zoffset=0; zoffset<mDepth; ++zoffset)
{
String name;
name = "rtt/" + StringConverter::toString((size_t)this) + "/" + parent->getName();
String name = getNameForRenderTexture(parent->getName());
GLSurfaceDesc surface;
surface.buffer = this;
surface.zoffset = zoffset;
Expand Down
3 changes: 1 addition & 2 deletions RenderSystems/GL3Plus/src/OgreGL3PlusTextureBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ namespace Ogre {
mSliceTRT.reserve(mDepth);
for(uint32 zoffset=0; zoffset<mDepth; ++zoffset)
{
String name;
name = "rtt/" + StringConverter::toString((size_t)this) + "/" + parent->getName();
String name = getNameForRenderTexture(parent->getName());
GLSurfaceDesc surface;
surface.buffer = this;
surface.zoffset = zoffset;
Expand Down
3 changes: 1 addition & 2 deletions RenderSystems/GLES2/src/OgreGLES2HardwarePixelBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ namespace Ogre {
mSliceTRT.reserve(mDepth);
for(uint32 zoffset=0; zoffset<mDepth; ++zoffset)
{
String name;
name = "rtt/" + StringConverter::toString((size_t)this) + "/" + parent->getName();
String name = getNameForRenderTexture(parent->getName());
GLSurfaceDesc surface;
surface.buffer = this;
surface.zoffset = zoffset;
Expand Down
3 changes: 1 addition & 2 deletions RenderSystems/Metal/src/OgreMetalHardwarePixelBuffer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,7 @@ of this software and associated documentation files (the "Software"), to deal
mSliceTRT.reserve(mDepth);
for(uint32 zoffset=0; zoffset<mDepth; ++zoffset)
{
String name;
name = "rtt/" + StringConverter::toString((size_t)this) + "/" + baseName;
String name = getNameForRenderTexture(baseName);
RenderTexture *trt = OGRE_NEW MetalRenderTexture( device, name, this,
renderTexture, resolveTexture,
mFormat, zoffset, mFace, fsaa, level,
Expand Down
3 changes: 1 addition & 2 deletions RenderSystems/Vulkan/src/OgreVulkanTextureGpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ namespace Ogre
mSliceTRT.reserve(mDepth);
for(size_t zoffset=0; zoffset<mDepth; ++zoffset)
{
String name;
name = "rtt/"+StringConverter::toString((size_t)this) + "/" + mParent->getName();
String name = getNameForRenderTexture(mParent->getName());

RenderTexture *trt = new VulkanRenderTexture(name, this, zoffset, mParent, mFace);
mSliceTRT.push_back(trt);
Expand Down

0 comments on commit 47ffa50

Please sign in to comment.