1 /************************************************************************************
3 Filename : stereo_ovf_fp.cpp
4 Content : Barrel fragment program compiled to a blob of assembly
5 Created : July 01, 2013
6 Modified by : Jan Boon (Kaetemi)
8 Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
10 Licensed under the Apache License, Version 2.0 (the "License");
11 you may not use this file except in compliance with the License.
12 You may obtain a copy of the License at
14 http://www.apache.org/licenses/LICENSE-2.0
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
22 ************************************************************************************/
31 const char *g_StereoOVR_fp40
=
33 "OPTION NV_fragment_program2;\n"
34 //# cgc version 3.1.0013, build date Apr 18 2012
35 //# command line args: -profile fp40
36 //# source file: pp_oculus_vr.cg
37 //#vendor NVIDIA Corporation
40 //#program pp_oculus_vr
41 //#semantic pp_oculus_vr.cLensCenter
42 //#semantic pp_oculus_vr.cScreenCenter
43 //#semantic pp_oculus_vr.cScale
44 //#semantic pp_oculus_vr.cScaleIn
45 //#semantic pp_oculus_vr.cHmdWarpParam
46 //#semantic pp_oculus_vr.cTex0 : TEX0
47 //#var float2 texCoord : $vin.TEXCOORD0 : TEX0 : 0 : 1
48 //#var float2 cLensCenter : : c[0] : 1 : 1
49 //#var float2 cScreenCenter : : c[1] : 2 : 1
50 //#var float2 cScale : : c[2] : 3 : 1
51 //#var float2 cScaleIn : : c[3] : 4 : 1
52 //#var float4 cHmdWarpParam : : c[4] : 5 : 1
53 //#var sampler2D nlTex0 : TEX0 : texunit 0 : 6 : 1
54 //#var float4 oCol : $vout.COLOR : COL : 7 : 1
55 //#const c[5] = 0.25 0.5 0
56 "PARAM c[6] = { program.env[0..4],\n" // program.local->program.env!
57 " { 0.25, 0.5, 0 } };\n"
63 "OUTPUT oCol = result.color;\n"
64 "ADDR R0.xy, fragment.texcoord[0], -c[0];\n"
65 "MULR R0.xy, R0, c[3];\n"
66 "MULR R0.z, R0.y, R0.y;\n"
67 "MADR R1.x, R0, R0, R0.z;\n"
68 "MULR R0.zw, R1.x, c[4].xywz;\n"
69 "MADR R1.y, R1.x, c[4], c[4].x;\n"
70 "MADR R0.w, R0, R1.x, R1.y;\n"
71 "MULR R0.z, R0, R1.x;\n"
72 "MADR R0.z, R0, R1.x, R0.w;\n"
73 "MULR R1.xy, R0, R0.z;\n"
75 "ADDR R1.zw, R0.xyxy, c[1].xyxy;\n"
76 "MOVR R0.zw, c[0].xyxy;\n"
77 "MADR R0.zw, R1.xyxy, c[2].xyxy, R0;\n"
78 "MINR R1.xy, R0.zwzw, R1.zwzw;\n"
79 "ADDR R0.xy, -R0, c[1];\n"
80 "MAXR R0.xy, R0, R1;\n"
81 "SEQR H0.xy, R0, R0.zwzw;\n"
82 "MULXC HC.x, H0, H0.y;\n"
84 "MOVR oCol, c[5].z;\n"
86 "TEX oCol, R0.zwzw, texture[0], 2D;\n"
89 //# 24 instructions, 2 R-regs, 1 H-regs
91 const char *g_StereoOVR_arbfp1
=
93 //# cgc version 3.1.0013, build date Apr 18 2012
94 //# command line args: -profile arbfp1
95 //# source file: pp_oculus_vr.cg
96 //#vendor NVIDIA Corporation
99 //#program pp_oculus_vr
100 //#semantic pp_oculus_vr.cLensCenter
101 //#semantic pp_oculus_vr.cScreenCenter
102 //#semantic pp_oculus_vr.cScale
103 //#semantic pp_oculus_vr.cScaleIn
104 //#semantic pp_oculus_vr.cHmdWarpParam
105 //#semantic pp_oculus_vr.cTex0 : TEX0
106 //#var float2 texCoord : $vin.TEXCOORD0 : TEX0 : 0 : 1
107 //#var float2 cLensCenter : : c[0] : 1 : 1
108 //#var float2 cScreenCenter : : c[1] : 2 : 1
109 //#var float2 cScale : : c[2] : 3 : 1
110 //#var float2 cScaleIn : : c[3] : 4 : 1
111 //#var float4 cHmdWarpParam : : c[4] : 5 : 1
112 //#var sampler2D nlTex0 : TEX0 : texunit 0 : 6 : 1
113 //#var float4 oCol : $vout.COLOR : COL : 7 : 1
114 //#const c[5] = 0.25 0.5 0 1
115 "PARAM c[6] = { program.env[0..4],\n"
116 " { 0.25, 0.5, 0, 1 } };\n"
119 "ADD R0.xy, fragment.texcoord[0], -c[0];\n"
120 "MUL R0.xy, R0, c[3];\n"
121 "MUL R0.z, R0.y, R0.y;\n"
122 "MAD R0.z, R0.x, R0.x, R0;\n"
123 "MUL R0.w, R0.z, c[4];\n"
124 "MUL R0.w, R0, R0.z;\n"
125 "MAD R1.y, R0.z, c[4], c[4].x;\n"
126 "MUL R1.x, R0.z, c[4].z;\n"
127 "MAD R1.x, R0.z, R1, R1.y;\n"
128 "MAD R0.z, R0.w, R0, R1.x;\n"
129 "MUL R0.xy, R0, R0.z;\n"
130 "MOV R0.zw, c[5].xyxy;\n"
131 "ADD R1.xy, R0.zwzw, c[1];\n"
132 "MUL R0.xy, R0, c[2];\n"
133 "ADD R0.xy, R0, c[0];\n"
134 "MIN R1.xy, R1, R0;\n"
135 "ADD R0.zw, -R0, c[1].xyxy;\n"
136 "MAX R0.zw, R0, R1.xyxy;\n"
137 "ADD R0.zw, R0, -R0.xyxy;\n"
139 "CMP R0.zw, -R0, c[5].z, c[5].w;\n"
140 "MUL R0.z, R0, R0.w;\n"
142 "CMP R0.z, -R0, c[5], c[5].w;\n"
144 "TEX R0, R0, texture[0], 2D;\n"
145 "CMP R1.x, -R1, c[5].z, c[5].w;\n"
146 "CMP result.color, -R1.x, R0, c[5].z;\n"
148 //# 28 instructions, 2 R-regs
150 const char *g_StereoOVR_ps_2_0
=
152 // cgc version 3.1.0013, build date Apr 18 2012
153 // command line args: -profile ps_2_0
154 // source file: pp_oculus_vr.cg
155 //vendor NVIDIA Corporation
158 //program pp_oculus_vr
159 //semantic pp_oculus_vr.cLensCenter
160 //semantic pp_oculus_vr.cScreenCenter
161 //semantic pp_oculus_vr.cScale
162 //semantic pp_oculus_vr.cScaleIn
163 //semantic pp_oculus_vr.cHmdWarpParam
164 //semantic pp_oculus_vr.cTex0 : TEX0
165 //var float2 texCoord : $vin.TEXCOORD0 : TEX0 : 0 : 1
166 //var float2 cLensCenter : : c[0] : 1 : 1
167 //var float2 cScreenCenter : : c[1] : 2 : 1
168 //var float2 cScale : : c[2] : 3 : 1
169 //var float2 cScaleIn : : c[3] : 4 : 1
170 //var float4 cHmdWarpParam : : c[4] : 5 : 1
171 //var sampler2D nlTex0 : TEX0 : texunit 0 : 6 : 1
172 //var float4 oCol : $vout.COLOR : COL : 7 : 1
173 //const c[5] = -0.25 -0.5 0.25 0.5
176 "def c5, -0.25000000, -0.50000000, 0.25000000, 0.50000000\n"
177 "def c6, 1.00000000, 0.00000000, 0, 0\n"
179 "add r0.xy, t0, -c0\n"
180 "mul r4.xy, r0, c3\n"
181 "mul r0.x, r4.y, r4.y\n"
182 "mad r0.x, r4, r4, r0\n"
183 "mul r1.x, r0, c4.w\n"
185 "mad r3.x, r0, c4.y, c4\n"
186 "mul r2.x, r0, c4.z\n"
187 "mad r2.x, r0, r2, r3\n"
188 "mad r0.x, r1, r0, r2\n"
189 "mul r0.xy, r4, r0.x\n"
190 "mul r0.xy, r0, c2\n"
191 "add r3.xy, r0, c0\n"
195 "add r2.xy, r1, r2\n"
197 "min r2.xy, r2, r3\n"
198 "add r1.xy, c5, r1\n"
199 "max r1.xy, r1, r2\n"
200 "add r1.xy, r1, -r3\n"
202 "cmp r1.xy, -r1, c6.x, c6.y\n"
203 "mul_pp r1.x, r1, r1.y\n"
205 "cmp_pp r1.x, -r1, c6, c6.y\n"
208 "cmp r0, -r1.x, r0, c6.y\n"
211 const char *g_StereoOVR_glsl330f
=
217 "uniform vec2 cLensCenter;\n"
218 "uniform vec2 cScreenCenter;\n"
219 "uniform vec2 cScale;\n"
220 "uniform vec2 cScaleIn;\n"
221 "uniform vec4 cHmdWarpParam;\n"
222 "uniform sampler2D nlTex0;\n"
226 "in vec4 nlTexCoord0;\n"
236 " _theta = (nlTexCoord0.xy - cLensCenter)*cScaleIn;\n"
237 " _rSq = _theta.x*_theta.x + _theta.y*_theta.y;\n"
238 " _theta1 = _theta*(cHmdWarpParam.x + cHmdWarpParam.y*_rSq + cHmdWarpParam.z*_rSq*_rSq + cHmdWarpParam.w*_rSq*_rSq*_rSq);\n"
239 " _tc = cLensCenter + cScale*_theta1;\n"
240 " _a0011 = cScreenCenter - vec2( 0.25, 0.5);\n"
241 " _b0011 = cScreenCenter + vec2( 0.25, 0.5);\n"
242 " _TMP3 = min(_b0011, _tc);\n"
243 " _TMP10 = max(_a0011, _TMP3);\n"
244 " _TMP1 = bvec2(_TMP10.x == _tc.x, _TMP10.y == _tc.y);\n"
245 " _TMP2 = _TMP1.x && _TMP1.y;\n"
247 " nlCol = vec4(0, 0, 0, 0);\n"
249 " nlCol = texture(nlTex0, _tc);\n"