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