Merge lp:~hikiko/nux/arb-srgba-shader into lp:nux
- arb-srgba-shader
- Merge into trunk
Status: | Needs review |
---|---|
Proposed branch: | lp:~hikiko/nux/arb-srgba-shader |
Merge into: | lp:nux |
Diff against target: |
913 lines (+419/-44) (has conflicts) 7 files modified
NuxGraphics/GraphicsEngine.cpp (+1/-0) NuxGraphics/GraphicsEngine.h (+28/-0) NuxGraphics/RenderingPipe.cpp (+15/-0) NuxGraphics/RenderingPipeAsm.cpp (+147/-42) NuxGraphics/RenderingPipeGLSL.cpp (+106/-0) gputests/Makefile.am (+5/-2) gputests/gamma_correction.cpp (+117/-0) Text conflict in NuxGraphics/GraphicsEngine.h Text conflict in NuxGraphics/RenderingPipe.cpp |
To merge this branch: | bzr merge lp:~hikiko/nux/arb-srgba-shader |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Tim Penhey (community) | Needs Fixing | ||
Review via email: mp+123701@code.launchpad.net |
Commit message
needs to be merged with: lp:~nicolas-doffay/nux/to-sRGB-conversion-shader branch first, it's extending nicolas-doffay's changes.
Description of the change
added a test program in gputests (gamma_
fixed the assembly sRGB pixel shader in NuxGraphics
- 657. By Eleni Maria Stea
-
fixed the test program (can now get gamma as en argument)
- 658. By Eleni Maria Stea
-
made gamma a parameter of the gamma_correction test program
- 659. By Eleni Maria Stea
-
checking that the gamma_correction argv[1] is actually a number
- 660. By Eleni Maria Stea
-
fixed InitAsmSRGBShader position
- 661. By Eleni Maria Stea
-
changed std::string to char* in InitAsmSRGBShader
- 662. By Eleni Maria Stea
-
expandtab, retab
- 663. By Eleni Maria Stea
-
replaced tabs with spaces in Makefile.am
- 664. By Eleni Maria Stea
-
expandtab, retab
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:664
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Unmerged revisions
- 664. By Eleni Maria Stea
-
expandtab, retab
- 663. By Eleni Maria Stea
-
replaced tabs with spaces in Makefile.am
- 662. By Eleni Maria Stea
-
expandtab, retab
- 661. By Eleni Maria Stea
-
changed std::string to char* in InitAsmSRGBShader
- 660. By Eleni Maria Stea
-
fixed InitAsmSRGBShader position
- 659. By Eleni Maria Stea
-
checking that the gamma_correction argv[1] is actually a number
- 658. By Eleni Maria Stea
-
made gamma a parameter of the gamma_correction test program
- 657. By Eleni Maria Stea
-
fixed the test program (can now get gamma as en argument)
- 656. By Eleni Maria Stea
-
removed useless comments and trailing whitespaces
- 655. By Eleni Maria Stea
-
minor change in main
Preview Diff
1 | === modified file 'NuxGraphics/GraphicsEngine.cpp' | |||
2 | --- NuxGraphics/GraphicsEngine.cpp 2012-09-17 09:55:43 +0000 | |||
3 | +++ NuxGraphics/GraphicsEngine.cpp 2012-09-24 06:59:20 +0000 | |||
4 | @@ -220,6 +220,7 @@ | |||
5 | 220 | InitAsm2TextureMod(); | 220 | InitAsm2TextureMod(); |
6 | 221 | InitAsm4TextureAdd(); | 221 | InitAsm4TextureAdd(); |
7 | 222 | InitAsmBlendModes(); | 222 | InitAsmBlendModes(); |
8 | 223 | InitAsmSRGBShader(); | ||
9 | 223 | 224 | ||
10 | 224 | InitAsmPower(); | 225 | InitAsmPower(); |
11 | 225 | InitAsmAlphaReplicate(); | 226 | InitAsmAlphaReplicate(); |
12 | 226 | 227 | ||
13 | === modified file 'NuxGraphics/GraphicsEngine.h' | |||
14 | --- NuxGraphics/GraphicsEngine.h 2012-09-17 09:55:43 +0000 | |||
15 | +++ NuxGraphics/GraphicsEngine.h 2012-09-24 06:59:20 +0000 | |||
16 | @@ -192,6 +192,7 @@ | |||
17 | 192 | Shader Output = ve4(tex.r, tex.g, tex.b, tex.a) | 192 | Shader Output = ve4(tex.r, tex.g, tex.b, tex.a) |
18 | 193 | */ | 193 | */ |
19 | 194 | void QRP_1Tex(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> Tex0, TexCoordXForm& texxform, const Color& color0); | 194 | void QRP_1Tex(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> Tex0, TexCoordXForm& texxform, const Color& color0); |
20 | 195 | <<<<<<< TREE | ||
21 | 195 | //! Render a textured quad. | 196 | //! Render a textured quad. |
22 | 196 | /*! | 197 | /*! |
23 | 197 | Multiply the shader rgb output with the texture alpha. | 198 | Multiply the shader rgb output with the texture alpha. |
24 | @@ -199,6 +200,9 @@ | |||
25 | 199 | */ | 200 | */ |
26 | 200 | void QRP_1TexPremultiply(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> Tex0, TexCoordXForm& texxform, const Color& color0); | 201 | void QRP_1TexPremultiply(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> Tex0, TexCoordXForm& texxform, const Color& color0); |
27 | 201 | void QRP_TexDesaturate(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> Tex0, TexCoordXForm& texxform, const Color& color0, float desaturation_factor); | 202 | void QRP_TexDesaturate(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> Tex0, TexCoordXForm& texxform, const Color& color0, float desaturation_factor); |
28 | 203 | ======= | ||
29 | 204 | void QRP_sRGB(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> tex, TexCoordXForm& texxform, const Color& colour, const float gamma); | ||
30 | 205 | >>>>>>> MERGE-SOURCE | ||
31 | 202 | void QRP_Pixelate(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm& texxform, const Color& c0, int pixel_size); | 206 | void QRP_Pixelate(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm& texxform, const Color& c0, int pixel_size); |
32 | 203 | void QRP_Color(int x, int y, int width, int height, const Color& c0); | 207 | void QRP_Color(int x, int y, int width, int height, const Color& c0); |
33 | 204 | void QRP_Color(int x, int y, int width, int height, const Color& c0, const Color& c1, const Color& c2, const Color& c3); | 208 | void QRP_Color(int x, int y, int width, int height, const Color& c0, const Color& c1, const Color& c2, const Color& c3); |
34 | @@ -271,7 +275,11 @@ | |||
35 | 271 | 275 | ||
36 | 272 | // ASM | 276 | // ASM |
37 | 273 | void QRP_ASM_1Tex(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> Tex0, TexCoordXForm& texxform, const Color& color0); | 277 | void QRP_ASM_1Tex(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> Tex0, TexCoordXForm& texxform, const Color& color0); |
38 | 278 | <<<<<<< TREE | ||
39 | 274 | void QRP_ASM_1TexPremultiply(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> Tex0, TexCoordXForm& texxform, const Color& color0); | 279 | void QRP_ASM_1TexPremultiply(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> Tex0, TexCoordXForm& texxform, const Color& color0); |
40 | 280 | ======= | ||
41 | 281 | void QRP_ASM_sRGB(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> tex, TexCoordXForm& texxform, const Color& colour, const float gamma); | ||
42 | 282 | >>>>>>> MERGE-SOURCE | ||
43 | 275 | void QRP_ASM_Pixelate(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm& texxform, const Color& c0, int pixel_size); | 283 | void QRP_ASM_Pixelate(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm& texxform, const Color& c0, int pixel_size); |
44 | 276 | 284 | ||
45 | 277 | void QRP_ASM_Color(int x, int y, int width, int height, const Color& c0); | 285 | void QRP_ASM_Color(int x, int y, int width, int height, const Color& c0); |
46 | @@ -391,8 +399,12 @@ | |||
47 | 391 | // GLSL | 399 | // GLSL |
48 | 392 | 400 | ||
49 | 393 | void QRP_GLSL_1Tex(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm& texxform, const Color& c0); | 401 | void QRP_GLSL_1Tex(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm& texxform, const Color& c0); |
50 | 402 | <<<<<<< TREE | ||
51 | 394 | void QRP_GLSL_1TexPremultiply(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm& texxform, const Color& c0); | 403 | void QRP_GLSL_1TexPremultiply(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm& texxform, const Color& c0); |
52 | 395 | void QRP_GLSL_TexDesaturate(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> Tex0, TexCoordXForm& texxform, const Color& color0, float desaturation_factor); | 404 | void QRP_GLSL_TexDesaturate(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> Tex0, TexCoordXForm& texxform, const Color& color0, float desaturation_factor); |
53 | 405 | ======= | ||
54 | 406 | void QRP_GLSL_sRGB(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> tex, TexCoordXForm& texxform, const Color& colour, const float gamma); | ||
55 | 407 | >>>>>>> MERGE-SOURCE | ||
56 | 396 | void QRP_GLSL_Pixelate(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm& texxform, const Color& c0, int pixel_size); | 408 | void QRP_GLSL_Pixelate(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm& texxform, const Color& c0, int pixel_size); |
57 | 397 | 409 | ||
58 | 398 | void QRP_GLSL_Color(int x, int y, int width, int height, const Color& c0); | 410 | void QRP_GLSL_Color(int x, int y, int width, int height, const Color& c0); |
59 | @@ -844,12 +856,21 @@ | |||
60 | 844 | //! Same as m_AsmTextureModColor for rectangle textures. | 856 | //! Same as m_AsmTextureModColor for rectangle textures. |
61 | 845 | ObjectPtr<IOpenGLAsmShaderProgram> m_AsmTextureRectModColor; | 857 | ObjectPtr<IOpenGLAsmShaderProgram> m_AsmTextureRectModColor; |
62 | 846 | 858 | ||
63 | 859 | <<<<<<< TREE | ||
64 | 847 | void InitAsmTexturePremultiplyShader(); | 860 | void InitAsmTexturePremultiplyShader(); |
65 | 848 | //! Render polygons with a texture modulated by a color. | 861 | //! Render polygons with a texture modulated by a color. |
66 | 849 | ObjectPtr<IOpenGLAsmShaderProgram> m_AsmTexturePremultiplyModColor; | 862 | ObjectPtr<IOpenGLAsmShaderProgram> m_AsmTexturePremultiplyModColor; |
67 | 850 | //! Same as m_AsmTextureModColor for rectangle textures. | 863 | //! Same as m_AsmTextureModColor for rectangle textures. |
68 | 851 | ObjectPtr<IOpenGLAsmShaderProgram> m_AsmTexturePremultiplyRectModColor; | 864 | ObjectPtr<IOpenGLAsmShaderProgram> m_AsmTexturePremultiplyRectModColor; |
69 | 852 | 865 | ||
70 | 866 | ======= | ||
71 | 867 | void InitAsmSRGBShader(); | ||
72 | 868 | //! Render a texture in linear colour space in an sRGB non-linear space. | ||
73 | 869 | ObjectPtr<IOpenGLAsmShaderProgram> m_AsmLineartoSRGB; | ||
74 | 870 | //! Render a texture rectangle in linear colour space in an sRGB non-linear space. | ||
75 | 871 | ObjectPtr<IOpenGLAsmShaderProgram> m_AsmLineartoSRGBRect; | ||
76 | 872 | |||
77 | 873 | >>>>>>> MERGE-SOURCE | ||
78 | 853 | void InitAsmPixelateShader(); | 874 | void InitAsmPixelateShader(); |
79 | 854 | //! Render a pixelated texture over a polygon. | 875 | //! Render a pixelated texture over a polygon. |
80 | 855 | ObjectPtr<IOpenGLAsmShaderProgram> m_AsmPixelate; | 876 | ObjectPtr<IOpenGLAsmShaderProgram> m_AsmPixelate; |
81 | @@ -928,10 +949,17 @@ | |||
82 | 928 | //! Render polygons with a texture modulated by a color. | 949 | //! Render polygons with a texture modulated by a color. |
83 | 929 | ObjectPtr<IOpenGLShaderProgram> m_SlTextureModColor; | 950 | ObjectPtr<IOpenGLShaderProgram> m_SlTextureModColor; |
84 | 930 | 951 | ||
85 | 952 | <<<<<<< TREE | ||
86 | 931 | void InitSlTexturePremultiplyShader(); | 953 | void InitSlTexturePremultiplyShader(); |
87 | 932 | //! Render polygons with a premultiplied texture modulated by a color. | 954 | //! Render polygons with a premultiplied texture modulated by a color. |
88 | 933 | ObjectPtr<IOpenGLShaderProgram> m_SlTexturePremultiplyModColor; | 955 | ObjectPtr<IOpenGLShaderProgram> m_SlTexturePremultiplyModColor; |
89 | 934 | 956 | ||
90 | 957 | ======= | ||
91 | 958 | void InitSRGBTextureShader(); | ||
92 | 959 | //! Renders a texture in linear colour space using non-linear sRGB. | ||
93 | 960 | ObjectPtr<IOpenGLShaderProgram> m_sRGBTexture; | ||
94 | 961 | |||
95 | 962 | >>>>>>> MERGE-SOURCE | ||
96 | 935 | void InitSlPixelateShader(); | 963 | void InitSlPixelateShader(); |
97 | 936 | //! Render a pixelated texture over a polygon. | 964 | //! Render a pixelated texture over a polygon. |
98 | 937 | ObjectPtr<IOpenGLShaderProgram> m_SLPixelate; | 965 | ObjectPtr<IOpenGLShaderProgram> m_SLPixelate; |
99 | 938 | 966 | ||
100 | === modified file 'NuxGraphics/RenderingPipe.cpp' | |||
101 | --- NuxGraphics/RenderingPipe.cpp 2012-09-14 18:26:55 +0000 | |||
102 | +++ NuxGraphics/RenderingPipe.cpp 2012-09-24 06:59:20 +0000 | |||
103 | @@ -368,6 +368,7 @@ | |||
104 | 368 | #endif | 368 | #endif |
105 | 369 | } | 369 | } |
106 | 370 | 370 | ||
107 | 371 | <<<<<<< TREE | ||
108 | 371 | void GraphicsEngine::QRP_1TexPremultiply(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform0, const Color &color0) | 372 | void GraphicsEngine::QRP_1TexPremultiply(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform0, const Color &color0) |
109 | 372 | { | 373 | { |
110 | 373 | #ifndef NUX_OPENGLES_20 | 374 | #ifndef NUX_OPENGLES_20 |
111 | @@ -395,6 +396,20 @@ | |||
112 | 395 | #endif | 396 | #endif |
113 | 396 | } | 397 | } |
114 | 397 | 398 | ||
115 | 399 | ======= | ||
116 | 400 | void GraphicsEngine::QRP_sRGB(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> tex, TexCoordXForm& texxform, const Color& colour, const float gamma) | ||
117 | 401 | { | ||
118 | 402 | #ifndef NUX_OPENGLES_20 | ||
119 | 403 | if (UsingGLSLCodePath()) | ||
120 | 404 | QRP_GLSL_sRGB(x, y, width, height, tex, texxform, colour, gamma); | ||
121 | 405 | else | ||
122 | 406 | QRP_ASM_sRGB(x, y, width, height, tex, texxform, colour, gamma); | ||
123 | 407 | #else | ||
124 | 408 | QRP_GLSL_sRGB(x, y, width, height, tex, texxform, colour, gamma); | ||
125 | 409 | #endif | ||
126 | 410 | } | ||
127 | 411 | |||
128 | 412 | >>>>>>> MERGE-SOURCE | ||
129 | 398 | void GraphicsEngine::QRP_Pixelate(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform, const Color &c0, int pixel_size) | 413 | void GraphicsEngine::QRP_Pixelate(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform, const Color &c0, int pixel_size) |
130 | 399 | { | 414 | { |
131 | 400 | #ifndef NUX_OPENGLES_20 | 415 | #ifndef NUX_OPENGLES_20 |
132 | 401 | 416 | ||
133 | === modified file 'NuxGraphics/RenderingPipeAsm.cpp' | |||
134 | --- NuxGraphics/RenderingPipeAsm.cpp 2012-08-17 12:41:21 +0000 | |||
135 | +++ NuxGraphics/RenderingPipeAsm.cpp 2012-09-24 06:59:20 +0000 | |||
136 | @@ -102,7 +102,7 @@ | |||
137 | 102 | 102 | ||
138 | 103 | void GraphicsEngine::InitAsmColorShader() | 103 | void GraphicsEngine::InitAsmColorShader() |
139 | 104 | { | 104 | { |
141 | 105 | NString AsmVtx = | 105 | NString AsmVtx = |
142 | 106 | "!!ARBvp1.0 \n\ | 106 | "!!ARBvp1.0 \n\ |
143 | 107 | ATTRIB iPos = vertex.position; \n\ | 107 | ATTRIB iPos = vertex.position; \n\ |
144 | 108 | ATTRIB iColor = vertex.attrib[3]; \n\ | 108 | ATTRIB iColor = vertex.attrib[3]; \n\ |
145 | @@ -117,7 +117,7 @@ | |||
146 | 117 | MOV oColor, iColor; \n\ | 117 | MOV oColor, iColor; \n\ |
147 | 118 | END"; | 118 | END"; |
148 | 119 | 119 | ||
150 | 120 | NString AsmFrg = | 120 | NString AsmFrg = |
151 | 121 | "!!ARBfp1.0 \n\ | 121 | "!!ARBfp1.0 \n\ |
152 | 122 | MOV result.color, fragment.color; \n\ | 122 | MOV result.color, fragment.color; \n\ |
153 | 123 | END"; | 123 | END"; |
154 | @@ -130,7 +130,7 @@ | |||
155 | 130 | 130 | ||
156 | 131 | void GraphicsEngine::InitAsmTextureShader() | 131 | void GraphicsEngine::InitAsmTextureShader() |
157 | 132 | { | 132 | { |
159 | 133 | NString AsmVtx = | 133 | NString AsmVtx = |
160 | 134 | "!!ARBvp1.0 \n\ | 134 | "!!ARBvp1.0 \n\ |
161 | 135 | ATTRIB iPos = vertex.position; \n\ | 135 | ATTRIB iPos = vertex.position; \n\ |
162 | 136 | ATTRIB iColor = vertex.attrib[3]; \n\ | 136 | ATTRIB iColor = vertex.attrib[3]; \n\ |
163 | @@ -147,14 +147,14 @@ | |||
164 | 147 | MOV oTexCoord0, vertex.attrib[8]; \n\ | 147 | MOV oTexCoord0, vertex.attrib[8]; \n\ |
165 | 148 | END"; | 148 | END"; |
166 | 149 | 149 | ||
168 | 150 | NString AsmFrg = | 150 | NString AsmFrg = |
169 | 151 | "!!ARBfp1.0 \n\ | 151 | "!!ARBfp1.0 \n\ |
170 | 152 | TEMP tex0; \n\ | 152 | TEMP tex0; \n\ |
171 | 153 | TEX tex0, fragment.texcoord[0], texture[0], 2D; \n\ | 153 | TEX tex0, fragment.texcoord[0], texture[0], 2D; \n\ |
172 | 154 | MUL result.color, fragment.color, tex0; \n\ | 154 | MUL result.color, fragment.color, tex0; \n\ |
173 | 155 | END"; | 155 | END"; |
174 | 156 | 156 | ||
176 | 157 | NString AsmFrgRect = | 157 | NString AsmFrgRect = |
177 | 158 | "!!ARBfp1.0 \n\ | 158 | "!!ARBfp1.0 \n\ |
178 | 159 | TEMP tex0; \n\ | 159 | TEMP tex0; \n\ |
179 | 160 | TEX tex0, fragment.texcoord[0], texture[0], RECT; \n\ | 160 | TEX tex0, fragment.texcoord[0], texture[0], RECT; \n\ |
180 | @@ -172,9 +172,58 @@ | |||
181 | 172 | m_AsmTextureRectModColor->Link(); | 172 | m_AsmTextureRectModColor->Link(); |
182 | 173 | } | 173 | } |
183 | 174 | 174 | ||
184 | 175 | void GraphicsEngine::InitAsmSRGBShader() | ||
185 | 176 | { | ||
186 | 177 | const char* vertex = | ||
187 | 178 | "!!ARBvp1.0 \n\ | ||
188 | 179 | OUTPUT oPos = result.position; \n\ | ||
189 | 180 | OUTPUT oTexCoord0 = result.texcoord[0]; \n\ | ||
190 | 181 | # Transform the vertex to clip coordinates. \n\ | ||
191 | 182 | DP4 oPos.x, state.matrix.mvp.row[0], vertex.position; \n\ | ||
192 | 183 | DP4 oPos.y, state.matrix.mvp.row[1], vertex.position; \n\ | ||
193 | 184 | DP4 oPos.z, state.matrix.mvp.row[2], vertex.position; \n\ | ||
194 | 185 | DP4 oPos.w, state.matrix.mvp.row[3], vertex.position; \n\ | ||
195 | 186 | MOV oTexCoord0, vertex.attrib[8]; \n\ | ||
196 | 187 | END"; | ||
197 | 188 | |||
198 | 189 | const char* pixel = | ||
199 | 190 | "!!ARBfp1.0 \n\ | ||
200 | 191 | PARAM gamma = program.local[0]; \n\ | ||
201 | 192 | TEMP T; \n\ | ||
202 | 193 | TEMP P; \n\ | ||
203 | 194 | TEX T.xyz, fragment.texcoord[0], texture[0], 2D; \n\ | ||
204 | 195 | POW P.x, T.x, gamma.x; \n\ | ||
205 | 196 | POW P.y, T.y, gamma.x; \n\ | ||
206 | 197 | POW P.z, T.z, gamma.x; \n\ | ||
207 | 198 | MOV result.color, P; \n\ | ||
208 | 199 | END"; | ||
209 | 200 | |||
210 | 201 | const char* rect = | ||
211 | 202 | "!!ARBfp1.0 \n\ | ||
212 | 203 | PARAM gamma = program.local[0]; \n\ | ||
213 | 204 | TEMP T; \n\ | ||
214 | 205 | TEMP P; \n\ | ||
215 | 206 | TEX T.xyz, fragment.texcoord[0], texture[0], 2D; \n\ | ||
216 | 207 | POW P.x, T.x, gamma.x; \n\ | ||
217 | 208 | POW P.y, T.y, gamma.x; \n\ | ||
218 | 209 | POW P.z, T.z, gamma.x; \n\ | ||
219 | 210 | MOV result.color, P; \n\ | ||
220 | 211 | END"; | ||
221 | 212 | |||
222 | 213 | m_AsmLineartoSRGB = GetGraphicsDisplay()->GetGpuDevice()->CreateAsmShaderProgram(); | ||
223 | 214 | m_AsmLineartoSRGB->LoadVertexShader(vertex); | ||
224 | 215 | m_AsmLineartoSRGB->LoadPixelShader(pixel); | ||
225 | 216 | m_AsmLineartoSRGB->Link(); | ||
226 | 217 | |||
227 | 218 | m_AsmLineartoSRGBRect = GetGraphicsDisplay()->GetGpuDevice()->CreateAsmShaderProgram(); | ||
228 | 219 | m_AsmLineartoSRGBRect->LoadVertexShader(vertex); | ||
229 | 220 | m_AsmLineartoSRGBRect->LoadPixelShader(rect); | ||
230 | 221 | m_AsmLineartoSRGBRect->Link(); | ||
231 | 222 | } | ||
232 | 223 | |||
233 | 175 | void GraphicsEngine::InitAsmColorModTexMaskAlpha() | 224 | void GraphicsEngine::InitAsmColorModTexMaskAlpha() |
234 | 176 | { | 225 | { |
236 | 177 | NString AsmVtx = | 226 | NString AsmVtx = |
237 | 178 | "!!ARBvp1.0 \n\ | 227 | "!!ARBvp1.0 \n\ |
238 | 179 | OUTPUT oPos = result.position; \n\ | 228 | OUTPUT oPos = result.position; \n\ |
239 | 180 | OUTPUT oColor = result.color; \n\ | 229 | OUTPUT oColor = result.color; \n\ |
240 | @@ -188,7 +237,7 @@ | |||
241 | 188 | MOV oTexCoord0, vertex.attrib[8]; \n\ | 237 | MOV oTexCoord0, vertex.attrib[8]; \n\ |
242 | 189 | END"; | 238 | END"; |
243 | 190 | 239 | ||
245 | 191 | NString AsmFrg = | 240 | NString AsmFrg = |
246 | 192 | "!!ARBfp1.0 \n\ | 241 | "!!ARBfp1.0 \n\ |
247 | 193 | TEMP tex0; \n\ | 242 | TEMP tex0; \n\ |
248 | 194 | TEMP temp; \n\ | 243 | TEMP temp; \n\ |
249 | @@ -198,7 +247,7 @@ | |||
250 | 198 | MOV result.color, temp; \n\ | 247 | MOV result.color, temp; \n\ |
251 | 199 | END"; | 248 | END"; |
252 | 200 | 249 | ||
254 | 201 | NString AsmFrgRect = | 250 | NString AsmFrgRect = |
255 | 202 | "!!ARBfp1.0 \n\ | 251 | "!!ARBfp1.0 \n\ |
256 | 203 | TEMP tex0; \n\ | 252 | TEMP tex0; \n\ |
257 | 204 | TEMP temp; \n\ | 253 | TEMP temp; \n\ |
258 | @@ -221,7 +270,7 @@ | |||
259 | 221 | 270 | ||
260 | 222 | void GraphicsEngine::InitAsm2TextureAdd() | 271 | void GraphicsEngine::InitAsm2TextureAdd() |
261 | 223 | { | 272 | { |
263 | 224 | NString AsmVtx = | 273 | NString AsmVtx = |
264 | 225 | "!!ARBvp1.0 \n\ | 274 | "!!ARBvp1.0 \n\ |
265 | 226 | ATTRIB iPos = vertex.position; \n\ | 275 | ATTRIB iPos = vertex.position; \n\ |
266 | 227 | OUTPUT oPos = result.position; \n\ | 276 | OUTPUT oPos = result.position; \n\ |
267 | @@ -236,7 +285,7 @@ | |||
268 | 236 | MOV oTexCoord1, vertex.attrib[9]; \n\ | 285 | MOV oTexCoord1, vertex.attrib[9]; \n\ |
269 | 237 | END"; | 286 | END"; |
270 | 238 | 287 | ||
272 | 239 | NString AsmFrg = | 288 | NString AsmFrg = |
273 | 240 | "!!ARBfp1.0 \n\ | 289 | "!!ARBfp1.0 \n\ |
274 | 241 | PARAM color0 = program.local[0]; \n\ | 290 | PARAM color0 = program.local[0]; \n\ |
275 | 242 | PARAM color1 = program.local[1]; \n\ | 291 | PARAM color1 = program.local[1]; \n\ |
276 | @@ -250,7 +299,7 @@ | |||
277 | 250 | MOV result.color, temp; \n\ | 299 | MOV result.color, temp; \n\ |
278 | 251 | END"; | 300 | END"; |
279 | 252 | 301 | ||
281 | 253 | NString AsmFrgRect = | 302 | NString AsmFrgRect = |
282 | 254 | "!!ARBfp1.0 \n\ | 303 | "!!ARBfp1.0 \n\ |
283 | 255 | PARAM color0 = program.local[0]; \n\ | 304 | PARAM color0 = program.local[0]; \n\ |
284 | 256 | PARAM color1 = program.local[1]; \n\ | 305 | PARAM color1 = program.local[1]; \n\ |
285 | @@ -277,7 +326,7 @@ | |||
286 | 277 | 326 | ||
287 | 278 | void GraphicsEngine::InitAsm2TextureDepRead() | 327 | void GraphicsEngine::InitAsm2TextureDepRead() |
288 | 279 | { | 328 | { |
290 | 280 | NString AsmVtx = | 329 | NString AsmVtx = |
291 | 281 | "!!ARBvp1.0 \n\ | 330 | "!!ARBvp1.0 \n\ |
292 | 282 | ATTRIB iPos = vertex.position; \n\ | 331 | ATTRIB iPos = vertex.position; \n\ |
293 | 283 | OUTPUT oPos = result.position; \n\ | 332 | OUTPUT oPos = result.position; \n\ |
294 | @@ -292,7 +341,7 @@ | |||
295 | 292 | MOV oTexCoord1, vertex.attrib[9]; \n\ | 341 | MOV oTexCoord1, vertex.attrib[9]; \n\ |
296 | 293 | END"; | 342 | END"; |
297 | 294 | 343 | ||
299 | 295 | NString AsmFrg = | 344 | NString AsmFrg = |
300 | 296 | "!!ARBfp1.0 \n\ | 345 | "!!ARBfp1.0 \n\ |
301 | 297 | PARAM color0 = program.local[0]; \n\ | 346 | PARAM color0 = program.local[0]; \n\ |
302 | 298 | PARAM color1 = program.local[1]; \n\ | 347 | PARAM color1 = program.local[1]; \n\ |
303 | @@ -309,7 +358,7 @@ | |||
304 | 309 | MUL result.color, color1, tex1; \n\ | 358 | MUL result.color, color1, tex1; \n\ |
305 | 310 | END"; | 359 | END"; |
306 | 311 | 360 | ||
308 | 312 | NString AsmFrgRect = | 361 | NString AsmFrgRect = |
309 | 313 | "!!ARBfp1.0 \n\ | 362 | "!!ARBfp1.0 \n\ |
310 | 314 | PARAM color0 = program.local[0]; \n\ | 363 | PARAM color0 = program.local[0]; \n\ |
311 | 315 | PARAM color1 = program.local[1]; \n\ | 364 | PARAM color1 = program.local[1]; \n\ |
312 | @@ -336,7 +385,7 @@ | |||
313 | 336 | 385 | ||
314 | 337 | void GraphicsEngine::InitAsm2TextureMod() | 386 | void GraphicsEngine::InitAsm2TextureMod() |
315 | 338 | { | 387 | { |
317 | 339 | NString AsmVtx = | 388 | NString AsmVtx = |
318 | 340 | "!!ARBvp1.0 \n\ | 389 | "!!ARBvp1.0 \n\ |
319 | 341 | ATTRIB iPos = vertex.position; \n\ | 390 | ATTRIB iPos = vertex.position; \n\ |
320 | 342 | OUTPUT oPos = result.position; \n\ | 391 | OUTPUT oPos = result.position; \n\ |
321 | @@ -351,7 +400,7 @@ | |||
322 | 351 | MOV oTexCoord1, vertex.attrib[9]; \n\ | 400 | MOV oTexCoord1, vertex.attrib[9]; \n\ |
323 | 352 | END"; | 401 | END"; |
324 | 353 | 402 | ||
326 | 354 | NString AsmFrg = | 403 | NString AsmFrg = |
327 | 355 | "!!ARBfp1.0 \n\ | 404 | "!!ARBfp1.0 \n\ |
328 | 356 | PARAM color0 = program.local[0]; \n\ | 405 | PARAM color0 = program.local[0]; \n\ |
329 | 357 | PARAM color1 = program.local[1]; \n\ | 406 | PARAM color1 = program.local[1]; \n\ |
330 | @@ -366,7 +415,7 @@ | |||
331 | 366 | MUL result.color, temp0, temp1; \n\ | 415 | MUL result.color, temp0, temp1; \n\ |
332 | 367 | END"; | 416 | END"; |
333 | 368 | 417 | ||
335 | 369 | NString AsmFrgRect = | 418 | NString AsmFrgRect = |
336 | 370 | "!!ARBfp1.0 \n\ | 419 | "!!ARBfp1.0 \n\ |
337 | 371 | PARAM color0 = program.local[0]; \n\ | 420 | PARAM color0 = program.local[0]; \n\ |
338 | 372 | PARAM color1 = program.local[1]; \n\ | 421 | PARAM color1 = program.local[1]; \n\ |
339 | @@ -394,7 +443,7 @@ | |||
340 | 394 | 443 | ||
341 | 395 | void GraphicsEngine::InitAsm4TextureAdd() | 444 | void GraphicsEngine::InitAsm4TextureAdd() |
342 | 396 | { | 445 | { |
344 | 397 | NString AsmVtx = | 446 | NString AsmVtx = |
345 | 398 | "!!ARBvp1.0 \n\ | 447 | "!!ARBvp1.0 \n\ |
346 | 399 | ATTRIB iPos = vertex.position; \n\ | 448 | ATTRIB iPos = vertex.position; \n\ |
347 | 400 | OUTPUT oPos = result.position; \n\ | 449 | OUTPUT oPos = result.position; \n\ |
348 | @@ -413,7 +462,7 @@ | |||
349 | 413 | MOV oTexCoord3, vertex.attrib[11]; \n\ | 462 | MOV oTexCoord3, vertex.attrib[11]; \n\ |
350 | 414 | END"; | 463 | END"; |
351 | 415 | 464 | ||
353 | 416 | NString AsmFrg = | 465 | NString AsmFrg = |
354 | 417 | "!!ARBfp1.0 \n\ | 466 | "!!ARBfp1.0 \n\ |
355 | 418 | PARAM color0 = program.local[0]; \n\ | 467 | PARAM color0 = program.local[0]; \n\ |
356 | 419 | PARAM color1 = program.local[1]; \n\ | 468 | PARAM color1 = program.local[1]; \n\ |
357 | @@ -435,7 +484,7 @@ | |||
358 | 435 | MOV result.color, temp; \n\ | 484 | MOV result.color, temp; \n\ |
359 | 436 | END"; | 485 | END"; |
360 | 437 | 486 | ||
362 | 438 | NString AsmFrgRect = | 487 | NString AsmFrgRect = |
363 | 439 | "!!ARBfp1.0 \n\ | 488 | "!!ARBfp1.0 \n\ |
364 | 440 | PARAM color0 = program.local[0]; \n\ | 489 | PARAM color0 = program.local[0]; \n\ |
365 | 441 | PARAM color1 = program.local[1]; \n\ | 490 | PARAM color1 = program.local[1]; \n\ |
366 | @@ -470,7 +519,7 @@ | |||
367 | 470 | 519 | ||
368 | 471 | void GraphicsEngine::InitAsmBlendModes() | 520 | void GraphicsEngine::InitAsmBlendModes() |
369 | 472 | { | 521 | { |
371 | 473 | NString AsmVtx = | 522 | NString AsmVtx = |
372 | 474 | "!!ARBvp1.0 \n\ | 523 | "!!ARBvp1.0 \n\ |
373 | 475 | OUTPUT oPos = result.position; \n\ | 524 | OUTPUT oPos = result.position; \n\ |
374 | 476 | OUTPUT oTexCoord0 = result.texcoord[0]; \n\ | 525 | OUTPUT oTexCoord0 = result.texcoord[0]; \n\ |
375 | @@ -484,7 +533,7 @@ | |||
376 | 484 | MOV oTexCoord1, vertex.attrib[9]; \n\ | 533 | MOV oTexCoord1, vertex.attrib[9]; \n\ |
377 | 485 | END"; | 534 | END"; |
378 | 486 | 535 | ||
380 | 487 | NString AsmPSBNormal = | 536 | NString AsmPSBNormal = |
381 | 488 | "!!ARBfp1.0 \n\ | 537 | "!!ARBfp1.0 \n\ |
382 | 489 | TEMP tex0; \n\ | 538 | TEMP tex0; \n\ |
383 | 490 | TEMP tex1; \n\ | 539 | TEMP tex1; \n\ |
384 | @@ -518,7 +567,7 @@ | |||
385 | 518 | m_AsmPSBLighten->Link(); | 567 | m_AsmPSBLighten->Link(); |
386 | 519 | 568 | ||
387 | 520 | // Darken | 569 | // Darken |
389 | 521 | NString AsmPSBDarken = | 570 | NString AsmPSBDarken = |
390 | 522 | "!!ARBfp1.0 \n\ | 571 | "!!ARBfp1.0 \n\ |
391 | 523 | TEMP tex0; \n\ | 572 | TEMP tex0; \n\ |
392 | 524 | TEMP tex1; \n\ | 573 | TEMP tex1; \n\ |
393 | @@ -537,7 +586,7 @@ | |||
394 | 537 | m_AsmPSBDarken->Link(); | 586 | m_AsmPSBDarken->Link(); |
395 | 538 | 587 | ||
396 | 539 | // Multiply | 588 | // Multiply |
398 | 540 | NString AsmPSBMultiply = | 589 | NString AsmPSBMultiply = |
399 | 541 | "!!ARBfp1.0 \n\ | 590 | "!!ARBfp1.0 \n\ |
400 | 542 | TEMP tex0; \n\ | 591 | TEMP tex0; \n\ |
401 | 543 | TEMP tex1; \n\ | 592 | TEMP tex1; \n\ |
402 | @@ -627,7 +676,7 @@ | |||
403 | 627 | 676 | ||
404 | 628 | CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0)); | 677 | CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0)); |
405 | 629 | CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0)); | 678 | CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0)); |
407 | 630 | 679 | ||
408 | 631 | ObjectPtr<IOpenGLAsmShaderProgram> shader_program = m_AsmTextureModColor; | 680 | ObjectPtr<IOpenGLAsmShaderProgram> shader_program = m_AsmTextureModColor; |
409 | 632 | if (device_texture->Type().IsDerivedFromType(IOpenGLRectangleTexture::StaticObjectType)) | 681 | if (device_texture->Type().IsDerivedFromType(IOpenGLRectangleTexture::StaticObjectType)) |
410 | 633 | { | 682 | { |
411 | @@ -677,6 +726,62 @@ | |||
412 | 677 | shader_program->End(); | 726 | shader_program->End(); |
413 | 678 | } | 727 | } |
414 | 679 | 728 | ||
415 | 729 | void GraphicsEngine::QRP_ASM_sRGB(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> tex, TexCoordXForm& texxform, const Color& color, const float gamma) | ||
416 | 730 | { | ||
417 | 731 | NUX_RETURN_IF_FALSE(m_AsmLineartoSRGB.IsValid() || m_AsmLineartoSRGBRect.IsValid()); | ||
418 | 732 | |||
419 | 733 | QRP_Compute_Texture_Coord(width, height, tex, texxform); | ||
420 | 734 | |||
421 | 735 | float fx = x; float fy = y; | ||
422 | 736 | |||
423 | 737 | float vertexArray[] = { | ||
424 | 738 | fx, fy, 0.0f, 1.0f, texxform.u0, texxform.v0, 0, 1.0f, color.red, color.green, color.blue, color.alpha, | ||
425 | 739 | fx, fy + height, 0.0f, 1.0f, texxform.u0, texxform.v1, 0, 1.0f, color.red, color.green, color.blue, color.alpha, | ||
426 | 740 | fx + width, fy + height, 0.0f, 1.0f, texxform.u1, texxform.v1, 0, 1.0f, color.red, color.green, color.blue, color.alpha, | ||
427 | 741 | fx + width, fy, 0.0f, 1.0f, texxform.u1, texxform.v0, 0, 1.0f, color.red, color.green, color.blue, color.alpha, | ||
428 | 742 | }; | ||
429 | 743 | |||
430 | 744 | CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0)); | ||
431 | 745 | CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0)); | ||
432 | 746 | |||
433 | 747 | ObjectPtr<IOpenGLAsmShaderProgram> shader_program = m_AsmLineartoSRGB; | ||
434 | 748 | if (tex->Type().IsDerivedFromType(IOpenGLRectangleTexture::StaticObjectType)) | ||
435 | 749 | shader_program = m_AsmLineartoSRGBRect; | ||
436 | 750 | |||
437 | 751 | shader_program->Begin(); | ||
438 | 752 | |||
439 | 753 | SetTexture(GL_TEXTURE0, tex); | ||
440 | 754 | CHECKGL(glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, gamma, 0.0, 0.0, 0.0)); | ||
441 | 755 | |||
442 | 756 | CHECKGL(glMatrixMode(GL_MODELVIEW)); | ||
443 | 757 | CHECKGL(glLoadIdentity()); | ||
444 | 758 | CHECKGL(glLoadMatrixf((FLOAT *) GetOpenGLModelViewMatrix().m)); | ||
445 | 759 | CHECKGL(glMatrixMode(GL_PROJECTION)); | ||
446 | 760 | CHECKGL(glLoadIdentity()); | ||
447 | 761 | CHECKGL(glLoadMatrixf((FLOAT *) GetOpenGLProjectionMatrix().m)); | ||
448 | 762 | |||
449 | 763 | int vertexLocation = VTXATTRIB_POSITION; | ||
450 | 764 | int textureCoord0Location = VTXATTRIB_TEXCOORD0; | ||
451 | 765 | int vertexColorLocation = VTXATTRIB_COLOR; | ||
452 | 766 | |||
453 | 767 | CHECKGL(glEnableVertexAttribArrayARB(vertexLocation)); | ||
454 | 768 | CHECKGL(glVertexAttribPointerARB((GLuint) vertexLocation, 4, GL_FLOAT, GL_FALSE, 48, vertexArray)); | ||
455 | 769 | |||
456 | 770 | CHECKGL(glEnableVertexAttribArrayARB(textureCoord0Location)); | ||
457 | 771 | CHECKGL(glVertexAttribPointerARB((GLuint)textureCoord0Location, 4, GL_FLOAT, GL_FALSE, 48, vertexArray + 4)); | ||
458 | 772 | |||
459 | 773 | CHECKGL(glEnableVertexAttribArrayARB(vertexColorLocation)); | ||
460 | 774 | CHECKGL(glVertexAttribPointerARB((GLuint)vertexColorLocation, 4, GL_FLOAT, GL_FALSE, 48, vertexArray + 8)); | ||
461 | 775 | |||
462 | 776 | CHECKGL(glDrawArrays(GL_TRIANGLE_FAN, 0, 4)); | ||
463 | 777 | |||
464 | 778 | CHECKGL(glDisableVertexAttribArrayARB(vertexLocation)); | ||
465 | 779 | CHECKGL(glDisableVertexAttribArrayARB(textureCoord0Location)); | ||
466 | 780 | CHECKGL(glDisableVertexAttribArrayARB(vertexColorLocation)); | ||
467 | 781 | |||
468 | 782 | shader_program->End(); | ||
469 | 783 | } | ||
470 | 784 | |||
471 | 680 | void GraphicsEngine::QRP_ASM_ColorModTexAlpha(int x, int y, int width, int height, | 785 | void GraphicsEngine::QRP_ASM_ColorModTexAlpha(int x, int y, int width, int height, |
472 | 681 | ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform, const Color &color) | 786 | ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform, const Color &color) |
473 | 682 | { | 787 | { |
474 | @@ -1241,7 +1346,7 @@ | |||
475 | 1241 | 1346 | ||
476 | 1242 | void GraphicsEngine::InitAsmPower() | 1347 | void GraphicsEngine::InitAsmPower() |
477 | 1243 | { | 1348 | { |
479 | 1244 | NString AsmVtx = | 1349 | NString AsmVtx = |
480 | 1245 | "!!ARBvp1.0 \n\ | 1350 | "!!ARBvp1.0 \n\ |
481 | 1246 | ATTRIB iPos = vertex.position; \n\ | 1351 | ATTRIB iPos = vertex.position; \n\ |
482 | 1247 | OUTPUT oPos = result.position; \n\ | 1352 | OUTPUT oPos = result.position; \n\ |
483 | @@ -1255,7 +1360,7 @@ | |||
484 | 1255 | END"; | 1360 | END"; |
485 | 1256 | 1361 | ||
486 | 1257 | 1362 | ||
488 | 1258 | NString AsmFrg = | 1363 | NString AsmFrg = |
489 | 1259 | "!!ARBfp1.0 \n\ | 1364 | "!!ARBfp1.0 \n\ |
490 | 1260 | PARAM color0 = program.local[0]; \n\ | 1365 | PARAM color0 = program.local[0]; \n\ |
491 | 1261 | PARAM exponent = program.local[1]; \n\ | 1366 | PARAM exponent = program.local[1]; \n\ |
492 | @@ -1269,7 +1374,7 @@ | |||
493 | 1269 | MUL result.color, color0, final; \n\ | 1374 | MUL result.color, color0, final; \n\ |
494 | 1270 | END"; | 1375 | END"; |
495 | 1271 | 1376 | ||
497 | 1272 | NString AsmFrgRect = | 1377 | NString AsmFrgRect = |
498 | 1273 | "!!ARBfp1.0 \n\ | 1378 | "!!ARBfp1.0 \n\ |
499 | 1274 | PARAM color0 = program.local[0]; \n\ | 1379 | PARAM color0 = program.local[0]; \n\ |
500 | 1275 | PARAM exponent = program.local[1]; \n\ | 1380 | PARAM exponent = program.local[1]; \n\ |
501 | @@ -1351,7 +1456,7 @@ | |||
502 | 1351 | 1456 | ||
503 | 1352 | void GraphicsEngine::InitAsmAlphaReplicate() | 1457 | void GraphicsEngine::InitAsmAlphaReplicate() |
504 | 1353 | { | 1458 | { |
506 | 1354 | NString AsmVtx = | 1459 | NString AsmVtx = |
507 | 1355 | "!!ARBvp1.0 \n\ | 1460 | "!!ARBvp1.0 \n\ |
508 | 1356 | ATTRIB iPos = vertex.position; \n\ | 1461 | ATTRIB iPos = vertex.position; \n\ |
509 | 1357 | OUTPUT oPos = result.position; \n\ | 1462 | OUTPUT oPos = result.position; \n\ |
510 | @@ -1365,7 +1470,7 @@ | |||
511 | 1365 | END"; | 1470 | END"; |
512 | 1366 | 1471 | ||
513 | 1367 | 1472 | ||
515 | 1368 | NString AsmFrg = | 1473 | NString AsmFrg = |
516 | 1369 | "!!ARBfp1.0 \n\ | 1474 | "!!ARBfp1.0 \n\ |
517 | 1370 | PARAM color0 = program.local[0]; \n\ | 1475 | PARAM color0 = program.local[0]; \n\ |
518 | 1371 | TEMP tex0; \n\ | 1476 | TEMP tex0; \n\ |
519 | @@ -1373,7 +1478,7 @@ | |||
520 | 1373 | MUL result.color, color0, tex0.aaaa; \n\ | 1478 | MUL result.color, color0, tex0.aaaa; \n\ |
521 | 1374 | END"; | 1479 | END"; |
522 | 1375 | 1480 | ||
524 | 1376 | NString AsmFrgRect = | 1481 | NString AsmFrgRect = |
525 | 1377 | "!!ARBfp1.0 \n\ | 1482 | "!!ARBfp1.0 \n\ |
526 | 1378 | PARAM color0 = program.local[0]; \n\ | 1483 | PARAM color0 = program.local[0]; \n\ |
527 | 1379 | TEMP tex0; \n\ | 1484 | TEMP tex0; \n\ |
528 | @@ -1450,7 +1555,7 @@ | |||
529 | 1450 | 1555 | ||
530 | 1451 | void GraphicsEngine::InitAsmColorMatrixFilter() | 1556 | void GraphicsEngine::InitAsmColorMatrixFilter() |
531 | 1452 | { | 1557 | { |
533 | 1453 | NString AsmVtx = | 1558 | NString AsmVtx = |
534 | 1454 | "!!ARBvp1.0 \n\ | 1559 | "!!ARBvp1.0 \n\ |
535 | 1455 | ATTRIB iPos = vertex.position; \n\ | 1560 | ATTRIB iPos = vertex.position; \n\ |
536 | 1456 | OUTPUT oPos = result.position; \n\ | 1561 | OUTPUT oPos = result.position; \n\ |
537 | @@ -1464,7 +1569,7 @@ | |||
538 | 1464 | END"; | 1569 | END"; |
539 | 1465 | 1570 | ||
540 | 1466 | 1571 | ||
542 | 1467 | NString AsmFrg = | 1572 | NString AsmFrg = |
543 | 1468 | "!!ARBfp1.0 \n\ | 1573 | "!!ARBfp1.0 \n\ |
544 | 1469 | PARAM color0 = program.local[0]; \n\ | 1574 | PARAM color0 = program.local[0]; \n\ |
545 | 1470 | PARAM CM0 = program.local[1]; \n\ | 1575 | PARAM CM0 = program.local[1]; \n\ |
546 | @@ -1482,7 +1587,7 @@ | |||
547 | 1482 | MUL result.color, color0, final; \n\ | 1587 | MUL result.color, color0, final; \n\ |
548 | 1483 | END"; | 1588 | END"; |
549 | 1484 | 1589 | ||
551 | 1485 | NString AsmFrgRect = | 1590 | NString AsmFrgRect = |
552 | 1486 | "!!ARBfp1.0 \n\ | 1591 | "!!ARBfp1.0 \n\ |
553 | 1487 | PARAM color0 = program.local[0]; \n\ | 1592 | PARAM color0 = program.local[0]; \n\ |
554 | 1488 | PARAM CM0 = program.local[1]; \n\ | 1593 | PARAM CM0 = program.local[1]; \n\ |
555 | @@ -1578,7 +1683,7 @@ | |||
556 | 1578 | 1683 | ||
557 | 1579 | void GraphicsEngine::InitAsmSeparableGaussFilter() | 1684 | void GraphicsEngine::InitAsmSeparableGaussFilter() |
558 | 1580 | { | 1685 | { |
560 | 1581 | NString AsmVtx = | 1686 | NString AsmVtx = |
561 | 1582 | "!!ARBvp1.0 \n\ | 1687 | "!!ARBvp1.0 \n\ |
562 | 1583 | ATTRIB iPos = vertex.position; \n\ | 1688 | ATTRIB iPos = vertex.position; \n\ |
563 | 1584 | OUTPUT oPos = result.position; \n\ | 1689 | OUTPUT oPos = result.position; \n\ |
564 | @@ -1604,7 +1709,7 @@ | |||
565 | 1604 | END"; | 1709 | END"; |
566 | 1605 | 1710 | ||
567 | 1606 | 1711 | ||
569 | 1607 | NString AsmFrg = | 1712 | NString AsmFrg = |
570 | 1608 | "!!ARBfp1.0 \n\ | 1713 | "!!ARBfp1.0 \n\ |
571 | 1609 | TEMP tex0; \n\ | 1714 | TEMP tex0; \n\ |
572 | 1610 | TEMP final; \n\ | 1715 | TEMP final; \n\ |
573 | @@ -1627,7 +1732,7 @@ | |||
574 | 1627 | END"; | 1732 | END"; |
575 | 1628 | 1733 | ||
576 | 1629 | 1734 | ||
578 | 1630 | NString AsmFrgRect = | 1735 | NString AsmFrgRect = |
579 | 1631 | "!!ARBfp1.0 \n\ | 1736 | "!!ARBfp1.0 \n\ |
580 | 1632 | TEMP tex0; \n\ | 1737 | TEMP tex0; \n\ |
581 | 1633 | TEMP final; \n\ | 1738 | TEMP final; \n\ |
582 | @@ -2021,7 +2126,7 @@ | |||
583 | 2021 | fx_structure->dst_texture->SetFiltering(GL_NEAREST, GL_NEAREST); | 2126 | fx_structure->dst_texture->SetFiltering(GL_NEAREST, GL_NEAREST); |
584 | 2022 | fx_structure->temp_texture->SetWrap(GL_CLAMP, GL_CLAMP, GL_CLAMP); | 2127 | fx_structure->temp_texture->SetWrap(GL_CLAMP, GL_CLAMP, GL_CLAMP); |
585 | 2023 | fx_structure->temp_texture->SetFiltering(GL_NEAREST, GL_NEAREST); | 2128 | fx_structure->temp_texture->SetFiltering(GL_NEAREST, GL_NEAREST); |
587 | 2024 | 2129 | ||
588 | 2025 | SetFrameBufferHelper(_offscreen_fbo, fx_structure->dst_texture, _offscreen_depth_rt0, buffer_width, buffer_height); | 2130 | SetFrameBufferHelper(_offscreen_fbo, fx_structure->dst_texture, _offscreen_depth_rt0, buffer_width, buffer_height); |
589 | 2026 | glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | 2131 | glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
590 | 2027 | 2132 | ||
591 | @@ -2050,7 +2155,7 @@ | |||
592 | 2050 | { | 2155 | { |
593 | 2051 | SetViewport(0, 0, previous_width, previous_height); | 2156 | SetViewport(0, 0, previous_width, previous_height); |
594 | 2052 | } | 2157 | } |
596 | 2053 | } | 2158 | } |
597 | 2054 | 2159 | ||
598 | 2055 | ObjectPtr<IOpenGLBaseTexture> GraphicsEngine::QRP_ASM_GetPower( | 2160 | ObjectPtr<IOpenGLBaseTexture> GraphicsEngine::QRP_ASM_GetPower( |
599 | 2056 | ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform, const Color & c0, const Vector4 &exponent) | 2161 | ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform, const Color & c0, const Vector4 &exponent) |
600 | @@ -2287,7 +2392,7 @@ | |||
601 | 2287 | 2392 | ||
602 | 2288 | void GraphicsEngine::InitAsmPixelateShader() | 2393 | void GraphicsEngine::InitAsmPixelateShader() |
603 | 2289 | { | 2394 | { |
605 | 2290 | NString AsmVtx = | 2395 | NString AsmVtx = |
606 | 2291 | "!!ARBvp1.0 \n\ | 2396 | "!!ARBvp1.0 \n\ |
607 | 2292 | ATTRIB iPos = vertex.position; \n\ | 2397 | ATTRIB iPos = vertex.position; \n\ |
608 | 2293 | ATTRIB iColor = vertex.attrib[3]; \n\ | 2398 | ATTRIB iColor = vertex.attrib[3]; \n\ |
609 | @@ -2304,7 +2409,7 @@ | |||
610 | 2304 | MOV oTexCoord0, vertex.attrib[8]; \n\ | 2409 | MOV oTexCoord0, vertex.attrib[8]; \n\ |
611 | 2305 | END"; | 2410 | END"; |
612 | 2306 | 2411 | ||
614 | 2307 | NString AsmFrg = | 2412 | NString AsmFrg = |
615 | 2308 | "!!ARBfp1.0 \n\ | 2413 | "!!ARBfp1.0 \n\ |
616 | 2309 | TEMP tex0; \n\ | 2414 | TEMP tex0; \n\ |
617 | 2310 | TEMP tex_coord; \n\ | 2415 | TEMP tex_coord; \n\ |
618 | @@ -2317,7 +2422,7 @@ | |||
619 | 2317 | MUL result.color, fragment.color, tex0; \n\ | 2422 | MUL result.color, fragment.color, tex0; \n\ |
620 | 2318 | END"; | 2423 | END"; |
621 | 2319 | 2424 | ||
623 | 2320 | NString AsmFrgRect = | 2425 | NString AsmFrgRect = |
624 | 2321 | "!!ARBfp1.0 \n\ | 2426 | "!!ARBfp1.0 \n\ |
625 | 2322 | TEMP tex0; \n\ | 2427 | TEMP tex0; \n\ |
626 | 2323 | TEMP tex_coord; \n\ | 2428 | TEMP tex_coord; \n\ |
627 | 2324 | 2429 | ||
628 | === modified file 'NuxGraphics/RenderingPipeGLSL.cpp' | |||
629 | --- NuxGraphics/RenderingPipeGLSL.cpp 2012-09-14 18:26:55 +0000 | |||
630 | +++ NuxGraphics/RenderingPipeGLSL.cpp 2012-09-24 06:59:20 +0000 | |||
631 | @@ -117,6 +117,52 @@ | |||
632 | 117 | m_SlTextureModColor->Link(); | 117 | m_SlTextureModColor->Link(); |
633 | 118 | } | 118 | } |
634 | 119 | 119 | ||
635 | 120 | void GraphicsEngine::InitSRGBTextureShader() | ||
636 | 121 | { | ||
637 | 122 | ObjectPtr<IOpenGLVertexShader> vertexShader = _graphics_display.m_DeviceFactory->CreateVertexShader(); | ||
638 | 123 | ObjectPtr<IOpenGLPixelShader> pixelShader = _graphics_display.m_DeviceFactory->CreatePixelShader(); | ||
639 | 124 | |||
640 | 125 | std::string vertexString = | ||
641 | 126 | NUX_VERTEX_SHADER_HEADER | ||
642 | 127 | "attribute vec4 vertex; \n\ | ||
643 | 128 | attribute vec4 textureCoord0; \n\ | ||
644 | 129 | uniform mat4 viewProjectionMatrix; \n\ | ||
645 | 130 | uniform float gamma; \n\ | ||
646 | 131 | varying vec4 varyTexCoord0; \n\ | ||
647 | 132 | void main() \n\ | ||
648 | 133 | { \n\ | ||
649 | 134 | gl_Position = viewProjectionMatrix * vertex; \n\ | ||
650 | 135 | varyTexCoord0 = textureCoord0; \n\ | ||
651 | 136 | }"; | ||
652 | 137 | |||
653 | 138 | std::string pixelString = | ||
654 | 139 | NUX_FRAGMENT_SHADER_HEADER | ||
655 | 140 | "uniform sampler2D textureObject; \n\ | ||
656 | 141 | uniform float gamma; \n\ | ||
657 | 142 | varying vec4 varyTexCoord0; \n\ | ||
658 | 143 | void main() \n\ | ||
659 | 144 | { \n\ | ||
660 | 145 | vec2 uv = varyTexCoord0.st; \n\ | ||
661 | 146 | vec4 tempTex = texture2D(textureObject, uv); \n\ | ||
662 | 147 | gl_FragColor.rgb = pow(tempTex.rgb, 1 / gamma); \n\ | ||
663 | 148 | gl_FragColor.a = tempTex.a; \n\ | ||
664 | 149 | }"; | ||
665 | 150 | |||
666 | 151 | m_sRGBTexture = _graphics_display.m_DeviceFactory->CreateShaderProgram(); | ||
667 | 152 | |||
668 | 153 | vertexShader->SetShaderCode(vertexString.c_str()); | ||
669 | 154 | pixelShader->SetShaderCode(pixelString.c_str()); | ||
670 | 155 | |||
671 | 156 | m_sRGBTexture->ClearShaderObjects(); | ||
672 | 157 | m_sRGBTexture->AddShaderObject(vertexShader); | ||
673 | 158 | m_sRGBTexture->AddShaderObject(pixelShader); | ||
674 | 159 | |||
675 | 160 | CHECKGL(glBindAttribLocation(m_sRGBTexture->GetOpenGLID(), 0, "vertex")); | ||
676 | 161 | CHECKGL(glBindAttribLocation(m_sRGBTexture->GetOpenGLID(), 1, "textureCoord0")); | ||
677 | 162 | |||
678 | 163 | m_sRGBTexture->Link(); | ||
679 | 164 | } | ||
680 | 165 | |||
681 | 120 | void GraphicsEngine::InitSlColorModTexMaskAlpha() | 166 | void GraphicsEngine::InitSlColorModTexMaskAlpha() |
682 | 121 | { | 167 | { |
683 | 122 | ObjectPtr<IOpenGLVertexShader> VS = _graphics_display.m_DeviceFactory->CreateVertexShader(); | 168 | ObjectPtr<IOpenGLVertexShader> VS = _graphics_display.m_DeviceFactory->CreateVertexShader(); |
684 | @@ -973,6 +1019,66 @@ | |||
685 | 973 | ShaderProg->End(); | 1019 | ShaderProg->End(); |
686 | 974 | } | 1020 | } |
687 | 975 | 1021 | ||
688 | 1022 | void GraphicsEngine::QRP_GLSL_sRGB(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> tex, TexCoordXForm& texxform, const Color& colour, const float gamma) | ||
689 | 1023 | { | ||
690 | 1024 | if (!m_sRGBTexture.IsValid()) | ||
691 | 1025 | InitSRGBTextureShader(); | ||
692 | 1026 | |||
693 | 1027 | m_quad_tex_stats++; | ||
694 | 1028 | QRP_Compute_Texture_Coord(width, height, tex, texxform); | ||
695 | 1029 | |||
696 | 1030 | float fx = x; | ||
697 | 1031 | float fy = y; | ||
698 | 1032 | float vertexBuffer[] = | ||
699 | 1033 | { | ||
700 | 1034 | fx, fy, 0.0f, 1.0f, texxform.u0, texxform.v0, 0, 0, colour.red, colour.green, colour.blue, colour.alpha, | ||
701 | 1035 | fx, fy + height, 0.0f, 1.0f, texxform.u0, texxform.v1, 0, 0, colour.red, colour.green, colour.blue, colour.alpha, | ||
702 | 1036 | fx + width, fy + height, 0.0f, 1.0f, texxform.u1, texxform.v1, 0, 0, colour.red, colour.green, colour.blue, colour.alpha, | ||
703 | 1037 | fx + width, fy + height, 0.0f, 1.0f, texxform.u1, texxform.v0, 0, 0, colour.red, colour.green, colour.blue, colour.alpha, | ||
704 | 1038 | }; | ||
705 | 1039 | |||
706 | 1040 | CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0)); | ||
707 | 1041 | CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0)); | ||
708 | 1042 | m_sRGBTexture->Begin(); | ||
709 | 1043 | |||
710 | 1044 | int vertexLocation = m_sRGBTexture->GetAttributeLocation("vertex"); | ||
711 | 1045 | int textureCoord0Location = m_sRGBTexture->GetAttributeLocation("textureCoord0"); | ||
712 | 1046 | int textureObjectLocation = m_sRGBTexture->GetUniformLocationARB("textureObject"); | ||
713 | 1047 | |||
714 | 1048 | //Set texture and it's uniform location. | ||
715 | 1049 | SetTexture(GL_TEXTURE0, tex); | ||
716 | 1050 | CHECKGL(glUniform1iARB(textureObjectLocation, 0)); | ||
717 | 1051 | |||
718 | 1052 | GLint viewProjMatLocation = m_sRGBTexture->GetUniformLocationARB("viewProjectionMatrix"); | ||
719 | 1053 | Matrix4 modelViewProjMat = GetOpenGLModelViewProjectionMatrix(); | ||
720 | 1054 | m_sRGBTexture->SetUniformLocMatrix4fv(viewProjMatLocation, 1, false, (GLfloat*) &(modelViewProjMat.m)); | ||
721 | 1055 | |||
722 | 1056 | //Set our gamma uniform. | ||
723 | 1057 | m_sRGBTexture->SetUniform1f("gamma", gamma); | ||
724 | 1058 | |||
725 | 1059 | if (vertexLocation != -1) | ||
726 | 1060 | { | ||
727 | 1061 | CHECKGL(glEnableVertexAttribArrayARB(vertexLocation)); | ||
728 | 1062 | CHECKGL(glVertexAttribPointerARB((GLuint)vertexLocation, 4, GL_FLOAT, GL_FALSE, 48, vertexBuffer)); | ||
729 | 1063 | } | ||
730 | 1064 | |||
731 | 1065 | if (textureCoord0Location != -1) | ||
732 | 1066 | { | ||
733 | 1067 | CHECKGL(glEnableVertexAttribArrayARB(textureCoord0Location)); | ||
734 | 1068 | CHECKGL(glVertexAttribPointerARB((GLuint)textureCoord0Location, 4, GL_FLOAT, GL_FALSE, 48, vertexBuffer + 4)); | ||
735 | 1069 | } | ||
736 | 1070 | |||
737 | 1071 | CHECKGL(glDrawArrays(GL_TRIANGLE_FAN, 0, 4)); | ||
738 | 1072 | |||
739 | 1073 | if (vertexLocation != -1) | ||
740 | 1074 | CHECKGL(glDisableVertexAttribArrayARB(vertexLocation)); | ||
741 | 1075 | |||
742 | 1076 | if (textureCoord0Location != -1) | ||
743 | 1077 | CHECKGL(glDisableVertexAttribArrayARB(textureCoord0Location)); | ||
744 | 1078 | |||
745 | 1079 | m_sRGBTexture->End(); | ||
746 | 1080 | } | ||
747 | 1081 | |||
748 | 976 | // Render the texture alpha into RGB and modulated by a color. | 1082 | // Render the texture alpha into RGB and modulated by a color. |
749 | 977 | void GraphicsEngine::QRP_GLSL_ColorModTexAlpha(int x, int y, int width, int height, | 1083 | void GraphicsEngine::QRP_GLSL_ColorModTexAlpha(int x, int y, int width, int height, |
750 | 978 | ObjectPtr< IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform, const Color &color) | 1084 | ObjectPtr< IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform, const Color &color) |
751 | 979 | 1085 | ||
752 | === modified file 'gputests/Makefile.am' | |||
753 | --- gputests/Makefile.am 2012-05-25 20:36:09 +0000 | |||
754 | +++ gputests/Makefile.am 2012-09-24 06:59:20 +0000 | |||
755 | @@ -7,7 +7,7 @@ | |||
756 | 7 | # This tells automake that we want to build binaries, but they shouldn't be | 7 | # This tells automake that we want to build binaries, but they shouldn't be |
757 | 8 | # installed. For each individual test, add it's binary name here | 8 | # installed. For each individual test, add it's binary name here |
758 | 9 | 9 | ||
760 | 10 | noinst_PROGRAMS = texture_power_of_2 framebufferobject quad_2texmod texture_copy_blur texture_blur texture_data | 10 | noinst_PROGRAMS = texture_power_of_2 gamma_correction framebufferobject quad_2texmod texture_copy_blur texture_blur texture_data |
761 | 11 | 11 | ||
762 | 12 | if !NUX_OPENGLES_20 | 12 | if !NUX_OPENGLES_20 |
763 | 13 | noinst_PROGRAMS += arb_programs_limits | 13 | noinst_PROGRAMS += arb_programs_limits |
764 | @@ -19,7 +19,7 @@ | |||
765 | 19 | -I$(srcdir) \ | 19 | -I$(srcdir) \ |
766 | 20 | -I$(top_srcdir) \ | 20 | -I$(top_srcdir) \ |
767 | 21 | -DPREFIX=\""$(prefix)"\" \ | 21 | -DPREFIX=\""$(prefix)"\" \ |
769 | 22 | -DLIBDIR=\""$(libdir)"\" \ | 22 | -DLIBDIR=\""$(libdir)"\" \ |
770 | 23 | -DDATADIR=\""$(datadir)"\" \ | 23 | -DDATADIR=\""$(datadir)"\" \ |
771 | 24 | -DG_LOG_DOMAIN=\"NuxGpuTests\" \ | 24 | -DG_LOG_DOMAIN=\"NuxGpuTests\" \ |
772 | 25 | $(GCC_FLAGS) \ | 25 | $(GCC_FLAGS) \ |
773 | @@ -39,6 +39,8 @@ | |||
774 | 39 | # you need a $exe_SOURCES and $exe_LDADD so it builds | 39 | # you need a $exe_SOURCES and $exe_LDADD so it builds |
775 | 40 | texture_power_of_2_SOURCES = texture_power_of_2.cpp | 40 | texture_power_of_2_SOURCES = texture_power_of_2.cpp |
776 | 41 | texture_power_of_2_LDADD = $(ALL_LIBS) | 41 | texture_power_of_2_LDADD = $(ALL_LIBS) |
777 | 42 | gamma_correction_SOURCES = gamma_correction.cpp | ||
778 | 43 | gamma_correction_LDADD = $(ALL_LIBS) | ||
779 | 42 | framebufferobject_SOURCES = framebufferobject.cpp | 44 | framebufferobject_SOURCES = framebufferobject.cpp |
780 | 43 | framebufferobject_LDADD = $(ALL_LIBS) | 45 | framebufferobject_LDADD = $(ALL_LIBS) |
781 | 44 | quad_2texmod_SOURCES = quad_2texmod.cpp | 46 | quad_2texmod_SOURCES = quad_2texmod.cpp |
782 | @@ -55,6 +57,7 @@ | |||
783 | 55 | # distribute source along to the documentation | 57 | # distribute source along to the documentation |
784 | 56 | sourcegputestsdir = "$(pkgdatadir)/gputests" | 58 | sourcegputestsdir = "$(pkgdatadir)/gputests" |
785 | 57 | sourcegputests_DATA = $(texture_power_of_2_SOURCES) \ | 59 | sourcegputests_DATA = $(texture_power_of_2_SOURCES) \ |
786 | 60 | $(gamma_correction_SOURCES) \ | ||
787 | 58 | $(framebufferobject_SOURCES) \ | 61 | $(framebufferobject_SOURCES) \ |
788 | 59 | $(quad_2texmod) \ | 62 | $(quad_2texmod) \ |
789 | 60 | $(texture_copy_blur_SOURCES) \ | 63 | $(texture_copy_blur_SOURCES) \ |
790 | 61 | 64 | ||
791 | === added file 'gputests/gamma_correction.cpp' | |||
792 | --- gputests/gamma_correction.cpp 1970-01-01 00:00:00 +0000 | |||
793 | +++ gputests/gamma_correction.cpp 2012-09-24 06:59:20 +0000 | |||
794 | @@ -0,0 +1,117 @@ | |||
795 | 1 | #include "NuxCore/NuxCore.h" | ||
796 | 2 | #include "NuxGraphics/BitmapFormats.h" | ||
797 | 3 | #include "NuxGraphics/GraphicsDisplay.h" | ||
798 | 4 | #include "NuxGraphics/GLWindowManager.h" | ||
799 | 5 | #include "NuxGraphics/GraphicsEngine.h" | ||
800 | 6 | |||
801 | 7 | /* | ||
802 | 8 | * Tests: | ||
803 | 9 | * - loading texture from the hard drive | ||
804 | 10 | * - performing gamma correction | ||
805 | 11 | */ | ||
806 | 12 | |||
807 | 13 | void correct_gamma(float g) | ||
808 | 14 | { | ||
809 | 15 | nux::GraphicsDisplay* m_GLWindow = gGLWindowManager.CreateGLWindow("Test gamma", 512, 512, nux::WINDOWSTYLE_NORMAL, 0, false); | ||
810 | 16 | nux::GraphicsEngine* m_GraphicsContext = m_GLWindow->GetGraphicsEngine(); | ||
811 | 17 | m_GLWindow->ShowWindow(); | ||
812 | 18 | |||
813 | 19 | const TCHAR* fname = TEXT("./data/img.png"); | ||
814 | 20 | nux::ObjectPtr<nux::IOpenGLTexture2D> tex; | ||
815 | 21 | nux::NBitmapData *bitmap = nux::LoadImageFile(fname); | ||
816 | 22 | nux::ImageSurface surface = bitmap->GetSurface(0); | ||
817 | 23 | surface.GetFormat(); | ||
818 | 24 | |||
819 | 25 | tex = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateTexture( | ||
820 | 26 | surface.GetWidth(), | ||
821 | 27 | surface.GetHeight(), | ||
822 | 28 | 1, | ||
823 | 29 | surface.GetFormat()); | ||
824 | 30 | |||
825 | 31 | nux::SURFACE_LOCKED_RECT lockrect; | ||
826 | 32 | tex->LockRect(0, &lockrect, 0); | ||
827 | 33 | |||
828 | 34 | BYTE *dest = (BYTE *) lockrect.pBits; | ||
829 | 35 | const BYTE *src = surface.GetPtrRawData(); | ||
830 | 36 | int RowByteSize = surface.GetPitch(); | ||
831 | 37 | int num_row = surface.GetBlockHeight(); | ||
832 | 38 | |||
833 | 39 | for (int Y = 0; Y < num_row; Y++ ) | ||
834 | 40 | { | ||
835 | 41 | // Take Min(RowByteSize, StrideY): the source and the destination may not have the same Pitch but | ||
836 | 42 | // they contain the same amount of valid data since they have the same width, height and format. | ||
837 | 43 | nux::Memcpy(dest + Y * lockrect.Pitch, &src[Y * RowByteSize], nux::Min (RowByteSize, lockrect.Pitch)); | ||
838 | 44 | } | ||
839 | 45 | |||
840 | 46 | tex->UnlockRect(0); | ||
841 | 47 | |||
842 | 48 | int w, h; | ||
843 | 49 | m_GraphicsContext->GetWindowSize(w, h); | ||
844 | 50 | m_GraphicsContext->SetViewport(0, 0, w, h); | ||
845 | 51 | m_GraphicsContext->SetContext(0, 0, w, h); | ||
846 | 52 | m_GraphicsContext->Push2DWindow(w, h); | ||
847 | 53 | |||
848 | 54 | nux::Event event; | ||
849 | 55 | memset(&event, 0, sizeof(nux::Event)); | ||
850 | 56 | |||
851 | 57 | do | ||
852 | 58 | { | ||
853 | 59 | CHECKGL(glClearColor(0, 0, 0, 1) ); | ||
854 | 60 | CHECKGL(glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT)); | ||
855 | 61 | |||
856 | 62 | m_GLWindow->GetSystemEvent(&event); | ||
857 | 63 | |||
858 | 64 | if(event.type == nux::NUX_SIZE_CONFIGURATION) | ||
859 | 65 | { | ||
860 | 66 | m_GraphicsContext->DisableAllTextureMode(0); | ||
861 | 67 | m_GraphicsContext->DisableAllTextureMode(1); | ||
862 | 68 | m_GraphicsContext->DisableAllTextureMode(2); | ||
863 | 69 | m_GraphicsContext->DisableAllTextureMode(3); | ||
864 | 70 | m_GraphicsContext->GetWindowSize(w, h); | ||
865 | 71 | m_GraphicsContext->SetViewport(0, 0, w, h); | ||
866 | 72 | m_GraphicsContext->SetScissor(0, 0, w, h); | ||
867 | 73 | m_GraphicsContext->SetContext(0, 0, w, h); | ||
868 | 74 | m_GraphicsContext->Push2DWindow(w, h); | ||
869 | 75 | } | ||
870 | 76 | |||
871 | 77 | int x=10; | ||
872 | 78 | int y=10; | ||
873 | 79 | |||
874 | 80 | m_GraphicsContext->SetTexture(GL_TEXTURE0, tex); | ||
875 | 81 | |||
876 | 82 | int width = tex->GetWidth(); | ||
877 | 83 | int height = tex->GetHeight(); | ||
878 | 84 | |||
879 | 85 | nux::TexCoordXForm texxform; | ||
880 | 86 | m_GraphicsContext->QRP_ASM_sRGB(x, y, width, height, tex, texxform, nux::color::White, g); | ||
881 | 87 | |||
882 | 88 | m_GLWindow->SwapBuffer(); | ||
883 | 89 | |||
884 | 90 | } while(event.type != nux::NUX_TERMINATE_APP); | ||
885 | 91 | |||
886 | 92 | tex.Release(); | ||
887 | 93 | delete m_GLWindow; | ||
888 | 94 | } | ||
889 | 95 | |||
890 | 96 | float g; | ||
891 | 97 | int main(int argc, char **argv) | ||
892 | 98 | { | ||
893 | 99 | if(argc > 1) { | ||
894 | 100 | char *endp; float val = strtof(argv[1], &endp); | ||
895 | 101 | |||
896 | 102 | if(!(endp == argv[1])) | ||
897 | 103 | g = val; | ||
898 | 104 | else | ||
899 | 105 | g = 1.0; | ||
900 | 106 | } | ||
901 | 107 | else | ||
902 | 108 | g = 1.0; | ||
903 | 109 | |||
904 | 110 | nux::NuxCoreInitialize(0); | ||
905 | 111 | nux::NuxGraphicsInitialize(); | ||
906 | 112 | |||
907 | 113 | printf("NuxGraphics Input gamma: %2f Exponent 1/gamma: %2f\n", g, (float)1.0 / g); | ||
908 | 114 | correct_gamma(g); | ||
909 | 115 | |||
910 | 116 | return 0; | ||
911 | 117 | } | ||
912 | 0 | 118 | ||
913 | === modified file 'gputests/quad_2texmod.cpp' (properties changed: +x to -x) |
NuxGraphics/ GraphicsEngine. cpp
Take a look at the merge proposal diff. You can see that you
have a few tabs there instead of spaces :-)
> NuxGraphics/ RenderingPipe. cpp
Please keep the # directives in line at the start of the line.
As a general curiousity, how does this method work? It doesn't
return anything. Is it modifying the texture passed in as
the "tex" param?
> void GraphicsEngine: :InitAsmSRGBSha der()
For the shaders here... please use "const char*" instead
of "std::string". It expresses intent perfectly fine, we are not
modifying the string at all, and it means you don't need the
.c_str() call in the load shader commands. I've been talking
with Michi about this too, and I think we will be changing them
all soonish.
Same thing for the other init shader methods.
gputests/ Makefile. am also has tabs
as does teh gamma_correctio n.cpp file.