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

Null pointer when setting Mip LOD Bias #255

Closed
kg opened this issue May 21, 2019 · 8 comments
Closed

Null pointer when setting Mip LOD Bias #255

kg opened this issue May 21, 2019 · 8 comments

Comments

@kg
Copy link
Contributor

kg commented May 21, 2019

image

states[i].value.values is NULL. It's a texture sampler. The name and semantic are also NULL. This is in EffectPass.Apply. The technique is ScreenSpaceBitmapWithLUTTechnique from https://github.com/sq/Fracture/blob/master/Squared/RenderLib/Shaders/SquaredBitmapShader.fx

@flibitijibibo
Copy link
Member

From what I can tell your shader doesn't have any references to MIPMAPLODBIAS... my guess is these values are all just nonsense; I base this mostly on my attempt to parse a binary version of that shader:

[flibitijibibo@flibitTower flibitBuild]$ gdb ./testparse 
GNU gdb (GDB) Fedora 8.3-2.fc30
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./testparse...
(gdb) run glsl120 bins/SquaredBitmapShader.fxb 
Starting program: /home/flibitijibibo/Programming/reProjects/mojoshader/flibitBuild/testparse glsl120 bins/SquaredBitmapShader.fxb
Missing separate debuginfos, use: dnf debuginfo-install glibc-2.29-12.fc30.x86_64
MojoShader testparse
Compiled against changeset hg-1202:3e07483a681c
Linked against changeset hg-1202:3e07483a681c

testparse: /home/flibitijibibo/Programming/reProjects/mojoshader/mojoshader_effects.c:375: readvalue: Assertion `mem->info.parameter_class >= MOJOSHADER_SYMCLASS_SCALAR && mem->info.parameter_class <= MOJOSHADER_SYMCLASS_VECTOR' failed.

Program received signal SIGABRT, Aborted.
0x00007ffff7cbfeb5 in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff7cbfeb5 in raise () from /lib64/libc.so.6
#1  0x00007ffff7caa895 in abort () from /lib64/libc.so.6
#2  0x00007ffff7caa769 in __assert_fail_base.cold () from /lib64/libc.so.6
#3  0x00007ffff7cb85b6 in __assert_fail () from /lib64/libc.so.6
#4  0x0000000000417d81 in readvalue (base=0x7ffff7b90018 "", typeoffset=4, valoffset=140, value=0x42b150, 
    objects=0x42a920, m=0x40c2d5 <MOJOSHADER_internal_malloc>, d=0x0)
    at /home/flibitijibibo/Programming/reProjects/mojoshader/mojoshader_effects.c:375
#5  0x0000000000418228 in readparameters (numparams=19, base=0x7ffff7b90018 "", ptr=0x7fffffffd210, 
    len=0x7fffffffd20c, params=0x42a8c0, objects=0x42a920, m=0x40c2d5 <MOJOSHADER_internal_malloc>, d=0x0)
    at /home/flibitijibibo/Programming/reProjects/mojoshader/mojoshader_effects.c:476
#6  0x00000000004197e6 in MOJOSHADER_parseEffect (profile=0x7fffffffd7e6 "glsl120", 
    buf=0x7ffff7b90010 "\001\t\377\376|\f", _len=41156, swiz=0x0, swizcount=0, smap=0x0, smapcount=0, 
    m=0x40c2d5 <MOJOSHADER_internal_malloc>, f=0x40c300 <MOJOSHADER_internal_free>, d=0x0)
    at /home/flibitijibibo/Programming/reProjects/mojoshader/mojoshader_effects.c:918
#7  0x0000000000403cdf in do_parse (fname=0x7fffffffd7ee "bins/SquaredBitmapShader.fxb", 
    buf=0x7ffff7b90010 "\001\t\377\376|\f", len=41156, prof=0x7fffffffd7e6 "glsl120")
    at /home/flibitijibibo/Programming/reProjects/mojoshader/utils/testparse.c:687
#8  0x0000000000403f10 in main (argc=3, argv=0x7fffffffd3f8)
    at /home/flibitijibibo/Programming/reProjects/mojoshader/utils/testparse.c:739
(gdb)

Looks like you've still got nested structs:

https://github.com/FNA-XNA/MojoShader/blob/fna/mojoshader_effects.c#L374

This is more of a MojoShader issue than FNA, so I've filed an issue over there for you: icculus/mojoshader#8

@flibitijibibo
Copy link
Member

Oh, it's even better than that, it's actually a struct with multidimensional parameters, which apparently didn't have a pleasant layout last time I looked at it (float4x4 rather than float4). Still roughly the same area to look at for fixes.

@kg
Copy link
Contributor Author

kg commented May 21, 2019

OK, I can try adjusting my shaders to see if that fixes this, or I can just see if I can fix this layout issue as well.

@flibitijibibo
Copy link
Member

The hg diff in the MojoShader issue seems to produce the correct struct size, so as long as the matrices don't need to be transposed at CommitChanges for some reason (SetValueMatrix should be doing that, right?) then this will be a quicker fix than expected, at least for matrices.

@kg
Copy link
Contributor Author

kg commented May 21, 2019

That's great. I don't actually see any nested structs in this shader's source so I bet it was just that diff.

@flibitijibibo
Copy link
Member

Also discovered our LODBIAS friend in the headers...

https://github.com/sq/Fracture/blob/master/Squared/RenderLib/Shaders/BitmapCommon.fxh#L26

The parser appears to pull this in just fine:

    PARAM #7
        VALUE: TextureSampler -> (null)
            CLASS: OBJECT
            TYPE: SAMPLER
            ROWS/COLUMNS/ELEMENTS: 0, 0, 0
            TOTAL VALUES: 2
            SAMPLER VALUES:
                TYPE: TEXTURE -> 2
                TYPE: MIPMAPLODBIAS -> 0.00

Texture "2" being the object index for the "BitmapTexture" mapping and MIPMAPLODBIAS correctly printing the value (I threw in some arbitrary values and it was correct each time).

@kg
Copy link
Contributor Author

kg commented May 21, 2019

That makes sense. If it's incompatible I can pull it out of the sampler and set it in code, anyway.

@flibitijibibo
Copy link
Member

GUESS WHO'S FIRED TODAY

ᵐᵉᵉᵉᵉᵉᵉᵉᵉᵉᵉ

50bfe12

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

No branches or pull requests

2 participants