Can't use miplevels in DirectX 10

  • luluco250
  • Topic Author
More
7 years 8 months ago #1 by luluco250 Can't use miplevels in DirectX 10 was created by luluco250
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?

Please Log in or Create an account to join the conversation.

  • crosire
More
7 years 8 months ago #2 by crosire Replied by crosire on topic Can't use miplevels in DirectX 10

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!

Please Log in or Create an account to join the conversation.

  • luluco250
  • Topic Author
More
7 years 8 months ago #3 by luluco250 Replied by luluco250 on topic Can't use miplevels in DirectX 10
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).

Please Log in or Create an account to join the conversation.

  • crosire
More
7 years 8 months ago #4 by crosire Replied by crosire on topic Can't use miplevels in DirectX 10
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.
The following user(s) said Thank You: Wicked Sick

Please Log in or Create an account to join the conversation.

  • luluco250
  • Topic Author
More
7 years 8 months ago - 7 years 8 months ago #5 by luluco250 Replied by luluco250 on topic Can't use miplevels in DirectX 10
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: 7 years 8 months ago by luluco250.

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.