Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DirectX9: Texture bug, IDirect3DStateBlock9 might contains invalid values. #3857

Closed
Nemirtingas opened this issue Mar 1, 2021 · 7 comments
Closed
Labels

Comments

@Nemirtingas
Copy link

Nemirtingas commented Mar 1, 2021

Version/Branch of Dear ImGui:

Version:
Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_dx9.cpp + imgui_impl_win32.cpp
Compiler: MSVC
Operating System: Windows 10 - 1909 - 18363.1379
CPU: Intel Core i5-7300HQ
GPU: NVidia GTX 1060 3Gb
GPU Driver: NVidia 452.06

My Issue/Question:
I'm building an in-game overlay, some games that use DX9 have an issue when using ImGui, some textures disapear when I open my overlay, it looks like the issue is triggered by the state block.

if (g_pd3dDevice->CreateStateBlock(D3DSBT_ALL, &d3d9_state_block) < 0)
return;

Adding a call to IDirect3DStateBlock9::Capture fixed those issues.

    // Backup the DX9 state
    IDirect3DStateBlock9* d3d9_state_block = NULL;
    if (FAILED(g_pd3dDevice->CreateStateBlock(D3DSBT_ALL, &d3d9_state_block)))
        return;

    if (FAILED(d3d9_state_block->Capture()))
    {
        d3d9_state_block->Release();
        return;
    }
@Demonese
Copy link
Contributor

Demonese commented Mar 1, 2021

interesting bug, but why?
CreateStateBlock and Capture should do the same thing, maybe a bug in d3d9?

I recommend a nice toolkit to debug d3d9: IntelGPA. Hope it can help you.

@ocornut
Copy link
Owner

ocornut commented Mar 2, 2021

Hello,

Same reaction as Demonese.

Before we go on adding random workarounds like this, I would like that you carry the burden of proof here by providing a repro or a deeper study or sufficient documentation as to why this would be needed.

Providing info about the hooked software, drivers involved, and maybe a video or with/without would give extra context.

@ocornut ocornut changed the title [Windows][DX9] Texture bug, IDirect3DStateBlock9 might contains invalid values. DirectX9: Texture bug, IDirect3DStateBlock9 might contains invalid values. Mar 2, 2021
@Nemirtingas
Copy link
Author

Nemirtingas commented Mar 2, 2021

Hi,

I understand perfectly, I'm just reporting some buggy behavior. Of course, hooking into a process and redirecting the 3D Renderer is also not something common.
I don't know what is the real problem nor I know if that's the right solution. I know very little about Rendering stuff,

I'll try to provide you some video with the Capture call on and off.

For now, I uploaded my overlay here if you need to take a look: https://github.com/Nemirtingas/ingame_overlay/

I tweaked a bit Dear ImGui on my fork: https://github.com/Nemirtingas/imgui

Here, I've uploaded a video of the bug happening: https://imgur.com/a/6ayy2vp
It happens in the game Black Mesa.

ocornut added a commit that referenced this issue Mar 18, 2021
…apture() after CreateStateBlock() which appears to workaround/fix state restoring issues. . (#3857)
@ocornut
Copy link
Owner

ocornut commented Mar 18, 2021

Thank you @Nemirtingas for the details and video.
I've committed the workaround in 61a0908

@ocornut ocornut closed this as completed Mar 18, 2021
@Nemirtingas
Copy link
Author

Thank you.

@dumbasPL
Copy link

I can also confirm that this gitch occurs in other source games and this does in fact fix it.
Thank you for finally fixing this.

@MMOForum
Copy link

MMOForum commented Mar 2, 2023

Hi bro texture problem
https://www.hizliresim.com/eajzfih

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants