Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: RenderTexture artifacts (Mac only)  (Read 5663 times)

0 Members and 1 Guest are viewing this topic.

Acrobat

  • Full Member
  • ***
  • Posts: 153
    • View Profile
RenderTexture artifacts (Mac only)
« on: December 04, 2012, 11:05:06 am »
I have a strange problem with Render Texture. I have a button with label on animated mesh, what i do:
1. create a render target with proper width and height.
2. render label in it.
3. copy result to image
sf::Image * image = new sf::Image(m_renderTexture->getTexture().copyToImage());
4. create new texture from image.
5. delete render texture.

Result:
When i repeat this for a couple times, i can see strange artifacts with other textures. They are valid, but memory is corrupted, or something like a sliced page in memory. I can see parts of textures from browser or else.

I can repeat it only on Mac.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: Re: RenderTexture artifacts (Mac only)
« Reply #1 on: December 04, 2012, 11:20:35 am »
I have a strange problem with Render Texture. I have a button with label on animated mesh, what i do:
1. create a render target with proper width and height.
Don't mix diffrent terms, otherwise it can get confusing quickly. ;)

When i repeat this for a couple times, i can see strange artifacts with other textures. They are valid, but memory is corrupted, or something like a sliced page in memory. I can see parts of textures from browser or else.
Although I've no idea why one would such strange things, the problem seems to be that you probably don't call rt.clear()...

Als rather than describing what you do you should provide a minimal and complete example.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Acrobat

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Re: RenderTexture artifacts (Mac only)
« Reply #2 on: December 04, 2012, 11:26:47 am »
I do clear with transparent color.
Also i do not create every time a new RenderTexture, i use the same, but i recreate it, if it have different dimensions.

I don't think it's possible to make a minimal example, we have a lot of code, and modified graphics package (only blend modes, and compressed textures). Artifacts somehow appear on the next loaded textures.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: Re: RenderTexture artifacts (Mac only)
« Reply #3 on: December 04, 2012, 01:02:45 pm »
I do clear with transparent color.
Also i do not create every time a new RenderTexture, i use the same, but i recreate it, if it have different dimensions.
Well if the render texture holds some junk and you "clear" it with a transparent color, the junk underneath will obviously still shine through...

I don't think it's possible to make a minimal example, we have a lot of code, and modified graphics package (only blend modes, and compressed textures). Artifacts somehow appear on the next loaded textures.
It is always possible and just a matter of will. You don't nessecarily have to take it from your code, but you can write a simple example from ground up. This has additionally the advantage, that one would notice, if it was caused by your modifications.

Generally the rule counts: If it's a problem with SFML, then it's reproducable with a minimal and complete example. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: RenderTexture artifacts (Mac only)
« Reply #4 on: December 04, 2012, 01:15:14 pm »
Quote
Well if the render texture holds some junk and you "clear" it with a transparent color, the junk underneath will obviously still shine through...
Nop. Pixels are overwritten with the color; whether its alpha is 255 or lower doesn't make any difference. The alpha is not interpreted, you're not drawing anything, just filling the backbuffer with a color.
So clearing with transparent color is perfectly valid. By the way, "transparent" is not a color, you'd better say "transparent black" for example -- the RGB components also have a value.
Laurent Gomila - SFML developer

Acrobat

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Re: RenderTexture artifacts (Mac only)
« Reply #5 on: December 04, 2012, 01:36:16 pm »
Well my problem is after when i render to texture, next loaded texture is not valid, it has parts of other textures (even not loaded, but icons from google chrome or else), if i comment the creating of render textures, everything is Ok.

But this code works perfect on Win Xp/7/8.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: RenderTexture artifacts (Mac only)
« Reply #6 on: December 04, 2012, 04:23:54 pm »
Can you provide a minimal code that reproduce the issue ?
SFML / OS X developer

Acrobat

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Re: RenderTexture artifacts (Mac only)
« Reply #7 on: December 04, 2012, 04:57:07 pm »
I'm afraid no  :( (have no time for this, project is commercial, and must be released soon), but i still can reproduce it.
I cant even imagine where is the problem, because everything works fine, except some textures are broken, i can see parts of icons from desktop and browser in my window. Also we have the same effect on other Mac.
Modifications i did in graphics package :
added function for loading DDS textures (only DXT5).

void Texture::updateDDS( const Uint8* pixels, unsigned int width, unsigned int height )
{
        assert(width <= m_size.x);
        assert(height <= m_size.y);

        if (pixels && m_texture)
        {
                ensureGlContext();

                // Make sure that the current texture binding will be preserved
                priv::TextureSaver save;

                // Copy pixels from the given array to the texture
                glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
                //glCheck(glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
                glCheck(glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, width, height, 0, ((width + 3) / 4) * ((height + 3) / 4) * 16, pixels));
                m_pixelsFlipped = false;
                m_cacheId = getUniqueId();
        }
}
 

and blend modes (there was a topic already, nothing wrong with this).

At the moment we commented out this animation in Mac builds.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: RenderTexture artifacts (Mac only)
« Reply #8 on: December 04, 2012, 05:01:43 pm »
Without minimal code I can't do anything. If you can, come back one day with one.
SFML / OS X developer

Acrobat

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Re: RenderTexture artifacts (Mac only)
« Reply #9 on: March 27, 2013, 03:46:39 pm »
Time to update this issue, it's not fixed. Same issue here : http://www.sfml-dev.org/old-forum/viewtopic.php?t=6769&sid=86d7d8d59ac0b9e1c18ede2c445ec0b1

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: RenderTexture artifacts (Mac only)
« Reply #10 on: March 27, 2013, 03:53:46 pm »
Well, then provide a SSCCE !

BTW, the linked topic is about an older version of SFML so I can't use that for testing.
SFML / OS X developer

Acrobat

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Re: RenderTexture artifacts (Mac only)
« Reply #11 on: March 27, 2013, 04:41:43 pm »
Well, then provide a SSCCE !

BTW, the linked topic is about an older version of SFML so I can't use that for testing.
Okay, nevermind.
Some words : we are using multithreaded loading for resources, and we had problems with it (mixing with render textures), after using render texture we had many other textures broken (strange glitches). I just added glFlush() everywhere where i create/load/delete sf::Texture and sf::RenderTexture. For me the problem is solved. I can send you screenshots but after the game will be released.  ;)

If someone will have the same issue : just use glFlush().