diff options
author | rlp@google.com <rlp@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-17 00:33:29 +0000 |
---|---|---|
committer | rlp@google.com <rlp@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-17 00:33:29 +0000 |
commit | a7c9a1aa1e81d8fb3634ca9f88d25e142b1d1d43 (patch) | |
tree | cd3c029939c98a6808fbbee9785ca3fde41ccd96 /o3d | |
parent | 212ea326e8afca40eb8280b4061e2dce893aaed8 (diff) | |
download | chromium_src-a7c9a1aa1e81d8fb3634ca9f88d25e142b1d1d43.zip chromium_src-a7c9a1aa1e81d8fb3634ca9f88d25e142b1d1d43.tar.gz chromium_src-a7c9a1aa1e81d8fb3634ca9f88d25e142b1d1d43.tar.bz2 |
Changes to make command buffers compile. Still failing some unit tests and examples, but wanted to get the compile fixes checked in.
Pulling out the main.scons so as not to affect the build.
Review URL: http://codereview.chromium.org/125169
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18571 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
19 files changed, 122 insertions, 71 deletions
diff --git a/o3d/command_buffer/client/cross/big_test_client.cc b/o3d/command_buffer/client/cross/big_test_client.cc index f829187..cf42ee5 100644 --- a/o3d/command_buffer/client/cross/big_test_client.cc +++ b/o3d/command_buffer/client/cross/big_test_client.cc @@ -34,7 +34,7 @@ #ifdef __native_client__ #include <sys/nacl_syscalls.h> #else -#include "native_client/service_runtime/nrd_xfer_lib/nrd_all_modules.h" +#include "third_party/native_client/googleclient/native_client/src/trusted/desc/nrd_all_modules.h" #endif #include "command_buffer/common/cross/gapi_interface.h" #include "command_buffer/common/cross/rpc_imc.h" diff --git a/o3d/command_buffer/common/cross/rpc.h b/o3d/command_buffer/common/cross/rpc.h index d2e0d9f..fb55a88 100644 --- a/o3d/command_buffer/common/cross/rpc.h +++ b/o3d/command_buffer/common/cross/rpc.h @@ -35,7 +35,7 @@ #include "base/basictypes.h" -#include "native_client/intermodule_comm/nacl_htp.h" +#include "third_party/native_client/googleclient/native_client/src/shared/imc/nacl_htp.h" namespace o3d { namespace command_buffer { diff --git a/o3d/command_buffer/common/cross/rpc_imc.cc b/o3d/command_buffer/common/cross/rpc_imc.cc index 1fcb9c7..5d6c1f7 100644 --- a/o3d/command_buffer/common/cross/rpc_imc.cc +++ b/o3d/command_buffer/common/cross/rpc_imc.cc @@ -33,7 +33,7 @@ #include <algorithm> #include "command_buffer/common/cross/logging.h" #include "command_buffer/common/cross/rpc_imc.h" -#include "native_client/intermodule_comm/nacl_htp.h" +#include "third_party/native_client/googleclient/native_client/src/shared/imc/nacl_htp.h" namespace o3d { namespace command_buffer { diff --git a/o3d/command_buffer/common/cross/rpc_imc.h b/o3d/command_buffer/common/cross/rpc_imc.h index 5d2624f..8e4aed4 100644 --- a/o3d/command_buffer/common/cross/rpc_imc.h +++ b/o3d/command_buffer/common/cross/rpc_imc.h @@ -33,7 +33,7 @@ #ifndef O3D_COMMAND_BUFFER_COMMON_CROSS_RPC_IMC_H_ #define O3D_COMMAND_BUFFER_COMMON_CROSS_RPC_IMC_H_ -#include "native_client/intermodule_comm/nacl_imc.h" +#include "third_party/native_client/googleclient/native_client/src/shared/imc/nacl_imc.h" #include "base/scoped_ptr.h" #include "command_buffer/common/cross/rpc.h" diff --git a/o3d/command_buffer/common/cross/types.h b/o3d/command_buffer/common/cross/types.h index add362f..ee97423 100644 --- a/o3d/command_buffer/common/cross/types.h +++ b/o3d/command_buffer/common/cross/types.h @@ -35,6 +35,7 @@ #ifndef O3D_COMMAND_BUFFER_COMMON_CROSS_TYPES_H_ #define O3D_COMMAND_BUFFER_COMMON_CROSS_TYPES_H_ +#include <build/build_config.h> #if !defined(COMPILER_MSVC) #include <stdint.h> #endif diff --git a/o3d/command_buffer/service/build.scons b/o3d/command_buffer/service/build.scons index 17ec60f..c8e9292 100644 --- a/o3d/command_buffer/service/build.scons +++ b/o3d/command_buffer/service/build.scons @@ -58,7 +58,7 @@ env.Append( ) if env['TARGET_PLATFORM'] == 'WINDOWS': - env.Append(CCFLAGS = ['/Wp64'], + env.Append(CCFLAGS = [], LIBS = [# System libs. 'd3d9', # TODO: remove link-time dependency on d3dx9, using diff --git a/o3d/command_buffer/service/cross/big_test.cc b/o3d/command_buffer/service/cross/big_test.cc index b68a9da..0c92508 100644 --- a/o3d/command_buffer/service/cross/big_test.cc +++ b/o3d/command_buffer/service/cross/big_test.cc @@ -42,7 +42,7 @@ #include "command_buffer/service/cross/buffer_rpc.h" #include "command_buffer/service/cross/cmd_buffer_engine.h" #include "command_buffer/service/cross/gapi_decoder.h" -#include "native_client/service_runtime/nrd_xfer_lib/nrd_all_modules.h" +#include "third_party/native_client/googleclient/native_client/src/trusted/desc/nrd_all_modules.h" namespace o3d { namespace command_buffer { diff --git a/o3d/command_buffer/service/cross/plugin.cc b/o3d/command_buffer/service/cross/plugin.cc index 651713d..b85dbbe8 100644 --- a/o3d/command_buffer/service/cross/plugin.cc +++ b/o3d/command_buffer/service/cross/plugin.cc @@ -48,8 +48,8 @@ #ifdef OS_WIN #include "command_buffer/service/win/d3d9/gapi_d3d9.h" #endif -#include "native_client/service_runtime/nrd_xfer_lib/nrd_all_modules.h" -#include "tools/idlglue/ng/static_glue/npapi/npn_api.h" +#include "third_party/native_client/googleclient/native_client/src/trusted/desc/nrd_all_modules.h" +#include "third_party/nixysa/files/static_glue/npapi/npn_api.h" namespace o3d { namespace command_buffer { diff --git a/o3d/core/cross/command_buffer/buffer_cb.cc b/o3d/core/cross/command_buffer/buffer_cb.cc index 4b35e7c..93d6b27 100644 --- a/o3d/core/cross/command_buffer/buffer_cb.cc +++ b/o3d/core/cross/command_buffer/buffer_cb.cc @@ -53,24 +53,23 @@ VertexBufferCB::VertexBufferCB(ServiceLocator* service_locator, VertexBufferCB::~VertexBufferCB() { - Destroy(); + ConcreteFree(); } // Sends the DESTROY_VERTEX_BUFFER command, and frees the ID from the allocator. -void VertexBufferCB::Destroy() { - if (size() != 0) { +void VertexBufferCB::ConcreteFree() { + if (GetSizeInBytes() != 0) { CommandBufferHelper *helper = renderer_->helper(); CommandBufferEntry args[1]; args[0].value_uint32 = resource_id_; helper->AddCommand(command_buffer::DESTROY_VERTEX_BUFFER, 1, args); - set_size(0); renderer_->vertex_buffer_ids().FreeID(resource_id_); } } // Allocates a resource ID, and sends the CREATE_VERTEX_BUFFER command. bool VertexBufferCB::ConcreteAllocate(size_t size_in_bytes) { - Destroy(); + ConcreteFree(); if (size_in_bytes > 0) { resource_id_ = renderer_->vertex_buffer_ids().AllocateID(); CommandBufferHelper *helper = renderer_->helper(); @@ -89,16 +88,16 @@ bool VertexBufferCB::ConcreteAllocate(size_t size_in_bytes) { // GET_VERTEX_BUFFER_DATA command). bool VertexBufferCB::ConcreteLock(AccessMode access_mode, void **buffer_data) { *buffer_data = NULL; - if (size() == 0 || lock_pointer_) + if (GetSizeInBytes() == 0 || lock_pointer_) return false; - lock_pointer_ = renderer_->allocator()->Alloc(size()); + lock_pointer_ = renderer_->allocator()->Alloc(GetSizeInBytes()); if (!lock_pointer_) return false; if (has_data_) { CommandBufferHelper *helper = renderer_->helper(); CommandBufferEntry args[5]; args[0].value_uint32 = resource_id_; args[1].value_uint32 = 0; - args[2].value_uint32 = size(); + args[2].value_uint32 = GetSizeInBytes(); args[3].value_uint32 = renderer_->transfer_shm_id(); args[4].value_uint32 = renderer_->allocator()->GetOffset(lock_pointer_); helper->AddCommand(command_buffer::GET_VERTEX_BUFFER_DATA, 5, args); @@ -111,13 +110,13 @@ bool VertexBufferCB::ConcreteLock(AccessMode access_mode, void **buffer_data) { // Copies the data into the resource by sending the SET_VERTEX_BUFFER_DATA // command, then frees the shared memory, pending the transfer completion. bool VertexBufferCB::ConcreteUnlock() { - if (size() == 0 || !lock_pointer_) + if (GetSizeInBytes() == 0 || !lock_pointer_) return false; CommandBufferHelper *helper = renderer_->helper(); CommandBufferEntry args[5]; args[0].value_uint32 = resource_id_; args[1].value_uint32 = 0; - args[2].value_uint32 = size(); + args[2].value_uint32 = GetSizeInBytes(); args[3].value_uint32 = renderer_->transfer_shm_id(); args[4].value_uint32 = renderer_->allocator()->GetOffset(lock_pointer_); helper->AddCommand(command_buffer::SET_VERTEX_BUFFER_DATA, 5, args); @@ -139,24 +138,23 @@ IndexBufferCB::IndexBufferCB(ServiceLocator* service_locator, IndexBufferCB::~IndexBufferCB() { - Destroy(); + ConcreteFree(); } // Sends the DESTROY_INDEX_BUFFER command, and frees the ID from the allocator. -void IndexBufferCB::Destroy() { - if (size() != 0) { +void IndexBufferCB::ConcreteFree() { + if (GetSizeInBytes() != 0) { CommandBufferHelper *helper = renderer_->helper(); CommandBufferEntry args[1]; args[0].value_uint32 = resource_id_; helper->AddCommand(command_buffer::DESTROY_INDEX_BUFFER, 1, args); - set_size(0); renderer_->index_buffer_ids().FreeID(resource_id_); } } // Allocates a resource ID, and sends the CREATE_INDEX_BUFFER command. bool IndexBufferCB::ConcreteAllocate(size_t size_in_bytes) { - Destroy(); + ConcreteFree(); if (size_in_bytes > 0) { resource_id_ = renderer_->index_buffer_ids().AllocateID(); CommandBufferHelper *helper = renderer_->helper(); @@ -175,16 +173,16 @@ bool IndexBufferCB::ConcreteAllocate(size_t size_in_bytes) { // GET_INDEX_BUFFER_DATA command). bool IndexBufferCB::ConcreteLock(AccessMode access_mode, void **buffer_data) { *buffer_data = NULL; - if (size() == 0 || lock_pointer_) + if (GetSizeInBytes() == 0 || lock_pointer_) return false; - lock_pointer_ = renderer_->allocator()->Alloc(size()); + lock_pointer_ = renderer_->allocator()->Alloc(GetSizeInBytes()); if (!lock_pointer_) return false; if (has_data_) { CommandBufferHelper *helper = renderer_->helper(); CommandBufferEntry args[5]; args[0].value_uint32 = resource_id_; args[1].value_uint32 = 0; - args[2].value_uint32 = size(); + args[2].value_uint32 = GetSizeInBytes(); args[3].value_uint32 = renderer_->transfer_shm_id(); args[4].value_uint32 = renderer_->allocator()->GetOffset(lock_pointer_); helper->AddCommand(command_buffer::GET_INDEX_BUFFER_DATA, 5, args); @@ -197,13 +195,13 @@ bool IndexBufferCB::ConcreteLock(AccessMode access_mode, void **buffer_data) { // Copies the data into the resource by sending the SET_INDEX_BUFFER_DATA // command, then frees the shared memory, pending the transfer completion. bool IndexBufferCB::ConcreteUnlock() { - if (size() == 0 || !lock_pointer_) + if (GetSizeInBytes() == 0 || !lock_pointer_) return false; CommandBufferHelper *helper = renderer_->helper(); CommandBufferEntry args[5]; args[0].value_uint32 = resource_id_; args[1].value_uint32 = 0; - args[2].value_uint32 = size(); + args[2].value_uint32 = GetSizeInBytes(); args[3].value_uint32 = renderer_->transfer_shm_id(); args[4].value_uint32 = renderer_->allocator()->GetOffset(lock_pointer_); helper->AddCommand(command_buffer::SET_INDEX_BUFFER_DATA, 5, args); diff --git a/o3d/core/cross/command_buffer/buffer_cb.h b/o3d/core/cross/command_buffer/buffer_cb.h index 5c417be..87cbb19 100644 --- a/o3d/core/cross/command_buffer/buffer_cb.h +++ b/o3d/core/cross/command_buffer/buffer_cb.h @@ -64,6 +64,9 @@ class VertexBufferCB : public VertexBuffer { // true if successful. virtual bool ConcreteAllocate(size_t size_in_bytes); + // The concrete version of Free + virtual void ConcreteFree(); + // Locks the vertex buffer for reading and writing. This allocates a buffer // into the transfer shared memory. If any data was set into the vertex // buffer, this function will copy it back for reading. Otherwise the data in @@ -83,9 +86,6 @@ class VertexBufferCB : public VertexBuffer { virtual bool ConcreteUnlock(); private: - // Destroys the resource, and frees the resource ID. - void Destroy(); - // The pointer to the region in the transfer shared memory buffer when the // vertex buffer is locked, or NULL if it is not locked. void *lock_pointer_; @@ -123,6 +123,9 @@ class IndexBufferCB : public IndexBuffer { // true if successful. virtual bool ConcreteAllocate(size_t size_in_bytes); + // The concrete version of Free + virtual void ConcreteFree(); + // Locks the index buffer for reading and writing. This allocates a buffer // into the transfer shared memory. If any data was set into the index // buffer, this function will copy it back for reading. Otherwise the data in diff --git a/o3d/core/cross/command_buffer/effect_cb.cc b/o3d/core/cross/command_buffer/effect_cb.cc index 0f74ab6..7a5d11b 100644 --- a/o3d/core/cross/command_buffer/effect_cb.cc +++ b/o3d/core/cross/command_buffer/effect_cb.cc @@ -198,4 +198,8 @@ void EffectCB::GetParameterInfo(EffectParameterInfoArray *array) { } } +void EffectCB::GetStreamInfo(EffectStreamInfoArray *array) { + // To be filled in +} + } // namespace o3d diff --git a/o3d/core/cross/command_buffer/effect_cb.h b/o3d/core/cross/command_buffer/effect_cb.h index c4da2b8..a50638e 100644 --- a/o3d/core/cross/command_buffer/effect_cb.h +++ b/o3d/core/cross/command_buffer/effect_cb.h @@ -65,6 +65,11 @@ class EffectCB : public Effect { // Overriden from Effect. virtual void GetParameterInfo(EffectParameterInfoArray* info_array); + // Gets info about the varying parameters this effects vertex shader needs. + // Parameters: + // info_array: EffectStreamInfoArray to receive info. + virtual void GetStreamInfo(EffectStreamInfoArray* info_array); + private: void Destroy(); // The command buffer resource ID for the effect. diff --git a/o3d/core/cross/command_buffer/primitive_cb.cc b/o3d/core/cross/command_buffer/primitive_cb.cc index 89b2634..95d4dc5 100644 --- a/o3d/core/cross/command_buffer/primitive_cb.cc +++ b/o3d/core/cross/command_buffer/primitive_cb.cc @@ -118,15 +118,16 @@ void PrimitiveCB::Render(Renderer* renderer, if (!param_cache_cb->ValidateAndCacheParams(effect_cb, draw_element, this, + stream_bank_cb, material, override)) { // TODO: should we do this here, or on the service side ? // InsertMissingVertexStreams(); } - IndexBufferCB *index_buffer = - static_cast<IndexBufferCB *>(index_stream_.buffer()); - if (!index_buffer) { + IndexBufferCB *index_buffer_cb = + down_cast<IndexBufferCB *>(index_buffer()); + if (!index_buffer_cb) { // TODO: draw non-index in this case ? we don't do it currently on // other platforms, so keep compatibility. DLOG(INFO) << "Trying to draw with an empty index buffer."; @@ -156,7 +157,7 @@ void PrimitiveCB::Render(Renderer* renderer, // Draws. args[0].value_uint32 = cb_primitive_type; - args[1].value_uint32 = index_buffer->resource_id(); + args[1].value_uint32 = index_buffer_cb->resource_id(); args[2].value_uint32 = 0; // first index. args[3].value_uint32 = number_primitives_; // primitive count. args[4].value_uint32 = 0; // min index. diff --git a/o3d/core/cross/command_buffer/renderer_cb.cc b/o3d/core/cross/command_buffer/renderer_cb.cc index fd30ac3..16a522e 100644 --- a/o3d/core/cross/command_buffer/renderer_cb.cc +++ b/o3d/core/cross/command_buffer/renderer_cb.cc @@ -95,11 +95,12 @@ RendererCB *RendererCB::CreateDefault(ServiceLocator* service_locator) { kDefaultTransferMemorySize); } -bool RendererCB::InitPlatformSpecific(const DisplayWindow& display, - bool off_screen) { +Renderer::InitStatus RendererCB::InitPlatformSpecific( + const DisplayWindow& display, + bool off_screen) { if (off_screen) { // TODO: Off-screen support ? - return false; + return UNINITIALIZED; // equivalent to 0/false } #ifdef OS_WIN @@ -116,11 +117,11 @@ bool RendererCB::InitPlatformSpecific(const DisplayWindow& display, int width = windowRect.right - windowRect.left; int height = windowRect.bottom - windowRect.top; InitCommon(width, height); - return true; + return SUCCESS; #else // TODO: Implement Mac/Linux support before shipping // command buffers. - return false; + return UNINITIALIZED; #endif } @@ -214,6 +215,23 @@ void RendererCB::EndDraw() { frame_token_ = helper_->InsertToken(); } +bool RendererCB::StartRendering() { + ++render_frame_count_; + transforms_culled_ = 0; + transforms_processed_ = 0; + draw_elements_culled_ = 0; + draw_elements_processed_ = 0; + draw_elements_rendered_ = 0; + primitives_rendered_ = 0; + + // Any device issues are handled in the command buffer backend + return true; +} + +void RendererCB::FinishRendering() { + // Any device issues are handled in the command buffer backend +} + void RendererCB::RenderElement(Element* element, DrawElement* draw_element, Material* material, diff --git a/o3d/core/cross/command_buffer/renderer_cb.h b/o3d/core/cross/command_buffer/renderer_cb.h index e0eccf2..df13f9b 100644 --- a/o3d/core/cross/command_buffer/renderer_cb.h +++ b/o3d/core/cross/command_buffer/renderer_cb.h @@ -67,8 +67,8 @@ class RendererCB : public Renderer { ~RendererCB(); // Initialises the renderer for use, claiming hardware resources. - virtual bool InitPlatformSpecific(const DisplayWindow& display_window, - bool off_screen); + virtual InitStatus InitPlatformSpecific(const DisplayWindow& display_window, + bool off_screen); // Handles the plugin resize event. virtual void Resize(int width, int height); @@ -93,6 +93,12 @@ class RendererCB : public Renderer { // Notifies the renderer that the draw calls for this frame are completed. virtual void EndDraw(); + // Does any pre-rendering preparation + virtual bool StartRendering(); + + // Presents the results of the draw calls for this frame. + virtual void FinishRendering(); + // Renders this Element using the parameters from override first, followed by // the draw_element, followed by params on this Primitive and material. // Parameters: diff --git a/o3d/core/cross/command_buffer/states_cb.cc b/o3d/core/cross/command_buffer/states_cb.cc index 71efee7..bf29c19 100644 --- a/o3d/core/cross/command_buffer/states_cb.cc +++ b/o3d/core/cross/command_buffer/states_cb.cc @@ -154,10 +154,6 @@ GAPIInterface::BlendFunc BlendFuncToCB(int func) { return GAPIInterface::BLEND_FUNC_INV_DST_COLOR; case State::BLENDFUNC_SOURCE_ALPHA_SATUTRATE: return GAPIInterface::BLEND_FUNC_SRC_ALPHA_SATUTRATE; - case State::BLENDFUNC_BLEND_FACTOR: - return GAPIInterface::BLEND_FUNC_BLEND_COLOR; - case State::BLENDFUNC_INVERSE_BLEND_FACTOR: - return GAPIInterface::BLEND_FUNC_INV_BLEND_COLOR; } } @@ -612,14 +608,6 @@ void RendererCB::StateManager::AddStateHandlers(RendererCB *renderer) { new BlendEqStateHandler<AlphaEq>(arg, dirty)); } - // Blending Color - { - bool *dirty = blending_color_helper_.dirty_ptr(); - CommandBufferEntry *args = blending_color_helper_.args(); - renderer->AddStateHandler(State::kBlendFactorParamName, - new BlendColorStateHandler(args, dirty)); - } - // Color Write { using command_buffer::set_color_write::DitherEnable; diff --git a/o3d/core/cross/command_buffer/stream_bank_cb.cc b/o3d/core/cross/command_buffer/stream_bank_cb.cc index f4e12f9..42b9158 100644 --- a/o3d/core/cross/command_buffer/stream_bank_cb.cc +++ b/o3d/core/cross/command_buffer/stream_bank_cb.cc @@ -110,19 +110,26 @@ static bool GetCBSemantic( } // Converts a data type from O3D enum values to command-buffer enum values. -static vertex_struct::Type GetCBType(Stream::DataType type) { - switch (type) { - case Stream::FLOAT1: - return vertex_struct::FLOAT1; - case Stream::FLOAT2: - return vertex_struct::FLOAT2; - case Stream::FLOAT3: - return vertex_struct::FLOAT3; - case Stream::FLOAT4: - return vertex_struct::FLOAT4; - default: - return vertex_struct::NUM_TYPES; +static vertex_struct::Type GetCBType(const Field& field) { + if (field.IsA(FloatField::GetApparentClass())) { + switch (field.num_components()) { + case 1: + return vertex_struct::FLOAT1; + case 2: + return vertex_struct::FLOAT2; + case 3: + return vertex_struct::FLOAT3; + case 4: + return vertex_struct::FLOAT4; + } + } else if (field.IsA(UByteNField::GetApparentClass())) { + switch (field.num_components()) { + case 4: + return vertex_struct::UCHAR4N; + } } + DLOG(ERROR) << "Unknown Stream DataType"; + return vertex_struct::NUM_TYPES; } // This function is overridden so that we can invalidate the vertex struct any @@ -154,25 +161,25 @@ void StreamBankCB::CreateVertexStruct() { << stream.semantic_index() << ") - ignoring stream."; continue; } - vertex_struct::Type cb_type = GetCBType(stream.data_type()); + vertex_struct::Type cb_type = GetCBType(stream.field()); if (cb_type == vertex_struct::NUM_TYPES) { - DLOG(INFO) << "Invalid type (" << stream.data_type() + DLOG(INFO) << "Invalid type (" << stream.field().num_components() << ") - ignoring stream."; continue; } namespace cmd = command_buffer::set_vertex_input_cmd; VertexBufferCB *vertex_buffer = - static_cast<VertexBufferCB *>(stream.buffer()); + static_cast<VertexBufferCB *>(stream.field().buffer()); args[0].value_uint32 = vertex_struct_id_; args[1].value_uint32 = i; args[2].value_uint32 = vertex_buffer->resource_id(); - args[3].value_uint32 = stream.offset(); + args[3].value_uint32 = stream.field().offset(); args[4].value_uint32 = cmd::SemanticIndex::MakeValue(cb_semantic_index) | cmd::Semantic::MakeValue(cb_semantic) | cmd::Type::MakeValue(cb_type) | - cmd::Stride::MakeValue(stream.stride()); + cmd::Stride::MakeValue(vertex_buffer->stride()); helper->AddCommand(command_buffer::SET_VERTEX_INPUT, 5, args); } } diff --git a/o3d/core/cross/command_buffer/texture_cb.cc b/o3d/core/cross/command_buffer/texture_cb.cc index 5ecd43c..069bfd3 100644 --- a/o3d/core/cross/command_buffer/texture_cb.cc +++ b/o3d/core/cross/command_buffer/texture_cb.cc @@ -57,6 +57,10 @@ namespace create_texture_2d_cmd = command_buffer::create_texture_2d_cmd; namespace create_texture_cube_cmd = command_buffer::create_texture_cube_cmd; namespace { + +const Texture::RGBASwizzleIndices g_cb_abgr32f_swizzle_indices = + {0, 1, 2, 3}; + // Converts an O3D texture format to a command buffer texture format. texture::Format CBFormatFromO3DFormat(Texture::Format format) { switch (format) { @@ -383,6 +387,9 @@ RenderSurface::Ref Texture2DCB::GetRenderSurface(int mip_level, Pack *pack) { return RenderSurface::Ref(NULL); } +const Texture::RGBASwizzleIndices& Texture2DCB::GetABGR32FSwizzleIndices() { + return g_cb_abgr32f_swizzle_indices; +} // TextureCUBECB --------------------------------------------------------------- // Creates a texture from a pre-existing texture resource. @@ -573,4 +580,8 @@ RenderSurface::Ref TextureCUBECB::GetRenderSurface(TextureCUBE::CubeFace face, return RenderSurface::Ref(NULL); } +const Texture::RGBASwizzleIndices& TextureCUBECB::GetABGR32FSwizzleIndices() { + return g_cb_abgr32f_swizzle_indices; +} + } // namespace o3d diff --git a/o3d/core/cross/command_buffer/texture_cb.h b/o3d/core/cross/command_buffer/texture_cb.h index 3833919..5831f70 100644 --- a/o3d/core/cross/command_buffer/texture_cb.h +++ b/o3d/core/cross/command_buffer/texture_cb.h @@ -87,6 +87,11 @@ class Texture2DCB : public Texture2D { // Gets the texture resource ID. command_buffer::ResourceID resource_id() const { return resource_id_; } + // Gets a RGBASwizzleIndices that contains a mapping from + // RGBA to the internal format used by the rendering API. + virtual const RGBASwizzleIndices& GetABGR32FSwizzleIndices(); + + private: // Initializes the Texture2DCB from a preexisting OpenCB texture handle // and raw Bitmap data. @@ -155,6 +160,10 @@ class TextureCUBECB : public TextureCUBE { // Gets the texture resource ID. command_buffer::ResourceID resource_id() const { return resource_id_; } + // Gets a RGBASwizzleIndices that contains a mapping from + // RGBA to the internal format used by the rendering API. + virtual const RGBASwizzleIndices& GetABGR32FSwizzleIndices(); + private: // Creates a texture from a pre-existing texture resource. TextureCUBECB(ServiceLocator* service_locator, |