Debian Codegraph @

src/thirdparty/SiftGPU/ProgramCG.h

raw
1 ////////////////////////////////////////////////////////////////////////////
2 // File: ProgramCG.h
3 // Author: Changchang Wu
4 // Description : interface for the ProgramCG classes.
5 // ProgramCG: Cg programs
6 // ShaderBagCG: All Cg shaders for Sift in a bag
7 // FilterGLCG: Cg Gaussian Filters
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 [email protected]
22 //
23 ////////////////////////////////////////////////////////////////////////////
24
25
26 #if defined(CG_SIFTGPU_ENABLED)
27
28 #ifndef _PROGRAM_CG_H
29 #define _PROGRAM_CG_H
30
31 #include "ProgramGPU.h"
32 class FragmentProgram;
33 #include "Cg/cgGL.h"
34
35 class ProgramCG:public ProgramGPU
36 {
37 CGprogram _programID;
38 CGprofile _profile;
39 int _valid;
40 public:
41 static CGcontext _Context;
42 static CGprofile _FProfile;
43 public:
44 operator CGprogram (){return _programID;}
45 CGprogram GetProgramID(){return _programID;}
46 int UseProgram();
47 int IsValidProgram(){return _programID && _valid;}
48 static void ErrorCallback();
49 static void InitContext();
50 static void DestroyContext();
51 ProgramCG(const char * code, const char** cg_compile_args= NULL, CGprofile profile = ProgramCG::_FProfile);
52 ProgramCG();
53 virtual ~ProgramCG();
54
55 };
56
57 class ShaderBagCG:public ShaderBag
58 {
59 CGparameter _param_dog_texu;
60 CGparameter _param_dog_texd;
61 CGparameter _param_genlist_start_tex0;
62 CGparameter _param_ftex_width;
63 CGparameter _param_genlist_step_tex;
64 CGparameter _param_genlist_step_tex0;
65 CGparameter _param_genvbo_size;
66 CGparameter _param_orientation_gtex;
67 CGparameter _param_orientation_stex;
68 CGparameter _param_orientation_size;
69 CGparameter _param_descriptor_gtex;
70 CGparameter _param_descriptor_size;
71 CGparameter _param_descriptor_dsize;
72 CGparameter _param_margin_copy_truncate;
73 CGparameter _param_genlist_init_bbox;
74 public:
75 virtual void LoadDescriptorShader();
76 void LoadDescriptorShaderF2();
77 static void WriteOrientationCodeToStream(ostream& out);
78 virtual void SetGenListInitParam(int w, int h);
79 virtual void SetMarginCopyParam(int xmax, int ymax);
80 virtual void SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int stex = 0, float step = 1.0f);
81 virtual void SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma);
82 virtual void SetSimpleOrientationInput(int oTex, float sigma, float sigma_step);
83 void LoadOrientationShader();
84 virtual void SetGenListStartParam(float width, int tex0);
85 static ProgramCG* LoadGenListStepShader(int start, int step);
86 static ProgramCG* LoadGenListStepShaderV2(int start, int step);
87 void LoadGenListShader(int ndoglev, int nlev);
88 virtual void UnloadProgram();
89 virtual void SetDogTexParam(int texU, int texD);
90 virtual void SetGenListStepParam(int tex, int tex0);
91 virtual void SetGenVBOParam( float width, float fwidth, float size);
92 virtual void LoadFixedShaders();
93 virtual void LoadDisplayShaders();
94 virtual void LoadKeypointShader(float threshold, float edgeThreshold);
95 virtual int LoadKeypointShaderMR(float threshold, float edgeThreshold);
96 ShaderBagCG();
97 virtual ~ShaderBagCG(){}
98 };
99
100
101 class FilterGLCG : public FilterProgram
102 {
103 private:
104 ProgramGPU* CreateFilterH(float kernel[], float offset[], int width);
105 ProgramGPU* CreateFilterV(float kernel[], float offset[], int height);
106 //packed version
107 ProgramGPU* CreateFilterHPK(float kernel[], float offset[], int width);
108 ProgramGPU* CreateFilterVPK(float kernel[], float offset[], int height);
109 };
110
111 class ShaderBagPKCG:public ShaderBag
112 {
113 private:
114 CGparameter _param_dog_texu;
115 CGparameter _param_dog_texd;
116 CGparameter _param_margin_copy_truncate;
117 CGparameter _param_grad_pass_texp;
118 CGparameter _param_genlist_init_bbox;
119 CGparameter _param_genlist_start_tex0;
120 CGparameter _param_ftex_width;
121 CGparameter _param_genlist_step_tex;
122 CGparameter _param_genlist_step_tex0;
123 CGparameter _param_genlist_end_ktex;
124 CGparameter _param_genvbo_size;
125 CGparameter _param_orientation_gtex;
126 CGparameter _param_orientation_otex;
127 CGparameter _param_orientation_size;
128 CGparameter _param_descriptor_gtex;
129 CGparameter _param_descriptor_otex;
130 CGparameter _param_descriptor_size;
131 CGparameter _param_descriptor_dsize;
132
133 public:
134 ShaderBagPKCG();
135 virtual ~ShaderBagPKCG(){}
136 virtual void LoadDescriptorShader();
137 virtual void LoadDescriptorShaderF2();
138 virtual void LoadOrientationShader();
139 virtual void LoadGenListShader(int ndoglev, int nlev);
140 virtual void LoadGenListShaderV2(int ndoglev, int nlev);
141 virtual void UnloadProgram() ;
142 virtual void LoadKeypointShader(float threshold, float edgeTrheshold);
143 virtual void LoadFixedShaders();
144 virtual void LoadDisplayShaders();
145 virtual void SetGradPassParam(int texP);
146 virtual void SetGenListEndParam(int ktex);
147 public:
148 //parameters
149 virtual void SetGenListStartParam(float width, int tex0);
150 virtual void SetGenListInitParam(int w, int h);
151 virtual void SetMarginCopyParam(int xmax, int ymax);
152 virtual void SetDogTexParam(int texU, int texD);
153 virtual void SetGenListStepParam(int tex, int tex0);
154 virtual void SetGenVBOParam( float width, float fwidth, float size);
155 virtual void SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma);
156 virtual void SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int stex, float step);
157 virtual void SetSimpleOrientationInput(int oTex, float sigma, float sigma_step);
158 };
159 #endif
160 #endif
161