The Dirtchamber
A mixed reality testing environment for real-time global illumination algorithms
Namespaces | Classes | Functions | Variables
dune Namespace Reference

Direct3D helper library. More...

Namespaces

 approx
 Approximate functions namespace.
 
 pbrt
 Helper functions to convert PBRT matrix operations.
 

Classes

struct  aabb
 An axis-aligned bounding-box. More...
 
class  assimp_mesh
 A d3d_mesh created with the help of Assimp. More...
 
class  camera
 A simple perspective camera. More...
 
class  cbuffer
 A wrapper for constant buffers. More...
 
class  composite_mesh
 A mesh composed from other meshes. More...
 
struct  d3d_mesh
 Main D3D mesh interface class. More...
 
class  deferred_renderer
 The deferred renderer base class. More...
 
class  delta_light_propagation_volume
 A Delta Light Propagation Volume (DLPV). More...
 
class  delta_sparse_voxel_octree
 A Delta Radiance Field of an SVO necessary for Delta Voxel Cone Tracing (DVCT) More...
 
struct  detection_info
 Detected pattern information block. More...
 
class  differential_directional_light
 A differential directional light source. More...
 
class  directional_light
 A simple directional light source with an RSM. More...
 
class  exception
 Exception class. More...
 
class  gbuffer
 A geometry buffer (collection of render_target objects). More...
 
class  gilga_mesh
 Default implementation of assimp_mesh (pun intended). More...
 
class  kinect_gbuffer
 A GBuffer fed from a Kinect camera. More...
 
class  light_propagation_volume
 A Light Propagation Volume. More...
 
struct  mesh
 Basic interface of a mesh. More...
 
class  pattern
 A basic pattern. More...
 
class  postprocessor
 A base interface for a postprocessor pipeline. More...
 
class  profile_query
 A GPU profiler. More...
 
class  render_target
 A render target wrapper. More...
 
struct  sampler_state
 A wrapper class for a sampler state. More...
 
class  sdk_mesh
 A d3d_mesh created with the SDKMesh DXUT loader. More...
 
class  serializer
 Seralizer to read/write Dune objects from/into JSON/XML. More...
 
struct  shader_resource
 A shader resource wrapper. More...
 
class  simple_mesh
 A very simple mesh class with position-only vertex attributes. More...
 
class  sparse_voxel_octree
 A sparse voxel octree (SVO). More...
 
class  texture
 Wrapper for a Direct3D texture object. More...
 
class  texture_cache
 A texture cache. More...
 
class  tracker
 A simple pattern tracker written with OpenCV. More...
 

Functions

std::vector< tstring > files_from_args (const tstring &args, const tstring &default_file=L"")
 Return a vector of strings from a given argument string. A default file will be pushed to the vector if args was empty.
 
tstring extract_path (const tstring &pattern)
 Extract a path from a given pattern, e.g. "C:/foo" from "C:/foo/\*.bar".
 
bool path_is_relative (const tstring &p)
 Returns true if the supplied path p was a relative URI.
 
tstring absolute_path ()
 Returns an absolute path of the current execution directory.
 
tstring make_absolute_path (const tstring &relative_filename)
 Return an absolute URI to a URI relative to the execution directory. Thus function is used in every loader.
 
bool is_srgb (DXGI_FORMAT f)
 Returns true of the DXGI_FORMAT descriptor is SRGB.
 
void set_viewport (ID3D11DeviceContext *context, size_t w, size_t h)
 Resize the current viewport. More...
 
void clear_rtvs (ID3D11DeviceContext *context, ID3D11RenderTargetView **rtvs, size_t num_rtvs, FLOAT *clear_color)
 Clear a list of render targets with a color. More...
 
template<typename T >
void safe_release (T &obj)
 Safely release an object of type T, setting it to nullptr afterwards.
 
template<typename T >
void exchange (T **oldv, T *newv)
 Exchange an object of type T with a new one. More...
 
bool is_srgb (ID3D11ShaderResourceView *rtv)
 Returns true of the SRV is an SRGB view.
 
float halton (int index, int base)
 Get a number of the Halton sequence.
 
void load_model (ID3D11Device *device, const tstring &file, std::shared_ptr< d3d_mesh > &ptr)
 Load a model specified by a filename. More...
 
bool is_visible (const aabb< DirectX::XMFLOAT3 > &bbox, const DirectX::XMFLOAT4X4 &to_clip)
 Check if a bounding-box is visible given a clipping matrix. More...
 
template<typename T >
void compile_shader (ID3D11Device *device, LPCTSTR filename, LPCSTR shadermodel, LPCSTR mainfunc, UINT shader_flags, D3D_SHADER_MACRO *defines, T **shader, ID3DBlob **binary=nullptr)
 (Re-)Compile a shader. More...
 
void load_texture (ID3D11Device *device, const tstring &filename, ID3D11ShaderResourceView **srv=nullptr)
 The principal function to load a texture. More...
 
serializeroperator<< (serializer &s, const camera &c)
 Read/write camera parameters from/to a serializer.
 
const serializeroperator>> (const serializer &s, camera &c)
 Read/write camera parameters from/to a serializer.
 
serializeroperator<< (serializer &s, const directional_light &l)
 Read/write directional_light parameters from/to a serializer.
 
const serializeroperator>> (const serializer &s, directional_light &l)
 Read/write directional_light parameters from/to a serializer.
 
serializeroperator<< (serializer &s, const light_propagation_volume &lpv)
 Read/write light_propagation_volume parameters from/to a serializer.
 
const serializeroperator>> (const serializer &s, light_propagation_volume &lpv)
 Read/write light_propagation_volume parameters from/to a serializer.
 
serializeroperator<< (serializer &s, const sparse_voxel_octree &lpv)
 Read/write sparse_voxel_octree parameters from/to a serializer.
 
const serializeroperator>> (const serializer &s, sparse_voxel_octree &lpv)
 Read/write sparse_voxel_octree parameters from/to a serializer.
 

Variables

const D3D11_INPUT_ELEMENT_DESC gilgamesh_vertex_desc [5]
 The default layout for a gigla_mesh.
 
const D3D11_INPUT_ELEMENT_DESC standard_vertex_desc []
 The standard layout of a d3d_mesh.
 

Detailed Description

Direct3D helper library.

Function Documentation

void dune::clear_rtvs ( ID3D11DeviceContext *  context,
ID3D11RenderTargetView **  rtvs,
size_t  num_rtvs,
FLOAT *  clear_color 
)

Clear a list of render targets with a color.

Parameters
contextA Direct3D context.
rtvsAn array of render target views.
num_rtvsThe number of RTVs in the rtvs array.
clear_colorFour float values specifiying the color with wich to clear all RTVs.

Referenced by dune::light_propagation_volume::inject(), dune::delta_light_propagation_volume::inject(), dc::rsm_renderer< dune::differential_directional_light >::render_rsm(), and dc::common_renderer::render_scene().

template<typename T >
void dune::compile_shader ( ID3D11Device *  device,
LPCTSTR  filename,
LPCSTR  shadermodel,
LPCSTR  mainfunc,
UINT  shader_flags,
D3D_SHADER_MACRO *  defines,
T **  shader,
ID3DBlob **  binary = nullptr 
)

(Re-)Compile a shader.

This function tries to compile a shader and returns the D3D shader object and a possible binary blob which contains layout information. Includes in HLSL are handled automatically, and error handling is done via the Dirtchamber logging mechanism. First, the shader file is loaded and compiled to a blob. If this didn't work, the blob is discarded and an error is written to the logger. Otherwise, the blob is turned to a proper shader and whatever shader pointer was supplied is now cleaned up and exchanged with a new shader.

If the shader file was not found, but a file cso/mainfunc.cso instead was found, this precompiled version will be loaded instead and no error is logged.

Parameters
deviceThe Direct3D device.
filenameA shader filename.
shadermodelAn identifier of the shader model used, e.g. vs_5_0.
mainfuncThe shader entry point.
shader_flagsAny shader flags such as D3DCOMPILE_ENABLE_STRICTNESS.
definesHLSL defines.
shaderA pointer to an ID3D11*Shader, which can already hold a valid shader object which will be replaced.
binaryAn optional pointer to an ID3D11Blob, which will contain the blob of the shader if it compiles.

References dune::exception::msg(), and safe_release().

Referenced by pppipe::do_set_shader().

template<typename T >
void dune::exchange ( T **  oldv,
T *  newv 
)

Exchange an object of type T with a new one.

Exchange a pointer to an object with a pointer to a new object of the same type if

  • The old pointer exists
  • The old pointer isn't the same as the new pointer
  • The new pointe exists

This will safe_release whatever the old object was pointing to and replace it's value by a new pointed to object. This function is useful to replace old shader pointer with new ones after compilation. If the compilation of a new shader fails, the old one is retained.

Parameters
oldvA pointer to the old object.
newvA pointer to the object which should replace oldv.

References safe_release().

Referenced by dune::delta_light_propagation_volume::set_direct_inject_shader(), dune::light_propagation_volume::set_inject_shader(), dune::light_propagation_volume::set_propagate_shader(), dune::composite_mesh::set_shader(), dune::d3d_mesh::set_shader(), dune::sparse_voxel_octree::set_shader_inject(), and dune::sparse_voxel_octree::set_shader_voxelize().

bool dune::is_visible ( const aabb< DirectX::XMFLOAT3 > &  bbox,
const DirectX::XMFLOAT4X4 &  to_clip 
)

Check if a bounding-box is visible given a clipping matrix.

This function determines if a bounding box is partially or fully visible, given a clip-space matrix.

Parameters
bboxThe bounding-box object.
to_clipA clip-space matrix.
Returns
True if bbox is partially or fully visible.

References dune::aabb< V >::bb_max(), dune::aabb< V >::bb_min(), and is_visible().

Referenced by is_visible(), and dune::gilga_mesh::render_direct().

void dune::load_model ( ID3D11Device *  device,
const tstring &  file,
std::shared_ptr< d3d_mesh > &  ptr 
)

Load a model specified by a filename.

This is the principal loading function for model data. A model is loaded from the disk and the correct loader to do so is determined by the file's extension. If loding the model was successful, a shared_ptr to a d3d_mesh is set.

Parameters
deviceThe Direct3D device.
fileA string of a filename on the disk.
ptrA shared_ptr to a d3d_mesh which will contain the model once successfully loaded.

Referenced by dune::composite_mesh::create().

void dune::load_texture ( ID3D11Device *  device,
const tstring &  filename,
ID3D11ShaderResourceView **  srv = nullptr 
)

The principal function to load a texture.

This function is used to load textures of any type. The correct loader will be deduced from the filename. Optionally, a shader resource view can be directly retreived for the file. This function will automatically populate the texture_cache instance.

Parameters
deviceThe Direct3D device
filenameA string of the filename on the disk
srvAn optional pointer to an empty SRV pointer. If this is nullptr, the parameter is ignored.

References dune::texture_cache::add_texture(), and dune::texture_cache::i().

void dune::set_viewport ( ID3D11DeviceContext *  context,
size_t  w,
size_t  h 
)