Panda3D
Public Types | Public Member Functions | Static Public Member Functions | List of all members
GPUCommand Class Reference

Class for storing data to be transferred to the GPU. More...

#include "gpuCommand.h"

Public Types

enum  CommandType {
  CMD_invalid = 0, CMD_store_light = 1, CMD_remove_light = 2, CMD_store_source = 3,
  CMD_remove_sources = 4
}
 The different types of GPUCommands. More...
 

Public Member Functions

 GPUCommand (CommandType command_type)
 Constructs a new GPUCommand with the given command type. More...
 
void push_float (float v)
 Appends a float to the GPUCommand. More...
 
void push_int (int v)
 RenderPipeline. More...
 
void push_mat3 (const LMatrix3 &v)
 Appends a floating point 3x3 matrix to the GPUCommand. More...
 
void push_mat4 (const LMatrix4 &v)
 Appends a floating point 4x4 matrix to the GPUCommand. More...
 
void push_vec3 (const LVecBase3 &v)
 Appends a 3-component floating point vector to the GPUCommand. More...
 
void push_vec3 (const LVecBase3i &v)
 Appends a 3-component integer vector to the GPUCommand. More...
 
void push_vec4 (const LVecBase4 &v)
 Appends a 4-component floating point vector to the GPUCommand. More...
 
void push_vec4 (const LVecBase4i &v)
 Appends a 4-component integer vector to the GPUCommand. More...
 
void write (std::ostream &out) const
 Prints out the GPUCommand to the console. More...
 
void write_to (const PTA_uchar &dest, size_t command_index)
 Writes the GPU command to a given target. More...
 

Static Public Member Functions

static bool get_uses_integer_packing ()
 Returns whether integers are packed as floats. More...
 

Detailed Description

Class for storing data to be transferred to the GPU.

This class can be seen like a packet, to be transferred to the GPU. It has a command type, which tells the GPU what to do once it recieved this "packet". It stores a limited amount of floating point components.

Definition at line 47 of file gpuCommand.h.

Member Enumeration Documentation

◆ CommandType

The different types of GPUCommands.

Each type has a special case in the command queue processor. When adding new types, those need to be handled in the command target, too.

Definition at line 54 of file gpuCommand.h.

Constructor & Destructor Documentation

◆ GPUCommand()

GPUCommand::GPUCommand ( CommandType  command_type)

Constructs a new GPUCommand with the given command type.

This will construct a new GPUCommand of the given command type. The command type should be of GPUCommand::CommandType, and determines what data the GPUCommand contains, and how it will be handled.

Parameters
command_typeThe type of the GPUCommand

Definition at line 44 of file gpuCommand.cxx.

References push_int().

Member Function Documentation

◆ get_uses_integer_packing()

bool GPUCommand::get_uses_integer_packing ( )
inlinestatic

Returns whether integers are packed as floats.

This returns how integer are packed into the data stream. If the returned value is true, then integers are packed using their binary representation converted to floating point format. If the returned value is false, then integers are packed by simply casting them to float, e.g. val = (float)i;

Returns
The integer representation flag

Definition at line 183 of file gpuCommand.I.

◆ push_float()

void GPUCommand::push_float ( float  v)
inline

Appends a float to the GPUCommand.

This adds an integer to the back of the GPUCommand. Its used by all other push_xxx methods, and simply stores the value, then increments the write pointer. When the amount of floats exceeds the capacity of the GPUCommand, an error will be printed, and the method returns without doing anything else.

Parameters
vThe float to append.

Definition at line 75 of file gpuCommand.I.

Referenced by push_int(), push_vec3(), push_vec4(), RPPointLight::write_to_command(), and RPSpotLight::write_to_command().

◆ push_int()

void GPUCommand::push_int ( int  v)
inline

RenderPipeline.

Copyright (c) 2014-2016 tobspr tobia.nosp@m.s.sp.nosp@m.ringe.nosp@m.r1@g.nosp@m.mail..nosp@m.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Appends an integer to the GPUCommand.

This adds an integer to the back of the GPUCommand. Depending on the setting in convert_int_to_float, this will either just convert the int to a float by casting it, or just do a bitwise copy.

Parameters
vThe integer to append.

Definition at line 37 of file gpuCommand.I.

References push_float().

Referenced by GPUCommand(), push_vec3(), push_vec4(), and RPLight::write_to_command().

◆ push_mat3()

void GPUCommand::push_mat3 ( const LMatrix3 &  v)
inline

Appends a floating point 3x3 matrix to the GPUCommand.

This appends a floating point 3x3 matrix to the GPUCommand, by pushing all components in row-order to the command. This occupies a space of 9 floats.

Parameters
vMatrix to append

Definition at line 150 of file gpuCommand.I.

◆ push_mat4()

void GPUCommand::push_mat4 ( const LMatrix4 &  v)
inline

Appends a floating point 4x4 matrix to the GPUCommand.

This appends a floating point 4x4 matrix to the GPUCommand, by pushing all components in row-order to the command. This occupies a space of 16 floats.

Parameters
vMatrix to append

Definition at line 166 of file gpuCommand.I.

◆ push_vec3() [1/2]

void GPUCommand::push_vec3 ( const LVecBase3 &  v)
inline

Appends a 3-component floating point vector to the GPUCommand.

This appends a 3-component floating point vector to the command. It basically just calls push_float() for every component, in the order x, y, z, which causes the vector to occupy the space of 3 floats.

Parameters
vInt-Vector to append.

Definition at line 91 of file gpuCommand.I.

References push_float().

Referenced by RPSpotLight::write_to_command().

◆ push_vec3() [2/2]

void GPUCommand::push_vec3 ( const LVecBase3i &  v)
inline

Appends a 3-component integer vector to the GPUCommand.

This appends a 3-component integer vector to the command. It basically just calls push_int() for every component, in the order x, y, z, which causes the vector to occupy the space of 3 floats.

Parameters
vInt-Vector to append.

Definition at line 106 of file gpuCommand.I.

References push_int().

◆ push_vec4() [1/2]

void GPUCommand::push_vec4 ( const LVecBase4 &  v)
inline

Appends a 4-component floating point vector to the GPUCommand.

This appends a 4-component floating point vector to the command. It basically just calls push_float() for every component, in the order x, y, z, which causes the vector to occupy the space of 3 floats.

Parameters
vInt-Vector to append.

Definition at line 120 of file gpuCommand.I.

References push_float().

◆ push_vec4() [2/2]

void GPUCommand::push_vec4 ( const LVecBase4i &  v)
inline

Appends a 4-component integer vector to the GPUCommand.

This appends a 4-component integer vector to the command. It basically just calls push_int() for every component, in the order x, y, z, w, which causes the vector to occupy the space of 4 floats.

Parameters
vInt-Vector to append.

Definition at line 135 of file gpuCommand.I.

References push_int().

◆ write()

void GPUCommand::write ( std::ostream &  out) const

Prints out the GPUCommand to the console.

This method prints the type, size, and data of the GPUCommand to the console. This helps for debugging the contents of the GPUCommand. Keep in mind that integers might be shown in their binary float representation, depending on the setting in the GPUCommand::convert_int_to_float method.

Definition at line 60 of file gpuCommand.cxx.

◆ write_to()

void GPUCommand::write_to ( const PTA_uchar &  dest,
size_t  command_index 
)

Writes the GPU command to a given target.

This method writes all the data of the GPU command to a given target. The target should be a pointer to memory being big enough to hold the data. Presumably #dest will be a handle to texture memory. The command_index controls the offset where the data will be written to.

Parameters
destHandle to the memory to write the command to
command_indexOffset to write the command to. The command will write its data to command_index * GPU_COMMAND_ENTRIES. When writing the GPUCommand in a GPUCommandList, the command_index will most likely be the index of the command in the list.

Definition at line 83 of file gpuCommand.cxx.


The documentation for this class was generated from the following files: