Welcome, Guest.
Username: Password: Remember me

TOPIC: Can't use miplevels in DirectX 10

Can't use miplevels in DirectX 10 4 months 1 week ago #1

  • luluco250
  • luluco250's Avatar
  • Offline
  • Posts: 80
  • Thank you received: 51
Hi, I've came across an issue with D3D10 where I cannot use MipLevels.

As you might know I use them in my HDR shader to get the lowest mipmap (a 1x1 texture) in order to easily determine the overall scene luminosity.
However I just stumbled on this error when attempting to use it in Crysis 1 (in DX10 mode):
E:\Steam Games\steamapps\common\Crysis\Bin32\ReShade\Shaders\HDR_Bloom.fx(222, 9): error: 'ID3D10Device::CreateTexture2D' failed with error code 2147942487!
Here's the full tracelog file generated by ReShade: www.dropbox.com/s/3v6ky7i0b4se3mf/dxgi.tracelog?dl=1

To try and replicate this glitch, try to create a texture with miplevels on a DirectX 10 game.

By the way, I'm porting HDR + Bloom + Tonemapping in a single standalone shader to 3.0, can I do a pull request to the reshade-shaders GitHub when it's finished and adapted to use ReShade.fxh?
The administrator has disabled public write access.

Can't use miplevels in DirectX 10 4 months 1 week ago #2

  • crosire
  • crosire's Avatar
  • Offline
  • Posts: 2438
  • Thank you received: 1387
luluco250 wrote:
However I just stumbled on this error when attempting to use it in Crysis 1 (in DX10 mode)
I managed to create a texture on D3D10 with more than once miplevel, so it has to be something else. What are the dimensions (width + height) of your texture and how many mipmaps are you trying to create for it? It could fail because you try to create more mipmaps than the texture dimensions allow.

luluco250 wrote:
By the way, I'm porting HDR + Bloom + Tonemapping in a single standalone shader to 3.0, can I do a pull request to the reshade-shaders GitHub when it's finished and adapted to use ReShade.fxh?
Absolutly!
Cheers, crosire =)
The administrator has disabled public write access.

Can't use miplevels in DirectX 10 4 months 1 week ago #3

  • luluco250
  • luluco250's Avatar
  • Offline
  • Posts: 80
  • Thank you received: 51
1024x1024, 32 miplevels (square root of 1024)

It's exactly this:
texture tSmall { Width=iHDRBloom_SmallTexRes; Height=iHDRBloom_SmallTexRes; Format=RGBA16F; MipLevels=sqrt(iHDRBloom_SmallTexRes); };
iHDRBloom_SmallTexRes is a preprocessor definition, yes, I've tried using literal values (instead of sqrt()).

This texture has always worked in DirectX 9 games such as Shift 2 Unleashed, Mass Effect, even on converted-to-D3D9 games like Morrowind and Fallout 1 (yes I know it's a weird game to use ReShade on).
The administrator has disabled public write access.

Can't use miplevels in DirectX 10 4 months 1 week ago #4

  • crosire
  • crosire's Avatar
  • Offline
  • Posts: 2438
  • Thank you received: 1387
Turns out to be a bug in the ReShade FX compiler. The "sqrt" there is not handled correctly and produces invalid data which DirectX 10 cannot handle. If you replace that with a constant for now, it works. Will be fixed in the next beta version.
Cheers, crosire =)
The administrator has disabled public write access.
The following user(s) said Thank You: Wicked Sick

Can't use miplevels in DirectX 10 4 months 6 days ago #5

  • luluco250
  • luluco250's Avatar
  • Offline
  • Posts: 80
  • Thank you received: 51
That's the weird thing, I've tried to use:
texture tSmall { Width=1024; Height=1024; Format=RGBA16F; MipLevels=32; };
But still got the same error.

Perhaps it's my own misunderstanding of miplevels, maybe I'm creating too many of them?
All I need is the lowest 1x1 mipmap.

I'll do some tests here and see if I can fix it with literal values.

EDIT:
Found a few things:
1) The max miplevel I can get with 1024 is 11.
2) Realized 11 is log2(1024) + 1
3) ReShade complains about the lack of a literal value when using log2()

So as of now I'll stick to manually inserting the values, the performance difference isn't too significant but the luminosity detection is much better and smoother at 1024x1024.
Last Edit: 4 months 5 days ago by luluco250.
The administrator has disabled public write access.