Comments (7)
Let's look at the AccessViolationExceptions first, do you have any traces from those?
I can reproduce the color issue on Linux and can confirm that it's the preshader; disabling preshaders gives us the D3D behavior. Here's the meptool output, let's debug from there:
With preshader:
PARAM #0
VALUE: World -> (null)
CLASS: ROW-MAJOR MATRIX
TYPE: FLOAT
ROWS/COLUMNS/ELEMENTS: 4, 4, 0
TOTAL VALUES: 16
FLOAT VALUES:
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
PARAM #1
VALUE: View -> (null)
CLASS: ROW-MAJOR MATRIX
TYPE: FLOAT
ROWS/COLUMNS/ELEMENTS: 4, 4, 0
TOTAL VALUES: 16
FLOAT VALUES:
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
PARAM #2
VALUE: Projection -> (null)
CLASS: ROW-MAJOR MATRIX
TYPE: FLOAT
ROWS/COLUMNS/ELEMENTS: 4, 4, 0
TOTAL VALUES: 16
FLOAT VALUES:
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
PARAM #3
VALUE: InvWorld -> (null)
CLASS: ROW-MAJOR MATRIX
TYPE: FLOAT
ROWS/COLUMNS/ELEMENTS: 4, 4, 0
TOTAL VALUES: 16
FLOAT VALUES:
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
TECHNIQUE #0 ('Technique1'):
PASS #0 ('Pass1'):
STATE 8:
VALUE: (null) -> (null)
CLASS: ROW-MAJOR MATRIX
TYPE: INT
ROWS/COLUMNS/ELEMENTS: 1, 1, 0
TOTAL VALUES: 1
INT VALUES:
1
STATE 146:
VALUE: (null) -> (null)
CLASS: OBJECT
TYPE: VERTEXSHADER
ROWS/COLUMNS/ELEMENTS: 0, 0, 0
TOTAL VALUES: 1
VERTEXSHADER VALUES:
1
STATE 147:
VALUE: (null) -> (null)
CLASS: OBJECT
TYPE: PIXELSHADER
ROWS/COLUMNS/ELEMENTS: 0, 0, 0
TOTAL VALUES: 1
PIXELSHADER VALUES:
2
OBJECT #1: SHADER, technique 0, pass 0
PROFILE: glsl
SHADER TYPE: vertex
VERSION: 2.0
INSTRUCTION COUNT: 13
INPUTS:
* position ("vs_v0")
OUTPUTS:
* (null) ("vs_oPos")
* (null) ("vs_oD0")
CONSTANTS: (none.)
UNIFORMS:
* 0: float ("vs_c0")
* 1: float ("vs_c1")
* 2: float ("vs_c2")
* 3: float ("vs_c3")
* 4: float ("vs_c4")
* 5: float ("vs_c5")
* 6: float ("vs_c6")
* 7: float ("vs_c7")
* 8: float ("vs_c8")
* 9: float ("vs_c9")
* 10: float ("vs_c10")
* 11: float ("vs_c11")
* 12: float ("vs_c12")
SAMPLERS: (none.)
SYMBOLS:
* 0: "Projection"
register set float4
register index 8
register count 4
symbol class column-major matrix
symbol type float
rows 4
columns 4
elements 1
* 1: "View"
register set float4
register index 4
register count 4
symbol class column-major matrix
symbol type float
rows 4
columns 4
elements 1
* 2: "World"
register set float4
register index 0
register count 4
symbol class column-major matrix
symbol type float
rows 4
columns 4
elements 1
PRESHADER:
SYMBOLS:
* 0: "InvWorld"
register set float4
register index 0
register count 3
symbol class column-major matrix
symbol type float
rows 4
columns 4
elements 1
mov c12.x, c0.z
mov c12.y, c1.z
mov c12.z, c2.z
mov c12.w, (1)
OUTPUT:
#version 120
uniform vec4 vs_uniforms_vec4[13];
uniform float vpFlip;
vec4 vs_r0;
vec4 vs_r1;
#define vs_c0 vs_uniforms_vec4[0]
#define vs_c1 vs_uniforms_vec4[1]
#define vs_c2 vs_uniforms_vec4[2]
#define vs_c3 vs_uniforms_vec4[3]
#define vs_c4 vs_uniforms_vec4[4]
#define vs_c5 vs_uniforms_vec4[5]
#define vs_c6 vs_uniforms_vec4[6]
#define vs_c7 vs_uniforms_vec4[7]
#define vs_c8 vs_uniforms_vec4[8]
#define vs_c9 vs_uniforms_vec4[9]
#define vs_c10 vs_uniforms_vec4[10]
#define vs_c11 vs_uniforms_vec4[11]
#define vs_c12 vs_uniforms_vec4[12]
attribute vec4 vs_v0;
#define vs_oPos gl_Position
#define vs_oD0 gl_FrontColor
void main()
{
vs_r0.x = dot(vs_v0, vs_c0);
vs_r0.y = dot(vs_v0, vs_c1);
vs_r0.z = dot(vs_v0, vs_c2);
vs_r0.w = dot(vs_v0, vs_c3);
vs_r1.x = dot(vs_r0, vs_c4);
vs_r1.y = dot(vs_r0, vs_c5);
vs_r1.z = dot(vs_r0, vs_c6);
vs_r1.w = dot(vs_r0, vs_c7);
vs_oPos.x = dot(vs_r1, vs_c8);
vs_oPos.y = dot(vs_r1, vs_c9);
vs_oPos.z = dot(vs_r1, vs_c10);
vs_oPos.w = dot(vs_r1, vs_c11);
vs_oD0 = vs_c12;
gl_Position.y = gl_Position.y * vpFlip;
gl_Position.z = gl_Position.z * 2.0 - gl_Position.w;
}
OBJECT #2: SHADER, technique 0, pass 0
PROFILE: glsl
SHADER TYPE: pixel
VERSION: 2.0
INSTRUCTION COUNT: 1
INPUTS: (none.)
OUTPUTS:
* (null) ("ps_oC0")
CONSTANTS: (none.)
UNIFORMS: (none.)
SAMPLERS: (none.)
SYMBOLS: (none.)
OUTPUT:
#version 120
#define ps_v0 gl_Color
#define ps_oC0 gl_FragColor
void main()
{
ps_oC0 = ps_v0;
}
Without preshader:
PARAM #0
VALUE: World -> (null)
CLASS: ROW-MAJOR MATRIX
TYPE: FLOAT
ROWS/COLUMNS/ELEMENTS: 4, 4, 0
TOTAL VALUES: 16
FLOAT VALUES:
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
PARAM #1
VALUE: View -> (null)
CLASS: ROW-MAJOR MATRIX
TYPE: FLOAT
ROWS/COLUMNS/ELEMENTS: 4, 4, 0
TOTAL VALUES: 16
FLOAT VALUES:
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
PARAM #2
VALUE: Projection -> (null)
CLASS: ROW-MAJOR MATRIX
TYPE: FLOAT
ROWS/COLUMNS/ELEMENTS: 4, 4, 0
TOTAL VALUES: 16
FLOAT VALUES:
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
PARAM #3
VALUE: InvWorld -> (null)
CLASS: ROW-MAJOR MATRIX
TYPE: FLOAT
ROWS/COLUMNS/ELEMENTS: 4, 4, 0
TOTAL VALUES: 16
FLOAT VALUES:
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
TECHNIQUE #0 ('Technique1'):
PASS #0 ('Pass1'):
STATE 8:
VALUE: (null) -> (null)
CLASS: ROW-MAJOR MATRIX
TYPE: INT
ROWS/COLUMNS/ELEMENTS: 1, 1, 0
TOTAL VALUES: 1
INT VALUES:
1
STATE 146:
VALUE: (null) -> (null)
CLASS: OBJECT
TYPE: VERTEXSHADER
ROWS/COLUMNS/ELEMENTS: 0, 0, 0
TOTAL VALUES: 1
VERTEXSHADER VALUES:
1
STATE 147:
VALUE: (null) -> (null)
CLASS: OBJECT
TYPE: PIXELSHADER
ROWS/COLUMNS/ELEMENTS: 0, 0, 0
TOTAL VALUES: 1
PIXELSHADER VALUES:
2
OBJECT #1: SHADER, technique 0, pass 0
PROFILE: glsl
SHADER TYPE: vertex
VERSION: 2.0
INSTRUCTION COUNT: 16
INPUTS:
* position ("vs_v0")
OUTPUTS:
* (null) ("vs_oPos")
* (null) ("vs_oD0")
CONSTANTS:
* 15: float (1.000000 0.000000 0.000000 0.000000)
UNIFORMS:
* 0: float ("vs_c0")
* 1: float ("vs_c1")
* 2: float ("vs_c2")
* 3: float ("vs_c3")
* 4: float ("vs_c4")
* 5: float ("vs_c5")
* 6: float ("vs_c6")
* 7: float ("vs_c7")
* 8: float ("vs_c8")
* 9: float ("vs_c9")
* 10: float ("vs_c10")
* 11: float ("vs_c11")
* 12: float ("vs_c12")
* 13: float ("vs_c13")
* 14: float ("vs_c14")
SAMPLERS: (none.)
SYMBOLS:
* 0: "InvWorld"
register set float4
register index 12
register count 3
symbol class column-major matrix
symbol type float
rows 4
columns 4
elements 1
* 1: "Projection"
register set float4
register index 8
register count 4
symbol class column-major matrix
symbol type float
rows 4
columns 4
elements 1
* 2: "View"
register set float4
register index 4
register count 4
symbol class column-major matrix
symbol type float
rows 4
columns 4
elements 1
* 3: "World"
register set float4
register index 0
register count 4
symbol class column-major matrix
symbol type float
rows 4
columns 4
elements 1
OUTPUT:
#version 120
uniform vec4 vs_uniforms_vec4[15];
uniform float vpFlip;
const vec4 vs_c15 = vec4(1.0, 0.0, 0.0, 0.0);
vec4 vs_r0;
vec4 vs_r1;
#define vs_c0 vs_uniforms_vec4[0]
#define vs_c1 vs_uniforms_vec4[1]
#define vs_c2 vs_uniforms_vec4[2]
#define vs_c3 vs_uniforms_vec4[3]
#define vs_c4 vs_uniforms_vec4[4]
#define vs_c5 vs_uniforms_vec4[5]
#define vs_c6 vs_uniforms_vec4[6]
#define vs_c7 vs_uniforms_vec4[7]
#define vs_c8 vs_uniforms_vec4[8]
#define vs_c9 vs_uniforms_vec4[9]
#define vs_c10 vs_uniforms_vec4[10]
#define vs_c11 vs_uniforms_vec4[11]
#define vs_c12 vs_uniforms_vec4[12]
#define vs_c13 vs_uniforms_vec4[13]
#define vs_c14 vs_uniforms_vec4[14]
attribute vec4 vs_v0;
#define vs_oPos gl_Position
#define vs_oD0 gl_FrontColor
void main()
{
vs_r0.x = dot(vs_v0, vs_c0);
vs_r0.y = dot(vs_v0, vs_c1);
vs_r0.z = dot(vs_v0, vs_c2);
vs_r0.w = dot(vs_v0, vs_c3);
vs_r1.x = dot(vs_r0, vs_c4);
vs_r1.y = dot(vs_r0, vs_c5);
vs_r1.z = dot(vs_r0, vs_c6);
vs_r1.w = dot(vs_r0, vs_c7);
vs_oPos.x = dot(vs_r1, vs_c8);
vs_oPos.y = dot(vs_r1, vs_c9);
vs_oPos.z = dot(vs_r1, vs_c10);
vs_oPos.w = dot(vs_r1, vs_c11);
vs_r0.xy = vs_c15.xy;
vs_oD0.xw = (vs_c12.zz * vs_r0.xy) + vs_r0.yx;
vs_oD0.y = vs_c13.z;
vs_oD0.z = vs_c14.z;
gl_Position.y = gl_Position.y * vpFlip;
gl_Position.z = gl_Position.z * 2.0 - gl_Position.w;
}
OBJECT #2: SHADER, technique 0, pass 0
PROFILE: glsl
SHADER TYPE: pixel
VERSION: 2.0
INSTRUCTION COUNT: 1
INPUTS: (none.)
OUTPUTS:
* (null) ("ps_oC0")
CONSTANTS: (none.)
UNIFORMS: (none.)
SAMPLERS: (none.)
SYMBOLS: (none.)
OUTPUT:
#version 120
#define ps_v0 gl_Color
#define ps_oC0 gl_FragColor
void main()
{
ps_oC0 = ps_v0;
}
from fna-mghistory.
Here's where the color becomes a mess:
Here's how the color is calculated in the GLSL:
// Example inputs, c15 is actually constant
vs_c12 = (-0.572867, 0, 0.819648, 0);
vs_c13 = (0, 1, 0, 0);
vs_c14 = (-0.819648, 0, -0.572867, 0);
vs_c15 = (1, 0);
// vs_oD0 is color output
vs_r0.xy = vs_c15.xy;
vs_oD0.xw = (vs_c12.zz * vs_r0.xy) + vs_r0.yx;
vs_oD0.y = vs_c13.z;
vs_oD0.z = vs_c14.z;
The result of this, given those values, should be (0.819648, 0, -0.572867, 1).
And here's the preshader:
// Example inputs
c0 = (-0.572867, 0, -0.819648, 0);
c1 = (0, 1, 0, 0);
c2 = (0.819648, 0, -0.572867, 0);
// c12 is unmodified in the GLSL, becomes color
mov c12.x, c0.z
mov c12.y, c1.z
mov c12.z, c2.z
mov c12.w, (1)
Notice anything wrong?
For some reason it's a mov
instruction and not a neg
instruction for c0.z. I don't know where the error is exactly; for all I know it wants to treat c0.z as -c0.z, though again, that really should be a neg
...
This probably means that we're parsing the preshader incorrectly. Here's where the parsing happens:
https://github.com/flibitijibibo/MojoShader/blob/master/mojoshader.c#L8234
I think this is the same as the duplicate method I had to make for technique shader selector preshaders, but maybe that's why this doesn't work:
https://github.com/flibitijibibo/MojoShader/blob/master/mojoshader.c#L9625
from fna-mghistory.
Actually disregard all that completely, it's actually a matrix transpose I've not done in the preshader input register copy. One sec...
from fna-mghistory.
This fixes it for me on my setup; it'll be a while before I can do a Win32 build so if you can self-build from repo, definitely do that.
from fna-mghistory.
Here's a Win32 build:
http://www.flibitijibibo.com/MojoShaderFix.tar.bz2
If this works I'll update fnalibs with the latest revision.
from fna-mghistory.
Looks fixed indeed! I can't seem to reproduce the AccessViolationException
with the new DLL either. Thanks!
from fna-mghistory.
fnalibs.tar.bz2 has been updated.
from fna-mghistory.
Related Issues (20)
- shader normalmap not work HOT 3
- Can't run on machine without audio device HOT 9
- [OpenGL] VMware/VBox Support? HOT 7
- [MojoShader] MOJOSHADER_glSetVertexAttribDivisor causes 'System.AccessViolationException' on some computers HOT 3
- [Keyboard] Proposal for Keyboard.GetLayoutEXT() HOT 1
- Microsoft.Xna.Framework.Input.GamePad.INTERNAL_AddInstance throws "An element with the same key already exists in the dictionary" HOT 2
- Unable to load a texture (.PNG) from stream HOT 9
- Initialization order mishap HOT 3
- GraphicsDeviceManager never set in Game HOT 1
- GL Object Disposal Wrappers are not thread-safe HOT 3
- DynamicSoundEffectInstance behavior incompatible with XNA4 HOT 8
- OpenGL 3.2+ Core Profile support HOT 4
- Starting game in full screen bug HOT 8
- Null reference when disposing sound effect after checking sound device exists HOT 5
- [QUESTIONS] learning, using FNA HOT 3
- More spec-compliant Touch Support HOT 34
- FNA Binary Release HOT 1
- RasterizerState.MultiSampleAntiAlias not implemented HOT 8
- Set Render Target to Another Window HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fna-mghistory.