root / rgbdslam / external / siftgpu / src / SiftGPU / ProgramGLSL.h @ 9240aaa3
History | View | Annotate | Download (9.21 KB)
1 |
////////////////////////////////////////////////////////////////////////////
|
---|---|
2 |
// File: ProgramGLSL.h
|
3 |
// Author: Changchang Wu
|
4 |
// Description : Interface for ProgramGLSL classes
|
5 |
// ProgramGLSL: Glsl Program
|
6 |
// FilterGLSL: Glsl Gaussian Filters
|
7 |
// ShaderBag: base class of ShaderBagPKSL and ShaderBagGLSL
|
8 |
//
|
9 |
// Copyright (c) 2007 University of North Carolina at Chapel Hill
|
10 |
// All Rights Reserved
|
11 |
//
|
12 |
// Permission to use, copy, modify and distribute this software and its
|
13 |
// documentation for educational, research and non-profit purposes, without
|
14 |
// fee, and without a written agreement is hereby granted, provided that the
|
15 |
// above copyright notice and the following paragraph appear in all copies.
|
16 |
//
|
17 |
// The University of North Carolina at Chapel Hill make no representations
|
18 |
// about the suitability of this software for any purpose. It is provided
|
19 |
// 'as is' without express or implied warranty.
|
20 |
//
|
21 |
// Please send BUG REPORTS to ccwu@cs.unc.edu
|
22 |
//
|
23 |
////////////////////////////////////////////////////////////////////////////
|
24 |
|
25 |
|
26 |
#ifndef _PROGRAM_GLSL_H
|
27 |
#define _PROGRAM_GLSL_H
|
28 |
|
29 |
|
30 |
#include "ProgramGPU.h" |
31 |
|
32 |
class ProgramGLSL:public ProgramGPU |
33 |
{ |
34 |
class ShaderObject |
35 |
{ |
36 |
GLuint _shaderID; |
37 |
int _type;
|
38 |
int _compiled;
|
39 |
static int ReadShaderFile(const char * source, char *& code); |
40 |
void CheckCompileLog();
|
41 |
public:
|
42 |
void PrintCompileLog(ostream & os );
|
43 |
int inline IsValidShaderObject(){ return _shaderID && _compiled;} |
44 |
int IsValidVertexShader();
|
45 |
int IsValidFragmentShader();
|
46 |
GLuint GetShaderID(){return _shaderID;}
|
47 |
~ShaderObject(); |
48 |
ShaderObject(int shadertype, const char * source, int filesource =0); |
49 |
}; |
50 |
|
51 |
protected:
|
52 |
int _linked;
|
53 |
GLuint _programID; |
54 |
private:
|
55 |
void AttachShaderObject(ShaderObject& shader);
|
56 |
void DetachShaderObject(ShaderObject& shader);
|
57 |
|
58 |
public:
|
59 |
void ReLink();
|
60 |
int IsNative();
|
61 |
int UseProgram();
|
62 |
void PrintLinkLog(std::ostream&os);
|
63 |
int ValidateProgram();
|
64 |
void CheckLinkLog();
|
65 |
int LinkProgram();
|
66 |
operator GLuint (){return _programID;}
|
67 |
virtual void * GetProgramID() { return (void*) _programID; } |
68 |
public:
|
69 |
ProgramGLSL(); |
70 |
~ProgramGLSL(); |
71 |
ProgramGLSL(const char* frag_source); |
72 |
}; |
73 |
|
74 |
|
75 |
class GLTexImage; |
76 |
class FilterGLSL : public FilterProgram |
77 |
{ |
78 |
private:
|
79 |
ProgramGPU* CreateFilterH(float kernel[], int width); |
80 |
ProgramGPU* CreateFilterV(float kernel[], int height); |
81 |
ProgramGPU* CreateFilterHPK(float kernel[], int width); |
82 |
ProgramGPU* CreateFilterVPK(float kernel[], int height); |
83 |
public:
|
84 |
void MakeFilterProgram(float kernel[], int width); |
85 |
public:
|
86 |
FilterGLSL(float sigma) ;
|
87 |
}; |
88 |
|
89 |
class SiftParam; |
90 |
|
91 |
/////////////////////////////////////////////////////////////////////////////////
|
92 |
//class ShaderBag
|
93 |
//desciption: pure virtual class
|
94 |
// provides storage and usage interface of all the shaders for SIFT
|
95 |
// two implementations are ShaderBagPKSL and ShaderBagGLSL
|
96 |
/////////////////////////////////////////////////////////////////////////////////
|
97 |
class ShaderBag |
98 |
{ |
99 |
public:
|
100 |
//shader: rgb to gray
|
101 |
ProgramGPU * s_gray; |
102 |
//shader: copy keypoint to PBO
|
103 |
ProgramGPU * s_copy_key; |
104 |
//shader: debug view
|
105 |
ProgramGPU * s_debug; |
106 |
//shader: orientation
|
107 |
//shader: assign simple orientation to keypoints if hardware is low
|
108 |
ProgramGPU * s_orientation; |
109 |
//shader: display gaussian levels
|
110 |
ProgramGPU * s_display_gaussian; |
111 |
//shader: display difference of gassian
|
112 |
ProgramGPU * s_display_dog; |
113 |
//shader: display gradient
|
114 |
ProgramGPU * s_display_grad; |
115 |
//shader: display keypoints as red(maximum) and blue (minimum)
|
116 |
ProgramGPU * s_display_keys; |
117 |
//shader: up/down-sample
|
118 |
ProgramGPU * s_sampling; |
119 |
//shader: compute gradient/dog
|
120 |
ProgramGPU * s_grad_pass; |
121 |
ProgramGPU * s_dog_pass; |
122 |
//shader: keypoint detection in one pass
|
123 |
ProgramGPU * s_keypoint; |
124 |
ProgramGPU * s_seperate_sp; |
125 |
//shader: feature list generations..
|
126 |
ProgramGPU * s_genlist_init_tight; |
127 |
ProgramGPU * s_genlist_init_ex; |
128 |
ProgramGPU * s_genlist_histo; |
129 |
ProgramGPU * s_genlist_start; |
130 |
ProgramGPU * s_genlist_step; |
131 |
ProgramGPU * s_genlist_end; |
132 |
ProgramGPU * s_zero_pass; |
133 |
//shader: generate vertex to display SIFT as a square
|
134 |
ProgramGPU * s_vertex_list; |
135 |
//shader: descriptor
|
136 |
ProgramGPU * s_descriptor_fp; |
137 |
//shader: copy pixels to margin
|
138 |
ProgramGPU * s_margin_copy; |
139 |
public:
|
140 |
FilterProgram * f_gaussian_skip0; |
141 |
vector<FilterProgram*> f_gaussian_skip0_v; |
142 |
FilterProgram * f_gaussian_skip1; |
143 |
FilterProgram ** f_gaussian_step; |
144 |
int _gaussian_step_num;
|
145 |
public:
|
146 |
virtual void SetGenListInitParam(int w, int h){}; |
147 |
virtual void SetGenListEndParam(int ktex){}; |
148 |
virtual void SetMarginCopyParam(int xmax, int ymax){}; |
149 |
virtual void LoadDescriptorShader(){};
|
150 |
virtual void SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma){}; |
151 |
virtual void SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int stex, float step){}; |
152 |
virtual void SetSimpleOrientationInput(int oTex, float sigma, float sigma_step){}; |
153 |
virtual void LoadOrientationShader() =0; |
154 |
virtual void SetGenListStartParam(float width, int tex0) =0; |
155 |
virtual void LoadGenListShader(int ndoglev, int nlev)=0; |
156 |
virtual void UnloadProgram()=0; |
157 |
virtual void LoadKeypointShader(float threshold, float edgeTrheshold) = 0; |
158 |
virtual void LoadFixedShaders()=0; |
159 |
virtual void LoadDisplayShaders() = 0; |
160 |
virtual void SetDogTexParam(int texU, int texD)=0; |
161 |
virtual void SetGradPassParam(int texP=0){} |
162 |
virtual void SetGenListStepParam(int tex, int tex0) = 0; |
163 |
virtual void SetGenVBOParam( float width, float fwidth, float size)=0; |
164 |
public:
|
165 |
void CreateGaussianFilters(SiftParam¶m);
|
166 |
void SelectInitialSmoothingFilter(int octave_min, SiftParam¶m); |
167 |
void LoadDynamicShaders(SiftParam& param);
|
168 |
ShaderBag(); |
169 |
virtual ~ShaderBag(); |
170 |
}; |
171 |
|
172 |
|
173 |
class ShaderBagGLSL:public ShaderBag |
174 |
{ |
175 |
GLint _param_dog_texu; |
176 |
GLint _param_dog_texd; |
177 |
GLint _param_ftex_width; |
178 |
GLint _param_genlist_start_tex0; |
179 |
GLint _param_genlist_step_tex; |
180 |
GLint _param_genlist_step_tex0; |
181 |
GLint _param_genvbo_size; |
182 |
GLint _param_orientation_gtex; |
183 |
GLint _param_orientation_size; |
184 |
GLint _param_orientation_stex; |
185 |
GLint _param_margin_copy_truncate; |
186 |
GLint _param_genlist_init_bbox; |
187 |
GLint _param_descriptor_gtex; |
188 |
GLint _param_descriptor_size; |
189 |
GLint _param_descriptor_dsize; |
190 |
public:
|
191 |
virtual void SetMarginCopyParam(int xmax, int ymax); |
192 |
void SetSimpleOrientationInput(int oTex, float sigma, float sigma_step); |
193 |
void LoadOrientationShader();
|
194 |
void LoadDescriptorShaderF2();
|
195 |
virtual void LoadDescriptorShader();
|
196 |
virtual void SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int stex = 0, float step = 1.0f); |
197 |
virtual void SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma); |
198 |
static void WriteOrientationCodeToStream(ostream& out); |
199 |
static ProgramGLSL* LoadGenListStepShader(int start, int step); |
200 |
virtual void SetGenListInitParam(int w, int h); |
201 |
virtual void SetGenListStartParam(float width, int tex0); |
202 |
virtual void LoadGenListShader(int ndoglev, int nlev); |
203 |
virtual void UnloadProgram();
|
204 |
virtual void LoadKeypointShader(float threshold, float edgeTrheshold); |
205 |
virtual void LoadFixedShaders();
|
206 |
virtual void LoadDisplayShaders();
|
207 |
virtual void SetDogTexParam(int texU, int texD); |
208 |
virtual void SetGenListStepParam(int tex, int tex0); |
209 |
virtual void SetGenVBOParam( float width, float fwidth, float size); |
210 |
virtual ~ShaderBagGLSL(){} |
211 |
}; |
212 |
|
213 |
|
214 |
class ShaderBagPKSL:public ShaderBag |
215 |
{ |
216 |
private:
|
217 |
GLint _param_dog_texu; |
218 |
GLint _param_dog_texd; |
219 |
GLint _param_margin_copy_truncate; |
220 |
GLint _param_grad_pass_texp; |
221 |
GLint _param_genlist_init_bbox; |
222 |
GLint _param_genlist_start_tex0; |
223 |
GLint _param_ftex_width; |
224 |
GLint _param_genlist_step_tex; |
225 |
GLint _param_genlist_step_tex0; |
226 |
GLint _param_genlist_end_ktex; |
227 |
GLint _param_genvbo_size; |
228 |
GLint _param_orientation_gtex; |
229 |
GLint _param_orientation_otex; |
230 |
GLint _param_orientation_size; |
231 |
GLint _param_descriptor_gtex; |
232 |
GLint _param_descriptor_otex; |
233 |
GLint _param_descriptor_size; |
234 |
GLint _param_descriptor_dsize; |
235 |
|
236 |
//
|
237 |
ProgramGLSL* s_rect_description; |
238 |
public:
|
239 |
ShaderBagPKSL () {s_rect_description = NULL; }
|
240 |
virtual ~ShaderBagPKSL() {if(s_rect_description) delete s_rect_description; }
|
241 |
virtual void LoadFixedShaders();
|
242 |
virtual void LoadDisplayShaders();
|
243 |
virtual void LoadOrientationShader() ;
|
244 |
virtual void SetGenListStartParam(float width, int tex0) ; |
245 |
virtual void LoadGenListShader(int ndoglev, int nlev); |
246 |
virtual void UnloadProgram();
|
247 |
virtual void LoadKeypointShader(float threshold, float edgeTrheshold) ; |
248 |
virtual void LoadDescriptorShader();
|
249 |
virtual void LoadDescriptorShaderF2();
|
250 |
static ProgramGLSL* LoadDescriptorProgramRECT();
|
251 |
static ProgramGLSL* LoadDescriptorProgramPKSL();
|
252 |
/////////////////
|
253 |
virtual void SetDogTexParam(int texU, int texD); |
254 |
virtual void SetGradPassParam(int texP); |
255 |
virtual void SetGenListStepParam(int tex, int tex0); |
256 |
virtual void SetGenVBOParam( float width, float fwidth, float size); |
257 |
virtual void SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma); |
258 |
virtual void SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int stex, float step); |
259 |
virtual void SetSimpleOrientationInput(int oTex, float sigma, float sigma_step); |
260 |
virtual void SetGenListEndParam(int ktex); |
261 |
virtual void SetGenListInitParam(int w, int h); |
262 |
virtual void SetMarginCopyParam(int xmax, int ymax); |
263 |
}; |
264 |
|
265 |
|
266 |
#endif
|
267 |
|