summaryrefslogtreecommitdiffstats
path: root/o3d/core
diff options
context:
space:
mode:
Diffstat (limited to 'o3d/core')
-rw-r--r--o3d/core/cross/command_buffer/buffer_cb.cc83
-rw-r--r--o3d/core/cross/command_buffer/effect_cb.cc16
-rw-r--r--o3d/core/cross/command_buffer/param_cache_cb.cc25
-rw-r--r--o3d/core/cross/command_buffer/primitive_cb.cc17
-rw-r--r--o3d/core/cross/command_buffer/render_surface_cb.cc30
-rw-r--r--o3d/core/cross/command_buffer/renderer_cb.cc39
-rw-r--r--o3d/core/cross/command_buffer/sampler_cb.cc42
-rw-r--r--o3d/core/cross/command_buffer/states_cb.cc180
-rw-r--r--o3d/core/cross/command_buffer/states_cb.h38
-rw-r--r--o3d/core/cross/command_buffer/stream_bank_cb.cc33
-rw-r--r--o3d/core/cross/command_buffer/texture_cb.cc102
11 files changed, 237 insertions, 368 deletions
diff --git a/o3d/core/cross/command_buffer/buffer_cb.cc b/o3d/core/cross/command_buffer/buffer_cb.cc
index 0914abd..32adbc9 100644
--- a/o3d/core/cross/command_buffer/buffer_cb.cc
+++ b/o3d/core/cross/command_buffer/buffer_cb.cc
@@ -56,29 +56,23 @@ VertexBufferCB::~VertexBufferCB() {
ConcreteFree();
}
-// Sends the DESTROY_VERTEX_BUFFER command, and frees the ID from the allocator.
+// Sends the DestroyVertexBuffer command, and frees the ID from the allocator.
void VertexBufferCB::ConcreteFree() {
if (resource_id_ != command_buffer::kInvalidResource) {
CommandBufferHelper *helper = renderer_->helper();
- CommandBufferEntry args[1];
- args[0].value_uint32 = resource_id_;
- helper->AddCommand(command_buffer::DESTROY_VERTEX_BUFFER, 1, args);
+ helper->DestroyVertexBuffer(resource_id_);
renderer_->vertex_buffer_ids().FreeID(resource_id_);
resource_id_ = command_buffer::kInvalidResource;
}
}
-// Allocates a resource ID, and sends the CREATE_VERTEX_BUFFER command.
+// Allocates a resource ID, and sends the CreateVertexBuffer command.
bool VertexBufferCB::ConcreteAllocate(size_t size_in_bytes) {
ConcreteFree();
if (size_in_bytes > 0) {
resource_id_ = renderer_->vertex_buffer_ids().AllocateID();
CommandBufferHelper *helper = renderer_->helper();
- CommandBufferEntry args[3];
- args[0].value_uint32 = resource_id_;
- args[1].value_uint32 = size_in_bytes;
- args[2].value_uint32 = 0; // no flags.
- helper->AddCommand(command_buffer::CREATE_VERTEX_BUFFER, 3, args);
+ helper->CreateVertexBuffer(resource_id_, size_in_bytes, 0);
has_data_ = false;
}
return true;
@@ -86,7 +80,7 @@ bool VertexBufferCB::ConcreteAllocate(size_t size_in_bytes) {
// Allocates the locked region into the transfer shared memory area. If the
// buffer resource contains data, copies it back (by sending the
-// GET_VERTEX_BUFFER_DATA command).
+// GetVertexBufferData command).
bool VertexBufferCB::ConcreteLock(AccessMode access_mode, void **buffer_data) {
*buffer_data = NULL;
if (GetSizeInBytes() == 0 || lock_pointer_)
@@ -95,32 +89,27 @@ bool VertexBufferCB::ConcreteLock(AccessMode access_mode, void **buffer_data) {
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 = 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);
+ helper->GetVertexBufferData(
+ resource_id_, 0, GetSizeInBytes(),
+ renderer_->transfer_shm_id(),
+ renderer_->allocator()->GetOffset(lock_pointer_));
helper->Finish();
}
*buffer_data = lock_pointer_;
return true;
}
-// Copies the data into the resource by sending the SET_VERTEX_BUFFER_DATA
+// Copies the data into the resource by sending the SetVertexBufferData
// command, then frees the shared memory, pending the transfer completion.
bool VertexBufferCB::ConcreteUnlock() {
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 = 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);
+ helper->SetVertexBufferData(
+ resource_id_, 0, GetSizeInBytes(),
+ renderer_->transfer_shm_id(),
+ renderer_->allocator()->GetOffset(lock_pointer_));
+
renderer_->allocator()->FreePendingToken(lock_pointer_,
helper->InsertToken());
lock_pointer_ = NULL;
@@ -142,29 +131,25 @@ IndexBufferCB::~IndexBufferCB() {
ConcreteFree();
}
-// Sends the DESTROY_INDEX_BUFFER command, and frees the ID from the allocator.
+// Sends the DestroyIndexBuffer command, and frees the ID from the allocator.
void IndexBufferCB::ConcreteFree() {
if (resource_id_ != command_buffer::kInvalidResource) {
CommandBufferHelper *helper = renderer_->helper();
- CommandBufferEntry args[1];
- args[0].value_uint32 = resource_id_;
- helper->AddCommand(command_buffer::DESTROY_INDEX_BUFFER, 1, args);
+ helper->DestroyIndexBuffer(resource_id_);
renderer_->index_buffer_ids().FreeID(resource_id_);
resource_id_ = command_buffer::kInvalidResource;
}
}
-// Allocates a resource ID, and sends the CREATE_INDEX_BUFFER command.
+// Allocates a resource ID, and sends the CreateIndexBuffer command.
bool IndexBufferCB::ConcreteAllocate(size_t size_in_bytes) {
ConcreteFree();
if (size_in_bytes > 0) {
resource_id_ = renderer_->index_buffer_ids().AllocateID();
CommandBufferHelper *helper = renderer_->helper();
- CommandBufferEntry args[3];
- args[0].value_uint32 = resource_id_;
- args[1].value_uint32 = size_in_bytes;
- args[2].value_uint32 = command_buffer::index_buffer::INDEX_32BIT;
- helper->AddCommand(command_buffer::CREATE_INDEX_BUFFER, 3, args);
+ helper->CreateIndexBuffer(
+ resource_id_, size_in_bytes,
+ command_buffer::index_buffer::INDEX_32BIT);
has_data_ = false;
}
return true;
@@ -172,7 +157,7 @@ bool IndexBufferCB::ConcreteAllocate(size_t size_in_bytes) {
// Allocates the locked region into the transfer shared memory area. If the
// buffer resource contains data, copies it back (by sending the
-// GET_INDEX_BUFFER_DATA command).
+// GetIndexBufferData command).
bool IndexBufferCB::ConcreteLock(AccessMode access_mode, void **buffer_data) {
*buffer_data = NULL;
if (GetSizeInBytes() == 0 || lock_pointer_)
@@ -181,32 +166,26 @@ bool IndexBufferCB::ConcreteLock(AccessMode access_mode, void **buffer_data) {
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 = 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);
+ helper->GetIndexBufferData(
+ resource_id_, 0, GetSizeInBytes(),
+ renderer_->transfer_shm_id(),
+ renderer_->allocator()->GetOffset(lock_pointer_));
helper->Finish();
}
*buffer_data = lock_pointer_;
return true;
}
-// Copies the data into the resource by sending the SET_INDEX_BUFFER_DATA
+// Copies the data into the resource by sending the SetIndexBufferData
// command, then frees the shared memory, pending the transfer completion.
bool IndexBufferCB::ConcreteUnlock() {
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 = 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);
+ helper->SetIndexBufferData(
+ resource_id_, 0, GetSizeInBytes(),
+ renderer_->transfer_shm_id(),
+ renderer_->allocator()->GetOffset(lock_pointer_));
renderer_->allocator()->FreePendingToken(lock_pointer_,
helper->InsertToken());
lock_pointer_ = NULL;
diff --git a/o3d/core/cross/command_buffer/effect_cb.cc b/o3d/core/cross/command_buffer/effect_cb.cc
index ed35a77..332da8f 100644
--- a/o3d/core/cross/command_buffer/effect_cb.cc
+++ b/o3d/core/cross/command_buffer/effect_cb.cc
@@ -92,19 +92,17 @@ bool EffectCB::LoadFromFXString(const String& source) {
ResourceID resource_id = renderer_->effect_ids().AllocateID();
CommandBufferHelper *helper = renderer_->helper();
- CommandBufferEntry args[4];
- args[0].value_uint32 = resource_id;
- args[1].value_uint32 = source_size;
- args[2].value_uint32 = renderer_->transfer_shm_id();
- args[3].value_uint32 = renderer_->allocator()->GetOffset(buffer_data);
- helper->AddCommand(command_buffer::CREATE_EFFECT, 4, args);
+ helper->CreateEffect(
+ resource_id, source_size,
+ renderer_->transfer_shm_id(),
+ renderer_->allocator()->GetOffset(buffer_data));
renderer_->allocator()->FreePendingToken(buffer_data, helper->InsertToken());
// NOTE: we're calling Finish to check the command result, to see if
// the effect has succesfully compiled.
helper->Finish();
if (renderer_->sync_interface()->GetParseError() !=
- BufferSyncInterface::PARSE_NO_ERROR) {
+ BufferSyncInterface::kParseNoError) {
O3D_ERROR(service_locator()) << "Effect failed to compile.";
renderer_->effect_ids().FreeID(resource_id);
return false;
@@ -140,9 +138,7 @@ void EffectCB::Destroy() {
++generation_;
if (resource_id_ != command_buffer::kInvalidResource) {
CommandBufferHelper *helper = renderer_->helper();
- CommandBufferEntry args[1];
- args[0].value_uint32 = resource_id_;
- helper->AddCommand(command_buffer::DESTROY_EFFECT, 1, args);
+ helper->DestroyEffect(resource_id_);
renderer_->effect_ids().FreeID(resource_id_);
resource_id_ = command_buffer::kInvalidResource;
}
diff --git a/o3d/core/cross/command_buffer/param_cache_cb.cc b/o3d/core/cross/command_buffer/param_cache_cb.cc
index c41d72e..e6351dc 100644
--- a/o3d/core/cross/command_buffer/param_cache_cb.cc
+++ b/o3d/core/cross/command_buffer/param_cache_cb.cc
@@ -70,15 +70,8 @@ class TypedParamHandlerCB : public ParamHandlerCB {
// This template definition only works for value types (floatn, matrix, int,
// ..., but not textures or samplers).
virtual void SetValue(CommandBufferHelper *helper) {
- static const unsigned int kEntryCount =
- (sizeof(typename T::DataType) + 3) / 4;
- CommandBufferEntry args[2 + kEntryCount];
typename T::DataType value = param_->value();
- args[0].value_uint32 = id_;
- args[1].value_uint32 = sizeof(value);
- memcpy(args + 2, &value, sizeof(value));
- helper->AddCommand(command_buffer::SET_PARAM_DATA_IMMEDIATE,
- 2 + kEntryCount, args);
+ helper->SetParamDataImmediate(id_, sizeof(value), &value);
}
private:
T* param_;
@@ -99,12 +92,8 @@ class MatrixParamHandlerColumnsCB : public ParamHandlerCB {
// Sends the param value to the service.
virtual void SetValue(CommandBufferHelper *helper) {
- CommandBufferEntry args[18];
Matrix4 value = transpose(param_->value());
- args[0].value_uint32 = id_;
- args[1].value_uint32 = sizeof(value);
- memcpy(args + 2, &value, sizeof(value));
- helper->AddCommand(command_buffer::SET_PARAM_DATA_IMMEDIATE, 18, args);
+ helper->SetParamDataImmediate(id_, sizeof(value), &value);
}
private:
ParamMatrix4* param_;
@@ -121,17 +110,15 @@ class SamplerParamHandlerCB : public ParamHandlerCB {
// Sends the param value to the service.
virtual void SetValue(CommandBufferHelper *helper) {
SamplerCB *sampler = down_cast<SamplerCB *>(param_->value());
- CommandBufferEntry args[3];
- args[0].value_uint32 = id_;
- args[1].value_uint32 = sizeof(ResourceID);
+ uint32 value;
if (!sampler) {
// TODO: use error sampler
- args[2].value_uint32 = command_buffer::kInvalidResource;
+ value = command_buffer::kInvalidResource;
} else {
sampler->SetTextureAndStates();
- args[2].value_uint32 = sampler->resource_id();
+ value = sampler->resource_id();
}
- helper->AddCommand(command_buffer::SET_PARAM_DATA_IMMEDIATE, 3, args);
+ helper->SetParamDataImmediate(id_, sizeof(value), &value);
}
private:
ParamSampler* param_;
diff --git a/o3d/core/cross/command_buffer/primitive_cb.cc b/o3d/core/cross/command_buffer/primitive_cb.cc
index 2f02dba..208a1b0 100644
--- a/o3d/core/cross/command_buffer/primitive_cb.cc
+++ b/o3d/core/cross/command_buffer/primitive_cb.cc
@@ -112,8 +112,7 @@ void PrimitiveCB::PlatformSpecificRender(Renderer* renderer,
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.
+ // TODO(gman): draw non-indexed primitives.
DLOG(INFO) << "Trying to draw with an empty index buffer.";
return;
}
@@ -130,23 +129,15 @@ void PrimitiveCB::PlatformSpecificRender(Renderer* renderer,
stream_bank_cb->BindStreamsForRendering();
CommandBufferHelper *helper = renderer_->helper();
- CommandBufferEntry args[6];
// Sets current effect.
// TODO: cache current effect ?
- args[0].value_uint32 = effect_cb->resource_id();
- helper->AddCommand(command_buffer::SET_EFFECT, 1, args);
+ helper->SetEffect(effect_cb->resource_id());
param_cache_cb->RunHandlers(helper);
-
// Draws.
- args[0].value_uint32 = cb_primitive_type;
- 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.
- args[5].value_uint32 = number_vertices_ - 1; // max index.
- helper->AddCommand(command_buffer::DRAW_INDEXED, 6, args);
+ helper->DrawIndexed(cb_primitive_type, index_buffer_cb->resource_id(),
+ 0, number_primitives_, 0, number_vertices_ - 1);
}
} // namespace o3d
diff --git a/o3d/core/cross/command_buffer/render_surface_cb.cc b/o3d/core/cross/command_buffer/render_surface_cb.cc
index bb967d2..443cc2f 100644
--- a/o3d/core/cross/command_buffer/render_surface_cb.cc
+++ b/o3d/core/cross/command_buffer/render_surface_cb.cc
@@ -59,17 +59,10 @@ RenderSurfaceCB::RenderSurfaceCB(ServiceLocator *service_locator,
ResourceID id = renderer_->render_surface_ids().AllocateID();
resource_id_ = id;
CommandBufferHelper *helper = renderer_->helper();
- CommandBufferEntry args[4];
- args[0].value_uint32 = id;
- args[1].value_uint32 =
- create_render_surface_cmd::Width::MakeValue(width) |
- create_render_surface_cmd::Height::MakeValue(height);
- args[2].value_uint32 =
- create_render_surface_cmd::Levels::MakeValue(mip_level) |
- create_render_surface_cmd::Side::MakeValue(side);
- args[3].value_uint32 =
- reinterpret_cast<ResourceID>(texture->GetTextureHandle());
- helper->AddCommand(command_buffer::CREATE_RENDER_SURFACE, 4, args);
+ helper->CreateRenderSurface(
+ id,
+ reinterpret_cast<uint32>(texture->GetTextureHandle()),
+ width, height, mip_level, side);
}
RenderSurfaceCB::~RenderSurfaceCB() {
@@ -80,9 +73,7 @@ void RenderSurfaceCB::Destroy() {
// This should never be called during rendering.
if (resource_id_ != command_buffer::kInvalidResource) {
CommandBufferHelper *helper = renderer_->helper();
- CommandBufferEntry args[1];
- args[0].value_uint32 = resource_id_;
- helper->AddCommand(command_buffer::DESTROY_RENDER_SURFACE, 1, args);
+ helper->DestroyRenderSurface(resource_id_);
renderer_->render_surface_ids().FreeID(resource_id_);
resource_id_ = command_buffer::kInvalidResource;
}
@@ -102,20 +93,13 @@ RenderDepthStencilSurfaceCB::RenderDepthStencilSurfaceCB(
ResourceID id = renderer_->depth_surface_ids().AllocateID();
resource_id_ = id;
CommandBufferHelper *helper = renderer_->helper();
- CommandBufferEntry args[2];
- args[0].value_uint32 = id;
- args[1].value_uint32 =
- create_render_surface_cmd::Width::MakeValue(width) |
- create_render_surface_cmd::Height::MakeValue(height);
- helper->AddCommand(command_buffer::CREATE_DEPTH_SURFACE, 2, args);
+ helper->CreateDepthSurface(id, width, height);
}
void RenderDepthStencilSurfaceCB::Destroy() {
if (resource_id_ != command_buffer::kInvalidResource) {
CommandBufferHelper *helper = renderer_->helper();
- CommandBufferEntry args[1];
- args[0].value_uint32 = resource_id_;
- helper->AddCommand(command_buffer::DESTROY_DEPTH_SURFACE, 1, args);
+ helper->DestroyDepthSurface(resource_id_);
renderer_->depth_surface_ids().FreeID(resource_id_);
resource_id_ = command_buffer::kInvalidResource;
}
diff --git a/o3d/core/cross/command_buffer/renderer_cb.cc b/o3d/core/cross/command_buffer/renderer_cb.cc
index e2d3998..f2d919b5 100644
--- a/o3d/core/cross/command_buffer/renderer_cb.cc
+++ b/o3d/core/cross/command_buffer/renderer_cb.cc
@@ -187,38 +187,31 @@ void RendererCB::PlatformSpecificClear(const Float4 &color,
uint32 buffers = (color_flag ? GAPIInterface::COLOR : 0) |
(depth_flag ? GAPIInterface::DEPTH : 0) |
(stencil_flag ? GAPIInterface::STENCIL : 0);
- command_buffer::CommandBufferEntry args[7];
- args[0].value_uint32 = buffers;
- args[1].value_float = color[0];
- args[2].value_float = color[1];
- args[3].value_float = color[2];
- args[4].value_float = color[3];
- args[5].value_float = depth;
- args[6].value_uint32 = stencil;
- helper_->AddCommand(command_buffer::CLEAR, 7, args);
+ helper_->Clear(buffers, color[0], color[1], color[2], color[3],
+ depth, stencil);
}
void RendererCB::PlatformSpecificEndDraw() {
}
-// Adds the BEGIN_FRAME command to the command buffer.
+// Adds the BeginFrame command to the command buffer.
bool RendererCB::PlatformSpecificStartRendering() {
// Any device issues are handled in the command buffer backend
DCHECK(helper_);
- helper_->AddCommand(command_buffer::BEGIN_FRAME, 0 , NULL);
+ helper_->BeginFrame();
return true;
}
-// Adds the END_FRAME command to the command buffer, and flushes the commands.
+// Adds the EndFrame command to the command buffer, and flushes the commands.
void RendererCB::PlatformSpecificFinishRendering() {
// Any device issues are handled in the command buffer backend
- helper_->AddCommand(command_buffer::END_FRAME, 0 , NULL);
+ helper_->EndFrame();
helper_->WaitForToken(frame_token_);
frame_token_ = helper_->InsertToken();
}
void RendererCB::PlatformSpecificPresent() {
- // TODO(gman): The END_FRAME command needs to be split into END_FRAME
+ // TODO(gman): The EndFrame command needs to be split into EndFrame
// and PRESENT.
}
@@ -231,14 +224,13 @@ void RendererCB::SetRenderSurfacesPlatformSpecific(
down_cast<const RenderSurfaceCB*>(surface);
const RenderDepthStencilSurfaceCB* surface_depth_cb =
down_cast<const RenderDepthStencilSurfaceCB*>(surface_depth);
- command_buffer::CommandBufferEntry args[2];
- args[0].value_uint32 = surface_cb->resource_id();
- args[1].value_uint32 = surface_depth_cb->resource_id();
- helper_->AddCommand(command_buffer::SET_RENDER_SURFACE, 2, args);
+ helper_->SetRenderSurface(
+ surface_cb->resource_id(),
+ surface_depth_cb->resource_id());
}
void RendererCB::SetBackBufferPlatformSpecific() {
- helper_->AddCommand(command_buffer::SET_BACK_SURFACES, 0, NULL);
+ helper_->SetBackSurfaces();
}
// Creates a StreamBank, returning a platform specific implementation class.
@@ -314,14 +306,7 @@ void RendererCB::SetViewportInPixels(int left,
int height,
float min_z,
float max_z) {
- command_buffer::CommandBufferEntry args[6];
- args[0].value_uint32 = left;
- args[1].value_uint32 = top;
- args[2].value_uint32 = width;
- args[3].value_uint32 = height;
- args[4].value_float = min_z;
- args[5].value_float = max_z;
- helper_->AddCommand(command_buffer::SET_VIEWPORT, 6, args);
+ helper_->SetViewport(left, top, width, height, min_z, max_z);
}
const int* RendererCB::GetRGBAUByteNSwizzleTable() {
diff --git a/o3d/core/cross/command_buffer/sampler_cb.cc b/o3d/core/cross/command_buffer/sampler_cb.cc
index df7b02f..b185076 100644
--- a/o3d/core/cross/command_buffer/sampler_cb.cc
+++ b/o3d/core/cross/command_buffer/sampler_cb.cc
@@ -86,15 +86,11 @@ SamplerCB::SamplerCB(ServiceLocator* service_locator, RendererCB* renderer)
renderer_(renderer) {
DCHECK(renderer_);
resource_id_ = renderer_->sampler_ids().AllocateID();
- CommandBufferEntry args[1];
- args[0].value_uint32 = resource_id_;
- renderer_->helper()->AddCommand(command_buffer::CREATE_SAMPLER, 1, args);
+ renderer_->helper()->CreateSampler(resource_id_);
}
SamplerCB::~SamplerCB() {
- CommandBufferEntry args[1];
- args[0].value_uint32 = resource_id_;
- renderer_->helper()->AddCommand(command_buffer::DESTROY_SAMPLER, 1, args);
+ renderer_->helper()->DestroySampler(resource_id_);
renderer_->sampler_ids().FreeID(resource_id_);
}
@@ -102,6 +98,7 @@ void SamplerCB::SetTextureAndStates() {
CommandBufferHelper *helper = renderer_->helper();
sampler::AddressingMode address_mode_u_cb = AddressModeToCB(address_mode_u());
sampler::AddressingMode address_mode_v_cb = AddressModeToCB(address_mode_v());
+ sampler::AddressingMode address_mode_w_cb = AddressModeToCB(address_mode_w());
sampler::FilteringMode mag_filter_cb = FilterTypeToCB(mag_filter());
sampler::FilteringMode min_filter_cb = FilterTypeToCB(min_filter());
sampler::FilteringMode mip_filter_cb = FilterTypeToCB(mip_filter());
@@ -113,24 +110,19 @@ void SamplerCB::SetTextureAndStates() {
if (min_filter() != Sampler::ANISOTROPIC) {
max_anisotropy_cb = 1;
}
- CommandBufferEntry args[5];
- args[0].value_uint32 = resource_id_;
- args[1].value_uint32 =
- set_sampler_states::AddressingU::MakeValue(address_mode_u_cb) |
- set_sampler_states::AddressingV::MakeValue(address_mode_v_cb) |
- set_sampler_states::AddressingW::MakeValue(sampler::WRAP) |
- set_sampler_states::MagFilter::MakeValue(mag_filter_cb) |
- set_sampler_states::MinFilter::MakeValue(min_filter_cb) |
- set_sampler_states::MipFilter::MakeValue(mip_filter_cb) |
- set_sampler_states::MaxAnisotropy::MakeValue(max_anisotropy_cb);
- helper->AddCommand(command_buffer::SET_SAMPLER_STATES, 2, args);
+ helper->SetSamplerStates(
+ resource_id_,
+ address_mode_u_cb,
+ address_mode_v_cb,
+ address_mode_w_cb,
+ mag_filter_cb,
+ min_filter_cb,
+ mip_filter_cb,
+ max_anisotropy_cb);
Float4 color = border_color();
- args[1].value_float = color[0];
- args[2].value_float = color[1];
- args[3].value_float = color[2];
- args[4].value_float = color[3];
- helper->AddCommand(command_buffer::SET_SAMPLER_BORDER_COLOR, 5, args);
+ helper->SetSamplerBorderColor(resource_id_,
+ color[0], color[1], color[2], color[3]);
Texture *texture_object = texture();
if (!texture_object) {
@@ -143,9 +135,9 @@ void SamplerCB::SetTextureAndStates() {
}
if (texture_object) {
- args[1].value_uint32 =
- reinterpret_cast<ResourceID>(texture_object->GetTextureHandle());
- helper->AddCommand(command_buffer::SET_SAMPLER_TEXTURE, 2, args);
+ helper->SetSamplerTexture(
+ resource_id_,
+ reinterpret_cast<uint32>(texture_object->GetTextureHandle()));
}
}
diff --git a/o3d/core/cross/command_buffer/states_cb.cc b/o3d/core/cross/command_buffer/states_cb.cc
index 9126069..c6d4818 100644
--- a/o3d/core/cross/command_buffer/states_cb.cc
+++ b/o3d/core/cross/command_buffer/states_cb.cc
@@ -441,31 +441,6 @@ class BlendEqStateHandler : public TypedStateHandler<ParamInteger> {
bool *dirty_;
};
-// A handler that sets the blending color.
-// Parameters:
-// args: a pointer to the arguments.
-// dirty: a pointer to the dirty bit.
-class BlendColorStateHandler : public TypedStateHandler<ParamFloat4> {
- public:
- BlendColorStateHandler(CommandBufferEntry *args, bool *dirty)
- : args_(args),
- dirty_(dirty) {
- }
-
- virtual void SetStateFromTypedParam(RendererCB* renderer,
- ParamFloat4* param) const {
- Float4 value = param->value();
- args_[0].value_float = value[0];
- args_[1].value_float = value[1];
- args_[2].value_float = value[2];
- args_[3].value_float = value[3];
- *dirty_ = true;
- }
- private:
- CommandBufferEntry *args_;
- bool *dirty_;
-};
-
// Adds all the state handlers for all the states. The list of handlers must
// match in names and types the list in Renderer::AddDefaultStates()
// (in renderer.cc).
@@ -475,52 +450,58 @@ void RendererCB::StateManager::AddStateHandlers(RendererCB *renderer) {
using command_buffer::set_point_line_raster::LineSmoothEnable;
using command_buffer::set_point_line_raster::PointSpriteEnable;
bool *dirty = point_line_helper_.dirty_ptr();
- uint32 *arg0 = &(point_line_helper_.args()[0].value_uint32);
- float *arg1 = &(point_line_helper_.args()[1].value_float);
+ command_buffer::cmd::SetPointLineRaster& cmd =
+ point_line_helper_.command();
renderer->AddStateHandler(
State::kLineSmoothEnableParamName,
- new EnableStateHandler<LineSmoothEnable>(arg0, dirty));
+ new EnableStateHandler<LineSmoothEnable>(&cmd.fixme0, dirty));
renderer->AddStateHandler(
State::kPointSpriteEnableParamName,
- new EnableStateHandler<PointSpriteEnable>(arg0, dirty));
+ new EnableStateHandler<PointSpriteEnable>(&cmd.fixme0, dirty));
renderer->AddStateHandler(State::kPointSizeParamName,
- new ValueStateHandler<ParamFloat>(arg1, dirty));
+ new ValueStateHandler<ParamFloat>(
+ &cmd.point_size, dirty));
}
// Polygon Raster
{
bool *dirty = poly_raster_helper_.dirty_ptr();
- uint32 *arg = &(poly_raster_helper_.args()[0].value_uint32);
+ command_buffer::cmd::SetPolygonRaster& cmd =
+ poly_raster_helper_.command();
renderer->AddStateHandler(State::kCullModeParamName,
- new CullModeStateHandler(arg, dirty));
+ new CullModeStateHandler(&cmd.fixme0, dirty));
renderer->AddStateHandler(State::kFillModeParamName,
- new FillModeStateHandler(arg, dirty));
+ new FillModeStateHandler(&cmd.fixme0, dirty));
}
// Polygon Offset
{
bool *dirty = poly_offset_helper_.dirty_ptr();
- float *arg0 = &(poly_offset_helper_.args()[0].value_float);
- float *arg1 = &(poly_offset_helper_.args()[1].value_float);
- renderer->AddStateHandler(State::kPolygonOffset1ParamName,
- new ValueStateHandler<ParamFloat>(arg0, dirty));
- renderer->AddStateHandler(State::kPolygonOffset2ParamName,
- new ValueStateHandler<ParamFloat>(arg1, dirty));
+ command_buffer::cmd::SetPolygonOffset& cmd =
+ poly_offset_helper_.command();
+ renderer->AddStateHandler(
+ State::kPolygonOffset1ParamName,
+ new ValueStateHandler<ParamFloat>(&cmd.slope_factor, dirty));
+ renderer->AddStateHandler(
+ State::kPolygonOffset2ParamName,
+ new ValueStateHandler<ParamFloat>(&cmd.units, dirty));
}
// Alpha test
{
using command_buffer::set_alpha_test::Enable;
using command_buffer::set_alpha_test::Func;
+ command_buffer::cmd::SetAlphaTest& cmd = alpha_test_helper_.command();
bool *dirty = alpha_test_helper_.dirty_ptr();
- uint32 *arg0 = &(alpha_test_helper_.args()[0].value_uint32);
- float *arg1 = &(alpha_test_helper_.args()[1].value_float);
- renderer->AddStateHandler(State::kAlphaTestEnableParamName,
- new EnableStateHandler<Enable>(arg0, dirty));
- renderer->AddStateHandler(State::kAlphaComparisonFunctionParamName,
- new ComparisonStateHandler<Func>(arg0, dirty));
- renderer->AddStateHandler(State::kAlphaReferenceParamName,
- new ValueStateHandler<ParamFloat>(arg1, dirty));
+ renderer->AddStateHandler(
+ State::kAlphaTestEnableParamName,
+ new EnableStateHandler<Enable>(&cmd.fixme0, dirty));
+ renderer->AddStateHandler(
+ State::kAlphaComparisonFunctionParamName,
+ new ComparisonStateHandler<Func>(&cmd.fixme0, dirty));
+ renderer->AddStateHandler(
+ State::kAlphaReferenceParamName,
+ new ValueStateHandler<ParamFloat>(&cmd.value, dirty));
}
// Depth Test
@@ -529,13 +510,16 @@ void RendererCB::StateManager::AddStateHandlers(RendererCB *renderer) {
using command_buffer::set_depth_test::WriteEnable;
using command_buffer::set_depth_test::Func;
bool *dirty = depth_test_helper_.dirty_ptr();
- uint32 *arg = &(depth_test_helper_.args()[0].value_uint32);
- renderer->AddStateHandler(State::kZWriteEnableParamName,
- new EnableStateHandler<WriteEnable>(arg, dirty));
- renderer->AddStateHandler(State::kZEnableParamName,
- new EnableStateHandler<Enable>(arg, dirty));
- renderer->AddStateHandler(State::kZComparisonFunctionParamName,
- new ComparisonStateHandler<Func>(arg, dirty));
+ command_buffer::cmd::SetDepthTest& cmd = depth_test_helper_.command();
+ renderer->AddStateHandler(
+ State::kZWriteEnableParamName,
+ new EnableStateHandler<WriteEnable>(&cmd.fixme0, dirty));
+ renderer->AddStateHandler(
+ State::kZEnableParamName,
+ new EnableStateHandler<Enable>(&cmd.fixme0, dirty));
+ renderer->AddStateHandler(
+ State::kZComparisonFunctionParamName,
+ new ComparisonStateHandler<Func>(&cmd.fixme0, dirty));
}
// Stencil Test
@@ -554,42 +538,49 @@ void RendererCB::StateManager::AddStateHandlers(RendererCB *renderer) {
using command_buffer::set_stencil_test::CCWFailOp;
using command_buffer::set_stencil_test::CCWZFailOp;
bool *dirty = stencil_test_helper_.dirty_ptr();
- uint32 *arg0 = &(stencil_test_helper_.args()[0].value_uint32);
- uint32 *arg1 = &(stencil_test_helper_.args()[1].value_uint32);
- renderer->AddStateHandler(State::kStencilEnableParamName,
- new EnableStateHandler<Enable>(arg0, dirty));
- renderer->AddStateHandler(State::kTwoSidedStencilEnableParamName,
- new EnableStateHandler<SeparateCCW>(arg0, dirty));
+ command_buffer::cmd::SetStencilTest& cmd = stencil_test_helper_.command();
+ renderer->AddStateHandler(
+ State::kStencilEnableParamName,
+ new EnableStateHandler<Enable>(&cmd.fixme0, dirty));
+ renderer->AddStateHandler(
+ State::kTwoSidedStencilEnableParamName,
+ new EnableStateHandler<SeparateCCW>(&cmd.fixme0, dirty));
renderer->AddStateHandler(
State::kStencilReferenceParamName,
- new BitFieldStateHandler<ReferenceValue>(arg0, dirty));
+ new BitFieldStateHandler<ReferenceValue>(&cmd.fixme0, dirty));
renderer->AddStateHandler(
State::kStencilMaskParamName,
- new BitFieldStateHandler<CompareMask>(arg0, dirty));
- renderer->AddStateHandler(State::kStencilWriteMaskParamName,
- new BitFieldStateHandler<WriteMask>(arg0, dirty));
+ new BitFieldStateHandler<CompareMask>(&cmd.fixme0, dirty));
+ renderer->AddStateHandler(
+ State::kStencilWriteMaskParamName,
+ new BitFieldStateHandler<WriteMask>(&cmd.fixme0, dirty));
- renderer->AddStateHandler(State::kStencilComparisonFunctionParamName,
- new ComparisonStateHandler<CWFunc>(arg1, dirty));
- renderer->AddStateHandler(State::kStencilPassOperationParamName,
- new StencilOpStateHandler<CWPassOp>(arg1, dirty));
- renderer->AddStateHandler(State::kStencilFailOperationParamName,
- new StencilOpStateHandler<CWFailOp>(arg1, dirty));
+ renderer->AddStateHandler(
+ State::kStencilComparisonFunctionParamName,
+ new ComparisonStateHandler<CWFunc>(&cmd.fixme1, dirty));
+ renderer->AddStateHandler(
+ State::kStencilPassOperationParamName,
+ new StencilOpStateHandler<CWPassOp>(&cmd.fixme1, dirty));
+ renderer->AddStateHandler(
+ State::kStencilFailOperationParamName,
+ new StencilOpStateHandler<CWFailOp>(&cmd.fixme1, dirty));
renderer->AddStateHandler(
State::kStencilZFailOperationParamName,
- new StencilOpStateHandler<CWZFailOp>(arg1, dirty));
+ new StencilOpStateHandler<CWZFailOp>(&cmd.fixme1, dirty));
+
+ renderer->AddStateHandler(
+ State::kCCWStencilComparisonFunctionParamName,
+ new ComparisonStateHandler<CCWFunc>(&cmd.fixme1, dirty));
- renderer->AddStateHandler(State::kCCWStencilComparisonFunctionParamName,
- new ComparisonStateHandler<CCWFunc>(arg1, dirty));
renderer->AddStateHandler(
State::kCCWStencilPassOperationParamName,
- new StencilOpStateHandler<CCWPassOp>(arg1, dirty));
+ new StencilOpStateHandler<CCWPassOp>(&cmd.fixme1, dirty));
renderer->AddStateHandler(
State::kCCWStencilFailOperationParamName,
- new StencilOpStateHandler<CCWFailOp>(arg1, dirty));
+ new StencilOpStateHandler<CCWFailOp>(&cmd.fixme1, dirty));
renderer->AddStateHandler(
State::kCCWStencilZFailOperationParamName,
- new StencilOpStateHandler<CCWZFailOp>(arg1, dirty));
+ new StencilOpStateHandler<CCWZFailOp>(&cmd.fixme1, dirty));
}
// Blending
@@ -603,29 +594,32 @@ void RendererCB::StateManager::AddStateHandlers(RendererCB *renderer) {
using command_buffer::set_blending::AlphaSrcFunc;
using command_buffer::set_blending::AlphaDstFunc;
bool *dirty = blending_helper_.dirty_ptr();
- uint32 *arg = &(blending_helper_.args()[0].value_uint32);
- renderer->AddStateHandler(State::kAlphaBlendEnableParamName,
- new EnableStateHandler<Enable>(arg, dirty));
+ command_buffer::cmd::SetBlending& cmd = blending_helper_.command();
+ renderer->AddStateHandler(
+ State::kAlphaBlendEnableParamName,
+ new EnableStateHandler<Enable>(&cmd.fixme0, dirty));
renderer->AddStateHandler(
State::kSeparateAlphaBlendEnableParamName,
- new EnableStateHandler<SeparateAlpha>(arg, dirty));
+ new EnableStateHandler<SeparateAlpha>(&cmd.fixme0, dirty));
renderer->AddStateHandler(
State::kSourceBlendFunctionParamName,
- new BlendFuncStateHandler<ColorSrcFunc>(arg, dirty));
+ new BlendFuncStateHandler<ColorSrcFunc>(&cmd.fixme0, dirty));
renderer->AddStateHandler(
State::kDestinationBlendFunctionParamName,
- new BlendFuncStateHandler<ColorDstFunc>(arg, dirty));
- renderer->AddStateHandler(State::kBlendEquationParamName,
- new BlendEqStateHandler<ColorEq>(arg, dirty));
+ new BlendFuncStateHandler<ColorDstFunc>(&cmd.fixme0, dirty));
+ renderer->AddStateHandler(
+ State::kBlendEquationParamName,
+ new BlendEqStateHandler<ColorEq>(&cmd.fixme0, dirty));
renderer->AddStateHandler(
State::kSourceBlendAlphaFunctionParamName,
- new BlendFuncStateHandler<AlphaSrcFunc>(arg, dirty));
+ new BlendFuncStateHandler<AlphaSrcFunc>(&cmd.fixme0, dirty));
renderer->AddStateHandler(
State::kDestinationBlendAlphaFunctionParamName,
- new BlendFuncStateHandler<AlphaDstFunc>(arg, dirty));
- renderer->AddStateHandler(State::kBlendAlphaEquationParamName,
- new BlendEqStateHandler<AlphaEq>(arg, dirty));
+ new BlendFuncStateHandler<AlphaDstFunc>(&cmd.fixme0, dirty));
+ renderer->AddStateHandler(
+ State::kBlendAlphaEquationParamName,
+ new BlendEqStateHandler<AlphaEq>(&cmd.fixme0, dirty));
}
// Color Write
@@ -633,12 +627,13 @@ void RendererCB::StateManager::AddStateHandlers(RendererCB *renderer) {
using command_buffer::set_color_write::DitherEnable;
using command_buffer::set_color_write::AllColorsMask;
bool *dirty = color_write_helper_.dirty_ptr();
- uint32 *arg = &(color_write_helper_.args()[0].value_uint32);
- renderer->AddStateHandler(State::kDitherEnableParamName,
- new EnableStateHandler<DitherEnable>(arg, dirty));
+ command_buffer::cmd::SetColorWrite& cmd = color_write_helper_.command();
+ renderer->AddStateHandler(
+ State::kDitherEnableParamName,
+ new EnableStateHandler<DitherEnable>(&cmd.flags, dirty));
renderer->AddStateHandler(
State::kColorWriteEnableParamName,
- new ColorWriteStateHandler(arg, dirty));
+ new ColorWriteStateHandler(&cmd.flags, dirty));
}
}
@@ -651,7 +646,6 @@ void RendererCB::StateManager::ValidateStates(CommandBufferHelper *helper) {
stencil_test_helper_.Validate(helper);
color_write_helper_.Validate(helper);
blending_helper_.Validate(helper);
- blending_color_helper_.Validate(helper);
}
} // namespace o3d
diff --git a/o3d/core/cross/command_buffer/states_cb.h b/o3d/core/cross/command_buffer/states_cb.h
index 352e1b0..471f92a 100644
--- a/o3d/core/cross/command_buffer/states_cb.h
+++ b/o3d/core/cross/command_buffer/states_cb.h
@@ -59,41 +59,43 @@ class RendererCB::StateManager {
// A template helper. This wraps a command sent to set a set of states. It
// keeps all the arguments of a single command, that get modified by the
// various handles, as well as a dirty bit.
- template <command_buffer::CommandId command, unsigned int arg_count>
+ template <typename CommandType>
class StateHelper {
public:
- static const unsigned int kArgCount = arg_count;
-
StateHelper() : dirty_(false) {
- for (unsigned int i = 0; i < kArgCount; ++i) {
- args_[i].value_uint32 = 0;
- }
+ // NOTE: This code assumes the state commands only need their
+ // header set and that the rest will be set by the state handlers.
+ memset(&command_, 0, sizeof(command_));
+ command_.SetHeader();
}
// Sends the command if it is marked as dirty.
void Validate(command_buffer::CommandBufferHelper *helper) {
if (!dirty_) return;
- helper->AddCommand(command, kArgCount, args_);
+ helper->AddTypedCmdData(command_);
dirty_ = false;
}
- command_buffer::CommandBufferEntry *args() { return args_; }
+ CommandType& command() {
+ return command_;
+ }
+
bool *dirty_ptr() { return &dirty_; }
private:
bool dirty_;
- command_buffer::CommandBufferEntry args_[kArgCount];
+ CommandType command_;
DISALLOW_COPY_AND_ASSIGN(StateHelper);
};
- StateHelper<command_buffer::SET_POINT_LINE_RASTER, 2> point_line_helper_;
- StateHelper<command_buffer::SET_POLYGON_OFFSET, 2> poly_offset_helper_;
- StateHelper<command_buffer::SET_POLYGON_RASTER, 1> poly_raster_helper_;
- StateHelper<command_buffer::SET_ALPHA_TEST, 2> alpha_test_helper_;
- StateHelper<command_buffer::SET_DEPTH_TEST, 1> depth_test_helper_;
- StateHelper<command_buffer::SET_STENCIL_TEST, 2> stencil_test_helper_;
- StateHelper<command_buffer::SET_COLOR_WRITE, 1> color_write_helper_;
- StateHelper<command_buffer::SET_BLENDING, 1> blending_helper_;
- StateHelper<command_buffer::SET_BLENDING_COLOR, 4> blending_color_helper_;
+ StateHelper<command_buffer::cmd::SetPointLineRaster> point_line_helper_;
+ StateHelper<command_buffer::cmd::SetPolygonOffset> poly_offset_helper_;
+ StateHelper<command_buffer::cmd::SetPolygonRaster> poly_raster_helper_;
+ StateHelper<command_buffer::cmd::SetAlphaTest> alpha_test_helper_;
+ StateHelper<command_buffer::cmd::SetDepthTest> depth_test_helper_;
+ StateHelper<command_buffer::cmd::SetStencilTest> stencil_test_helper_;
+ StateHelper<command_buffer::cmd::SetColorWrite> color_write_helper_;
+ StateHelper<command_buffer::cmd::SetBlending> blending_helper_;
+ StateHelper<command_buffer::cmd::SetBlendingColor> blending_color_helper_;
DISALLOW_COPY_AND_ASSIGN(StateManager);
};
diff --git a/o3d/core/cross/command_buffer/stream_bank_cb.cc b/o3d/core/cross/command_buffer/stream_bank_cb.cc
index 42b9158..1ddca52 100644
--- a/o3d/core/cross/command_buffer/stream_bank_cb.cc
+++ b/o3d/core/cross/command_buffer/stream_bank_cb.cc
@@ -147,10 +147,7 @@ void StreamBankCB::CreateVertexStruct() {
DCHECK_EQ(kInvalidResource, vertex_struct_id_);
vertex_struct_id_ = renderer_->vertex_structs_ids().AllocateID();
CommandBufferHelper *helper = renderer_->helper();
- CommandBufferEntry args[5];
- args[0].value_uint32 = vertex_struct_id_;
- args[1].value_uint32 = vertex_stream_params_.size();
- helper->AddCommand(command_buffer::CREATE_VERTEX_STRUCT, 2, args);
+ helper->CreateVertexStruct(vertex_struct_id_, vertex_stream_params_.size());
for (unsigned int i = 0; i < vertex_stream_params_.size(); ++i) {
const Stream &stream = vertex_stream_params_[i]->stream();
vertex_struct::Semantic cb_semantic;
@@ -168,19 +165,16 @@ void StreamBankCB::CreateVertexStruct() {
continue;
}
- namespace cmd = command_buffer::set_vertex_input_cmd;
VertexBufferCB *vertex_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.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(vertex_buffer->stride());
- helper->AddCommand(command_buffer::SET_VERTEX_INPUT, 5, args);
+ helper->SetVertexInput(
+ vertex_struct_id_, i,
+ vertex_buffer->resource_id(),
+ stream.field().offset(),
+ cb_semantic,
+ cb_semantic_index,
+ cb_type,
+ vertex_buffer->stride());
}
}
@@ -188,9 +182,7 @@ void StreamBankCB::CreateVertexStruct() {
void StreamBankCB::DestroyVertexStruct() {
if (vertex_struct_id_ != kInvalidResource) {
CommandBufferHelper *helper = renderer_->helper();
- CommandBufferEntry args[1];
- args[0].value_uint32 = vertex_struct_id_;
- helper->AddCommand(command_buffer::DESTROY_VERTEX_STRUCT, 1, args);
+ helper->DestroyVertexStruct(vertex_struct_id_);
renderer_->vertex_structs_ids().FreeID(vertex_struct_id_);
vertex_struct_id_ = kInvalidResource;
}
@@ -200,10 +192,7 @@ void StreamBankCB::BindStreamsForRendering() {
if (vertex_struct_id_ == kInvalidResource)
CreateVertexStruct();
CommandBufferHelper *helper = renderer_->helper();
- CommandBufferEntry args[6];
- // Sets current vertex struct.
- args[0].value_uint32 = vertex_struct_id_;
- helper->AddCommand(command_buffer::SET_VERTEX_STRUCT, 1, args);
+ helper->SetVertexStruct(vertex_struct_id_);
}
} // namespace o3d
diff --git a/o3d/core/cross/command_buffer/texture_cb.cc b/o3d/core/cross/command_buffer/texture_cb.cc
index 12e3d98..d00a094 100644
--- a/o3d/core/cross/command_buffer/texture_cb.cc
+++ b/o3d/core/cross/command_buffer/texture_cb.cc
@@ -120,7 +120,7 @@ void SetTextureDataBuffer(Texture::Format format,
}
}
-// Sends the SET_TEXTURE_DATA command after formatting the args properly.
+// Sends the SetTextureData command after formatting the args properly.
void SetTextureData(RendererCB *renderer,
ResourceID texture_id,
unsigned int x,
@@ -136,27 +136,16 @@ void SetTextureData(RendererCB *renderer,
unsigned char* mip_data) {
FencedAllocatorWrapper *allocator = renderer->allocator();
CommandBufferHelper *helper = renderer->helper();
-
- CommandBufferEntry args[10];
- args[0].value_uint32 = texture_id;
- args[1].value_uint32 =
- set_texture_data_cmd::X::MakeValue(x) |
- set_texture_data_cmd::Y::MakeValue(y);
- args[2].value_uint32 =
- set_texture_data_cmd::Width::MakeValue(mip_width) |
- set_texture_data_cmd::Height::MakeValue(mip_height);
- args[3].value_uint32 =
- set_texture_data_cmd::Z::MakeValue(z) |
- set_texture_data_cmd::Depth::MakeValue(depth);
- args[4].value_uint32 =
- set_texture_data_cmd::Level::MakeValue(level) |
- set_texture_data_cmd::Face::MakeValue(face);
- args[5].value_uint32 = pitch;
- args[6].value_uint32 = 0; // slice_pitch
- args[7].value_uint32 = mip_size;
- args[8].value_uint32 = renderer->transfer_shm_id();
- args[9].value_uint32 = allocator->GetOffset(mip_data);
- helper->AddCommand(command_buffer::SET_TEXTURE_DATA, 10, args);
+ helper->SetTextureData(
+ texture_id,
+ x, y, z,
+ mip_width, mip_height, depth,
+ level, face,
+ pitch,
+ 0, // slice_pitch
+ mip_size,
+ renderer->transfer_shm_id(),
+ allocator->GetOffset(mip_data));
allocator->FreePendingToken(mip_data, helper->InsertToken());
}
// Updates a command buffer texture resource from a bitmap, rescaling if
@@ -213,26 +202,21 @@ void CopyBackResourceToBitmap(RendererCB *renderer,
size_t pitch = image::ComputeBufferSize(mip_width, 1, bitmap.format());
- CommandBufferEntry args[10];
- args[0].value_uint32 = texture_id;
- args[1].value_uint32 =
- get_texture_data_cmd::X::MakeValue(0) |
- get_texture_data_cmd::Y::MakeValue(0);
- args[2].value_uint32 =
- get_texture_data_cmd::Width::MakeValue(mip_width) |
- get_texture_data_cmd::Height::MakeValue(mip_height);
- args[3].value_uint32 =
- get_texture_data_cmd::Z::MakeValue(0) |
- get_texture_data_cmd::Depth::MakeValue(1);
- args[4].value_uint32 =
- get_texture_data_cmd::Level::MakeValue(level) |
- get_texture_data_cmd::Face::MakeValue(face);
- args[5].value_uint32 = pitch;
- args[6].value_uint32 = 0; // slice_pitch
- args[7].value_uint32 = mip_size;
- args[8].value_uint32 = renderer->transfer_shm_id();
- args[9].value_uint32 = allocator->GetOffset(buffer);
- helper->AddCommand(command_buffer::GET_TEXTURE_DATA, 10, args);
+ helper->GetTextureData(
+ texture_id,
+ 0,
+ 0,
+ 0,
+ mip_width,
+ mip_height,
+ 1,
+ level,
+ face,
+ pitch,
+ 0,
+ mip_size,
+ renderer->transfer_shm_id(),
+ allocator->GetOffset(buffer));
helper->Finish();
memcpy(bitmap.GetMipData(level), buffer, mip_size);
allocator->Free(buffer);
@@ -272,9 +256,7 @@ Texture2DCB::Texture2DCB(ServiceLocator* service_locator,
Texture2DCB::~Texture2DCB() {
if (resource_id_ != command_buffer::kInvalidResource) {
- CommandBufferEntry args[1];
- args[0].value_uint32 = resource_id_;
- renderer_->helper()->AddCommand(command_buffer::DESTROY_TEXTURE, 1, args);
+ renderer_->helper()->DestroyTexture(resource_id_);
}
}
@@ -301,16 +283,10 @@ Texture2DCB* Texture2DCB::Create(ServiceLocator* service_locator,
}
ResourceID texture_id = renderer->texture_ids().AllocateID();
- CommandBufferEntry args[3];
- args[0].value_uint32 = texture_id;
- args[1].value_uint32 =
- create_texture_2d_cmd::Width::MakeValue(width) |
- create_texture_2d_cmd::Height::MakeValue(height);
- args[2].value_uint32 =
- create_texture_2d_cmd::Levels::MakeValue(levels) |
- create_texture_2d_cmd::Format::MakeValue(cb_format) |
- create_texture_2d_cmd::Flags::MakeValue(enable_render_surfaces);
- renderer->helper()->AddCommand(command_buffer::CREATE_TEXTURE_2D, 3, args);
+ renderer->helper()->CreateTexture2d(
+ texture_id,
+ width, height,
+ levels, cb_format, enable_render_surfaces);
Texture2DCB *texture = new Texture2DCB(service_locator, texture_id,
format, levels, width, height,
@@ -496,9 +472,7 @@ TextureCUBECB::TextureCUBECB(ServiceLocator* service_locator,
TextureCUBECB::~TextureCUBECB() {
if (resource_id_ != command_buffer::kInvalidResource) {
- CommandBufferEntry args[1];
- args[0].value_uint32 = resource_id_;
- renderer_->helper()->AddCommand(command_buffer::DESTROY_TEXTURE, 1, args);
+ renderer_->helper()->DestroyTexture(resource_id_);
}
}
@@ -524,14 +498,10 @@ TextureCUBECB* TextureCUBECB::Create(ServiceLocator* service_locator,
}
ResourceID texture_id = renderer->texture_ids().AllocateID();
- CommandBufferEntry args[3];
- args[0].value_uint32 = texture_id;
- args[1].value_uint32 = create_texture_cube_cmd::Side::MakeValue(edge_length);
- args[2].value_uint32 =
- create_texture_cube_cmd::Levels::MakeValue(levels) |
- create_texture_cube_cmd::Format::MakeValue(cb_format) |
- create_texture_cube_cmd::Flags::MakeValue(enable_render_surfaces);
- renderer->helper()->AddCommand(command_buffer::CREATE_TEXTURE_CUBE, 3, args);
+ renderer->helper()->CreateTextureCube(
+ texture_id,
+ edge_length,
+ levels, cb_format, enable_render_surfaces);
TextureCUBECB* texture =
new TextureCUBECB(service_locator, texture_id, format, levels,