Panda3D
config_dxgsg9.cxx
1 // Filename: config_dxgsg9.cxx
2 // Created by: drose (06Oct99)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "config_dxgsg9.h"
16 #include "dxGraphicsStateGuardian9.h"
17 #include "dxTextureContext9.h"
18 #include "dxVertexBufferContext9.h"
19 #include "dxIndexBufferContext9.h"
20 #include "dxOcclusionQueryContext9.h"
21 #include "dxShaderContext9.h"
22 #include "dxGeomMunger9.h"
23 #include "graphicsPipeSelection.h"
24 #include "wdxGraphicsWindow9.h"
25 #include "wdxGraphicsPipe9.h"
26 #include "wdxGraphicsBuffer9.h"
27 #include "pandaSystem.h"
28 
29 #include "dconfig.h"
30 
31 DToolConfigure(config_dxgsg9);
32 NotifyCategoryDef(dxgsg9, ":display:gsg");
33 NotifyCategoryDef(wdxdisplay9, "display");
34 
35 // Configure this variable true to cause the DXGSG to show each
36 // transform space it renders by drawing a little unit axis. This
37 // cannot be enabled when the player is compiled in NDEBUG mode.
38 ConfigVariableBool dx_show_transforms
39 ("dx-show-transforms", false);
40 
41 // if true, if card only supports per-vertex fog, it will be treated as no-HW fog capability
42 ConfigVariableBool dx_no_vertex_fog
43 ("dx-no-vertex-fog", false);
44 
45 // if true, overwrite cursor bitmap tip with "D3D" to distinguish it from GDI cursor
46 ConfigVariableBool dx_show_cursor_watermark
47 ("dx-show-cursor-watermark",
48 #ifdef _DEBUG
49  true
50 #else
51  false
52 #endif
53  );
54 
55 // if true, triangle filter will be used to generate mipmap levels instead of default box filter
56 ConfigVariableBool dx_use_triangle_mipgen_filter
57 ("dx-use-triangle-mipgen-filter", false);
58 
59 ConfigVariableBool dx_broken_max_index
60 ("dx-broken-max-index", false,
61  PRC_DESC("Configure this true if you have a buggy graphics driver that "
62  "doesn't correctly implement the third parameter, NumVertices, "
63  "of DrawIndexedPrimitive(). In particular, the NVIDIA Quadro "
64  "driver version 6.14.10.7184 seems to treat this as a maximum "
65  "vertex index, rather than a delta between the maximum and "
66  "minimum vertex index. Turn this on if you are seeing stray "
67  "triangles, or you are not seeing all of your triangles. Enabling "
68  "this should work around this bug, at the cost of some additional "
69  "rendering overhead on the GPU."));
70 
71 ConfigVariableBool dx_broken_depth_bias
72 ("dx-broken-depth-bias", true,
73  PRC_DESC("Configure this true if your graphics driver claims to support "
74  "D3DPRASTERCAPS_DEPTHBIAS, but doesn't appear to do anything "
75  "useful when you set it. In fact, there's not much reason not "
76  "to just leave this set, since the workaround seems to be "
77  "sufficient for all cases."));
78 
79 ConfigVariableDouble dx_depth_bias_scale
80 ("dx-depth-bias-scale", 0.000001,
81  PRC_DESC("If depth bias is not directly supported by the graphics driver "
82  "(or if dx-broken-depth-bias is set true), this configures the "
83  "amount by which we slide the viewport back to achieve the effect "
84  "of a depth bias. It should generally be a small number."));
85 
86 ConfigVariableBool dx_count_all_cards_memory
87 ("dx-count-all-cards-memory", true,
88  PRC_DESC("Set this to false to skip the counting of extra cards memory "
89  "via DX7 calls."));
90 
91 #ifndef NDEBUG
92 // debugging flag
93 // values are same as D3DCULL enumtype, 0 - no force, 1 - force none, 2 - force CW, 3 - force CCW
94 ConfigVariableInt dx_force_backface_culling
95 ("dx-force-backface-culling", 0);
96 #endif
97 
98 ConfigVariableBool dx_mipmap_everything
99 ("dx-mipmap-everything", false);
100 ConfigVariableBool dx_ignore_mipmaps
101 ("dx-ignore-mipmaps", false);
102 
103 // if this is set, more accurate but more expensive fog computations are performed
104 ConfigVariableBool dx_use_rangebased_fog
105 ("dx-use-rangebased-fog", false);
106 ConfigVariableBool dx_no_dithering
107 ("dx-no-dithering", false);
108 ConfigVariableBool dx_force_16bpp_zbuffer
109 ("dx-force-16bpp-zbuffer", false);
110 ConfigVariableBool dx_do_vidmemsize_check
111 ("do-vidmemsize-check", true);
112 // Setting this true theoretically hinders render performance, because
113 // it forces the FPU to go through some extra work to clean itself up
114 // after rendering a frame, but the performance cost seems to be
115 // small. On the other hand, setting it false can force the
116 // application to run in single-precision arithmetic mode, even if
117 // it believes it is using double-precision variables.
118 ConfigVariableBool dx_preserve_fpu_state
119 ("dx-preserve-fpu-state", true);
120 
121 ConfigVariableInt dx_preferred_device_id
122 ("dx-preferred-device-id", -1);
123 
124 ConfigVariableBool dx_intel_compressed_texture_bug
125 ("dx-intel-compressed-texture-bug", true,
126  PRC_DESC("Set this true to work around a bug in the Intel driver "
127  "igdumd32.dll, for at least the 965 Express chipset family, "
128  "which breaks compressed texture images smaller "
129  "than about 256x256 (even mipmap levels). The workaround is "
130  "simply to disable compressed texture support when this "
131  "driver is detected."));
132 
133 #ifdef _DEBUG
134 ConfigVariableDouble dx_global_miplevel_bias
135 ("dx-global-miplevel-bias", 0.0);
136 ConfigVariableBool dx_debug_view_mipmaps
137 ("dx-debug-view-mipmaps", false);
138 #endif
139 
140 ConfigVariableBool dx_force_anisotropic_filtering
141 ("dx-force-anisotropic-filtering", false);
142 
143 // set 'retained-mode #t' and this to have prepare_geom concatenate all tristrips within a geom
144 // together using degenerate tris
145 ConfigVariableBool link_tristrips
146 ("link-tristrips", false);
147 
148 // true = use DirectX management of video memory
149 // false = see dx_lru_management config variable below
150 ConfigVariableBool dx_management
151 ("dx-management", false);
152 
153 // valid only if dx_management == false
154 // true = use DirectX management of texture memory
155 // false = lru will manage texture memory
156 ConfigVariableBool dx_texture_management
157 ("dx-texture-management", true);
158 
159 // valid only if dx_management == false
160 // true = enable LRU management of video memory
161 // false = no video memory management
162 ConfigVariableBool dx_lru_management
163 ("dx-lru-management", true);
164 
165 // number of LRU pages to pre-allocate
166 // if the maximum number of pages is used up,
167 // then LRU pages will be dynamically allocated/freed
168 ConfigVariableInt dx_lru_maximum_pages
169 ("dx-lru-maximum-pages", 8192);
170 
171 // the amount of video memory the LRU will try not to use
172 // this will allow DirectX some space in case of memory fragmentation, ...
173 // this does not apply if dx_lru_minimum_memory_requirement is not met
174 ConfigVariableInt dx_lru_free_memory_requirement
175 ("dx-lru-free-memory-requirement", 12000000);
176 
177 // this is like the minimum recommended amount of video memory
178 ConfigVariableInt dx_lru_minimum_memory_requirement
179 ("dx-lru-minimum-memory-requirement", 64000000);
180 
181 // used to cap the amount of video memory used
182 // 0 = use all available DirectX video memory
183 ConfigVariableInt dx_lru_maximum_memory_requirement
184 ("dx-lru-maximum-memory-requirement", 0);
185 
186 // the number of LRU pages the LRU will update per frame
187 // do not set this too high or it will degrade performance
188 ConfigVariableInt dx_lru_maximum_page_updates_per_frame
189 ("dx-lru-maximum-page-updates-per-frame", 40);
190 
191 // lru debug on/off
192 ConfigVariableBool dx_lru_debug
193 ("dx-lru-debug", false);
194 
195 // valid only if dx_lru_debug == true
196 // number of frames to wait until printing out the LRU status
197 ConfigVariableInt dx_lru_debug_frames_til_output
198 ("dx-lru-debug-frames-til-output", 500);
199 
200 // valid only if dx_lru_debug == true
201 ConfigVariableBool dx_lru_debug_textures
202 ("dx-lru-debug-textures", false);
203 
204 // valid only if dx_lru_debug == true
205 ConfigVariableBool dx_lru_debug_vertex_buffers
206 ("dx-lru-debug-vertex-buffers", false);
207 
208 ConfigVariableBool dx_use_dynamic_textures
209 ("dx-use-dynamic-textures", true);
210 
211 // DX device option
212 ConfigVariableBool dx_use_multithread
213 ("dx-use-multithread", false);
214 
215 // DX device option
216 ConfigVariableBool dx_use_puredevice
217 ("dx-use-puredevice", false);
218 
219 // DX device option
220 ConfigVariableBool dx_disable_driver_management
221 ("dx-disable-driver-management", false);
222 
223 // DX device option
224 ConfigVariableBool dx_disable_driver_management_ex
225 ("dx-disable-driver-management-ex", false);
226 
227 // nVidia's performace heads up display
228 ConfigVariableBool dx_use_nvperfhud
229 ("dx-use-nvperfhud", false);
230 
231 ConfigureFn(config_dxgsg9) {
232  init_libdxgsg9();
233 }
234 
235 ////////////////////////////////////////////////////////////////////
236 // Function: init_libdxgsg
237 // Description: Initializes the library. This must be called at
238 // least once before any of the functions or classes in
239 // this library can be used. Normally it will be
240 // called by the static initializers and need not be
241 // called explicitly, but special cases exist.
242 ////////////////////////////////////////////////////////////////////
243 void
244 init_libdxgsg9() {
245  static bool initialized = false;
246  if (initialized) {
247  return;
248  }
249  initialized = true;
250 
251  DXGraphicsStateGuardian9::init_type();
252  DXTextureContext9::init_type();
253  DXVertexBufferContext9::init_type();
254  DXIndexBufferContext9::init_type();
255  DXOcclusionQueryContext9::init_type();
256  DXShaderContext9::init_type();
257  DXGeomMunger9::init_type();
258 
259  wdxGraphicsPipe9::init_type();
260  wdxGraphicsWindow9::init_type();
261  wdxGraphicsBuffer9::init_type();
262 
264  selection->add_pipe_type(wdxGraphicsPipe9::get_class_type(),
265  wdxGraphicsPipe9::pipe_constructor);
266 
268  ps->add_system("DirectX9");
269 }
static PandaSystem * get_global_ptr()
Returns the global PandaSystem object.
This class is used as a namespace to group several global properties of Panda.
Definition: pandaSystem.h:29
This is a convenience class to specialize ConfigVariable as a boolean type.
void add_system(const string &system)
Intended for use by each subsystem to register itself at startup.
This is a convenience class to specialize ConfigVariable as a floating-point type.
This maintains a list of GraphicsPipes by type that are available for creation.
static GraphicsPipeSelection * get_global_ptr()
Returns a pointer to the one global GraphicsPipeSelection object.
bool add_pipe_type(TypeHandle type, PipeConstructorFunc *func)
Adds a new kind of GraphicsPipe to the list of available pipes for creation.
This is a convenience class to specialize ConfigVariable as an integer type.