diff options
57 files changed, 2265 insertions, 2303 deletions
diff --git a/o3d/command_buffer/client/cross/big_test_client.cc b/o3d/command_buffer/client/cross/big_test_client.cc index 568b81f..676b21b 100644 --- a/o3d/command_buffer/client/cross/big_test_client.cc +++ b/o3d/command_buffer/client/cross/big_test_client.cc @@ -112,12 +112,12 @@ void BigTestClient(nacl::HtpHandle handle) { // Clear the buffers. RGBA color = {0.2f, 0.2f, 0.2f, 1.f}; - cmd_buffer.Clear(GAPIInterface::COLOR | GAPIInterface::DEPTH, + cmd_buffer.Clear(command_buffer::kColor | command_buffer::kDepth, color.red, color.green, color.blue, color.alpha, 1.f, 0); - const ResourceID vertex_buffer_id = 1; - const ResourceID vertex_struct_id = 1; + const ResourceId vertex_buffer_id = 1; + const ResourceId vertex_struct_id = 1; static const CustomVertex vertices[4] = { {-.5f, -.5f, 0.f, 1.f, 0, 0}, @@ -125,7 +125,8 @@ void BigTestClient(nacl::HtpHandle handle) { {-.5f, .5f, 0.f, 1.f, 0, 1}, {.5f, .5f, 0.f, 1.f, 1, 1}, }; - cmd_buffer.CreateVertexBuffer(vertex_buffer_id, sizeof(vertices), 0); + cmd_buffer.CreateVertexBuffer(vertex_buffer_id, sizeof(vertices), + vertex_buffer::kNone); memcpy(shm_address, vertices, sizeof(vertices)); cmd_buffer.SetVertexBufferData( @@ -136,25 +137,25 @@ void BigTestClient(nacl::HtpHandle handle) { // Set POSITION input stream cmd_buffer.SetVertexInput(vertex_struct_id, 0, vertex_buffer_id, 0, - vertex_struct::POSITION, 0, - vertex_struct::FLOAT4, sizeof(CustomVertex)); + vertex_struct::kPosition, 0, + vertex_struct::kFloat4, sizeof(CustomVertex)); // Set TEXCOORD0 input stream cmd_buffer.SetVertexInput(vertex_struct_id, 1, vertex_buffer_id, 16, - vertex_struct::TEX_COORD, 0, - vertex_struct::FLOAT2, sizeof(CustomVertex)); + vertex_struct::kTexCoord, 0, + vertex_struct::kFloat2, sizeof(CustomVertex)); // wait for previous transfer to be executed, so that we can re-use the // transfer shared memory buffer. cmd_buffer.WaitForToken(token); memcpy(shm_address, effect_data, sizeof(effect_data)); - const ResourceID effect_id = 1; + const ResourceId effect_id = 1; cmd_buffer.CreateEffect(effect_id, sizeof(effect_data), shm_id, 0); token = cmd_buffer.InsertToken(); // Create a 4x4 2D texture. - const ResourceID texture_id = 1; - cmd_buffer.CreateTexture2d(texture_id, 4, 4, 1, texture::ARGB8, 0); + const ResourceId texture_id = 1; + cmd_buffer.CreateTexture2d(texture_id, 4, 4, 1, texture::kARGB8, 0); static const unsigned int texels[4] = { 0xff0000ff, @@ -169,7 +170,8 @@ void BigTestClient(nacl::HtpHandle handle) { // Creates a 4x4 texture by uploading 2x2 data in each quadrant. for (unsigned int x = 0; x < 2; ++x) for (unsigned int y = 0; y < 2; ++y) { - cmd_buffer.SetTextureData(texture_id, x * 2, y * 2, 0, 2, 2, 1, 0, 0, + cmd_buffer.SetTextureData(texture_id, x * 2, y * 2, 0, 2, 2, 1, 0, + texture::kFaceNone, sizeof(texels[0]) * 2, // row_pitch 0, // slice_pitch sizeof(texels), // size @@ -178,27 +180,27 @@ void BigTestClient(nacl::HtpHandle handle) { } token = cmd_buffer.InsertToken(); - const ResourceID sampler_id = 1; + const ResourceId sampler_id = 1; cmd_buffer.CreateSampler(sampler_id); cmd_buffer.SetSamplerTexture(sampler_id, texture_id); cmd_buffer.SetSamplerStates(sampler_id, - sampler::CLAMP_TO_EDGE, - sampler::CLAMP_TO_EDGE, - sampler::CLAMP_TO_EDGE, - sampler::POINT, - sampler::POINT, - sampler::NONE, + sampler::kClampToEdge, + sampler::kClampToEdge, + sampler::kClampToEdge, + sampler::kPoint, + sampler::kPoint, + sampler::kNone, 1); // Create a parameter for the sampler. - const ResourceID sampler_param_id = 1; + const ResourceId sampler_param_id = 1; { static const char param_name[] = "s0"; cmd_buffer.CreateParamByNameImmediate(sampler_param_id, effect_id, sizeof(param_name), param_name); } - const ResourceID matrix_param_id = 2; + const ResourceId matrix_param_id = 2; { static const char param_name[] = "worldViewProj"; cmd_buffer.CreateParamByNameImmediate(matrix_param_id, effect_id, @@ -213,7 +215,7 @@ void BigTestClient(nacl::HtpHandle handle) { m *= math::Matrix4::rotationY(t * 2 * 3.1415926f); cmd_buffer.BeginFrame(); // Clear the background with an animated color (black to red). - cmd_buffer.Clear(GAPIInterface::COLOR | GAPIInterface::DEPTH, + cmd_buffer.Clear(command_buffer::kColor | command_buffer::kDepth, color.red, color.green, color.blue, color.alpha, 1.f, 0); @@ -223,7 +225,7 @@ void BigTestClient(nacl::HtpHandle handle) { sampler_param_id, sizeof(uint32), &sampler_id); // NOLINT cmd_buffer.SetParamDataImmediate( matrix_param_id, sizeof(m), &m); - cmd_buffer.Draw(GAPIInterface::TRIANGLE_STRIPS, 0, 2); + cmd_buffer.Draw(command_buffer::kTriangleStrips, 0, 2); cmd_buffer.EndFrame(); cmd_buffer.Flush(); diff --git a/o3d/command_buffer/client/cross/cmd_buffer_helper.h b/o3d/command_buffer/client/cross/cmd_buffer_helper.h index 8e13555..b00c8fc6 100644 --- a/o3d/command_buffer/client/cross/cmd_buffer_helper.h +++ b/o3d/command_buffer/client/cross/cmd_buffer_helper.h @@ -219,92 +219,97 @@ class CommandBufferHelper { cmd.Init(left, top, width, height, z_min, z_max); } - void CreateVertexBuffer(uint32 id, uint32 size, uint32 flags) { + void CreateVertexBuffer( + ResourceId vertex_buffer_id, uint32 size, vertex_buffer::Flags flags) { cmd::CreateVertexBuffer& cmd = GetCmdSpace<cmd::CreateVertexBuffer>(); - cmd.Init(id, size, flags); + cmd.Init(vertex_buffer_id, size, flags); } - void DestroyVertexBuffer(uint32 id) { + void DestroyVertexBuffer(ResourceId vertex_buffer_id) { cmd::DestroyVertexBuffer& cmd = GetCmdSpace<cmd::DestroyVertexBuffer>(); - cmd.Init(id); + cmd.Init(vertex_buffer_id); } void SetVertexBufferDataImmediate( - uint32 id, uint32 offset, + ResourceId vertex_buffer_id, uint32 offset, const void* data, uint32 size) { cmd::SetVertexBufferDataImmediate& cmd = GetImmediateCmdSpace<cmd::SetVertexBufferDataImmediate>(size); - cmd.Init(id, offset, data, size); + cmd.Init(vertex_buffer_id, offset, data, size); } void SetVertexBufferData( - uint32 id, uint32 offset, uint32 size, + ResourceId vertex_buffer_id, uint32 offset, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { cmd::SetVertexBufferData& cmd = GetCmdSpace<cmd::SetVertexBufferData>(); - cmd.Init(id, offset, size, + cmd.Init(vertex_buffer_id, offset, size, shared_memory_id, shared_memory_offset); } void GetVertexBufferData( - uint32 id, uint32 offset, uint32 size, + ResourceId vertex_buffer_id, uint32 offset, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { cmd::GetVertexBufferData& cmd = GetCmdSpace<cmd::GetVertexBufferData>(); - cmd.Init(id, offset, size, + cmd.Init(vertex_buffer_id, offset, size, shared_memory_id, shared_memory_offset); } - void CreateIndexBuffer(uint32 id, uint32 size, uint32 flags) { + void CreateIndexBuffer( + ResourceId index_buffer_id, uint32 size, index_buffer::Flags flags) { cmd::CreateIndexBuffer& cmd = GetCmdSpace<cmd::CreateIndexBuffer>(); - cmd.Init(id, size, flags); + cmd.Init(index_buffer_id, size, flags); } - void DestroyIndexBuffer(uint32 id) { + void DestroyIndexBuffer(ResourceId index_buffer_id) { cmd::DestroyIndexBuffer& cmd = GetCmdSpace<cmd::DestroyIndexBuffer>(); - cmd.Init(id); + cmd.Init(index_buffer_id); } void SetIndexBufferDataImmediate( - uint32 id, uint32 offset, const void* data, uint32 size) { + ResourceId index_buffer_id, uint32 offset, + const void* data, uint32 size) { cmd::SetIndexBufferDataImmediate& cmd = GetImmediateCmdSpace<cmd::SetIndexBufferDataImmediate>(size); - cmd.Init(id, offset, data, size); + cmd.Init(index_buffer_id, offset, data, size); } void SetIndexBufferData( - uint32 id, uint32 offset, uint32 size, + ResourceId index_buffer_id, uint32 offset, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { cmd::SetIndexBufferData& cmd = GetCmdSpace<cmd::SetIndexBufferData>(); - cmd.Init(id, offset, size, shared_memory_id, shared_memory_offset); + cmd.Init(index_buffer_id, offset, size, + shared_memory_id, shared_memory_offset); } void GetIndexBufferData( - uint32 id, uint32 offset, uint32 size, + ResourceId index_buffer_id, uint32 offset, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { cmd::GetIndexBufferData& cmd = GetCmdSpace<cmd::GetIndexBufferData>(); - cmd.Init(id, offset, size, shared_memory_id, shared_memory_offset); + cmd.Init(index_buffer_id, offset, size, + shared_memory_id, shared_memory_offset); } - void CreateVertexStruct(uint32 id, uint32 input_count) { + void CreateVertexStruct(ResourceId vertex_struct_id, uint32 input_count) { cmd::CreateVertexStruct& cmd = GetCmdSpace<cmd::CreateVertexStruct>(); - cmd.Init(id, input_count); + cmd.Init(vertex_struct_id, input_count); } - void DestroyVertexStruct(uint32 id) { + void DestroyVertexStruct(ResourceId vertex_struct_id) { cmd::DestroyVertexStruct& cmd = GetCmdSpace<cmd::DestroyVertexStruct>(); - cmd.Init(id); + cmd.Init(vertex_struct_id); } void SetVertexInput( - uint32 vertex_struct_id, + ResourceId vertex_struct_id, uint32 input_index, - uint32 vertex_buffer_id, + ResourceId vertex_buffer_id, uint32 offset, - uint8 semantic, + vertex_struct::Semantic semantic, uint32 semantic_index, - uint8 type, + vertex_struct::Type type, uint32 stride) { cmd::SetVertexInput& cmd = GetCmdSpace<cmd::SetVertexInput>(); cmd.Init( @@ -318,19 +323,19 @@ class CommandBufferHelper { stride); } - void SetVertexStruct(uint32 id) { + void SetVertexStruct(ResourceId vertex_struct_id) { cmd::SetVertexStruct& cmd = GetCmdSpace<cmd::SetVertexStruct>(); - cmd.Init(id); + cmd.Init(vertex_struct_id); } - void Draw(uint32 primitive_type, uint32 first, uint32 count) { + void Draw(PrimitiveType primitive_type, uint32 first, uint32 count) { cmd::Draw& cmd = GetCmdSpace<cmd::Draw>(); cmd.Init(primitive_type, first, count); } void DrawIndexed( - uint32 primitive_type, - uint32 index_buffer_id, + PrimitiveType primitive_type, + ResourceId index_buffer_id, uint32 first, uint32 count, uint32 min_index, @@ -346,103 +351,106 @@ class CommandBufferHelper { } void CreateEffect( - uint32 id, uint32 size, + ResourceId effect_id, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { cmd::CreateEffect& cmd = GetCmdSpace<cmd::CreateEffect>(); - cmd.Init(id, size, shared_memory_id, shared_memory_offset); + cmd.Init(effect_id, size, shared_memory_id, shared_memory_offset); } - void CreateEffectImmediate(uint32 id, uint32 size, const void* data) { + void CreateEffectImmediate( + ResourceId effect_id, uint32 size, const void* data) { cmd::CreateEffectImmediate& cmd = GetImmediateCmdSpace<cmd::CreateEffectImmediate>(size); - cmd.Init(id, size, data); + cmd.Init(effect_id, size, data); } - void DestroyEffect(uint32 id) { + void DestroyEffect(ResourceId effect_id) { cmd::DestroyEffect& cmd = GetCmdSpace<cmd::DestroyEffect>(); - cmd.Init(id); + cmd.Init(effect_id); } - void SetEffect(uint32 id) { + void SetEffect(ResourceId effect_id) { cmd::SetEffect& cmd = GetCmdSpace<cmd::SetEffect>(); - cmd.Init(id); + cmd.Init(effect_id); } void GetParamCount( - uint32 id, uint32 size, + ResourceId effect_id, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { cmd::GetParamCount& cmd = GetCmdSpace<cmd::GetParamCount>(); - cmd.Init(id, size, shared_memory_id, shared_memory_offset); + cmd.Init(effect_id, size, shared_memory_id, shared_memory_offset); } - void CreateParam(uint32 param_id, uint32 effect_id, uint32 index) { + void CreateParam(ResourceId param_id, ResourceId effect_id, uint32 index) { cmd::CreateParam& cmd = GetCmdSpace<cmd::CreateParam>(); cmd.Init(param_id, effect_id, index); } void CreateParamByName( - uint32 param_id, uint32 effect_id, uint32 size, + ResourceId param_id, ResourceId effect_id, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { cmd::CreateParamByName& cmd = GetCmdSpace<cmd::CreateParamByName>(); cmd.Init(param_id, effect_id, size, shared_memory_id, shared_memory_offset); } void CreateParamByNameImmediate( - uint32 param_id, uint32 effect_id, uint32 size, const void* data) { + ResourceId param_id, ResourceId effect_id, + uint32 size, const void* data) { cmd::CreateParamByNameImmediate& cmd = GetImmediateCmdSpace<cmd::CreateParamByNameImmediate>(size); cmd.Init(param_id, effect_id, size, data); } - void DestroyParam(uint32 id) { + void DestroyParam(ResourceId param_id) { cmd::DestroyParam& cmd = GetCmdSpace<cmd::DestroyParam>(); - cmd.Init(id); + cmd.Init(param_id); } void SetParamData( - uint32 id, uint32 size, + ResourceId param_id, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { cmd::SetParamData& cmd = GetCmdSpace<cmd::SetParamData>(); - cmd.Init(id, size, shared_memory_id, shared_memory_offset); + cmd.Init(param_id, size, shared_memory_id, shared_memory_offset); } - void SetParamDataImmediate(uint32 id, uint32 size, const void* data) { + void SetParamDataImmediate( + ResourceId param_id, uint32 size, const void* data) { cmd::SetParamDataImmediate& cmd = GetImmediateCmdSpace<cmd::SetParamDataImmediate>(size); - cmd.Init(id, size, data); + cmd.Init(param_id, size, data); } void GetParamDesc( - uint32 id, uint32 size, + ResourceId param_id, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { cmd::GetParamDesc& cmd = GetCmdSpace<cmd::GetParamDesc>(); - cmd.Init(id, size, shared_memory_id, shared_memory_offset); + cmd.Init(param_id, size, shared_memory_id, shared_memory_offset); } void GetStreamCount( - uint32 id, uint32 size, + ResourceId effect_id, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { cmd::GetStreamCount& cmd = GetCmdSpace<cmd::GetStreamCount>(); - cmd.Init(id, size, shared_memory_id, shared_memory_offset); + cmd.Init(effect_id, size, shared_memory_id, shared_memory_offset); } void GetStreamDesc( - uint32 id, uint32 index, uint32 size, + ResourceId effect_id, uint32 index, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { cmd::GetStreamDesc& cmd = GetCmdSpace<cmd::GetStreamDesc>(); - cmd.Init(id, index, size, shared_memory_id, shared_memory_offset); + cmd.Init(effect_id, index, size, shared_memory_id, shared_memory_offset); } - void DestroyTexture(uint32 id) { + void DestroyTexture(ResourceId texture_id) { cmd::DestroyTexture& cmd = GetCmdSpace<cmd::DestroyTexture>(); - cmd.Init(id); + cmd.Init(texture_id); } void CreateTexture2d( - uint32 texture_id, + ResourceId texture_id, uint32 width, uint32 height, - uint32 levels, uint32 format, - uint32 enable_render_surfaces) { + uint32 levels, texture::Format format, + bool enable_render_surfaces) { cmd::CreateTexture2d& cmd = GetCmdSpace<cmd::CreateTexture2d>(); cmd.Init(texture_id, width, height, levels, format, @@ -450,10 +458,10 @@ class CommandBufferHelper { } void CreateTexture3d( - uint32 texture_id, + ResourceId texture_id, uint32 width, uint32 height, uint32 depth, - uint32 levels, uint32 format, - uint32 enable_render_surfaces) { + uint32 levels, texture::Format format, + bool enable_render_surfaces) { cmd::CreateTexture3d& cmd = GetCmdSpace<cmd::CreateTexture3d>(); cmd.Init(texture_id, width, height, depth, @@ -462,9 +470,9 @@ class CommandBufferHelper { } void CreateTextureCube( - uint32 texture_id, - uint32 edge_length, uint32 levels, uint32 format, - uint32 enable_render_surfaces) { + ResourceId texture_id, + uint32 edge_length, uint32 levels, texture::Format format, + bool enable_render_surfaces) { cmd::CreateTextureCube& cmd = GetCmdSpace<cmd::CreateTextureCube>(); cmd.Init(texture_id, edge_length, levels, format, @@ -472,7 +480,7 @@ class CommandBufferHelper { } void SetTextureData( - uint32 texture_id, + ResourceId texture_id, uint32 x, uint32 y, uint32 z, @@ -480,7 +488,7 @@ class CommandBufferHelper { uint32 height, uint32 depth, uint32 level, - uint32 face, + texture::Face face, uint32 row_pitch, uint32 slice_pitch, uint32 size, @@ -505,7 +513,7 @@ class CommandBufferHelper { } void SetTextureDataImmediate( - uint32 texture_id, + ResourceId texture_id, uint32 x, uint32 y, uint32 z, @@ -513,7 +521,7 @@ class CommandBufferHelper { uint32 height, uint32 depth, uint32 level, - uint32 face, + texture::Face face, uint32 row_pitch, uint32 slice_pitch, uint32 size, @@ -537,7 +545,7 @@ class CommandBufferHelper { } void GetTextureData( - uint32 texture_id, + ResourceId texture_id, uint32 x, uint32 y, uint32 z, @@ -545,7 +553,7 @@ class CommandBufferHelper { uint32 height, uint32 depth, uint32 level, - uint32 face, + texture::Face face, uint32 row_pitch, uint32 slice_pitch, uint32 size, @@ -569,27 +577,28 @@ class CommandBufferHelper { shared_memory_offset); } - void CreateSampler(uint32 id) { + void CreateSampler(ResourceId sampler_id) { cmd::CreateSampler& cmd = GetCmdSpace<cmd::CreateSampler>(); - cmd.Init(id); + cmd.Init(sampler_id); } - void DestroySampler(uint32 id) { + void DestroySampler(ResourceId sampler_id) { cmd::DestroySampler& cmd = GetCmdSpace<cmd::DestroySampler>(); - cmd.Init(id); - } - - void SetSamplerStates(uint32 id, - uint32 address_u_value, - uint32 address_v_value, - uint32 address_w_value, - uint32 mag_filter_value, - uint32 min_filter_value, - uint32 mip_filter_value, - uint32 max_anisotropy) { + cmd.Init(sampler_id); + } + + void SetSamplerStates( + ResourceId sampler_id, + sampler::AddressingMode address_u_value, + sampler::AddressingMode address_v_value, + sampler::AddressingMode address_w_value, + sampler::FilteringMode mag_filter_value, + sampler::FilteringMode min_filter_value, + sampler::FilteringMode mip_filter_value, + uint8 max_anisotropy) { cmd::SetSamplerStates& cmd = GetCmdSpace<cmd::SetSamplerStates>(); cmd.Init( - id, + sampler_id, address_u_value, address_v_value, address_w_value, @@ -600,16 +609,16 @@ class CommandBufferHelper { } void SetSamplerBorderColor( - uint32 id, + ResourceId sampler_id, float red, float green, float blue, float alpha) { cmd::SetSamplerBorderColor& cmd = GetCmdSpace<cmd::SetSamplerBorderColor>(); - cmd.Init(id, red, green, blue, alpha); + cmd.Init(sampler_id, red, green, blue, alpha); } - void SetSamplerTexture(uint32 id, uint32 texture_id) { + void SetSamplerTexture(ResourceId sampler_id, ResourceId texture_id) { cmd::SetSamplerTexture& cmd = GetCmdSpace<cmd::SetSamplerTexture>(); - cmd.Init(id, texture_id); + cmd.Init(sampler_id, texture_id); } void SetScissor( @@ -638,17 +647,17 @@ class CommandBufferHelper { cmd.Init(line_smooth_enable, point_sprite_enable, point_size); } - void SetPolygonRaster(uint32 fill_mode, uint32 cull_mode) { + void SetPolygonRaster(PolygonMode fill_mode, FaceCullMode cull_mode) { cmd::SetPolygonRaster& cmd = GetCmdSpace<cmd::SetPolygonRaster>(); cmd.Init(fill_mode, cull_mode); } - void SetAlphaTest(uint32 func, bool enable, float value) { + void SetAlphaTest(Comparison func, bool enable, float value) { cmd::SetAlphaTest& cmd = GetCmdSpace<cmd::SetAlphaTest>(); cmd.Init(func, enable, value); } - void SetDepthTest(uint32 func, bool write_enable, bool enable) { + void SetDepthTest(Comparison func, bool write_enable, bool enable) { cmd::SetDepthTest& cmd = GetCmdSpace<cmd::SetDepthTest>(); cmd.Init(func, write_enable, enable); } @@ -659,14 +668,14 @@ class CommandBufferHelper { uint8 reference_value, bool separate_ccw, bool enable, - uint8 cw_func, - uint8 cw_pass_op, - uint8 cw_fail_op, - uint8 cw_z_fail_op, - uint8 ccw_func, - uint8 ccw_pass_op, - uint8 ccw_fail_op, - uint8 ccw_z_fail_op) { + Comparison cw_func, + StencilOp cw_pass_op, + StencilOp cw_fail_op, + StencilOp cw_z_fail_op, + Comparison ccw_func, + StencilOp ccw_pass_op, + StencilOp ccw_fail_op, + StencilOp ccw_z_fail_op) { cmd::SetStencilTest& cmd = GetCmdSpace<cmd::SetStencilTest>(); cmd.Init( write_mask, @@ -690,12 +699,12 @@ class CommandBufferHelper { } void SetBlending( - uint8 color_src_func, - uint8 color_dst_func, - uint8 color_eq, - uint8 alpha_src_func, - uint8 alpha_dst_func, - uint8 alpha_eq, + BlendFunc color_src_func, + BlendFunc color_dst_func, + BlendEq color_eq, + BlendFunc alpha_src_func, + BlendFunc alpha_dst_func, + BlendEq alpha_eq, bool separate_alpha, bool enable) { cmd::SetBlending& cmd = GetCmdSpace<cmd::SetBlending>(); @@ -716,30 +725,32 @@ class CommandBufferHelper { } void CreateRenderSurface( - uint32 id, uint32 texture_id, + ResourceId render_surface_id, ResourceId texture_id, uint32 width, uint32 height, uint32 level, uint32 side) { cmd::CreateRenderSurface& cmd = GetCmdSpace<cmd::CreateRenderSurface>(); - cmd.Init(id, texture_id, width, height, level, side); + cmd.Init(render_surface_id, texture_id, width, height, level, side); } - void DestroyRenderSurface(uint32 id) { + void DestroyRenderSurface(ResourceId render_surface_id) { cmd::DestroyRenderSurface& cmd = GetCmdSpace<cmd::DestroyRenderSurface>(); - cmd.Init(id); + cmd.Init(render_surface_id); } - void CreateDepthSurface(uint32 id, uint32 width, uint32 height) { + void CreateDepthSurface( + ResourceId depth_surface_id, uint32 width, uint32 height) { cmd::CreateDepthSurface& cmd = GetCmdSpace<cmd::CreateDepthSurface>(); - cmd.Init(id, width, height); + cmd.Init(depth_surface_id, width, height); } - void DestroyDepthSurface(uint32 id) { + void DestroyDepthSurface(ResourceId depth_surface_id) { cmd::DestroyDepthSurface& cmd = GetCmdSpace<cmd::DestroyDepthSurface>(); - cmd.Init(id); + cmd.Init(depth_surface_id); } - void SetRenderSurface(uint32 render_surface_id, uint32 depth_surface_id) { + void SetRenderSurface( + ResourceId render_surface_id, ResourceId depth_surface_id) { cmd::SetRenderSurface& cmd = GetCmdSpace<cmd::SetRenderSurface>(); cmd.Init(render_surface_id, depth_surface_id); } diff --git a/o3d/command_buffer/client/cross/effect_helper.cc b/o3d/command_buffer/client/cross/effect_helper.cc index b9254cc..6cfbf66 100644 --- a/o3d/command_buffer/client/cross/effect_helper.cc +++ b/o3d/command_buffer/client/cross/effect_helper.cc @@ -43,7 +43,7 @@ namespace o3d { namespace command_buffer { -bool EffectHelper::CreateEffectParameters(ResourceID effect_id, +bool EffectHelper::CreateEffectParameters(ResourceId effect_id, std::vector<EffectParamDesc> *descs) { using effect_param::Desc; DCHECK_NE(effect_id, kInvalidResource); @@ -197,7 +197,7 @@ void EffectHelper::DestroyEffectParameters( } } -bool EffectHelper::GetEffectStreams(ResourceID effect_id, +bool EffectHelper::GetEffectStreams(ResourceId effect_id, std::vector<EffectStreamDesc> *descs) { using effect_stream::Desc; DCHECK_NE(effect_id, kInvalidResource); diff --git a/o3d/command_buffer/client/cross/effect_helper.h b/o3d/command_buffer/client/cross/effect_helper.h index d802e4a..cc6b3bb 100644 --- a/o3d/command_buffer/client/cross/effect_helper.h +++ b/o3d/command_buffer/client/cross/effect_helper.h @@ -50,7 +50,7 @@ class EffectHelper { public: // A more usable version of effect_param::Desc struct EffectParamDesc { - ResourceID id; // The resource ID for the param. + ResourceId id; // The resource ID for the param. String name; // The name of the param. String semantic; // The semantic of the param. effect_param::DataType data_type; // The data type of a param. @@ -92,14 +92,14 @@ class EffectHelper { // This function will call Finish(), hence will block. // // Parameters: - // effect_id: the ResourceID of the effect. + // effect_id: the ResourceId of the effect. // descs: A pointer to a vector containing the returned descriptions. // The pointed vector will be cleared. // Returns: // true if successful. Reasons for failure are: // - invalid effect_id, // - not enough memory in the shm_allocator_. - bool CreateEffectParameters(ResourceID effect_id, + bool CreateEffectParameters(ResourceId effect_id, std::vector<EffectParamDesc> *descs); // Gets the strings for a desc. This will fill in the values for the name and @@ -112,15 +112,15 @@ class EffectHelper { // // Parameters: // desc: a pointer to the description for a parameter. The id field should - // be set to the ResourceID of the parameter. + // be set to the ResourceId of the parameter. // Returns: // true if successful. Reasons for failure are: - // - invalid parameter ResourceID, + // - invalid parameter ResourceId, // - not enough memory in the shm_allocator_. bool GetParamStrings(EffectParamDesc *desc); // Destroys all parameter resources referenced by the descriptions. The - // ResourceID will be freed from the param_id_allocator. + // ResourceId will be freed from the param_id_allocator. // Parameters: // descs: the vector of descriptions containing the ResourceIDs of the // parameters to destroy. @@ -132,14 +132,14 @@ class EffectHelper { // This function will call Finish(), hence will block. // // Parameters: - // effect_id: the ResourceID of the effect. + // effect_id: the ResourceId of the effect. // descs: A pointer to a vector containing the returned descriptions. // The pointed vector will be cleared. // Returns: // true if successful. Reasons for failure are: // - invalid effect_id, // - not enough memory in the shm_allocator_. - bool GetEffectStreams(ResourceID effect_id, + bool GetEffectStreams(ResourceId effect_id, std::vector<EffectStreamDesc> *descs); private: diff --git a/o3d/command_buffer/client/cross/id_allocator.h b/o3d/command_buffer/client/cross/id_allocator.h index 26fe1f5..8a91022 100644 --- a/o3d/command_buffer/client/cross/id_allocator.h +++ b/o3d/command_buffer/client/cross/id_allocator.h @@ -50,19 +50,19 @@ class IdAllocator { IdAllocator(); // Allocates a new resource ID. - command_buffer::ResourceID AllocateID() { + command_buffer::ResourceId AllocateID() { unsigned int bit = FindFirstFree(); SetBit(bit, true); return bit; } // Frees a resource ID. - void FreeID(command_buffer::ResourceID id) { + void FreeID(command_buffer::ResourceId id) { SetBit(id, false); } // Checks whether or not a resource ID is in use. - bool InUse(command_buffer::ResourceID id) { + bool InUse(command_buffer::ResourceId id) { return GetBit(id); } private: diff --git a/o3d/command_buffer/client/cross/id_allocator_test.cc b/o3d/command_buffer/client/cross/id_allocator_test.cc index 96ba097..dacc9ef 100644 --- a/o3d/command_buffer/client/cross/id_allocator_test.cc +++ b/o3d/command_buffer/client/cross/id_allocator_test.cc @@ -38,7 +38,7 @@ namespace o3d { namespace command_buffer { -using command_buffer::ResourceID; +using command_buffer::ResourceId; class IdAllocatorTest : public testing::Test { protected: @@ -58,12 +58,12 @@ TEST_F(IdAllocatorTest, TestBasic) { EXPECT_FALSE(allocator->InUse(0)); // Allocate an ID, check that it's in use. - ResourceID id1 = allocator->AllocateID(); + ResourceId id1 = allocator->AllocateID(); EXPECT_TRUE(allocator->InUse(id1)); // Allocate another ID, check that it's in use, and different from the first // one. - ResourceID id2 = allocator->AllocateID(); + ResourceId id2 = allocator->AllocateID(); EXPECT_TRUE(allocator->InUse(id2)); EXPECT_NE(id1, id2); @@ -83,7 +83,7 @@ TEST_F(IdAllocatorTest, TestAdvanced) { // Allocate a significant number of resources. const unsigned int kNumResources = 100; - ResourceID ids[kNumResources]; + ResourceId ids[kNumResources]; for (int i = 0; i < kNumResources; ++i) { ids[i] = allocator->AllocateID(); EXPECT_TRUE(allocator->InUse(ids[i])); @@ -102,10 +102,10 @@ TEST_F(IdAllocatorTest, TestAdvanced) { } // Check that a new allocation re-uses the resource we just freed. - ResourceID id1 = ids[kNumResources / 2]; + ResourceId id1 = ids[kNumResources / 2]; allocator->FreeID(id1); EXPECT_FALSE(allocator->InUse(id1)); - ResourceID id2 = allocator->AllocateID(); + ResourceId id2 = allocator->AllocateID(); EXPECT_TRUE(allocator->InUse(id2)); EXPECT_EQ(id1, id2); } diff --git a/o3d/command_buffer/common/cross/cmd_buffer_format.h b/o3d/command_buffer/common/cross/cmd_buffer_format.h index 96e0578..2b819b5 100644 --- a/o3d/command_buffer/common/cross/cmd_buffer_format.h +++ b/o3d/command_buffer/common/cross/cmd_buffer_format.h @@ -61,287 +61,14 @@ #include "base/basictypes.h" #include "command_buffer/common/cross/types.h" +#include "command_buffer/common/cross/logging.h" +#include "command_buffer/common/cross/resource.h" #include "command_buffer/common/cross/bitfield_helpers.h" #include "core/cross/packing.h" namespace o3d { namespace command_buffer { -namespace cmd { - enum ArgFlags { - kFixed = 0x0, - kAtLeastN = 0x1, - }; -} // namespace cmd - -// Computes the number of command buffer entries needed for a certain size. In -// other words it rounds up to a multiple of entries. -inline uint32 ComputeNumEntries(size_t size_in_bytes) { - return static_cast<uint32>( - (size_in_bytes + sizeof(uint32) - 1) / sizeof(uint32)); // NOLINT -} - -// Rounds up to a multiple of entries in bytes. -inline size_t RoundSizeToMultipleOfEntries(size_t size_in_bytes) { - return ComputeNumEntries(size_in_bytes) * sizeof(uint32); // NOLINT -} - -// Struct that defines the command header in the command buffer. -struct CommandHeader { - Uint32 size:8; - Uint32 command:24; - - void Init(uint32 _command, uint32 _size) { - command = _command; - size = _size; - } - - // Sets the header based on the passed in command. Can not be used for - // variable sized commands like immediate commands or Noop. - template <typename T> - void SetCmd() { - COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed); - Init(T::kCmdId, ComputeNumEntries(sizeof(T))); // NOLINT - } - - // Sets the header by a size in bytes. - template <typename T> - void SetCmdBySize(uint32 size_in_bytes) { - COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); - Init(T::kCmdId, ComputeNumEntries(sizeof(T) + size_in_bytes)); // NOLINT - } -}; - -COMPILE_ASSERT(sizeof(CommandHeader) == 4, Sizeof_CommandHeader_is_not_4); - -// Union that defines possible command buffer entries. -union CommandBufferEntry { - CommandHeader value_header; - Uint32 value_uint32; - Int32 value_int32; - float value_float; -}; - -COMPILE_ASSERT(sizeof(CommandBufferEntry) == 4, - Sizeof_CommandBufferEntry_is_not_4); - -// Bitfields for the SetVertexInput command. -namespace set_vertex_input_cmd { -// argument 4 -typedef BitField<0, 4> SemanticIndex; // TODO(gman): shouldn't this be bigger - // than 4 bits for future expansion? -typedef BitField<4, 4> Semantic; -typedef BitField<8, 8> Type; -typedef BitField<16, 16> Stride; -} // namespace set_vertex_input_cmd - -// Bitfields for the CreateTexture2d command. -namespace create_texture_2d_cmd { -// argument 1 -typedef BitField<0, 16> Width; -typedef BitField<16, 16> Height; -// argument 2 -typedef BitField<0, 4> Levels; -typedef BitField<4, 4> Unused; -typedef BitField<8, 8> Format; -typedef BitField<16, 16> Flags; -} // namespace create_texture_2d_cmd - -// Bitfields for the CreateTexture3d command. -namespace create_texture_3d_cmd { -// argument 1 -typedef BitField<0, 16> Width; -typedef BitField<16, 16> Height; -// argument 2 -typedef BitField<0, 16> Depth; -typedef BitField<16, 16> Unused1; -// argument 3 -typedef BitField<0, 4> Levels; -typedef BitField<4, 4> Unused2; -typedef BitField<8, 8> Format; -typedef BitField<16, 16> Flags; -} // namespace create_texture_3d_cmd - -// Bitfields for the CreateTextureCube command. -namespace create_texture_cube_cmd { -// argument 1 -typedef BitField<0, 16> Side; -typedef BitField<16, 16> Unused1; -// argument 2 -typedef BitField<0, 4> Levels; -typedef BitField<4, 4> Unused2; -typedef BitField<8, 8> Format; -typedef BitField<16, 16> Flags; -} // namespace create_texture_cube_cmd - -// Bitfields for the CreateRenderSurface command. -namespace create_render_surface_cmd { -// argument 1 -typedef BitField<0, 16> Width; -typedef BitField<16, 16> Height; -// argument 2 may refer to side or depth -typedef BitField<0, 16> Levels; -typedef BitField<16, 16> Side; -} // namespace create_render_surface_cmd - -// Bitfields for the CreateDepthSurface command. -namespace create_depth_surface_cmd { -// argument 1 -typedef BitField<0, 16> Width; -typedef BitField<16, 16> Height; -} // namespace create_depth_surface_cmd - -// Bitfields for the SetTextureData command. -namespace set_texture_data_cmd { -// argument 1 -typedef BitField<0, 16> X; -typedef BitField<16, 16> Y; -// argument 2 -typedef BitField<0, 16> Width; -typedef BitField<16, 16> Height; -// argument 3 -typedef BitField<0, 16> Z; -typedef BitField<16, 16> Depth; -// argument 4 -typedef BitField<0, 4> Level; -typedef BitField<4, 3> Face; -typedef BitField<7, 25> Unused; -} // namespace set_texture_data_cmd - -// Bitfields for the SetTextureDataImmediate command. -namespace set_texture_data_immediate_cmd { -// argument 1 -typedef BitField<0, 16> X; -typedef BitField<16, 16> Y; -// argument 2 -typedef BitField<0, 16> Width; -typedef BitField<16, 16> Height; -// argument 3 -typedef BitField<0, 16> Z; -typedef BitField<16, 16> Depth; -// argument 4 -typedef BitField<0, 4> Level; -typedef BitField<4, 3> Face; -typedef BitField<7, 25> Unused; -} // namespace set_texture_data_immediate_cmd - -// Bitfields for the GetTextureData command. -namespace get_texture_data_cmd { -// argument 1 -typedef BitField<0, 16> X; -typedef BitField<16, 16> Y; -// argument 2 -typedef BitField<0, 16> Width; -typedef BitField<16, 16> Height; -// argument 3 -typedef BitField<0, 16> Z; -typedef BitField<16, 16> Depth; -// argument 4 -typedef BitField<0, 4> Level; -typedef BitField<4, 3> Face; -typedef BitField<7, 25> Unused; -} // namespace get_texture_data_cmd - -// Bitfields for the SetSamplerStates command. -namespace set_sampler_states { -// argument 2 -typedef BitField<0, 3> AddressingU; -typedef BitField<3, 3> AddressingV; -typedef BitField<6, 3> AddressingW; -typedef BitField<9, 3> MagFilter; -typedef BitField<12, 3> MinFilter; -typedef BitField<15, 3> MipFilter; -typedef BitField<18, 6> Unused; -typedef BitField<24, 8> MaxAnisotropy; -} // namespace get_texture_data_cmd - -namespace set_scissor { -// argument 0 -typedef BitField<0, 15> X; -typedef BitField<15, 1> Unused; -typedef BitField<16, 15> Y; -typedef BitField<31, 1> Enable; -// argument 1 -typedef BitField<0, 16> Width; -typedef BitField<16, 16> Height; -} // namespace set_scissor - -namespace set_point_line_raster { -// argument 0 -typedef BitField<0, 1> LineSmoothEnable; -typedef BitField<1, 1> PointSpriteEnable; -typedef BitField<2, 30> Unused; -} // namespace set_point_line_raster - -namespace set_polygon_raster { -// argument 0 -typedef BitField<0, 2> FillMode; -typedef BitField<2, 2> CullMode; -typedef BitField<4, 28> Unused; -} // namespace set_polygon_raster - -namespace set_alpha_test { -// argument 0 -typedef BitField<0, 3> Func; -typedef BitField<3, 28> Unused; -typedef BitField<31, 1> Enable; -} // namespace set_alpha_test - -namespace set_depth_test { -// argument 0 -typedef BitField<0, 3> Func; -typedef BitField<3, 27> Unused; -typedef BitField<30, 1> WriteEnable; -typedef BitField<31, 1> Enable; -} // namespace set_depth_test - -namespace set_stencil_test { -// argument 0 -typedef BitField<0, 8> WriteMask; -typedef BitField<8, 8> CompareMask; -typedef BitField<16, 8> ReferenceValue; -typedef BitField<24, 6> Unused0; -typedef BitField<30, 1> SeparateCCW; -typedef BitField<31, 1> Enable; -// argument 1 -typedef BitField<0, 3> CWFunc; -typedef BitField<3, 3> CWPassOp; -typedef BitField<6, 3> CWFailOp; -typedef BitField<9, 3> CWZFailOp; -typedef BitField<12, 4> Unused1; -typedef BitField<16, 3> CCWFunc; -typedef BitField<19, 3> CCWPassOp; -typedef BitField<22, 3> CCWFailOp; -typedef BitField<25, 3> CCWZFailOp; -typedef BitField<28, 4> Unused2; -} // namespace set_stencil_test - -namespace set_color_write { -// argument 0 -typedef BitField<0, 1> RedMask; -typedef BitField<1, 1> GreenMask; -typedef BitField<2, 1> BlueMask; -typedef BitField<3, 1> AlphaMask; -typedef BitField<0, 4> AllColorsMask; // alias for RGBA -typedef BitField<4, 27> Unused; -typedef BitField<31, 1> DitherEnable; -} // namespace set_color_write - -namespace set_blending { -// argument 0 -typedef BitField<0, 4> ColorSrcFunc; -typedef BitField<4, 4> ColorDstFunc; -typedef BitField<8, 3> ColorEq; -typedef BitField<11, 5> Unused0; -typedef BitField<16, 4> AlphaSrcFunc; -typedef BitField<20, 4> AlphaDstFunc; -typedef BitField<24, 3> AlphaEq; -typedef BitField<27, 3> Unused1; -typedef BitField<30, 1> SeparateAlpha; -typedef BitField<31, 1> Enable; -} // namespace set_blending - - // This macro is used to safely and convienently expand the list of commnad // buffer commands in to various lists and never have them get out of sync. To // add a new command, add it this list, create the corresponding structure below @@ -423,6 +150,157 @@ enum CommandId { O3D_COMMAND_BUFFER_CMDS #undef O3D_COMMAND_BUFFER_CMD_OP + + kNumCommands, +}; + +namespace cmd { + enum ArgFlags { + kFixed = 0x0, + kAtLeastN = 0x1, + }; +} // namespace cmd + +// Computes the number of command buffer entries needed for a certain size. In +// other words it rounds up to a multiple of entries. +inline uint32 ComputeNumEntries(size_t size_in_bytes) { + return static_cast<uint32>( + (size_in_bytes + sizeof(uint32) - 1) / sizeof(uint32)); // NOLINT +} + +// Rounds up to a multiple of entries in bytes. +inline size_t RoundSizeToMultipleOfEntries(size_t size_in_bytes) { + return ComputeNumEntries(size_in_bytes) * sizeof(uint32); // NOLINT +} + +// Struct that defines the command header in the command buffer. +struct CommandHeader { + Uint32 size:8; + Uint32 command:24; + + void Init(uint32 _command, uint32 _size) { + DCHECK_LT(_size, 256); + DCHECK_LT(_command, static_cast<int>(kNumCommands)); + command = _command; + size = _size; + } + + // Sets the header based on the passed in command. Can not be used for + // variable sized commands like immediate commands or Noop. + template <typename T> + void SetCmd() { + COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed); + Init(T::kCmdId, ComputeNumEntries(sizeof(T))); // NOLINT + } + + // Sets the header by a size in bytes. + template <typename T> + void SetCmdBySize(uint32 size_in_bytes) { + COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); + Init(T::kCmdId, ComputeNumEntries(sizeof(T) + size_in_bytes)); // NOLINT + } +}; + +COMPILE_ASSERT(sizeof(CommandHeader) == 4, Sizeof_CommandHeader_is_not_4); + +// Union that defines possible command buffer entries. +union CommandBufferEntry { + CommandHeader value_header; + Uint32 value_uint32; + Int32 value_int32; + float value_float; +}; + +COMPILE_ASSERT(sizeof(CommandBufferEntry) == 4, + Sizeof_CommandBufferEntry_is_not_4); + +// Bit definitions for buffers to clear. +enum ClearBuffer { + kColor = 0x1, + kDepth = 0x2, + kStencil = 0x4, + kAllBuffers = kColor | kDepth | kStencil +}; + +// Polygon mode for SetPolygonRaster +enum PolygonMode { + kPolygonModePoints, + kPolygonModeLines, + kPolygonModeFill, + kNumPolygonMode +}; + +// Face culling mode for SetPolygonRaster +enum FaceCullMode { + kCullNone, + kCullCW, + kCullCCW, + kNumFaceCullMode +}; + +// Primitive type for Draw and DrawIndexed. +enum PrimitiveType { + kPoints, + kLines, + kLineStrips, + kTriangles, + kTriangleStrips, + kTriangleFans, + kMaxPrimitiveType +}; + +// Comparison function for alpha or depth test +enum Comparison { + kNever, + kLess, + kEqual, + kLEqual, + kGreater, + kNotEqual, + kGEqual, + kAlways, + kNumComparison +}; + +// Stencil operation +enum StencilOp { + kKeep, + kZero, + kReplace, + kIncNoWrap, + kDecNoWrap, + kInvert, + kIncWrap, + kDecWrap, + kNumStencilOp +}; + +// Blend Equation +enum BlendEq { + kBlendEqAdd, + kBlendEqSub, + kBlendEqRevSub, + kBlendEqMin, + kBlendEqMax, + kNumBlendEq +}; + +// Blend Funtion +enum BlendFunc { + kBlendFuncZero, + kBlendFuncOne, + kBlendFuncSrcColor, + kBlendFuncInvSrcColor, + kBlendFuncSrcAlpha, + kBlendFuncInvSrcAlpha, + kBlendFuncDstAlpha, + kBlendFuncInvDstAlpha, + kBlendFuncDstColor, + kBlendFuncInvDstColor, + kBlendFuncSrcAlphaSaturate, + kBlendFuncBlendColor, + kBlendFuncInvBlendColor, + kNumBlendFunc }; namespace cmd { @@ -714,20 +592,22 @@ struct CreateVertexBuffer { header.SetCmd<ValueType>(); } - void Init(uint32 _id, uint32 _size, uint32 _flags) { + void Init(ResourceId _vertex_buffer_id, uint32 _size, + vertex_buffer::Flags _flags) { SetHeader(); - id = _id; + vertex_buffer_id = _vertex_buffer_id; size = _size; - flags = _flags; + flags = static_cast<uint32>(_flags); } - static void* Set(void* cmd, uint32 id, uint32 size, uint32 flags) { - static_cast<ValueType*>(cmd)->Init(id, size, flags); + static void* Set(void* cmd, ResourceId vertex_buffer_id, + uint32 size, vertex_buffer::Flags flags) { + static_cast<ValueType*>(cmd)->Init(vertex_buffer_id, size, flags); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId vertex_buffer_id; uint32 size; uint32 flags; }; @@ -736,8 +616,8 @@ COMPILE_ASSERT(sizeof(CreateVertexBuffer) == 16, Sizeof_CreateVertexBuffer_is_not_16); COMPILE_ASSERT(offsetof(CreateVertexBuffer, header) == 0, OffsetOf_CreateVertexBuffer_header_not_0); -COMPILE_ASSERT(offsetof(CreateVertexBuffer, id) == 4, - OffsetOf_CreateVertexBuffer_id_not_4); +COMPILE_ASSERT(offsetof(CreateVertexBuffer, vertex_buffer_id) == 4, + OffsetOf_CreateVertexBuffer_vertex_buffer_id_not_4); COMPILE_ASSERT(offsetof(CreateVertexBuffer, size) == 8, OffsetOf_CreateVertexBuffer_size_not_8); COMPILE_ASSERT(offsetof(CreateVertexBuffer, flags) == 12, @@ -752,26 +632,26 @@ struct DestroyVertexBuffer { header.SetCmd<ValueType>(); } - void Init(uint32 _id) { + void Init(ResourceId _vertex_buffer_id) { SetHeader(); - id = _id; + vertex_buffer_id = _vertex_buffer_id; } - static void* Set(void* cmd, uint32 id) { - static_cast<ValueType*>(cmd)->Init(id); + static void* Set(void* cmd, ResourceId vertex_buffer_id) { + static_cast<ValueType*>(cmd)->Init(vertex_buffer_id); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId vertex_buffer_id; }; COMPILE_ASSERT(sizeof(DestroyVertexBuffer) == 8, Sizeof_DestroyVertexBuffer_is_not_8); COMPILE_ASSERT(offsetof(DestroyVertexBuffer, header) == 0, OffsetOf_DestroyVertexBuffer_header_not_0); -COMPILE_ASSERT(offsetof(DestroyVertexBuffer, id) == 4, - OffsetOf_DestroyVertexBuffer_id_not_4); +COMPILE_ASSERT(offsetof(DestroyVertexBuffer, vertex_buffer_id) == 4, + OffsetOf_DestroyVertexBuffer_vertex_buffer_id_not_4); struct SetVertexBufferDataImmediate { typedef SetVertexBufferDataImmediate ValueType; @@ -782,21 +662,22 @@ struct SetVertexBufferDataImmediate { header.SetCmdBySize<ValueType>(size); } - void Init(uint32 _id, uint32 _offset, const void* data, uint32 size) { + void Init(ResourceId _vertex_buffer_id, uint32 _offset, + const void* data, uint32 size) { SetHeader(size); - id = _id; + vertex_buffer_id = _vertex_buffer_id; offset = _offset; memcpy(ImmediateDataAddress(this), data, size); } - static void* Set(void* cmd, uint32 id, uint32 offset, + static void* Set(void* cmd, ResourceId vertex_buffer_id, uint32 offset, const void* data, uint32 size) { - static_cast<ValueType*>(cmd)->Init(id, offset, data, size); + static_cast<ValueType*>(cmd)->Init(vertex_buffer_id, offset, data, size); return NextImmediateCmdAddress<ValueType>(cmd, size); } CommandHeader header; - uint32 id; + ResourceId vertex_buffer_id; uint32 offset; }; @@ -804,8 +685,8 @@ COMPILE_ASSERT(sizeof(SetVertexBufferDataImmediate) == 12, Sizeof_SetVertexBufferDataImmediate_is_not_12); COMPILE_ASSERT(offsetof(SetVertexBufferDataImmediate, header) == 0, OffsetOf_SetVertexBufferDataImmediate_header_not_0); -COMPILE_ASSERT(offsetof(SetVertexBufferDataImmediate, id) == 4, - OffsetOf_SetVertexBufferDataImmediate_id_not_4); +COMPILE_ASSERT(offsetof(SetVertexBufferDataImmediate, vertex_buffer_id) == 4, + OffsetOf_SetVertexBufferDataImmediate_vertex_buffer_id_not_4); COMPILE_ASSERT(offsetof(SetVertexBufferDataImmediate, offset) == 8, OffsetOf_SetVertexBufferDataImmediate_offset_not_8); @@ -818,24 +699,25 @@ struct SetVertexBufferData { header.SetCmd<ValueType>(); } - void Init(uint32 _id, uint32 _offset, uint32 _size, + void Init(ResourceId _vertex_buffer_id, uint32 _offset, uint32 _size, uint32 shared_memory_id, uint32 shared_memory_offset) { SetHeader(); - id = _id; + vertex_buffer_id = _vertex_buffer_id; offset = _offset; size = _size; shared_memory.Init(shared_memory_id, shared_memory_offset); } - static void* Set(void* cmd, uint32 id, uint32 offset, uint32 size, + static void* Set(void* cmd, ResourceId vertex_buffer_id, + uint32 offset, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { - static_cast<ValueType*>(cmd)->Init(id, offset, size, + static_cast<ValueType*>(cmd)->Init(vertex_buffer_id, offset, size, shared_memory_id, shared_memory_offset); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId vertex_buffer_id; uint32 offset; uint32 size; SharedMemory shared_memory; @@ -845,8 +727,8 @@ COMPILE_ASSERT(sizeof(SetVertexBufferData) == 24, Sizeof_SetVertexBufferData_is_not_24); COMPILE_ASSERT(offsetof(SetVertexBufferData, header) == 0, OffsetOf_SetVertexBufferData_header_not_0); -COMPILE_ASSERT(offsetof(SetVertexBufferData, id) == 4, - OffsetOf_SetVertexBufferData_id_not_4); +COMPILE_ASSERT(offsetof(SetVertexBufferData, vertex_buffer_id) == 4, + OffsetOf_SetVertexBufferData_vertex_buffer_id_not_4); COMPILE_ASSERT(offsetof(SetVertexBufferData, offset) == 8, OffsetOf_SetVertexBufferData_offset_not_8); COMPILE_ASSERT(offsetof(SetVertexBufferData, size) == 12, @@ -863,24 +745,25 @@ struct GetVertexBufferData { header.SetCmd<ValueType>(); } - void Init(uint32 _id, uint32 _offset, uint32 _size, + void Init(ResourceId _vertex_buffer_id, uint32 _offset, uint32 _size, uint32 shared_memory_id, uint32 shared_memory_offset) { SetHeader(); - id = _id; + vertex_buffer_id = _vertex_buffer_id; offset = _offset; size = _size; shared_memory.Init(shared_memory_id, shared_memory_offset); } - static void* Set(void* cmd, uint32 id, uint32 offset, uint32 size, + static void* Set(void* cmd, ResourceId vertex_buffer_id, + uint32 offset, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { - static_cast<ValueType*>(cmd)->Init(id, offset, size, + static_cast<ValueType*>(cmd)->Init(vertex_buffer_id, offset, size, shared_memory_id, shared_memory_offset); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId vertex_buffer_id; uint32 offset; uint32 size; SharedMemory shared_memory; @@ -890,8 +773,8 @@ COMPILE_ASSERT(sizeof(GetVertexBufferData) == 24, Sizeof_GetVertexBufferData_is_not_24); COMPILE_ASSERT(offsetof(GetVertexBufferData, header) == 0, OffsetOf_GetVertexBufferData_header_not_0); -COMPILE_ASSERT(offsetof(GetVertexBufferData, id) == 4, - OffsetOf_GetVertexBufferData_id_not_4); +COMPILE_ASSERT(offsetof(GetVertexBufferData, vertex_buffer_id) == 4, + OffsetOf_GetVertexBufferData_vertex_buffer_id_not_4); COMPILE_ASSERT(offsetof(GetVertexBufferData, offset) == 8, OffsetOf_GetVertexBufferData_offset_not_8); COMPILE_ASSERT(offsetof(GetVertexBufferData, size) == 12, @@ -908,20 +791,22 @@ struct CreateIndexBuffer { header.SetCmd<ValueType>(); } - void Init(uint32 _id, uint32 _size, uint32 _flags) { + void Init(ResourceId _index_buffer_id, uint32 _size, + index_buffer::Flags _flags) { SetHeader(); - id = _id; + index_buffer_id = _index_buffer_id; size = _size; - flags = _flags; + flags = static_cast<uint32>(_flags); } - static void* Set(void* cmd, uint32 id, uint32 size, uint32 flags) { - static_cast<ValueType*>(cmd)->Init(id, size, flags); + static void* Set(void* cmd, ResourceId index_buffer_id, + uint32 size, index_buffer::Flags flags) { + static_cast<ValueType*>(cmd)->Init(index_buffer_id, size, flags); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId index_buffer_id; uint32 size; uint32 flags; }; @@ -930,8 +815,8 @@ COMPILE_ASSERT(sizeof(CreateIndexBuffer) == 16, Sizeof_CreateIndexBuffer_is_not_16); COMPILE_ASSERT(offsetof(CreateIndexBuffer, header) == 0, OffsetOf_CreateIndexBuffer_header_not_0); -COMPILE_ASSERT(offsetof(CreateIndexBuffer, id) == 4, - OffsetOf_CreateIndexBuffer_id_not_4); +COMPILE_ASSERT(offsetof(CreateIndexBuffer, index_buffer_id) == 4, + OffsetOf_CreateIndexBuffer_index_buffer_id_not_4); COMPILE_ASSERT(offsetof(CreateIndexBuffer, size) == 8, OffsetOf_CreateIndexBuffer_size_not_8); COMPILE_ASSERT(offsetof(CreateIndexBuffer, flags) == 12, @@ -946,26 +831,26 @@ struct DestroyIndexBuffer { header.SetCmd<ValueType>(); } - void Init(uint32 _id) { + void Init(ResourceId _index_buffer_id) { SetHeader(); - id = _id; + index_buffer_id = _index_buffer_id; } - static void* Set(void* cmd, uint32 id) { - static_cast<ValueType*>(cmd)->Init(id); + static void* Set(void* cmd, ResourceId index_buffer_id) { + static_cast<ValueType*>(cmd)->Init(index_buffer_id); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId index_buffer_id; }; COMPILE_ASSERT(sizeof(DestroyIndexBuffer) == 8, Sizeof_DestroyIndexBuffer_is_not_8); COMPILE_ASSERT(offsetof(DestroyIndexBuffer, header) == 0, OffsetOf_DestroyIndexBuffer_header_not_0); -COMPILE_ASSERT(offsetof(DestroyIndexBuffer, id) == 4, - OffsetOf_DestroyIndexBuffer_id_not_4); +COMPILE_ASSERT(offsetof(DestroyIndexBuffer, index_buffer_id) == 4, + OffsetOf_DestroyIndexBuffer_index_buffer_id_not_4); struct SetIndexBufferDataImmediate { typedef SetIndexBufferDataImmediate ValueType; @@ -976,21 +861,22 @@ struct SetIndexBufferDataImmediate { header.SetCmdBySize<ValueType>(size); } - void Init(uint32 _id, uint32 _offset, const void* data, uint32 size) { + void Init(ResourceId _index_buffer_id, uint32 _offset, + const void* data, uint32 size) { SetHeader(size); - id = _id; + index_buffer_id = _index_buffer_id; offset = _offset; memcpy(ImmediateDataAddress(this), data, size); } - static void* Set(void* cmd, uint32 id, uint32 offset, const void* data, - uint32 size) { - static_cast<ValueType*>(cmd)->Init(id, offset, data, size); + static void* Set(void* cmd, ResourceId index_buffer_id, uint32 offset, + const void* data, uint32 size) { + static_cast<ValueType*>(cmd)->Init(index_buffer_id, offset, data, size); return NextImmediateCmdAddress<ValueType>(cmd, size); } CommandHeader header; - uint32 id; + ResourceId index_buffer_id; uint32 offset; }; @@ -998,8 +884,8 @@ COMPILE_ASSERT(sizeof(SetIndexBufferDataImmediate) == 12, Sizeof_SetIndexBufferDataImmediate_is_not_12); COMPILE_ASSERT(offsetof(SetIndexBufferDataImmediate, header) == 0, OffsetOf_SetIndexBufferDataImmediate_header_not_0); -COMPILE_ASSERT(offsetof(SetIndexBufferDataImmediate, id) == 4, - OffsetOf_SetIndexBufferDataImmediate_id_not_4); +COMPILE_ASSERT(offsetof(SetIndexBufferDataImmediate, index_buffer_id) == 4, + OffsetOf_SetIndexBufferDataImmediate_index_buffer_id_not_4); COMPILE_ASSERT(offsetof(SetIndexBufferDataImmediate, offset) == 8, OffsetOf_SetIndexBufferDataImmediate_offset_not_8); @@ -1012,24 +898,25 @@ struct SetIndexBufferData { header.SetCmd<ValueType>(); } - void Init(uint32 _id, uint32 _offset, uint32 _size, + void Init(ResourceId _index_buffer_id, uint32 _offset, uint32 _size, uint32 shared_memory_id, uint32 shared_memory_offset) { SetHeader(); - id = _id; + index_buffer_id = _index_buffer_id; offset = _offset; size = _size; shared_memory.Init(shared_memory_id, shared_memory_offset); } - static void* Set(void* cmd, uint32 id, uint32 offset, uint32 size, + static void* Set(void* cmd, + ResourceId index_buffer_id, uint32 offset, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { - static_cast<ValueType*>(cmd)->Init(id, offset, size, + static_cast<ValueType*>(cmd)->Init(index_buffer_id, offset, size, shared_memory_id, shared_memory_offset); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId index_buffer_id; uint32 offset; uint32 size; SharedMemory shared_memory; @@ -1039,8 +926,8 @@ COMPILE_ASSERT(sizeof(SetIndexBufferData) == 24, Sizeof_SetIndexBufferData_is_not_24); COMPILE_ASSERT(offsetof(SetIndexBufferData, header) == 0, OffsetOf_SetIndexBufferData_header_not_0); -COMPILE_ASSERT(offsetof(SetIndexBufferData, id) == 4, - OffsetOf_SetIndexBufferData_id_not_4); +COMPILE_ASSERT(offsetof(SetIndexBufferData, index_buffer_id) == 4, + OffsetOf_SetIndexBufferData_index_buffer_id_not_4); COMPILE_ASSERT(offsetof(SetIndexBufferData, offset) == 8, OffsetOf_SetIndexBufferData_offset_not_8); COMPILE_ASSERT(offsetof(SetIndexBufferData, size) == 12, @@ -1057,24 +944,25 @@ struct GetIndexBufferData { header.SetCmd<ValueType>(); } - void Init(uint32 _id, uint32 _offset, uint32 _size, + void Init(ResourceId _index_buffer_id, uint32 _offset, uint32 _size, uint32 shared_memory_id, uint32 shared_memory_offset) { SetHeader(); - id = _id; + index_buffer_id = _index_buffer_id; offset = _offset; size = _size; shared_memory.Init(shared_memory_id, shared_memory_offset); } - static void* Set(void* cmd, uint32 id, uint32 offset, uint32 size, + static void* Set(void* cmd, ResourceId index_buffer_id, + uint32 offset, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { - static_cast<ValueType*>(cmd)->Init(id, offset, size, + static_cast<ValueType*>(cmd)->Init(index_buffer_id, offset, size, shared_memory_id, shared_memory_offset); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId index_buffer_id; uint32 offset; uint32 size; SharedMemory shared_memory; @@ -1084,8 +972,8 @@ COMPILE_ASSERT(sizeof(GetIndexBufferData) == 24, Sizeof_GetIndexBufferData_is_not_24); COMPILE_ASSERT(offsetof(GetIndexBufferData, header) == 0, OffsetOf_GetIndexBufferData_header_not_0); -COMPILE_ASSERT(offsetof(GetIndexBufferData, id) == 4, - OffsetOf_GetIndexBufferData_id_not_4); +COMPILE_ASSERT(offsetof(GetIndexBufferData, index_buffer_id) == 4, + OffsetOf_GetIndexBufferData_index_buffer_id_not_4); COMPILE_ASSERT(offsetof(GetIndexBufferData, offset) == 8, OffsetOf_GetIndexBufferData_offset_not_8); COMPILE_ASSERT(offsetof(GetIndexBufferData, size) == 12, @@ -1102,19 +990,19 @@ struct CreateVertexStruct { header.SetCmd<ValueType>(); } - void Init(uint32 _id, uint32 _input_count) { + void Init(ResourceId _vertex_struct_id, uint32 _input_count) { SetHeader(); - id = _id; + vertex_struct_id = _vertex_struct_id; input_count = _input_count; } - static void* Set(void* cmd, uint32 id, uint32 input_count) { - static_cast<ValueType*>(cmd)->Init(id, input_count); + static void* Set(void* cmd, ResourceId vertex_struct_id, uint32 input_count) { + static_cast<ValueType*>(cmd)->Init(vertex_struct_id, input_count); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId vertex_struct_id; uint32 input_count; }; @@ -1122,8 +1010,8 @@ COMPILE_ASSERT(sizeof(CreateVertexStruct) == 12, Sizeof_CreateVertexStruct_is_not_12); COMPILE_ASSERT(offsetof(CreateVertexStruct, header) == 0, OffsetOf_CreateVertexStruct_header_not_0); -COMPILE_ASSERT(offsetof(CreateVertexStruct, id) == 4, - OffsetOf_CreateVertexStruct_id_not_4); +COMPILE_ASSERT(offsetof(CreateVertexStruct, vertex_struct_id) == 4, + OffsetOf_CreateVertexStruct_vertex_struct_id_not_4); COMPILE_ASSERT(offsetof(CreateVertexStruct, input_count) == 8, OffsetOf_CreateVertexStruct_input_count_not_8); @@ -1136,65 +1024,71 @@ struct DestroyVertexStruct { header.SetCmd<ValueType>(); } - void Init(uint32 _id) { + void Init(ResourceId _vertex_struct_id) { SetHeader(); - id = _id; + vertex_struct_id = _vertex_struct_id; } - static void* Set(void* cmd, uint32 id) { - static_cast<ValueType*>(cmd)->Init(id); + static void* Set(void* cmd, ResourceId vertex_struct_id) { + static_cast<ValueType*>(cmd)->Init(vertex_struct_id); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId vertex_struct_id; }; COMPILE_ASSERT(sizeof(DestroyVertexStruct) == 8, Sizeof_DestroyVertexStruct_is_not_8); COMPILE_ASSERT(offsetof(DestroyVertexStruct, header) == 0, OffsetOf_DestroyVertexStruct_header_not_0); -COMPILE_ASSERT(offsetof(DestroyVertexStruct, id) == 4, - OffsetOf_DestroyVertexStruct_id_not_4); +COMPILE_ASSERT(offsetof(DestroyVertexStruct, vertex_struct_id) == 4, + OffsetOf_DestroyVertexStruct_vertex_struct_id_not_4); struct SetVertexInput { typedef SetVertexInput ValueType; static const CommandId kCmdId = command_buffer::kSetVertexInput; static const ArgFlags kArgFlags = kFixed; + // type_stride_semantic field. + typedef BitField<0, 4> SemanticIndex; + typedef BitField<4, 4> Semantic; + typedef BitField<8, 8> Type; + typedef BitField<16, 16> Stride; + void SetHeader() { header.SetCmd<ValueType>(); } - void Init(uint32 _vertex_struct_id, + void Init(ResourceId _vertex_struct_id, uint32 _input_index, - uint32 _vertex_buffer_id, + ResourceId _vertex_buffer_id, uint32 _offset, - uint8 _semantic, + vertex_struct::Semantic _semantic, uint32 _semantic_index, - uint8 _type, + vertex_struct::Type _type, uint32 _stride) { SetHeader(); vertex_struct_id = _vertex_struct_id; input_index = _input_index; vertex_buffer_id = _vertex_buffer_id; offset = _offset; - fixme4 = - set_vertex_input_cmd::Semantic::MakeValue(_semantic) | - set_vertex_input_cmd::SemanticIndex::MakeValue(_semantic_index) | - set_vertex_input_cmd::Type::MakeValue(_type) | - set_vertex_input_cmd::Stride::MakeValue(_stride); + type_stride_semantic = + Semantic::MakeValue(_semantic) | + SemanticIndex::MakeValue(_semantic_index) | + Type::MakeValue(_type) | + Stride::MakeValue(_stride); } static void* Set( void* cmd, - uint32 vertex_struct_id, + ResourceId vertex_struct_id, uint32 input_index, - uint32 vertex_buffer_id, + ResourceId vertex_buffer_id, uint32 offset, - uint8 semantic, + vertex_struct::Semantic semantic, uint32 semantic_index, - uint8 type, + vertex_struct::Type type, uint32 stride) { static_cast<ValueType*>(cmd)->Init( vertex_struct_id, @@ -1209,11 +1103,11 @@ struct SetVertexInput { } CommandHeader header; - uint32 vertex_struct_id; + ResourceId vertex_struct_id; uint32 input_index; - uint32 vertex_buffer_id; + ResourceId vertex_buffer_id; uint32 offset; - uint32 fixme4; + uint32 type_stride_semantic; }; COMPILE_ASSERT(sizeof(SetVertexInput) == 24, @@ -1228,8 +1122,8 @@ COMPILE_ASSERT(offsetof(SetVertexInput, vertex_buffer_id) == 12, OffsetOf_SetVertexInput_vertex_buffer_id_not_12); COMPILE_ASSERT(offsetof(SetVertexInput, offset) == 16, OffsetOf_SetVertexInput_offset_not_16); -COMPILE_ASSERT(offsetof(SetVertexInput, fixme4) == 20, - OffsetOf_SetVertexInput_fixme4_not_20); +COMPILE_ASSERT(offsetof(SetVertexInput, type_stride_semantic) == 20, + OffsetOf_SetVertexInput_type_stride_semantic_not_20); struct SetVertexStruct { typedef SetVertexStruct ValueType; @@ -1240,26 +1134,26 @@ struct SetVertexStruct { header.SetCmd<ValueType>(); } - void Init(uint32 _id) { + void Init(ResourceId _vertex_struct_id) { SetHeader(); - id = _id; + vertex_struct_id = _vertex_struct_id; } - static void* Set(void* cmd, uint32 id) { - static_cast<ValueType*>(cmd)->Init(id); + static void* Set(void* cmd, ResourceId vertex_struct_id) { + static_cast<ValueType*>(cmd)->Init(vertex_struct_id); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId vertex_struct_id; }; COMPILE_ASSERT(sizeof(SetVertexStruct) == 8, Sizeof_SetVertexStruct_is_not_8); COMPILE_ASSERT(offsetof(SetVertexStruct, header) == 0, OffsetOf_SetVertexStruct_header_not_0); -COMPILE_ASSERT(offsetof(SetVertexStruct, id) == 4, - OffsetOf_SetVertexStruct_id_not_4); +COMPILE_ASSERT(offsetof(SetVertexStruct, vertex_struct_id) == 4, + OffsetOf_SetVertexStruct_vertex_struct_id_not_4); struct Draw { typedef Draw ValueType; @@ -1270,14 +1164,14 @@ struct Draw { header.SetCmd<ValueType>(); } - void Init(uint32 _primitive_type, uint32 _first, uint32 _count) { + void Init(PrimitiveType _primitive_type, uint32 _first, uint32 _count) { SetHeader(); primitive_type = _primitive_type; first = _first; count = _count; } - static void* Set(void* cmd, uint32 primitive_type, uint32 first, + static void* Set(void* cmd, PrimitiveType primitive_type, uint32 first, uint32 count) { static_cast<ValueType*>(cmd)->Init(primitive_type, first, count); return NextCmdAddress<ValueType>(cmd); @@ -1309,8 +1203,8 @@ struct DrawIndexed { } void Init( - uint32 _primitive_type, - uint32 _index_buffer_id, + PrimitiveType _primitive_type, + ResourceId _index_buffer_id, uint32 _first, uint32 _count, uint32 _min_index, @@ -1325,8 +1219,8 @@ struct DrawIndexed { } static void* Set(void* cmd, - uint32 primitive_type, - uint32 index_buffer_id, + PrimitiveType primitive_type, + ResourceId index_buffer_id, uint32 first, uint32 count, uint32 min_index, @@ -1343,7 +1237,7 @@ struct DrawIndexed { CommandHeader header; uint32 primitive_type; - uint32 index_buffer_id; + ResourceId index_buffer_id; uint32 first; uint32 count; uint32 min_index; @@ -1375,23 +1269,23 @@ struct CreateEffect { header.SetCmd<ValueType>(); } - void Init(uint32 _id, uint32 _size, + void Init(ResourceId _effect_id, uint32 _size, uint32 shared_memory_id, uint32 shared_memory_offset) { SetHeader(); - id = _id; + effect_id = _effect_id; size = _size; shared_memory.Init(shared_memory_id, shared_memory_offset); } - static void* Set(void* cmd, uint32 id, uint32 size, + static void* Set(void* cmd, ResourceId effect_id, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { - static_cast<ValueType*>(cmd)->Init(id, size, + static_cast<ValueType*>(cmd)->Init(effect_id, size, shared_memory_id, shared_memory_offset); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId effect_id; uint32 size; SharedMemory shared_memory; }; @@ -1399,8 +1293,8 @@ struct CreateEffect { COMPILE_ASSERT(sizeof(CreateEffect) == 20, Sizeof_CreateEffect_is_not_20); COMPILE_ASSERT(offsetof(CreateEffect, header) == 0, OffsetOf_CreateEffect_header_not_0); -COMPILE_ASSERT(offsetof(CreateEffect, id) == 4, - OffsetOf_CreateEffect_id_not_4); +COMPILE_ASSERT(offsetof(CreateEffect, effect_id) == 4, + OffsetOf_CreateEffect_effect_id_not_4); COMPILE_ASSERT(offsetof(CreateEffect, size) == 8, OffsetOf_CreateEffect_size_not_8); COMPILE_ASSERT(offsetof(CreateEffect, shared_memory) == 12, @@ -1415,19 +1309,20 @@ struct CreateEffectImmediate { header.SetCmdBySize<ValueType>(size); } - void Init(uint32 _id, uint32 _size, const void* data) { + void Init(ResourceId _effect_id, uint32 _size, const void* data) { SetHeader(_size); - id = _id; + effect_id = _effect_id; size = _size; } - static void* Set(void* cmd, uint32 id, uint32 size, const void* data) { - static_cast<ValueType*>(cmd)->Init(id, size, data); + static void* Set(void* cmd, + ResourceId effect_id, uint32 size, const void* data) { + static_cast<ValueType*>(cmd)->Init(effect_id, size, data); return NextImmediateCmdAddress<ValueType>(cmd, size); } CommandHeader header; - uint32 id; + ResourceId effect_id; uint32 size; }; @@ -1435,8 +1330,8 @@ COMPILE_ASSERT(sizeof(CreateEffectImmediate) == 12, Sizeof_CreateEffectImmediate_is_not_12); COMPILE_ASSERT(offsetof(CreateEffectImmediate, header) == 0, OffsetOf_CreateEffectImmediate_header_not_0); -COMPILE_ASSERT(offsetof(CreateEffectImmediate, id) == 4, - OffsetOf_CreateEffectImmediate_id_not_4); +COMPILE_ASSERT(offsetof(CreateEffectImmediate, effect_id) == 4, + OffsetOf_CreateEffectImmediate_effect_id_not_4); COMPILE_ASSERT(offsetof(CreateEffectImmediate, size) == 8, OffsetOf_CreateEffectImmediate_size_not_8); @@ -1449,25 +1344,25 @@ struct DestroyEffect { header.SetCmd<ValueType>(); } - void Init(uint32 _id) { + void Init(ResourceId _effect_id) { SetHeader(); - id = _id; + effect_id = _effect_id; } - static void* Set(void* cmd, uint32 id) { - static_cast<ValueType*>(cmd)->Init(id); + static void* Set(void* cmd, ResourceId effect_id) { + static_cast<ValueType*>(cmd)->Init(effect_id); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId effect_id; }; COMPILE_ASSERT(sizeof(DestroyEffect) == 8, Sizeof_DestroyEffect_is_not_8); COMPILE_ASSERT(offsetof(DestroyEffect, header) == 0, OffsetOf_DestroyEffect_header_not_0); -COMPILE_ASSERT(offsetof(DestroyEffect, id) == 4, - OffsetOf_DestroyEffect_id_not_4); +COMPILE_ASSERT(offsetof(DestroyEffect, effect_id) == 4, + OffsetOf_DestroyEffect_effect_id_not_4); struct SetEffect { typedef SetEffect ValueType; @@ -1478,25 +1373,25 @@ struct SetEffect { header.SetCmd<ValueType>(); } - void Init(uint32 _id) { + void Init(ResourceId _effect_id) { SetHeader(); - id = _id; + effect_id = _effect_id; } - static void* Set(void* cmd, uint32 id) { - static_cast<ValueType*>(cmd)->Init(id); + static void* Set(void* cmd, ResourceId effect_id) { + static_cast<ValueType*>(cmd)->Init(effect_id); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId effect_id; }; COMPILE_ASSERT(sizeof(SetEffect) == 8, Sizeof_SetEffect_is_not_8); COMPILE_ASSERT(offsetof(SetEffect, header) == 0, OffsetOf_SetEffect_header_not_0); -COMPILE_ASSERT(offsetof(SetEffect, id) == 4, - OffsetOf_SetEffect_id_not_4); +COMPILE_ASSERT(offsetof(SetEffect, effect_id) == 4, + OffsetOf_SetEffect_effect_id_not_4); struct GetParamCount { typedef GetParamCount ValueType; @@ -1507,23 +1402,23 @@ struct GetParamCount { header.SetCmd<ValueType>(); } - void Init(uint32 _id, uint32 _size, + void Init(ResourceId _effect_id, uint32 _size, uint32 shared_memory_id, uint32 shared_memory_offset) { SetHeader(); - id = _id; + effect_id = _effect_id; size = _size; shared_memory.Init(shared_memory_id, shared_memory_offset); } - static void* Set(void* cmd, uint32 id, uint32 size, + static void* Set(void* cmd, ResourceId effect_id, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { - static_cast<ValueType*>(cmd)->Init(id, size, + static_cast<ValueType*>(cmd)->Init(effect_id, size, shared_memory_id, shared_memory_offset); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId effect_id; uint32 size; SharedMemory shared_memory; }; @@ -1531,8 +1426,8 @@ struct GetParamCount { COMPILE_ASSERT(sizeof(GetParamCount) == 20, Sizeof_GetParamCount_is_not_20); COMPILE_ASSERT(offsetof(GetParamCount, header) == 0, OffsetOf_GetParamCount_header_not_0); -COMPILE_ASSERT(offsetof(GetParamCount, id) == 4, - OffsetOf_GetParamCount_id_not_4); +COMPILE_ASSERT(offsetof(GetParamCount, effect_id) == 4, + OffsetOf_GetParamCount_effect_id_not_4); COMPILE_ASSERT(offsetof(GetParamCount, size) == 8, OffsetOf_GetParamCount_size_not_8); COMPILE_ASSERT(offsetof(GetParamCount, shared_memory) == 12, @@ -1547,7 +1442,7 @@ struct CreateParam { header.SetCmd<ValueType>(); } - void Init(uint32 _param_id, uint32 _effect_id, uint32 _index) { + void Init(ResourceId _param_id, ResourceId _effect_id, uint32 _index) { SetHeader(); param_id = _param_id; effect_id = _effect_id; @@ -1555,14 +1450,14 @@ struct CreateParam { } static void* Set(void* cmd, - uint32 param_id, uint32 effect_id, uint32 index) { + ResourceId param_id, ResourceId effect_id, uint32 index) { static_cast<ValueType*>(cmd)->Init(param_id, effect_id, index); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 param_id; - uint32 effect_id; + ResourceId param_id; + ResourceId effect_id; uint32 index; }; @@ -1585,7 +1480,7 @@ struct CreateParamByName { header.SetCmd<ValueType>(); } - void Init(uint32 _param_id, uint32 _effect_id, uint32 _size, + void Init(ResourceId _param_id, ResourceId _effect_id, uint32 _size, uint32 shared_memory_id, uint32 shared_memory_offset) { SetHeader(); param_id = _param_id; @@ -1594,7 +1489,8 @@ struct CreateParamByName { shared_memory.Init(shared_memory_id, shared_memory_offset); } - static void* Set(void* cmd, uint32 param_id, uint32 effect_id, uint32 size, + static void* Set(void* cmd, ResourceId param_id, ResourceId effect_id, + uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { static_cast<ValueType*>(cmd)->Init(param_id, effect_id, size, shared_memory_id, shared_memory_offset); @@ -1602,8 +1498,8 @@ struct CreateParamByName { } CommandHeader header; - uint32 param_id; - uint32 effect_id; + ResourceId param_id; + ResourceId effect_id; uint32 size; SharedMemory shared_memory; }; @@ -1630,7 +1526,7 @@ struct CreateParamByNameImmediate { header.SetCmdBySize<ValueType>(size); } - void Init(uint32 _param_id, uint32 _effect_id, uint32 _size, + void Init(ResourceId _param_id, ResourceId _effect_id, uint32 _size, const void* data) { SetHeader(_size); param_id = _param_id; @@ -1639,15 +1535,15 @@ struct CreateParamByNameImmediate { memcpy(ImmediateDataAddress(this), data, _size); } - static void* Set(void* cmd, uint32 param_id, uint32 effect_id, uint32 size, - const void* data) { + static void* Set(void* cmd, ResourceId param_id, ResourceId effect_id, + uint32 size, const void* data) { static_cast<ValueType*>(cmd)->Init(param_id, effect_id, size, data); return NextImmediateCmdAddress<ValueType>(cmd, size); } CommandHeader header; - uint32 param_id; - uint32 effect_id; + ResourceId param_id; + ResourceId effect_id; uint32 size; }; @@ -1671,25 +1567,25 @@ struct DestroyParam { header.SetCmd<ValueType>(); } - void Init(uint32 _id) { + void Init(ResourceId _param_id) { SetHeader(); - id = _id; + param_id = _param_id; } - static void* Set(void* cmd, uint32 id) { - static_cast<ValueType*>(cmd)->Init(id); + static void* Set(void* cmd, ResourceId param_id) { + static_cast<ValueType*>(cmd)->Init(param_id); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId param_id; }; COMPILE_ASSERT(sizeof(DestroyParam) == 8, Sizeof_DestroyParam_is_not_8); COMPILE_ASSERT(offsetof(DestroyParam, header) == 0, OffsetOf_DestroyParam_header_not_0); -COMPILE_ASSERT(offsetof(DestroyParam, id) == 4, - OffsetOf_DestroyParam_id_not_4); +COMPILE_ASSERT(offsetof(DestroyParam, param_id) == 4, + OffsetOf_DestroyParam_param_id_not_4); struct SetParamData { typedef SetParamData ValueType; @@ -1700,23 +1596,23 @@ struct SetParamData { header.SetCmd<ValueType>(); } - void Init(uint32 _id, uint32 _size, + void Init(ResourceId _param_id, uint32 _size, uint32 shared_memory_id, uint32 shared_memory_offset) { SetHeader(); - id = _id; + param_id = _param_id; size = _size; shared_memory.Init(shared_memory_id, shared_memory_offset); } - static void* Set(void* cmd, uint32 id, uint32 size, + static void* Set(void* cmd, ResourceId param_id, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { - static_cast<ValueType*>(cmd)->Init(id, size, + static_cast<ValueType*>(cmd)->Init(param_id, size, shared_memory_id, shared_memory_offset); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId param_id; uint32 size; SharedMemory shared_memory; }; @@ -1724,8 +1620,8 @@ struct SetParamData { COMPILE_ASSERT(sizeof(SetParamData) == 20, Sizeof_SetParamData_is_not_20); COMPILE_ASSERT(offsetof(SetParamData, header) == 0, OffsetOf_SetParamData_header_not_0); -COMPILE_ASSERT(offsetof(SetParamData, id) == 4, - OffsetOf_SetParamData_id_not_4); +COMPILE_ASSERT(offsetof(SetParamData, param_id) == 4, + OffsetOf_SetParamData_param_id_not_4); COMPILE_ASSERT(offsetof(SetParamData, size) == 8, OffsetOf_SetParamData_size_not_8); COMPILE_ASSERT(offsetof(SetParamData, shared_memory) == 12, @@ -1740,20 +1636,21 @@ struct SetParamDataImmediate { header.SetCmdBySize<ValueType>(size); } - void Init(uint32 _id, uint32 _size, const void* data) { + void Init(ResourceId _param_id, uint32 _size, const void* data) { SetHeader(_size); - id = _id; + param_id = _param_id; size = _size; memcpy(ImmediateDataAddress(this), data, _size); } - static void* Set(void* cmd, uint32 id, uint32 size, const void* data) { - static_cast<ValueType*>(cmd)->Init(id, size, data); + static void* Set(void* cmd, ResourceId param_id, + uint32 size, const void* data) { + static_cast<ValueType*>(cmd)->Init(param_id, size, data); return NextImmediateCmdAddress<ValueType>(cmd, size); } CommandHeader header; - uint32 id; + ResourceId param_id; uint32 size; }; @@ -1761,8 +1658,8 @@ COMPILE_ASSERT(sizeof(SetParamDataImmediate) == 12, Sizeof_SetParamDataImmediate_is_not_12); COMPILE_ASSERT(offsetof(SetParamDataImmediate, header) == 0, OffsetOf_SetParamDataImmediate_header_not_0); -COMPILE_ASSERT(offsetof(SetParamDataImmediate, id) == 4, - OffsetOf_SetParamDataImmediate_id_not_4); +COMPILE_ASSERT(offsetof(SetParamDataImmediate, param_id) == 4, + OffsetOf_SetParamDataImmediate_param_id_not_4); COMPILE_ASSERT(offsetof(SetParamDataImmediate, size) == 8, OffsetOf_SetParamDataImmediate_size_not_8); @@ -1775,23 +1672,23 @@ struct GetParamDesc { header.SetCmd<ValueType>(); } - void Init(uint32 _id, uint32 _size, + void Init(ResourceId _param_id, uint32 _size, uint32 shared_memory_id, uint32 shared_memory_offset) { SetHeader(); - id = _id; + param_id = _param_id; size = _size; shared_memory.Init(shared_memory_id, shared_memory_offset); } - static void* Set(void* cmd, uint32 id, uint32 size, + static void* Set(void* cmd, ResourceId param_id, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { - static_cast<ValueType*>(cmd)->Init(id, size, + static_cast<ValueType*>(cmd)->Init(param_id, size, shared_memory_id, shared_memory_offset); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId param_id; uint32 size; SharedMemory shared_memory; }; @@ -1799,7 +1696,7 @@ struct GetParamDesc { COMPILE_ASSERT(sizeof(GetParamDesc) == 20, Sizeof_GetParamDesc_is_not_20); COMPILE_ASSERT(offsetof(GetParamDesc, header) == 0, OffsetOf_GetParamDesc_header_not_0); -COMPILE_ASSERT(offsetof(GetParamDesc, id) == 4, +COMPILE_ASSERT(offsetof(GetParamDesc, param_id) == 4, OffsetOf_GetParamDesc_id_not_4); COMPILE_ASSERT(offsetof(GetParamDesc, size) == 8, OffsetOf_GetParamDesc_size_not_8); @@ -1815,23 +1712,23 @@ struct GetStreamCount { header.SetCmd<ValueType>(); } - void Init(uint32 _id, uint32 _size, + void Init(ResourceId _effect_id, uint32 _size, uint32 shared_memory_id, uint32 shared_memory_offset) { SetHeader(); - id = _id; + effect_id = _effect_id; size = _size; shared_memory.Init(shared_memory_id, shared_memory_offset); } - static void* Set(void* cmd, uint32 id, uint32 size, + static void* Set(void* cmd, ResourceId effect_id, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { - static_cast<ValueType*>(cmd)->Init(id, size, + static_cast<ValueType*>(cmd)->Init(effect_id, size, shared_memory_id, shared_memory_offset); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId effect_id; uint32 size; SharedMemory shared_memory; }; @@ -1840,8 +1737,8 @@ COMPILE_ASSERT(sizeof(GetStreamCount) == 20, Sizeof_GetStreamCount_is_not_20); COMPILE_ASSERT(offsetof(GetStreamCount, header) == 0, OffsetOf_GetStreamCount_header_not_0); -COMPILE_ASSERT(offsetof(GetStreamCount, id) == 4, - OffsetOf_GetStreamCount_id_not_4); +COMPILE_ASSERT(offsetof(GetStreamCount, effect_id) == 4, + OffsetOf_GetStreamCount_effect_id_not_4); COMPILE_ASSERT(offsetof(GetStreamCount, size) == 8, OffsetOf_GetStreamCount_size_not_8); COMPILE_ASSERT(offsetof(GetStreamCount, shared_memory) == 12, @@ -1856,24 +1753,24 @@ struct GetStreamDesc { header.SetCmd<ValueType>(); } - void Init(uint32 _id, uint32 _index, uint32 _size, + void Init(ResourceId _effect_id, uint32 _index, uint32 _size, uint32 shared_memory_id, uint32 shared_memory_offset) { SetHeader(); - id = _id; + effect_id = _effect_id; index = _index; size = _size; shared_memory.Init(shared_memory_id, shared_memory_offset); } - static void* Set(void* cmd, uint32 id, uint32 index, uint32 size, + static void* Set(void* cmd, ResourceId effect_id, uint32 index, uint32 size, uint32 shared_memory_id, uint32 shared_memory_offset) { - static_cast<ValueType*>(cmd)->Init(id, index, size, + static_cast<ValueType*>(cmd)->Init(effect_id, index, size, shared_memory_id, shared_memory_offset); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId effect_id; uint32 index; uint32 size; SharedMemory shared_memory; @@ -1882,8 +1779,8 @@ struct GetStreamDesc { COMPILE_ASSERT(sizeof(GetStreamDesc) == 24, Sizeof_GetStreamDesc_is_not_24); COMPILE_ASSERT(offsetof(GetStreamDesc, header) == 0, OffsetOf_GetStreamDesc_header_not_0); -COMPILE_ASSERT(offsetof(GetStreamDesc, id) ==4 , - OffsetOf_GetStreamDesc_id_not_4); +COMPILE_ASSERT(offsetof(GetStreamDesc, effect_id) ==4 , + OffsetOf_GetStreamDesc_effect_id_not_4); COMPILE_ASSERT(offsetof(GetStreamDesc, index) == 8, OffsetOf_GetStreamDesc_index_not_8); COMPILE_ASSERT(offsetof(GetStreamDesc, size) == 12, @@ -1900,52 +1797,61 @@ struct DestroyTexture { header.SetCmd<ValueType>(); } - void Init(uint32 _id) { + void Init(ResourceId _texture_id) { SetHeader(); - id = _id; + texture_id = _texture_id; } - static void* Set(void* cmd, uint32 id) { - static_cast<ValueType*>(cmd)->Init(id); + static void* Set(void* cmd, ResourceId texture_id) { + static_cast<ValueType*>(cmd)->Init(texture_id); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId texture_id; }; COMPILE_ASSERT(sizeof(DestroyTexture) == 8, Sizeof_DestroyTexture_is_not_8); COMPILE_ASSERT(offsetof(DestroyTexture, header) == 0, OffsetOf_DestroyTexture_header_not_0); -COMPILE_ASSERT(offsetof(DestroyTexture, id) == 4, - OffsetOf_DestroyTexture_id_not_4); +COMPILE_ASSERT(offsetof(DestroyTexture, texture_id) == 4, + OffsetOf_DestroyTexture_texture_id_not_4); struct CreateTexture2d { typedef CreateTexture2d ValueType; static const CommandId kCmdId = command_buffer::kCreateTexture2d; static const ArgFlags kArgFlags = kFixed; + // argument 1 + typedef BitField<0, 16> Width; + typedef BitField<16, 16> Height; + // argument 2 + typedef BitField<0, 4> Levels; + typedef BitField<4, 4> Unused; + typedef BitField<8, 8> Format; + typedef BitField<16, 16> Flags; + void SetHeader() { header.SetCmd<ValueType>(); } - void Init(uint32 _texture_id, - uint32 _width, uint32 _height, uint32 _levels, uint32 _format, - uint32 _enable_render_surfaces) { + void Init(ResourceId _texture_id, + uint32 _width, uint32 _height, uint32 _levels, + texture::Format _format, + bool _enable_render_surfaces) { SetHeader(); texture_id = _texture_id; - fixme1 = - create_texture_2d_cmd::Width::MakeValue(_width) | - create_texture_2d_cmd::Height::MakeValue(_height); - fixme2 = - create_texture_2d_cmd::Levels::MakeValue(_levels) | - create_texture_2d_cmd::Format::MakeValue(_format) | - create_texture_2d_cmd::Flags::MakeValue(_enable_render_surfaces); - } - - static void* Set(void* cmd, uint32 texture_id, - uint32 width, uint32 height, uint32 levels, uint32 format, - uint32 enable_render_surfaces) { + width_height = Width::MakeValue(_width) | Height::MakeValue(_height); + levels_format_flags = + Levels::MakeValue(_levels) | + Format::MakeValue(_format) | + Flags::MakeValue(_enable_render_surfaces ? 1 : 0); + } + + static void* Set(void* cmd, ResourceId texture_id, + uint32 width, uint32 height, uint32 levels, + texture::Format format, + bool enable_render_surfaces) { static_cast<ValueType*>(cmd)->Init(texture_id, width, height, levels, format, enable_render_surfaces); @@ -1954,9 +1860,9 @@ struct CreateTexture2d { // TODO(gman): fix this to not use obfusticated fields. CommandHeader header; - uint32 texture_id; - uint32 fixme1; - uint32 fixme2; + ResourceId texture_id; + uint32 width_height; + uint32 levels_format_flags; }; COMPILE_ASSERT(sizeof(CreateTexture2d) == 16, @@ -1965,41 +1871,50 @@ COMPILE_ASSERT(offsetof(CreateTexture2d, header) == 0, OffsetOf_CreateTexture2d_header_not_0); COMPILE_ASSERT(offsetof(CreateTexture2d, texture_id) == 4, OffsetOf_CreateTexture2d_texture_id_not_4); -COMPILE_ASSERT(offsetof(CreateTexture2d, fixme1) == 8, - OffsetOf_CreateTexture2d_fixme1_not_8); -COMPILE_ASSERT(offsetof(CreateTexture2d, fixme2) == 12, - OffsetOf_CreateTexture2d_fixme2_not_12); +COMPILE_ASSERT(offsetof(CreateTexture2d, width_height) == 8, + OffsetOf_CreateTexture2d_width_height_not_8); +COMPILE_ASSERT(offsetof(CreateTexture2d, levels_format_flags) == 12, + OffsetOf_CreateTexture2d_levels_format_flags_not_12); struct CreateTexture3d { typedef CreateTexture3d ValueType; static const CommandId kCmdId = command_buffer::kCreateTexture3d; static const ArgFlags kArgFlags = kFixed; + // argument 1 + typedef BitField<0, 16> Width; + typedef BitField<16, 16> Height; + // argument 2 + typedef BitField<0, 16> Depth; + typedef BitField<16, 16> Unused1; + // argument 3 + typedef BitField<0, 4> Levels; + typedef BitField<4, 4> Unused2; + typedef BitField<8, 8> Format; + typedef BitField<16, 16> Flags; + void SetHeader() { header.SetCmd<ValueType>(); } - void Init(uint32 _texture_id, + void Init(ResourceId _texture_id, uint32 _width, uint32 _height, uint32 _depth, - uint32 _levels, uint32 _format, - uint32 _enable_render_surfaces) { + uint32 _levels, texture::Format _format, + bool _enable_render_surfaces) { SetHeader(); texture_id = _texture_id; - fixme1 = - create_texture_3d_cmd::Width::MakeValue(_width) | - create_texture_3d_cmd::Height::MakeValue(_height); - fixme2 = - create_texture_3d_cmd::Depth::MakeValue(_depth); - fixme3 = - create_texture_3d_cmd::Levels::MakeValue(_levels) | - create_texture_3d_cmd::Format::MakeValue(_format) | - create_texture_3d_cmd::Flags::MakeValue(_enable_render_surfaces); - } - - static void* Set(void* cmd, uint32 texture_id, + width_height = Width::MakeValue(_width) | Height::MakeValue(_height); + depth_unused = Depth::MakeValue(_depth); + levels_format_flags = + Levels::MakeValue(_levels) | + Format::MakeValue(_format) | + Flags::MakeValue(_enable_render_surfaces ? 1 : 0); + } + + static void* Set(void* cmd, ResourceId texture_id, uint32 width, uint32 height, uint32 depth, - uint32 levels, uint32 format, - uint32 enable_render_surfaces) { + uint32 levels, texture::Format format, + bool enable_render_surfaces) { static_cast<ValueType*>(cmd)->Init(texture_id, width, height, depth, levels, format, @@ -2009,10 +1924,10 @@ struct CreateTexture3d { // TODO(gman): fix this to not use obfusticated fields. CommandHeader header; - uint32 texture_id; - uint32 fixme1; - uint32 fixme2; - uint32 fixme3; + ResourceId texture_id; + uint32 width_height; + uint32 depth_unused; + uint32 levels_format_flags; }; COMPILE_ASSERT(sizeof(CreateTexture3d) == 20, @@ -2021,37 +1936,46 @@ COMPILE_ASSERT(offsetof(CreateTexture3d, header) == 0, OffsetOf_CreateTexture3d_header_not_0); COMPILE_ASSERT(offsetof(CreateTexture3d, texture_id) == 4, OffsetOf_CreateTexture3d_texture_id_not_4); -COMPILE_ASSERT(offsetof(CreateTexture3d, fixme1) == 8, - OffsetOf_CreateTexture3d_fixme1_not_8); -COMPILE_ASSERT(offsetof(CreateTexture3d, fixme2) == 12, - OffsetOf_CreateTexture3d_fixme2_not_12); -COMPILE_ASSERT(offsetof(CreateTexture3d, fixme3) == 16, - OffsetOf_CreateTexture3d_fixme3_not_16); +COMPILE_ASSERT(offsetof(CreateTexture3d, width_height) == 8, + OffsetOf_CreateTexture3d_width_height_not_8); +COMPILE_ASSERT(offsetof(CreateTexture3d, depth_unused) == 12, + OffsetOf_CreateTexture3d_depth_unused_not_12); +COMPILE_ASSERT(offsetof(CreateTexture3d, levels_format_flags) == 16, + OffsetOf_CreateTexture3d_levels_format_flags_not_16); struct CreateTextureCube { typedef CreateTextureCube ValueType; static const CommandId kCmdId = command_buffer::kCreateTextureCube; static const ArgFlags kArgFlags = kFixed; + // argument 1 + typedef BitField<0, 16> Side; + typedef BitField<16, 16> Unused1; + // argument 2 + typedef BitField<0, 4> Levels; + typedef BitField<4, 4> Unused2; + typedef BitField<8, 8> Format; + typedef BitField<16, 16> Flags; + void SetHeader() { header.SetCmd<ValueType>(); } - void Init(uint32 _texture_id, - uint32 _edge_length, uint32 _levels, uint32 _format, - uint32 _enable_render_surfaces) { + void Init(ResourceId _texture_id, + uint32 _edge_length, uint32 _levels, texture::Format _format, + bool _enable_render_surfaces) { SetHeader(); texture_id = _texture_id; edge_length = _edge_length; - fixme2 = - create_texture_2d_cmd::Levels::MakeValue(_levels) | - create_texture_2d_cmd::Format::MakeValue(_format) | - create_texture_2d_cmd::Flags::MakeValue(_enable_render_surfaces); + levels_format_flags = + Levels::MakeValue(_levels) | + Format::MakeValue(_format) | + Flags::MakeValue(_enable_render_surfaces ? 1 : 0); } - static void* Set(void* cmd, uint32 texture_id, - uint32 edge_length, uint32 levels, uint32 format, - uint32 enable_render_surfaces) { + static void* Set(void* cmd, ResourceId texture_id, + uint32 edge_length, uint32 levels, texture::Format format, + bool enable_render_surfaces) { static_cast<ValueType*>(cmd)->Init(texture_id, edge_length, levels, format, enable_render_surfaces); @@ -2060,9 +1984,9 @@ struct CreateTextureCube { // TODO(gman): fix this to not use obfusticated fields. CommandHeader header; - uint32 texture_id; + ResourceId texture_id; uint32 edge_length; - uint32 fixme2; + uint32 levels_format_flags; }; COMPILE_ASSERT(sizeof(CreateTextureCube) == 16, @@ -2073,20 +1997,34 @@ COMPILE_ASSERT(offsetof(CreateTextureCube, texture_id) == 4, OffsetOf_CreateTextureCube_texture_id_not_4); COMPILE_ASSERT(offsetof(CreateTextureCube, edge_length) == 8, OffsetOf_CreateTextureCube_edge_length_not_8); -COMPILE_ASSERT(offsetof(CreateTextureCube, fixme2) == 12, - OffsetOf_CreateTextureCube_fixme2_not_12); +COMPILE_ASSERT(offsetof(CreateTextureCube, levels_format_flags) == 12, + OffsetOf_CreateTextureCube_levels_format_flags_not_12); struct SetTextureData { typedef SetTextureData ValueType; static const CommandId kCmdId = command_buffer::kSetTextureData; static const ArgFlags kArgFlags = kFixed; + // argument 1 + typedef BitField<0, 16> X; + typedef BitField<16, 16> Y; + // argument 2 + typedef BitField<0, 16> Width; + typedef BitField<16, 16> Height; + // argument 3 + typedef BitField<0, 16> Z; + typedef BitField<16, 16> Depth; + // argument 4 + typedef BitField<0, 4> Level; + typedef BitField<4, 3> Face; + typedef BitField<7, 25> Unused; + void SetHeader() { header.SetCmd<ValueType>(); } void Init( - uint32 _texture_id, + ResourceId _texture_id, uint32 _x, uint32 _y, uint32 _z, @@ -2094,7 +2032,7 @@ struct SetTextureData { uint32 _height, uint32 _depth, uint32 _level, - uint32 _face, + texture::Face _face, uint32 _row_pitch, uint32 _slice_pitch, uint32 _size, @@ -2102,18 +2040,10 @@ struct SetTextureData { uint32 shared_memory_offset) { SetHeader(); texture_id = _texture_id; - fixme1 = - set_texture_data_cmd::X::MakeValue(_x) | - set_texture_data_cmd::Y::MakeValue(_y); - fixme2 = - set_texture_data_cmd::Width::MakeValue(_width) | - set_texture_data_cmd::Height::MakeValue(_height); - fixme3 = - set_texture_data_cmd::Z::MakeValue(_z) | - set_texture_data_cmd::Depth::MakeValue(_depth); - fixme4 = - set_texture_data_cmd::Level::MakeValue(_level) | - set_texture_data_cmd::Face::MakeValue(_face); + x_y = X::MakeValue(_x) | Y::MakeValue(_y); + width_height = Width::MakeValue(_width) | Height::MakeValue(_height); + z_depth = Z::MakeValue(_z) | Depth::MakeValue(_depth); + level_face = Level::MakeValue(_level) | Face::MakeValue(_face); row_pitch = _row_pitch; slice_pitch = _slice_pitch; size = _size; @@ -2122,7 +2052,7 @@ struct SetTextureData { static void* Set( void* cmd, - uint32 texture_id, + ResourceId texture_id, uint32 x, uint32 y, uint32 z, @@ -2130,7 +2060,7 @@ struct SetTextureData { uint32 height, uint32 depth, uint32 level, - uint32 face, + texture::Face face, uint32 row_pitch, uint32 slice_pitch, uint32 size, @@ -2156,11 +2086,11 @@ struct SetTextureData { // TODO(gman): fix this to not use obfusticated fields. CommandHeader header; - uint32 texture_id; - uint32 fixme1; - uint32 fixme2; - uint32 fixme3; - uint32 fixme4; + ResourceId texture_id; + uint32 x_y; + uint32 width_height; + uint32 z_depth; + uint32 level_face; uint32 row_pitch; uint32 slice_pitch; uint32 size; @@ -2173,14 +2103,14 @@ COMPILE_ASSERT(offsetof(SetTextureData, header) == 0, OffsetOf_SetTextureData_header_not_0); COMPILE_ASSERT(offsetof(SetTextureData, texture_id) == 4, OffsetOf_SetTextureData_texture_id_not_4); -COMPILE_ASSERT(offsetof(SetTextureData, fixme1) == 8, - OffsetOf_SetTextureData_fixme1_not_8); -COMPILE_ASSERT(offsetof(SetTextureData, fixme2) == 12, - OffsetOf_SetTextureData_fixme2_not_12); -COMPILE_ASSERT(offsetof(SetTextureData, fixme3) == 16, - OffsetOf_SetTextureData_fixme3_not_16); -COMPILE_ASSERT(offsetof(SetTextureData, fixme4) == 20, - OffsetOf_SetTextureData_fixme4_not_20); +COMPILE_ASSERT(offsetof(SetTextureData, x_y) == 8, + OffsetOf_SetTextureData_x_y_not_8); +COMPILE_ASSERT(offsetof(SetTextureData, width_height) == 12, + OffsetOf_SetTextureData_width_height_not_12); +COMPILE_ASSERT(offsetof(SetTextureData, z_depth) == 16, + OffsetOf_SetTextureData_z_depth_not_16); +COMPILE_ASSERT(offsetof(SetTextureData, level_face) == 20, + OffsetOf_SetTextureData_level_face_not_20); COMPILE_ASSERT(offsetof(SetTextureData, row_pitch) == 24, OffsetOf_SetTextureData_row_pitch_not_24); COMPILE_ASSERT(offsetof(SetTextureData, slice_pitch) == 28, @@ -2195,12 +2125,26 @@ struct SetTextureDataImmediate { static const CommandId kCmdId = command_buffer::kSetTextureDataImmediate; static const ArgFlags kArgFlags = kAtLeastN; + // argument 1 + typedef BitField<0, 16> X; + typedef BitField<16, 16> Y; + // argument 2 + typedef BitField<0, 16> Width; + typedef BitField<16, 16> Height; + // argument 3 + typedef BitField<0, 16> Z; + typedef BitField<16, 16> Depth; + // argument 4 + typedef BitField<0, 4> Level; + typedef BitField<4, 3> Face; + typedef BitField<7, 25> Unused; + void SetHeader(uint32 size) { header.SetCmdBySize<ValueType>(size); } void Init( - uint32 _texture_id, + ResourceId _texture_id, uint32 _x, uint32 _y, uint32 _z, @@ -2208,25 +2152,17 @@ struct SetTextureDataImmediate { uint32 _height, uint32 _depth, uint32 _level, - uint32 _face, + texture::Face _face, uint32 _row_pitch, uint32 _slice_pitch, uint32 _size, const void* data) { SetHeader(_size); texture_id = _texture_id; - fixme1 = - set_texture_data_cmd::X::MakeValue(_x) | - set_texture_data_cmd::Y::MakeValue(_y); - fixme2 = - set_texture_data_cmd::Width::MakeValue(_width) | - set_texture_data_cmd::Height::MakeValue(_height); - fixme3 = - set_texture_data_cmd::Z::MakeValue(_z) | - set_texture_data_cmd::Depth::MakeValue(_depth); - fixme4 = - set_texture_data_cmd::Level::MakeValue(_level) | - set_texture_data_cmd::Face::MakeValue(_face); + x_y = X::MakeValue(_x) | Y::MakeValue(_y); + width_height = Width::MakeValue(_width) | Height::MakeValue(_height); + z_depth = Z::MakeValue(_z) | Depth::MakeValue(_depth); + level_face = Level::MakeValue(_level) | Face::MakeValue(_face); row_pitch = _row_pitch; slice_pitch = _slice_pitch; size = _size; @@ -2235,7 +2171,7 @@ struct SetTextureDataImmediate { static void* Set( void* cmd, - uint32 texture_id, + ResourceId texture_id, uint32 x, uint32 y, uint32 z, @@ -2243,7 +2179,7 @@ struct SetTextureDataImmediate { uint32 height, uint32 depth, uint32 level, - uint32 face, + texture::Face face, uint32 row_pitch, uint32 slice_pitch, uint32 size, @@ -2267,11 +2203,11 @@ struct SetTextureDataImmediate { // TODO(gman): fix this to not use obfusticated fields. CommandHeader header; - uint32 texture_id; - uint32 fixme1; - uint32 fixme2; - uint32 fixme3; - uint32 fixme4; + ResourceId texture_id; + uint32 x_y; + uint32 width_height; + uint32 z_depth; + uint32 level_face; uint32 row_pitch; uint32 slice_pitch; uint32 size; @@ -2283,14 +2219,14 @@ COMPILE_ASSERT(offsetof(SetTextureDataImmediate, header) == 0, OffsetOf_SetTextureDataImmediate_header_not_0); COMPILE_ASSERT(offsetof(SetTextureDataImmediate, texture_id) == 4, OffsetOf_SetTextureDataImmediate_texture_id_not_4); -COMPILE_ASSERT(offsetof(SetTextureDataImmediate, fixme1) == 8, - OffsetOf_SetTextureDataImmediate_fixme1_not_8); -COMPILE_ASSERT(offsetof(SetTextureDataImmediate, fixme2) == 12, - OffsetOf_SetTextureDataImmediate_fixme2_not_12); -COMPILE_ASSERT(offsetof(SetTextureDataImmediate, fixme3) == 16, - OffsetOf_SetTextureDataImmediate_fixme3_not_16); -COMPILE_ASSERT(offsetof(SetTextureDataImmediate, fixme4) == 20, - OffsetOf_SetTextureDataImmediate_fixme4_not_20); +COMPILE_ASSERT(offsetof(SetTextureDataImmediate, x_y) == 8, + OffsetOf_SetTextureDataImmediate_x_y_not_8); +COMPILE_ASSERT(offsetof(SetTextureDataImmediate, width_height) == 12, + OffsetOf_SetTextureDataImmediate_width_height_not_12); +COMPILE_ASSERT(offsetof(SetTextureDataImmediate, z_depth) == 16, + OffsetOf_SetTextureDataImmediate_z_depth_not_16); +COMPILE_ASSERT(offsetof(SetTextureDataImmediate, level_face) == 20, + OffsetOf_SetTextureDataImmediate_level_face_not_20); COMPILE_ASSERT(offsetof(SetTextureDataImmediate, row_pitch) == 24, OffsetOf_SetTextureDataImmediate_row_pitch_not_24); COMPILE_ASSERT(offsetof(SetTextureDataImmediate, slice_pitch) == 28, @@ -2303,12 +2239,26 @@ struct GetTextureData { static const CommandId kCmdId = command_buffer::kGetTextureData; static const ArgFlags kArgFlags = kFixed; + // argument 1 + typedef BitField<0, 16> X; + typedef BitField<16, 16> Y; + // argument 2 + typedef BitField<0, 16> Width; + typedef BitField<16, 16> Height; + // argument 3 + typedef BitField<0, 16> Z; + typedef BitField<16, 16> Depth; + // argument 4 + typedef BitField<0, 4> Level; + typedef BitField<4, 3> Face; + typedef BitField<7, 25> Unused; + void SetHeader() { header.SetCmd<ValueType>(); } void Init( - uint32 _texture_id, + ResourceId _texture_id, uint32 _x, uint32 _y, uint32 _z, @@ -2316,7 +2266,7 @@ struct GetTextureData { uint32 _height, uint32 _depth, uint32 _level, - uint32 _face, + texture::Face _face, uint32 _row_pitch, uint32 _slice_pitch, uint32 _size, @@ -2324,18 +2274,10 @@ struct GetTextureData { uint32 shared_memory_offset) { SetHeader(); texture_id = _texture_id; - fixme1 = - set_texture_data_cmd::X::MakeValue(_x) | - set_texture_data_cmd::Y::MakeValue(_y); - fixme2 = - set_texture_data_cmd::Width::MakeValue(_width) | - set_texture_data_cmd::Height::MakeValue(_height); - fixme3 = - set_texture_data_cmd::Z::MakeValue(_z) | - set_texture_data_cmd::Depth::MakeValue(_depth); - fixme4 = - set_texture_data_cmd::Level::MakeValue(_level) | - set_texture_data_cmd::Face::MakeValue(_face); + x_y = X::MakeValue(_x) | Y::MakeValue(_y); + width_height = Width::MakeValue(_width) | Height::MakeValue(_height); + z_depth = Z::MakeValue(_z) | Depth::MakeValue(_depth); + level_face = Level::MakeValue(_level) | Face::MakeValue(_face); row_pitch = _row_pitch; slice_pitch = _slice_pitch; size = _size; @@ -2344,7 +2286,7 @@ struct GetTextureData { static void* Set( void* cmd, - uint32 texture_id, + ResourceId texture_id, uint32 x, uint32 y, uint32 z, @@ -2352,7 +2294,7 @@ struct GetTextureData { uint32 height, uint32 depth, uint32 level, - uint32 face, + texture::Face face, uint32 row_pitch, uint32 slice_pitch, uint32 size, @@ -2378,11 +2320,11 @@ struct GetTextureData { // TODO(gman): fix this to not use obfusticated fields. CommandHeader header; - uint32 texture_id; - uint32 fixme1; - uint32 fixme2; - uint32 fixme3; - uint32 fixme4; + ResourceId texture_id; + uint32 x_y; + uint32 width_height; + uint32 z_depth; + uint32 level_face; uint32 row_pitch; uint32 slice_pitch; uint32 size; @@ -2395,14 +2337,14 @@ COMPILE_ASSERT(offsetof(GetTextureData, header) == 0, OffsetOf_GetTextureData_header_not_0); COMPILE_ASSERT(offsetof(GetTextureData, texture_id) == 4, OffsetOf_GetTextureData_texture_id_not_4); -COMPILE_ASSERT(offsetof(GetTextureData, fixme1) == 8, - OffsetOf_GetTextureData_fixme1_not_8); -COMPILE_ASSERT(offsetof(GetTextureData, fixme2) == 12, - OffsetOf_GetTextureData_fixme2_not_12); -COMPILE_ASSERT(offsetof(GetTextureData, fixme3) == 16, - OffsetOf_GetTextureData_fixme3_not_16); -COMPILE_ASSERT(offsetof(GetTextureData, fixme4) == 20, - OffsetOf_GetTextureData_fixme4_not_20); +COMPILE_ASSERT(offsetof(GetTextureData, x_y) == 8, + OffsetOf_GetTextureData_x_y_not_8); +COMPILE_ASSERT(offsetof(GetTextureData, width_height) == 12, + OffsetOf_GetTextureData_width_height_not_12); +COMPILE_ASSERT(offsetof(GetTextureData, z_depth) == 16, + OffsetOf_GetTextureData_z_depth_not_16); +COMPILE_ASSERT(offsetof(GetTextureData, level_face) == 20, + OffsetOf_GetTextureData_level_face_not_20); COMPILE_ASSERT(offsetof(GetTextureData, row_pitch) == 24, OffsetOf_GetTextureData_row_pitch_not_24); COMPILE_ASSERT(offsetof(GetTextureData, slice_pitch) == 28, @@ -2421,25 +2363,25 @@ struct CreateSampler { header.SetCmd<ValueType>(); } - void Init(uint32 _id) { + void Init(ResourceId _sampler_id) { SetHeader(); - id = _id; + sampler_id = _sampler_id; } - static void* Set(void* cmd, uint32 id) { - static_cast<ValueType*>(cmd)->Init(id); + static void* Set(void* cmd, ResourceId sampler_id) { + static_cast<ValueType*>(cmd)->Init(sampler_id); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId sampler_id; }; COMPILE_ASSERT(sizeof(CreateSampler) == 8, Sizeof_CreateSampler_is_not_8); COMPILE_ASSERT(offsetof(CreateSampler, header) == 0, OffsetOf_CreateSampler_header_not_0); -COMPILE_ASSERT(offsetof(CreateSampler, id) == 4, - OffsetOf_CreateSampler_id_not_4); +COMPILE_ASSERT(offsetof(CreateSampler, sampler_id) == 4, + OffsetOf_CreateSampler_sampler_id_not_4); struct DestroySampler { typedef DestroySampler ValueType; @@ -2450,67 +2392,77 @@ struct DestroySampler { header.SetCmd<ValueType>(); } - void Init(uint32 _id) { + void Init(ResourceId _sampler_id) { SetHeader(); - id = _id; + sampler_id = _sampler_id; } - static void* Set(void* cmd, uint32 id) { - static_cast<ValueType*>(cmd)->Init(id); + static void* Set(void* cmd, ResourceId sampler_id) { + static_cast<ValueType*>(cmd)->Init(sampler_id); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId sampler_id; }; COMPILE_ASSERT(sizeof(DestroySampler) == 8, Sizeof_DestroySampler_is_not_8); COMPILE_ASSERT(offsetof(DestroySampler, header) == 0, OffsetOf_DestroySampler_header_not_0); -COMPILE_ASSERT(offsetof(DestroySampler, id) == 4, - OffsetOf_DestroySampler_id_not_4); +COMPILE_ASSERT(offsetof(DestroySampler, sampler_id) == 4, + OffsetOf_DestroySampler_sampler_id_not_4); struct SetSamplerStates { typedef SetSamplerStates ValueType; static const CommandId kCmdId = command_buffer::kSetSamplerStates; static const ArgFlags kArgFlags = kFixed; + // argument 2 + typedef BitField<0, 3> AddressingU; + typedef BitField<3, 3> AddressingV; + typedef BitField<6, 3> AddressingW; + typedef BitField<9, 3> MagFilter; + typedef BitField<12, 3> MinFilter; + typedef BitField<15, 3> MipFilter; + typedef BitField<18, 6> Unused; + typedef BitField<24, 8> MaxAnisotropy; + void SetHeader() { header.SetCmd<ValueType>(); } void Init( - uint32 _id, - uint32 _address_u_value, - uint32 _address_v_value, - uint32 _address_w_value, - uint32 _mag_filter_value, - uint32 _min_filter_value, - uint32 _mip_filter_value, - uint32 _max_anisotropy) { + ResourceId _sampler_id, + sampler::AddressingMode _address_u_value, + sampler::AddressingMode _address_v_value, + sampler::AddressingMode _address_w_value, + sampler::FilteringMode _mag_filter_value, + sampler::FilteringMode _min_filter_value, + sampler::FilteringMode _mip_filter_value, + uint8 _max_anisotropy) { SetHeader(); - id = _id; - fixme1 = - set_sampler_states::AddressingU::MakeValue(_address_u_value) | - set_sampler_states::AddressingV::MakeValue(_address_v_value) | - set_sampler_states::AddressingW::MakeValue(_address_w_value) | - set_sampler_states::MagFilter::MakeValue(_mag_filter_value) | - set_sampler_states::MinFilter::MakeValue(_min_filter_value) | - set_sampler_states::MipFilter::MakeValue(_mip_filter_value) | - set_sampler_states::MaxAnisotropy::MakeValue(_max_anisotropy); + sampler_id = _sampler_id; + sampler_states = + AddressingU::MakeValue(_address_u_value) | + AddressingV::MakeValue(_address_v_value) | + AddressingW::MakeValue(_address_w_value) | + MagFilter::MakeValue(_mag_filter_value) | + MinFilter::MakeValue(_min_filter_value) | + MipFilter::MakeValue(_mip_filter_value) | + MaxAnisotropy::MakeValue(_max_anisotropy); } static void* Set(void* cmd, - uint32 id, - uint32 address_u_value, - uint32 address_v_value, - uint32 address_w_value, - uint32 mag_filter_value, - uint32 min_filter_value, - uint32 mip_filter_value, - uint32 max_anisotropy) { + ResourceId sampler_id, + sampler::AddressingMode address_u_value, + sampler::AddressingMode address_v_value, + sampler::AddressingMode address_w_value, + sampler::FilteringMode mag_filter_value, + sampler::FilteringMode min_filter_value, + sampler::FilteringMode mip_filter_value, + uint8 max_anisotropy) { static_cast<ValueType*>(cmd)->Init( - id, + sampler_id, address_u_value, address_v_value, address_w_value, @@ -2523,18 +2475,18 @@ struct SetSamplerStates { // TODO(gman): fix this to not use obfusticated fields. CommandHeader header; - uint32 id; - uint32 fixme1; + ResourceId sampler_id; + uint32 sampler_states; }; COMPILE_ASSERT(sizeof(SetSamplerStates) == 12, Sizeof_SetSamplerStates_is_not_12); COMPILE_ASSERT(offsetof(SetSamplerStates, header) == 0, OffsetOf_SetSamplerStates_header_not_0); -COMPILE_ASSERT(offsetof(SetSamplerStates, id) == 4, - OffsetOf_SetSamplerStates_id_not_4); -COMPILE_ASSERT(offsetof(SetSamplerStates, fixme1) == 8, - OffsetOf_SetSamplerStates_fixme1_not_8); +COMPILE_ASSERT(offsetof(SetSamplerStates, sampler_id) == 4, + OffsetOf_SetSamplerStates_sampler_id_not_4); +COMPILE_ASSERT(offsetof(SetSamplerStates, sampler_states) == 8, + OffsetOf_SetSamplerStates_sampler_states_not_8); struct SetSamplerBorderColor { typedef SetSamplerBorderColor ValueType; @@ -2545,24 +2497,24 @@ struct SetSamplerBorderColor { header.SetCmd<ValueType>(); } - void Init(uint32 _id, + void Init(ResourceId _sampler_id, float _red, float _green, float _blue, float _alpha) { SetHeader(); - id = _id; + sampler_id = _sampler_id; red = _red; green = _green; blue = _blue; alpha = _alpha; } - static void* Set(void* cmd, uint32 id, + static void* Set(void* cmd, ResourceId sampler_id, float red, float green, float blue, float alpha) { - static_cast<ValueType*>(cmd)->Init(id, red, green, blue, alpha); + static_cast<ValueType*>(cmd)->Init(sampler_id, red, green, blue, alpha); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId sampler_id; float red; float blue; float green; @@ -2573,8 +2525,8 @@ COMPILE_ASSERT(sizeof(SetSamplerBorderColor) == 24, Sizeof_SetSamplerBorderColor_is_not_24); COMPILE_ASSERT(offsetof(SetSamplerBorderColor, header) == 0, OffsetOf_SetSamplerBorderColor_header_not_0); -COMPILE_ASSERT(offsetof(SetSamplerBorderColor, id) == 4, - OffsetOf_SetSamplerBorderColor_id_not_4); +COMPILE_ASSERT(offsetof(SetSamplerBorderColor, sampler_id) == 4, + OffsetOf_SetSamplerBorderColor_sampler_id_not_4); COMPILE_ASSERT(offsetof(SetSamplerBorderColor, red) == 8, OffsetOf_SetSamplerBorderColor_red_not_8); COMPILE_ASSERT(offsetof(SetSamplerBorderColor, blue) == 12, @@ -2593,28 +2545,28 @@ struct SetSamplerTexture { header.SetCmd<ValueType>(); } - void Init(uint32 _id, uint32 _texture_id) { + void Init(ResourceId _sampler_id, ResourceId _texture_id) { SetHeader(); - id = _id; + sampler_id = _sampler_id; texture_id = _texture_id; } - static void* Set(void* cmd, uint32 id, uint32 texture_id) { - static_cast<ValueType*>(cmd)->Init(id, texture_id); + static void* Set(void* cmd, ResourceId sampler_id, ResourceId texture_id) { + static_cast<ValueType*>(cmd)->Init(sampler_id, texture_id); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; - uint32 texture_id; + ResourceId sampler_id; + ResourceId texture_id; }; COMPILE_ASSERT(sizeof(SetSamplerTexture) == 12, Sizeof_SetSamplerTexture_is_not_12); COMPILE_ASSERT(offsetof(SetSamplerTexture, header) == 0, OffsetOf_SetSamplerTexture_header_not_0); -COMPILE_ASSERT(offsetof(SetSamplerTexture, id) == 4, - OffsetOf_SetSamplerTexture_id_not_4); +COMPILE_ASSERT(offsetof(SetSamplerTexture, sampler_id) == 4, + OffsetOf_SetSamplerTexture_sampler_id_not_4); COMPILE_ASSERT(offsetof(SetSamplerTexture, texture_id) == 8, OffsetOf_SetSamplerTexture_texture_id_not_8); @@ -2623,6 +2575,15 @@ struct SetScissor { static const CommandId kCmdId = command_buffer::kSetScissor; static const ArgFlags kArgFlags = kFixed; + // argument 0 + typedef BitField<0, 15> X; + typedef BitField<15, 1> Unused; + typedef BitField<16, 15> Y; + typedef BitField<31, 1> Enable; + // argument 1 + typedef BitField<0, 16> Width; + typedef BitField<16, 16> Height; + void SetHeader() { header.SetCmd<ValueType>(); } @@ -2633,13 +2594,11 @@ struct SetScissor { uint32 _height, bool _enable) { SetHeader(); - fixme0 = - set_scissor::X::MakeValue(_x) | - set_scissor::Y::MakeValue(_y) | - set_scissor::Enable::MakeValue(_enable ? 1 : 0); - fixme1 = - set_scissor::Width::MakeValue(_width) | - set_scissor::Height::MakeValue(_height); + x_y_enable = + X::MakeValue(_x) | + Y::MakeValue(_y) | + Enable::MakeValue(_enable ? 1 : 0); + width_height = Width::MakeValue(_width) | Height::MakeValue(_height); } static void* Set( @@ -2660,17 +2619,17 @@ struct SetScissor { // TODO(gman): fix this to not use obfusticated fields. CommandHeader header; - uint32 fixme0; - uint32 fixme1; + uint32 x_y_enable; + uint32 width_height; }; COMPILE_ASSERT(sizeof(SetScissor) == 12, Sizeof_SetScissor_is_not_12); COMPILE_ASSERT(offsetof(SetScissor, header) == 0, OffsetOf_SetScissor_header_not_0); -COMPILE_ASSERT(offsetof(SetScissor, fixme0) == 4, - OffsetOf_SetScissor_fixme0_not_4); -COMPILE_ASSERT(offsetof(SetScissor, fixme1) == 8, - OffsetOf_SetScissor_fixme1_not_8); +COMPILE_ASSERT(offsetof(SetScissor, x_y_enable) == 4, + OffsetOf_SetScissor_x_y_enable_not_4); +COMPILE_ASSERT(offsetof(SetScissor, width_height) == 8, + OffsetOf_SetScissor_width_height_not_8); struct SetPolygonOffset { typedef SetPolygonOffset ValueType; @@ -2711,6 +2670,11 @@ struct SetPointLineRaster { static const CommandId kCmdId = command_buffer::kSetPointLineRaster; static const ArgFlags kArgFlags = kFixed; + // argument 0 + typedef BitField<0, 1> LineSmoothEnable; + typedef BitField<1, 1> PointSpriteEnable; + typedef BitField<2, 30> Unused; + void SetHeader() { header.SetCmd<ValueType>(); } @@ -2718,11 +2682,9 @@ struct SetPointLineRaster { void Init(bool _line_smooth_enable, bool _point_sprite_enable, float _point_size) { SetHeader(); - fixme0 = - set_point_line_raster::LineSmoothEnable::MakeValue( - _line_smooth_enable ? 1 : 0) | - set_point_line_raster::PointSpriteEnable::MakeValue( - _point_sprite_enable ? 1 : 0); + enables = + LineSmoothEnable::MakeValue( _line_smooth_enable ? 1 : 0) | + PointSpriteEnable::MakeValue(_point_sprite_enable ? 1 : 0); point_size = _point_size; } @@ -2735,7 +2697,7 @@ struct SetPointLineRaster { // TODO(gman): fix this to not use obfusticated fields. CommandHeader header; - uint32 fixme0; + uint32 enables; float point_size; }; @@ -2743,8 +2705,8 @@ COMPILE_ASSERT(sizeof(SetPointLineRaster) == 12, Sizeof_SetPointLineRaster_is_not_12); COMPILE_ASSERT(offsetof(SetPointLineRaster, header) == 0, OffsetOf_SetPointLineRaster_header_not_0); -COMPILE_ASSERT(offsetof(SetPointLineRaster, fixme0) == 4, - OffsetOf_SetPointLineRaster_fixme0_not_4); +COMPILE_ASSERT(offsetof(SetPointLineRaster, enables) == 4, + OffsetOf_SetPointLineRaster_enables_not_4); COMPILE_ASSERT(offsetof(SetPointLineRaster, point_size) == 8, OffsetOf_SetPointLineRaster_point_size_not_8); @@ -2753,67 +2715,74 @@ struct SetPolygonRaster { static const CommandId kCmdId = command_buffer::kSetPolygonRaster; static const ArgFlags kArgFlags = kFixed; + // argument 0 + typedef BitField<0, 2> FillMode; + typedef BitField<2, 2> CullMode; + typedef BitField<4, 28> Unused; + void SetHeader() { header.SetCmd<ValueType>(); } - void Init(uint32 _fill_mode, uint32 _cull_mode) { + void Init(PolygonMode _fill_mode, FaceCullMode _cull_mode) { SetHeader(); - fixme0 = - set_polygon_raster::FillMode::MakeValue(_fill_mode) | - set_polygon_raster::CullMode::MakeValue(_cull_mode); + fill_cull = FillMode::MakeValue(_fill_mode) | + CullMode::MakeValue(_cull_mode); } - static void* Set(void* cmd, uint32 fill_mode, uint32 cull_mode) { + static void* Set(void* cmd, PolygonMode fill_mode, FaceCullMode cull_mode) { static_cast<ValueType*>(cmd)->Init(fill_mode, cull_mode); return NextCmdAddress<ValueType>(cmd); } // TODO(gman): fix this to not use obfusticated fields. CommandHeader header; - uint32 fixme0; + uint32 fill_cull; }; COMPILE_ASSERT(sizeof(SetPolygonRaster) == 8, Sizeof_SetPolygonRaster_is_not_8); COMPILE_ASSERT(offsetof(SetPolygonRaster, header) == 0, OffsetOf_SetPolygonRaster_header_not_0); -COMPILE_ASSERT(offsetof(SetPolygonRaster, fixme0) == 4, - OffsetOf_SetPolygonRaster_fixme0_not_4); +COMPILE_ASSERT(offsetof(SetPolygonRaster, fill_cull) == 4, + OffsetOf_SetPolygonRaster_fill_cull_not_4); struct SetAlphaTest { typedef SetAlphaTest ValueType; static const CommandId kCmdId = command_buffer::kSetAlphaTest; static const ArgFlags kArgFlags = kFixed; + // argument 0 + typedef BitField<0, 3> Func; + typedef BitField<3, 28> Unused; + typedef BitField<31, 1> Enable; + void SetHeader() { header.SetCmd<ValueType>(); } - void Init(uint32 _func, bool _enable, float _value) { + void Init(Comparison _func, bool _enable, float _value) { SetHeader(); - fixme0 = - set_alpha_test::Func::MakeValue(_func) | - set_alpha_test::Enable::MakeValue(_enable ? 1 : 0); + func_enable = Func::MakeValue(_func) | Enable::MakeValue(_enable ? 1 : 0); value = _value; } - static void* Set(void* cmd, uint32 func, bool enable, float value) { + static void* Set(void* cmd, Comparison func, bool enable, float value) { static_cast<ValueType*>(cmd)->Init(func, enable, value); return NextCmdAddress<ValueType>(cmd); } // TODO(gman): fix this to not use obfusticated fields. CommandHeader header; - uint32 fixme0; + uint32 func_enable; float value; }; COMPILE_ASSERT(sizeof(SetAlphaTest) == 12, Sizeof_SetAlphaTest_is_not_12); COMPILE_ASSERT(offsetof(SetAlphaTest, header) == 0, OffsetOf_SetAlphaTest_header_not_0); -COMPILE_ASSERT(offsetof(SetAlphaTest, fixme0) == 4, - OffsetOf_SetAlphaTest_fixme0_not_4); +COMPILE_ASSERT(offsetof(SetAlphaTest, func_enable) == 4, + OffsetOf_SetAlphaTest_func_enable_not_4); COMPILE_ASSERT(offsetof(SetAlphaTest, value) == 8, OffsetOf_SetAlphaTest_value_not_8); @@ -2822,39 +2791,65 @@ struct SetDepthTest { static const CommandId kCmdId = command_buffer::kSetDepthTest; static const ArgFlags kArgFlags = kFixed; + // argument 0 + typedef BitField<0, 3> Func; + typedef BitField<3, 27> Unused; + typedef BitField<30, 1> WriteEnable; + typedef BitField<31, 1> Enable; + void SetHeader() { header.SetCmd<ValueType>(); } - void Init(uint32 _func, bool _write_enable, bool _enable) { + void Init(Comparison _func, bool _write_enable, bool _enable) { SetHeader(); - fixme0 = - set_depth_test::Func::MakeValue(_func) | - set_depth_test::WriteEnable::MakeValue(_write_enable ? 1 : 0) | - set_depth_test::Enable::MakeValue(_enable ? 1 : 0); + func_enable = + Func::MakeValue(_func) | + WriteEnable::MakeValue(_write_enable ? 1 : 0) | + Enable::MakeValue(_enable ? 1 : 0); } - static void* Set(void* cmd, uint32 func, bool write_enable, bool enable) { + static void* Set(void* cmd, + Comparison func, bool write_enable, bool enable) { static_cast<ValueType*>(cmd)->Init(func, write_enable, enable); return NextCmdAddress<ValueType>(cmd); } // TODO(gman): fix this to not use obfusticated fields. CommandHeader header; - uint32 fixme0; + uint32 func_enable; }; COMPILE_ASSERT(sizeof(SetDepthTest) == 8, Sizeof_SetDepthTest_is_not_8); COMPILE_ASSERT(offsetof(SetDepthTest, header) == 0, OffsetOf_SetDepthTest_header_not_0); -COMPILE_ASSERT(offsetof(SetDepthTest, fixme0) == 4, - OffsetOf_SetDepthTest_fixme0_not_4); +COMPILE_ASSERT(offsetof(SetDepthTest, func_enable) == 4, + OffsetOf_SetDepthTest_func_enable_not_4); struct SetStencilTest { typedef SetStencilTest ValueType; static const CommandId kCmdId = command_buffer::kSetStencilTest; static const ArgFlags kArgFlags = kFixed; + // argument 0 + typedef BitField<0, 8> WriteMask; + typedef BitField<8, 8> CompareMask; + typedef BitField<16, 8> ReferenceValue; + typedef BitField<24, 6> Unused0; + typedef BitField<30, 1> SeparateCCW; + typedef BitField<31, 1> Enable; + // argument 1 + typedef BitField<0, 3> CWFunc; + typedef BitField<3, 3> CWPassOp; + typedef BitField<6, 3> CWFailOp; + typedef BitField<9, 3> CWZFailOp; + typedef BitField<12, 4> Unused1; + typedef BitField<16, 3> CCWFunc; + typedef BitField<19, 3> CCWPassOp; + typedef BitField<22, 3> CCWFailOp; + typedef BitField<25, 3> CCWZFailOp; + typedef BitField<28, 4> Unused2; + void SetHeader() { header.SetCmd<ValueType>(); } @@ -2864,30 +2859,30 @@ struct SetStencilTest { uint8 _reference_value, bool _separate_ccw, bool _enable, - uint8 _cw_func, - uint8 _cw_pass_op, - uint8 _cw_fail_op, - uint8 _cw_z_fail_op, - uint8 _ccw_func, - uint8 _ccw_pass_op, - uint8 _ccw_fail_op, - uint8 _ccw_z_fail_op) { + Comparison _cw_func, + StencilOp _cw_pass_op, + StencilOp _cw_fail_op, + StencilOp _cw_z_fail_op, + Comparison _ccw_func, + StencilOp _ccw_pass_op, + StencilOp _ccw_fail_op, + StencilOp _ccw_z_fail_op) { SetHeader(); - fixme0 = - set_stencil_test::WriteMask::MakeValue(_write_mask) | - set_stencil_test::CompareMask::MakeValue(_compare_mask) | - set_stencil_test::ReferenceValue::MakeValue(_reference_value) | - set_stencil_test::SeparateCCW::MakeValue(_separate_ccw ? 1 : 0) | - set_stencil_test::Enable::MakeValue(_enable ? 1 : 0); - fixme1 = - set_stencil_test::CWFunc::MakeValue(_cw_func) | - set_stencil_test::CWPassOp::MakeValue(_cw_pass_op) | - set_stencil_test::CWFailOp::MakeValue(_cw_fail_op) | - set_stencil_test::CWZFailOp::MakeValue(_cw_z_fail_op) | - set_stencil_test::CCWFunc::MakeValue(_ccw_func) | - set_stencil_test::CCWPassOp::MakeValue(_ccw_pass_op) | - set_stencil_test::CCWFailOp::MakeValue(_ccw_fail_op) | - set_stencil_test::CCWZFailOp::MakeValue(_ccw_z_fail_op); + stencil_args0 = + WriteMask::MakeValue(_write_mask) | + CompareMask::MakeValue(_compare_mask) | + ReferenceValue::MakeValue(_reference_value) | + SeparateCCW::MakeValue(_separate_ccw ? 1 : 0) | + Enable::MakeValue(_enable ? 1 : 0); + stencil_args1 = + CWFunc::MakeValue(_cw_func) | + CWPassOp::MakeValue(_cw_pass_op) | + CWFailOp::MakeValue(_cw_fail_op) | + CWZFailOp::MakeValue(_cw_z_fail_op) | + CCWFunc::MakeValue(_ccw_func) | + CCWPassOp::MakeValue(_ccw_pass_op) | + CCWFailOp::MakeValue(_ccw_fail_op) | + CCWZFailOp::MakeValue(_ccw_z_fail_op); } static void* Set( @@ -2897,14 +2892,14 @@ struct SetStencilTest { uint8 reference_value, bool separate_ccw, bool enable, - uint8 cw_func, - uint8 cw_pass_op, - uint8 cw_fail_op, - uint8 cw_z_fail_op, - uint8 ccw_func, - uint8 ccw_pass_op, - uint8 ccw_fail_op, - uint8 ccw_z_fail_op) { + Comparison cw_func, + StencilOp cw_pass_op, + StencilOp cw_fail_op, + StencilOp cw_z_fail_op, + Comparison ccw_func, + StencilOp ccw_pass_op, + StencilOp ccw_fail_op, + StencilOp ccw_z_fail_op) { static_cast<ValueType*>(cmd)->Init( write_mask, compare_mask, @@ -2924,24 +2919,33 @@ struct SetStencilTest { // TODO(gman): fix this to not use obfusticated fields. CommandHeader header; - uint32 fixme0; - uint32 fixme1; + uint32 stencil_args0; + uint32 stencil_args1; }; COMPILE_ASSERT(sizeof(SetStencilTest) == 12, Sizeof_SetStencilTest_is_not_12); COMPILE_ASSERT(offsetof(SetStencilTest, header) == 0, OffsetOf_SetStencilTest_header_not_0); -COMPILE_ASSERT(offsetof(SetStencilTest, fixme0) == 4, - OffsetOf_SetStencilTest_fixme0_not_4); -COMPILE_ASSERT(offsetof(SetStencilTest, fixme1) == 8, - OffsetOf_SetStencilTest_fixme1_not_8); +COMPILE_ASSERT(offsetof(SetStencilTest, stencil_args0) == 4, + OffsetOf_SetStencilTest_stencil_args0_not_4); +COMPILE_ASSERT(offsetof(SetStencilTest, stencil_args1) == 8, + OffsetOf_SetStencilTest_stencil_args1_not_8); struct SetColorWrite { typedef SetColorWrite ValueType; static const CommandId kCmdId = command_buffer::kSetColorWrite; static const ArgFlags kArgFlags = kFixed; + // argument 0 + typedef BitField<0, 1> RedMask; + typedef BitField<1, 1> GreenMask; + typedef BitField<2, 1> BlueMask; + typedef BitField<3, 1> AlphaMask; + typedef BitField<0, 4> AllColorsMask; // alias for RGBA + typedef BitField<4, 27> Unused; + typedef BitField<31, 1> DitherEnable; + void SetHeader() { header.SetCmd<ValueType>(); } @@ -2949,11 +2953,11 @@ struct SetColorWrite { void Init(uint8 _mask, bool _dither_enable) { SetHeader(); flags = - set_color_write::RedMask::MakeValue((_mask | 0x01) != 0 ? 1 : 0) | - set_color_write::GreenMask::MakeValue((_mask | 0x02) != 0 ? 1 : 0) | - set_color_write::BlueMask::MakeValue((_mask | 0x02) != 0 ? 1 : 0) | - set_color_write::AlphaMask::MakeValue((_mask | 0x02) != 0 ? 1 : 0) | - set_color_write::DitherEnable::MakeValue(_dither_enable ? 1 : 0); + RedMask::MakeValue((_mask | 0x01) != 0 ? 1 : 0) | + GreenMask::MakeValue((_mask | 0x02) != 0 ? 1 : 0) | + BlueMask::MakeValue((_mask | 0x02) != 0 ? 1 : 0) | + AlphaMask::MakeValue((_mask | 0x02) != 0 ? 1 : 0) | + DitherEnable::MakeValue(_dither_enable ? 1 : 0); } static void* Set(void* cmd, uint8 mask, bool dither_enable) { @@ -2976,39 +2980,51 @@ struct SetBlending { static const CommandId kCmdId = command_buffer::kSetBlending; static const ArgFlags kArgFlags = kFixed; + // argument 0 + typedef BitField<0, 4> ColorSrcFunc; + typedef BitField<4, 4> ColorDstFunc; + typedef BitField<8, 3> ColorEq; + typedef BitField<11, 5> Unused0; + typedef BitField<16, 4> AlphaSrcFunc; + typedef BitField<20, 4> AlphaDstFunc; + typedef BitField<24, 3> AlphaEq; + typedef BitField<27, 3> Unused1; + typedef BitField<30, 1> SeparateAlpha; + typedef BitField<31, 1> Enable; + void SetHeader() { header.SetCmd<ValueType>(); } void Init( - uint8 _color_src_func, - uint8 _color_dst_func, - uint8 _color_eq, - uint8 _alpha_src_func, - uint8 _alpha_dst_func, - uint8 _alpha_eq, + BlendFunc _color_src_func, + BlendFunc _color_dst_func, + BlendEq _color_eq, + BlendFunc _alpha_src_func, + BlendFunc _alpha_dst_func, + BlendEq _alpha_eq, bool _separate_alpha, bool _enable) { SetHeader(); - fixme0 = - set_blending::ColorSrcFunc::MakeValue(_color_src_func) | - set_blending::ColorDstFunc::MakeValue(_color_dst_func) | - set_blending::ColorEq::MakeValue(_color_eq) | - set_blending::AlphaSrcFunc::MakeValue(_alpha_src_func) | - set_blending::AlphaDstFunc::MakeValue(_alpha_dst_func) | - set_blending::AlphaEq::MakeValue(_alpha_eq) | - set_blending::SeparateAlpha::MakeValue(_separate_alpha ? 1 : 0) | - set_blending::Enable::MakeValue(_enable ? 1 : 0); + blend_settings = + ColorSrcFunc::MakeValue(_color_src_func) | + ColorDstFunc::MakeValue(_color_dst_func) | + ColorEq::MakeValue(_color_eq) | + AlphaSrcFunc::MakeValue(_alpha_src_func) | + AlphaDstFunc::MakeValue(_alpha_dst_func) | + AlphaEq::MakeValue(_alpha_eq) | + SeparateAlpha::MakeValue(_separate_alpha ? 1 : 0) | + Enable::MakeValue(_enable ? 1 : 0); } static void* Set( void* cmd, - uint8 color_src_func, - uint8 color_dst_func, - uint8 color_eq, - uint8 alpha_src_func, - uint8 alpha_dst_func, - uint8 alpha_eq, + BlendFunc color_src_func, + BlendFunc color_dst_func, + BlendEq color_eq, + BlendFunc alpha_src_func, + BlendFunc alpha_dst_func, + BlendEq alpha_eq, bool separate_alpha, bool enable) { static_cast<ValueType*>(cmd)->Init( @@ -3025,14 +3041,14 @@ struct SetBlending { // TODO(gman): fix this to not use obfusticated fields. CommandHeader header; - uint32 fixme0; + uint32 blend_settings; }; COMPILE_ASSERT(sizeof(SetBlending) == 8, Sizeof_SetBlending_is_not_8); COMPILE_ASSERT(offsetof(SetBlending, header) == 0, OffsetOf_SetBlending_header_not_0); -COMPILE_ASSERT(offsetof(SetBlending, fixme0) == 4, - OffsetOf_SetBlending_fixme0_not_4); +COMPILE_ASSERT(offsetof(SetBlending, blend_settings) == 4, + OffsetOf_SetBlending_blend_settings_not_4); struct SetBlendingColor { typedef SetBlendingColor ValueType; @@ -3082,51 +3098,57 @@ struct CreateRenderSurface { static const CommandId kCmdId = command_buffer::kCreateRenderSurface; static const ArgFlags kArgFlags = kFixed; + // argument 1 + typedef BitField<0, 16> Width; + typedef BitField<16, 16> Height; + // argument 2 may refer to side or depth + typedef BitField<0, 16> Levels; + typedef BitField<16, 16> Side; + void SetHeader() { header.SetCmd<ValueType>(); } - void Init(uint32 _id, uint32 _texture_id, uint32 _width, uint32 _height, + void Init(ResourceId _render_surface_id, + ResourceId _texture_id, uint32 _width, uint32 _height, uint32 _level, uint32 _side) { SetHeader(); - id = _id; + render_surface_id = _render_surface_id; // TODO(gman): Why does this need a width and height. It's inherited from // the texture isn't it? - fixme1 = - create_render_surface_cmd::Width::MakeValue(_width) | - create_render_surface_cmd::Height::MakeValue(_height); - fixme2 = - create_render_surface_cmd::Levels::MakeValue(_level) | - create_render_surface_cmd::Side::MakeValue(_side); + width_height = Width::MakeValue(_width) | Height::MakeValue(_height); + levels_side = Levels::MakeValue(_level) | Side::MakeValue(_side); texture_id = _texture_id; } - static void* Set(void* cmd, uint32 id, uint32 texture_id, + static void* Set(void* cmd, + ResourceId render_surface_id, ResourceId texture_id, uint32 width, uint32 height, uint32 level, uint32 side) { - static_cast<ValueType*>(cmd)->Init(id, texture_id, width, height, + static_cast<ValueType*>(cmd)->Init(render_surface_id, texture_id, + width, height, level, side); return NextCmdAddress<ValueType>(cmd); } // TODO(gman): fix this to not use obfusticated fields. CommandHeader header; - uint32 id; - uint32 fixme1; - uint32 fixme2; - uint32 texture_id; + ResourceId render_surface_id; + uint32 width_height; + uint32 levels_side; + ResourceId texture_id; }; COMPILE_ASSERT(sizeof(CreateRenderSurface) == 20, Sizeof_CreateRenderSurface_is_not_20); COMPILE_ASSERT(offsetof(CreateRenderSurface, header) == 0, OffsetOf_CreateRenderSurface_header_not_0); -COMPILE_ASSERT(offsetof(CreateRenderSurface, id) == 4, - OffsetOf_CreateRenderSurface_id_not_4); -COMPILE_ASSERT(offsetof(CreateRenderSurface, fixme1) == 8, - OffsetOf_CreateRenderSurface_fixme1_not_8); -COMPILE_ASSERT(offsetof(CreateRenderSurface, fixme2) == 12, - OffsetOf_CreateRenderSurface_fixme2_not_12); +COMPILE_ASSERT(offsetof(CreateRenderSurface, render_surface_id) == 4, + OffsetOf_CreateRenderSurface_render_surface_id_not_4); +COMPILE_ASSERT(offsetof(CreateRenderSurface, width_height) == 8, + OffsetOf_CreateRenderSurface_width_height_not_8); +COMPILE_ASSERT(offsetof(CreateRenderSurface, levels_side) == 12, + OffsetOf_CreateRenderSurface_levels_side_not_12); COMPILE_ASSERT(offsetof(CreateRenderSurface, texture_id) == 16, OffsetOf_CreateRenderSurface_texture_id_not_16); @@ -3139,63 +3161,66 @@ struct DestroyRenderSurface { header.SetCmd<ValueType>(); } - void Init(uint32 _id) { + void Init(ResourceId _render_surface_id) { SetHeader(); - id = _id; + render_surface_id = _render_surface_id; } - static void* Set(void* cmd, uint32 id) { - static_cast<ValueType*>(cmd)->Init(id); + static void* Set(void* cmd, ResourceId render_surface_id) { + static_cast<ValueType*>(cmd)->Init(render_surface_id); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId render_surface_id; }; COMPILE_ASSERT(sizeof(DestroyRenderSurface) == 8, Sizeof_DestroyRenderSurface_is_not_8); COMPILE_ASSERT(offsetof(DestroyRenderSurface, header) == 0, OffsetOf_DestroyRenderSurface_header_not_0); -COMPILE_ASSERT(offsetof(DestroyRenderSurface, id) == 4, - OffsetOf_DestroyRenderSurface_id_not_4); +COMPILE_ASSERT(offsetof(DestroyRenderSurface, render_surface_id) == 4, + OffsetOf_DestroyRenderSurface_render_surface_id_not_4); struct CreateDepthSurface { typedef CreateDepthSurface ValueType; static const CommandId kCmdId = command_buffer::kCreateDepthSurface; static const ArgFlags kArgFlags = kFixed; + // argument 1 + typedef BitField<0, 16> Width; + typedef BitField<16, 16> Height; + void SetHeader() { header.SetCmd<ValueType>(); } - void Init(uint32 _id, uint32 _width, uint32 _height) { + void Init(ResourceId _depth_surface_id, uint32 _width, uint32 _height) { SetHeader(); - id = _id; - fixme1 = - create_depth_surface_cmd::Width::MakeValue(_width) | - create_depth_surface_cmd::Height::MakeValue(_height); + depth_surface_id = _depth_surface_id; + width_height = Width::MakeValue(_width) | Height::MakeValue(_height); } - static void* Set(void* cmd, uint32 id, uint32 width, uint32 height) { - static_cast<ValueType*>(cmd)->Init(id, width, height); + static void* Set(void* cmd, ResourceId depth_surface_id, + uint32 width, uint32 height) { + static_cast<ValueType*>(cmd)->Init(depth_surface_id, width, height); return NextCmdAddress<ValueType>(cmd); } // TODO(gman): fix this to not use obfusticated fields. CommandHeader header; - uint32 id; - uint32 fixme1; + ResourceId depth_surface_id; + uint32 width_height; }; COMPILE_ASSERT(sizeof(CreateDepthSurface) == 12, Sizeof_CreateDepthSurface_is_not_12); COMPILE_ASSERT(offsetof(CreateDepthSurface, header) == 0, OffsetOf_CreateDepthSurface_header_not_0); -COMPILE_ASSERT(offsetof(CreateDepthSurface, id) == 4, - OffsetOf_CreateDepthSurface_id_not_4); -COMPILE_ASSERT(offsetof(CreateDepthSurface, fixme1) == 8, - OffsetOf_CreateDepthSurface_fixme1_not_8); +COMPILE_ASSERT(offsetof(CreateDepthSurface, depth_surface_id) == 4, + OffsetOf_CreateDepthSurface_depth_surface_id_not_4); +COMPILE_ASSERT(offsetof(CreateDepthSurface, width_height) == 8, + OffsetOf_CreateDepthSurface_width_height_not_8); struct DestroyDepthSurface { typedef DestroyDepthSurface ValueType; @@ -3206,26 +3231,26 @@ struct DestroyDepthSurface { header.SetCmd<ValueType>(); } - void Init(uint32 _id) { + void Init(ResourceId _depth_surface_id) { SetHeader(); - id = _id; + depth_surface_id = _depth_surface_id; } - static void* Set(void* cmd, uint32 id) { - static_cast<ValueType*>(cmd)->Init(id); + static void* Set(void* cmd, ResourceId depth_surface_id) { + static_cast<ValueType*>(cmd)->Init(depth_surface_id); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 id; + ResourceId depth_surface_id; }; COMPILE_ASSERT(sizeof(DestroyDepthSurface) == 8, Sizeof_DestroyDepthSurface_is_not_8); COMPILE_ASSERT(offsetof(DestroyDepthSurface, header) == 0, OffsetOf_DestroyDepthSurface_header_not_0); -COMPILE_ASSERT(offsetof(DestroyDepthSurface, id) == 4, - OffsetOf_DestroyDepthSurface_id_not_4); +COMPILE_ASSERT(offsetof(DestroyDepthSurface, depth_surface_id) == 4, + OffsetOf_DestroyDepthdepth_surface_id_not_4); struct SetRenderSurface { typedef SetRenderSurface ValueType; @@ -3236,21 +3261,21 @@ struct SetRenderSurface { header.SetCmd<ValueType>(); } - void Init(uint32 _render_surface_id, uint32 _depth_surface_id) { + void Init(ResourceId _render_surface_id, ResourceId _depth_surface_id) { SetHeader(); render_surface_id = _render_surface_id; depth_surface_id = _depth_surface_id; } static void* Set(void* cmd, - uint32 render_surface_id, uint32 depth_surface_id) { + ResourceId render_surface_id, ResourceId depth_surface_id) { static_cast<ValueType*>(cmd)->Init(render_surface_id, depth_surface_id); return NextCmdAddress<ValueType>(cmd); } CommandHeader header; - uint32 render_surface_id; - uint32 depth_surface_id; + ResourceId render_surface_id; + ResourceId depth_surface_id; }; COMPILE_ASSERT(sizeof(SetRenderSurface) == 12, diff --git a/o3d/command_buffer/common/cross/gapi_interface.h b/o3d/command_buffer/common/cross/gapi_interface.h index 1766428..f72b858 100644 --- a/o3d/command_buffer/common/cross/gapi_interface.h +++ b/o3d/command_buffer/common/cross/gapi_interface.h @@ -38,6 +38,7 @@ #include "command_buffer/common/cross/buffer_sync_api.h" #include "command_buffer/common/cross/resource.h" +#include "command_buffer/common/cross/cmd_buffer_format.h" namespace o3d { namespace command_buffer { @@ -66,95 +67,6 @@ class GAPIInterface { // Destroys the graphics context. virtual void Destroy() = 0; - // Bit definitions for buffers to clear. - enum ClearBuffer { - COLOR = 0x1, - DEPTH = 0x2, - STENCIL = 0x4, - ALL_BUFFERS = COLOR | DEPTH | STENCIL - }; - - // Primitive type for Draw and DrawIndexed. - enum PrimitiveType { - POINTS, - LINES, - LINE_STRIPS, - TRIANGLES, - TRIANGLE_STRIPS, - TRIANGLE_FANS, - MAX_PRIMITIVE_TYPE - }; - - // Polygon mode for SetPolygonRaster - enum PolygonMode { - POLYGON_MODE_POINTS, - POLYGON_MODE_LINES, - POLYGON_MODE_FILL, - NUM_POLYGON_MODE - }; - - // Face culling mode for SetPolygonRaster - enum FaceCullMode { - CULL_NONE, - CULL_CW, - CULL_CCW, - NUM_FACE_CULL_MODE - }; - - // Comparison function for alpha or depth test - enum Comparison { - NEVER, - LESS, - EQUAL, - LEQUAL, - GREATER, - NOT_EQUAL, - GEQUAL, - ALWAYS, - NUM_COMPARISON - }; - - // Stencil operation - enum StencilOp { - KEEP, - ZERO, - REPLACE, - INC_NO_WRAP, - DEC_NO_WRAP, - INVERT, - INC_WRAP, - DEC_WRAP, - NUM_STENCIL_OP - }; - - // Blend Equation - enum BlendEq { - BLEND_EQ_ADD, - BLEND_EQ_SUB, - BLEND_EQ_REV_SUB, - BLEND_EQ_MIN, - BLEND_EQ_MAX, - NUM_BLEND_EQ - }; - - // Blend Funtion - enum BlendFunc { - BLEND_FUNC_ZERO, - BLEND_FUNC_ONE, - BLEND_FUNC_SRC_COLOR, - BLEND_FUNC_INV_SRC_COLOR, - BLEND_FUNC_SRC_ALPHA, - BLEND_FUNC_INV_SRC_ALPHA, - BLEND_FUNC_DST_ALPHA, - BLEND_FUNC_INV_DST_ALPHA, - BLEND_FUNC_DST_COLOR, - BLEND_FUNC_INV_DST_COLOR, - BLEND_FUNC_SRC_ALPHA_SATUTRATE, - BLEND_FUNC_BLEND_COLOR, - BLEND_FUNC_INV_BLEND_COLOR, - NUM_BLEND_FUNC - }; - // Starts a frame. Rendering should occur between BeginFrame and EndFrame. virtual void BeginFrame() = 0; @@ -182,7 +94,7 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError CreateVertexBuffer(ResourceID id, + virtual ParseError CreateVertexBuffer(ResourceId id, unsigned int size, unsigned int flags) = 0; @@ -192,7 +104,7 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if an invalid vertex buffer // ID was passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError DestroyVertexBuffer(ResourceID id) = 0; + virtual ParseError DestroyVertexBuffer(ResourceId id) = 0; // Sets data into a vertex buffer. // Parameters: @@ -204,7 +116,7 @@ class GAPIInterface { // BufferSyncInterface::kParseInvalidArguments if invalid arguments were // passed: invalid resource ID, or offset or size out of range. // BufferSyncInterface::kParseNoError otherwise. - virtual ParseError SetVertexBufferData(ResourceID id, + virtual ParseError SetVertexBufferData(ResourceId id, unsigned int offset, unsigned int size, const void *data) = 0; @@ -219,7 +131,7 @@ class GAPIInterface { // BufferSyncInterface::kParseInvalidArguments if invalid arguments were // passed: invalid resource ID, or offset or size out of range. // BufferSyncInterface::kParseNoError otherwise. - virtual ParseError GetVertexBufferData(ResourceID id, + virtual ParseError GetVertexBufferData(ResourceId id, unsigned int offset, unsigned int size, void *data) = 0; @@ -234,7 +146,7 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError CreateIndexBuffer(ResourceID id, + virtual ParseError CreateIndexBuffer(ResourceId id, unsigned int size, unsigned int flags) = 0; @@ -244,7 +156,7 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if an invalid index buffer // ID was passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError DestroyIndexBuffer(ResourceID id) = 0; + virtual ParseError DestroyIndexBuffer(ResourceId id) = 0; // Sets data into an index buffer. // Parameters: @@ -256,7 +168,7 @@ class GAPIInterface { // BufferSyncInterface::kParseInvalidArguments if invalid arguments were // passed: invalid resource ID, or offset or size out of range. // BufferSyncInterface::kParseNoError otherwise. - virtual ParseError SetIndexBufferData(ResourceID id, + virtual ParseError SetIndexBufferData(ResourceId id, unsigned int offset, unsigned int size, const void *data) = 0; @@ -271,7 +183,7 @@ class GAPIInterface { // BufferSyncInterface::kParseInvalidArguments if invalid arguments were // passed: invalid resource ID, or offset or size out of range. // BufferSyncInterface::kParseNoError otherwise. - virtual ParseError GetIndexBufferData(ResourceID id, + virtual ParseError GetIndexBufferData(ResourceId id, unsigned int offset, unsigned int size, void *data) = 0; @@ -284,7 +196,7 @@ class GAPIInterface { // returns: // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError CreateVertexStruct(ResourceID id, + virtual ParseError CreateVertexStruct(ResourceId id, unsigned int input_count) = 0; // Destroys a vertex struct. @@ -293,7 +205,7 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if an invalid vertex struct // ID was passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError DestroyVertexStruct(ResourceID id) = 0; + virtual ParseError DestroyVertexStruct(ResourceId id) = 0; // Sets an input into a vertex struct. // Parameters: @@ -309,9 +221,9 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError SetVertexInput(ResourceID vertex_struct_id, + virtual ParseError SetVertexInput(ResourceId vertex_struct_id, unsigned int input_index, - ResourceID vertex_buffer_id, + ResourceId vertex_buffer_id, unsigned int offset, unsigned int stride, vertex_struct::Type type, @@ -325,7 +237,7 @@ class GAPIInterface { // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed (invalid vertex struct), BufferSyncInterface::kParseNoError // otherwise. - virtual ParseError SetVertexStruct(ResourceID id) = 0; + virtual ParseError SetVertexStruct(ResourceId id) = 0; // Draws primitives, using the current vertex struct and the current effect. // Parameters: @@ -352,7 +264,7 @@ class GAPIInterface { // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed, BufferSyncInterface::kParseNoError otherwise. virtual ParseError DrawIndexed(PrimitiveType primitive_type, - ResourceID index_buffer_id, + ResourceId index_buffer_id, unsigned int first, unsigned int count, unsigned int min_index, @@ -367,7 +279,7 @@ class GAPIInterface { // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed or the effect failed to compile, // BufferSyncInterface::kParseNoError otherwise. - virtual ParseError CreateEffect(ResourceID id, + virtual ParseError CreateEffect(ResourceId id, unsigned int size, const void *data) = 0; @@ -377,7 +289,7 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if an invalid effect ID // was passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError DestroyEffect(ResourceID id) = 0; + virtual ParseError DestroyEffect(ResourceId id) = 0; // Sets the active effect for drawing. // Parameters: @@ -385,7 +297,7 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError SetEffect(ResourceID id) = 0; + virtual ParseError SetEffect(ResourceId id) = 0; // Gets the number of parameters in an effect, returning it in a memory // buffer as a Uint32. @@ -397,7 +309,7 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError GetParamCount(ResourceID id, + virtual ParseError GetParamCount(ResourceId id, unsigned int size, void *data) = 0; @@ -412,8 +324,8 @@ class GAPIInterface { // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed, such as invalid effect ID, unmatching data type or invalid // index, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError CreateParam(ResourceID param_id, - ResourceID effect_id, + virtual ParseError CreateParam(ResourceId param_id, + ResourceId effect_id, unsigned int index) = 0; // Creates an effect parameter by name. @@ -429,8 +341,8 @@ class GAPIInterface { // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed, such as invalid effect ID, unmatching data type or no parameter // was found with this name, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError CreateParamByName(ResourceID param_id, - ResourceID effect_id, + virtual ParseError CreateParamByName(ResourceId param_id, + ResourceId effect_id, unsigned int size, const void *name) = 0; @@ -440,7 +352,7 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if an invalid parameter ID // was passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError DestroyParam(ResourceID id) = 0; + virtual ParseError DestroyParam(ResourceId id) = 0; // Sets the effect parameter data. // Parameters: @@ -451,7 +363,7 @@ class GAPIInterface { // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed, such as invalid parameter ID, or unmatching data size, // BufferSyncInterface::kParseNoError otherwise. - virtual ParseError SetParamData(ResourceID id, + virtual ParseError SetParamData(ResourceId id, unsigned int size, const void *data) = 0; @@ -477,7 +389,7 @@ class GAPIInterface { // itself fits, not necessarily the names. To make sure all the information // is available, the caller should compare the returned size member of the // effect_param::Desc structure to the size parameter passed in. - virtual ParseError GetParamDesc(ResourceID id, + virtual ParseError GetParamDesc(ResourceId id, unsigned int size, void *data) = 0; @@ -491,7 +403,7 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError GetStreamCount(ResourceID id, + virtual ParseError GetStreamCount(ResourceId id, unsigned int size, void *data) = 0; @@ -504,7 +416,7 @@ class GAPIInterface { // size: the size of the data buffer. Must be at least 8 (the size of two // Uint32). // data: the buffer receiving the data. - virtual ParseError GetStreamDesc(ResourceID id, + virtual ParseError GetStreamDesc(ResourceId id, unsigned int index, unsigned int size, void *data) = 0; @@ -522,7 +434,7 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError CreateTexture2D(ResourceID id, + virtual ParseError CreateTexture2D(ResourceId id, unsigned int width, unsigned int height, unsigned int levels, @@ -544,7 +456,7 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError CreateTexture3D(ResourceID id, + virtual ParseError CreateTexture3D(ResourceId id, unsigned int width, unsigned int height, unsigned int depth, @@ -565,7 +477,7 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError CreateTextureCube(ResourceID id, + virtual ParseError CreateTextureCube(ResourceId id, unsigned int side, unsigned int levels, texture::Format format, @@ -602,7 +514,7 @@ class GAPIInterface { // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed, for example invalid size, or out-of-bounds rectangle/volume, // BufferSyncInterface::kParseNoError otherwise. - virtual ParseError SetTextureData(ResourceID id, + virtual ParseError SetTextureData(ResourceId id, unsigned int x, unsigned int y, unsigned int z, @@ -646,7 +558,7 @@ class GAPIInterface { // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed, for example invalid size, or out-of-bounds rectangle/volume, // BufferSyncInterface::kParseNoError otherwise. - virtual ParseError GetTextureData(ResourceID id, + virtual ParseError GetTextureData(ResourceId id, unsigned int x, unsigned int y, unsigned int z, @@ -666,14 +578,14 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if an invalid texture // resource ID was passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError DestroyTexture(ResourceID id) = 0; + virtual ParseError DestroyTexture(ResourceId id) = 0; // Creates a sampler resource. // Parameters: // id: the resource ID of the sampler. // Returns: // BufferSyncInterface::kParseNoError. - virtual ParseError CreateSampler(ResourceID id) = 0; + virtual ParseError CreateSampler(ResourceId id) = 0; // Destroys a sampler resource. // Parameters: @@ -681,7 +593,7 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if an invalid sampler // resource ID was passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError DestroySampler(ResourceID id) = 0; + virtual ParseError DestroySampler(ResourceId id) = 0; // Sets the states in a sampler resource. // Parameters: @@ -696,7 +608,7 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if an invalid sampler // resource ID was passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError SetSamplerStates(ResourceID id, + virtual ParseError SetSamplerStates(ResourceId id, sampler::AddressingMode addressing_u, sampler::AddressingMode addressing_v, sampler::AddressingMode addressing_w, @@ -712,7 +624,7 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if an invalid sampler // resource ID was passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError SetSamplerBorderColor(ResourceID id, + virtual ParseError SetSamplerBorderColor(ResourceId id, const RGBA &color) = 0; // Sets the texture resource used by a sampler resource. @@ -722,8 +634,8 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if an invalid sampler // resource ID was passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError SetSamplerTexture(ResourceID id, - ResourceID texture_id) = 0; + virtual ParseError SetSamplerTexture(ResourceId id, + ResourceId texture_id) = 0; // Sets the viewport, and depth range. // Parameters: @@ -786,7 +698,7 @@ class GAPIInterface { // Sets the depth test states. // Note: if the depth test is disabled, z values are not written to the z - // buffer (i.e enable/ALWAYS is different from disable/*). + // buffer (i.e enable/kAlways is different from disable/*). // Parameters: // enable: depth test enable state. // write_enable: depth write enable state. @@ -862,12 +774,12 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError CreateRenderSurface(ResourceID id, + virtual ParseError CreateRenderSurface(ResourceId id, unsigned int width, unsigned int height,
unsigned int mip_level,
unsigned int side, - ResourceID texture_id) = 0; + ResourceId texture_id) = 0; // Destroys a render surface resource. // Parameters: @@ -876,7 +788,7 @@ class GAPIInterface { // BufferSyncInterface::kParseInvalidArguments if an invalid render // surface // resource ID was passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError DestroyRenderSurface(ResourceID id) = 0; + virtual ParseError DestroyRenderSurface(ResourceId id) = 0; // Creates a depth stencil surface resource. // Parameters: @@ -886,7 +798,7 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError CreateDepthSurface(ResourceID id, + virtual ParseError CreateDepthSurface(ResourceId id, unsigned int width, unsigned int height) = 0; @@ -897,7 +809,7 @@ class GAPIInterface { // BufferSyncInterface::kParseInvalidArguments if an invalid render // surface // resource ID was passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError DestroyDepthSurface(ResourceID id) = 0; + virtual ParseError DestroyDepthSurface(ResourceId id) = 0; // Switches the render surface and depth stencil surface to those // corresponding to the passed in IDs. @@ -907,8 +819,8 @@ class GAPIInterface { // Returns: // BufferSyncInterface::kParseInvalidArguments if invalid arguments are // passed, BufferSyncInterface::kParseNoError otherwise. - virtual ParseError SetRenderSurface(ResourceID render_surface_id, - ResourceID depth_stencil_id) = 0; + virtual ParseError SetRenderSurface(ResourceId render_surface_id, + ResourceId depth_stencil_id) = 0; // Switch the render surface and depth stencil surface back to the main // surfaces stored in the render diff --git a/o3d/command_buffer/common/cross/resource.cc b/o3d/command_buffer/common/cross/resource.cc index cf7082f..a077bf1 100644 --- a/o3d/command_buffer/common/cross/resource.cc +++ b/o3d/command_buffer/common/cross/resource.cc @@ -42,12 +42,12 @@ namespace texture { // Gets the number of bytes per block for a given format. unsigned int GetBytesPerBlock(Format format) { switch (format) { - case XRGB8: - case ARGB8: + case kXRGB8: + case kARGB8: return 4; - case ABGR16F: + case kABGR16F: return 8; - case DXT1: + case kDXT1: return 8; default: LOG(FATAL) << "Invalid format"; @@ -58,11 +58,11 @@ unsigned int GetBytesPerBlock(Format format) { // Gets the width of a block for a given format. unsigned int GetBlockSizeX(Format format) { switch (format) { - case XRGB8: - case ARGB8: - case ABGR16F: + case kXRGB8: + case kARGB8: + case kABGR16F: return 1; - case DXT1: + case kDXT1: return 4; default: LOG(FATAL) << "Invalid format"; @@ -83,26 +83,26 @@ namespace effect_param { // Gets the size of the data of a given parameter type. unsigned int GetDataSize(DataType type) { switch (type) { - case UNKNOWN: + case kUnknown: return 0; - case FLOAT1: + case kFloat1: return sizeof(float); // NOLINT - case FLOAT2: - return sizeof(float)*2; // NOLINT - case FLOAT3: - return sizeof(float)*3; // NOLINT - case FLOAT4: - return sizeof(float)*4; // NOLINT - case MATRIX4: - return sizeof(float)*16; // NOLINT - case INT: + case kFloat2: + return sizeof(float) * 2; // NOLINT + case kFloat3: + return sizeof(float) * 3; // NOLINT + case kFloat4: + return sizeof(float) * 4; // NOLINT + case kMatrix4: + return sizeof(float) * 16; // NOLINT + case kInt: return sizeof(int); // NOLINT - case BOOL: + case kBool: return sizeof(bool); // NOLINT - case SAMPLER: - return sizeof(ResourceID); // NOLINT - case TEXTURE: - return sizeof(ResourceID); // NOLINT + case kSampler: + return sizeof(ResourceId); // NOLINT + case kTexture: + return sizeof(ResourceId); // NOLINT default: LOG(FATAL) << "Invalid type."; return 0; diff --git a/o3d/command_buffer/common/cross/resource.h b/o3d/command_buffer/common/cross/resource.h index 408f8ea..a556c19 100644 --- a/o3d/command_buffer/common/cross/resource.h +++ b/o3d/command_buffer/common/cross/resource.h @@ -46,25 +46,26 @@ namespace o3d { namespace command_buffer { // A resource ID, key to the resource maps. -// TODO(gman): Shouldn't this be a uint32? -typedef unsigned int ResourceID; +typedef uint32 ResourceId; // Invalid resource ID. -static const ResourceID kInvalidResource = 0xffffffffU; +static const ResourceId kInvalidResource = 0xffffffffU; namespace vertex_buffer { // Vertex buffer flags. enum Flags { - DYNAMIC = 0x01, // This vertex buffer is dynamic and is expected to have - // its data updated often. + kNone = 0x00, + kDynamic = 0x01, // This vertex buffer is dynamic and is expected to have + // its data updated often. }; } // namespace vertex_buffer namespace index_buffer { // Index buffer flags. enum Flags { - DYNAMIC = 0x01, // This index buffer is dynamic and is expected to have - // its data updated often. - INDEX_32BIT = 0x02, // Indices contained in this index buffer are 32 bits + kNone = 0x00, + kDynamic = 0x01, // This index buffer is dynamic and is expected to have + // its data updated often. + kIndex32Bit = 0x02, // Indices contained in this index buffer are 32 bits // (unsigned int) instead of 16 bit (unsigned short). }; } // namespace index_buffer @@ -72,40 +73,40 @@ enum Flags { namespace vertex_struct { // Semantics for input data. enum Semantic { - UNKNOWN_SEMANTIC = -1, - POSITION = 0, - NORMAL, - COLOR, - TEX_COORD, - NUM_SEMANTICS + kUnknownSemantic = -1, + kPosition = 0, + kNormal, + kColor, + kTexCoord, + kNumSemantics }; // Input data types. enum Type { - FLOAT1, - FLOAT2, - FLOAT3, - FLOAT4, - UCHAR4N, - NUM_TYPES + kFloat1, + kFloat2, + kFloat3, + kFloat4, + kUChar4N, + kNumTypes }; } // namespace vertex_struct namespace effect_param { enum DataType { - UNKNOWN, // A parameter exists in the effect, but the type is not + kUnknown, // A parameter exists in the effect, but the type is not // representable (e.g. MATRIX3x4). - FLOAT1, - FLOAT2, - FLOAT3, - FLOAT4, - MATRIX4, - INT, - BOOL, - SAMPLER, - TEXTURE, - NUM_TYPES, - MAKE_32_BIT = 0x7fffffff, + kFloat1, + kFloat2, + kFloat3, + kFloat4, + kMatrix4, + kInt, + kBool, + kSampler, + kTexture, + kNumTypes, + kMake32Bit = 0x7fffffff, }; COMPILE_ASSERT(sizeof(DataType) == 4, DataType_should_be_32_bits); @@ -141,7 +142,7 @@ struct Desc { namespace effect_stream { struct Desc { Desc() - : semantic(vertex_struct::UNKNOWN_SEMANTIC), + : semantic(vertex_struct::kUnknownSemantic), semantic_index(0) {} Desc(Uint32 semantic, Uint32 semantic_index) : semantic(semantic), @@ -154,34 +155,36 @@ struct Desc { namespace texture { // Texture flags. enum Flags { - DYNAMIC = 0x01, // This texture is dynamic and is expected to have - // its data updated often. + kNone = 0x00, + kDynamic = 0x01, // This texture is dynamic and is expected to have + // its data updated often. }; // Texel formats. enum Format { - XRGB8, - ARGB8, - ABGR16F, - DXT1, - NUM_FORMATS + kXRGB8, + kARGB8, + kABGR16F, + kDXT1, + kNumFormats }; // Texture type. enum Type { - TEXTURE_2D, - TEXTURE_3D, - TEXTURE_CUBE, + kTexture2d, + kTexture3d, + kTextureCube, }; // Cube map face. enum Face { - FACE_POSITIVE_X, - FACE_NEGATIVE_X, - FACE_POSITIVE_Y, - FACE_NEGATIVE_Y, - FACE_POSITIVE_Z, - FACE_NEGATIVE_Z, + kFacePositiveX, + kFaceNegativeX, + kFacePositiveY, + kFaceNegativeY, + kFacePositiveZ, + kFaceNegativeZ, + kFaceNone = kFacePositiveX, // For non-cube maps. }; // Gets the number of bytes per block for a given texture format. For most @@ -205,18 +208,18 @@ static unsigned int GetMipMapDimension(unsigned int base, namespace sampler { enum AddressingMode { - WRAP, - MIRROR_REPEAT, - CLAMP_TO_EDGE, - CLAMP_TO_BORDER, - NUM_ADDRESSING_MODE + kWrap, + kMirrorRepeat, + kClampToEdge, + kClampToBorder, + kNumAddressingMode }; enum FilteringMode { - NONE, - POINT, - LINEAR, - NUM_FILTERING_MODE + kNone, + kPoint, + kLinear, + kNumFilteringMode }; } // namespace sampler diff --git a/o3d/command_buffer/samples/bubble/bubble_module.cc b/o3d/command_buffer/samples/bubble/bubble_module.cc index b24a3d1..5d5a2f7 100644 --- a/o3d/command_buffer/samples/bubble/bubble_module.cc +++ b/o3d/command_buffer/samples/bubble/bubble_module.cc @@ -345,24 +345,24 @@ class BubbleDemo { const math::Vector3& rotation); nacl::HtpHandle handle_pair_[2]; - ResourceID vertex_buffer_id_; - ResourceID index_buffer_id_; - ResourceID vertex_struct_id_; - ResourceID effect_id_; - ResourceID noise_texture_id_; - ResourceID iridescence_texture_id_; - ResourceID cubemap_id_; - ResourceID noise_sampler_id_; - ResourceID iridescence_sampler_id_; - ResourceID cubemap_sampler_id_; - ResourceID noise_sampler_param_id_; - ResourceID iridescence_sampler_param_id_; - ResourceID cubemap_sampler_param_id_; - ResourceID mvp_param_id_; - ResourceID world_param_id_; - ResourceID worldIT_param_id_; - ResourceID eye_param_id_; - ResourceID thickness_param_id_; + ResourceId vertex_buffer_id_; + ResourceId index_buffer_id_; + ResourceId vertex_struct_id_; + ResourceId effect_id_; + ResourceId noise_texture_id_; + ResourceId iridescence_texture_id_; + ResourceId cubemap_id_; + ResourceId noise_sampler_id_; + ResourceId iridescence_sampler_id_; + ResourceId cubemap_sampler_id_; + ResourceId noise_sampler_param_id_; + ResourceId iridescence_sampler_param_id_; + ResourceId cubemap_sampler_param_id_; + ResourceId mvp_param_id_; + ResourceId world_param_id_; + ResourceId worldIT_param_id_; + ResourceId eye_param_id_; + ResourceId thickness_param_id_; scoped_ptr<IMCSender> sender_; scoped_ptr<BufferSyncProxy> proxy_; scoped_ptr<CommandBufferHelper> helper_; diff --git a/o3d/command_buffer/service/cross/gapi_decoder.cc b/o3d/command_buffer/service/cross/gapi_decoder.cc index 7f40d97..3e6f0a2 100644 --- a/o3d/command_buffer/service/cross/gapi_decoder.cc +++ b/o3d/command_buffer/service/cross/gapi_decoder.cc @@ -152,7 +152,7 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleClear( // Pull out some values so they can't be changed by another thread after we've // validated them. uint32 buffers = args.buffers; - if (buffers & ~GAPIInterface::ALL_BUFFERS) + if (buffers & ~command_buffer::kAllBuffers) return BufferSyncInterface::kParseInvalidArguments; RGBA rgba; rgba.red = args.red; @@ -178,13 +178,14 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleSetViewport( BufferSyncInterface::ParseError GAPIDecoder::HandleCreateVertexBuffer( uint32 arg_count, const cmd::CreateVertexBuffer& args) { - return gapi_->CreateVertexBuffer(args.id, args.size, args.flags); + return gapi_->CreateVertexBuffer( + args.vertex_buffer_id, args.size, args.flags); } BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyVertexBuffer( uint32 arg_count, const cmd::DestroyVertexBuffer& args) { - return gapi_->DestroyVertexBuffer(args.id); + return gapi_->DestroyVertexBuffer(args.vertex_buffer_id); } BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexBufferDataImmediate( @@ -192,9 +193,9 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexBufferDataImmediate( const cmd::SetVertexBufferDataImmediate& args) { uint32 size = ImmediateDataSize(arg_count, args); if (size == 0) { - return ParseError::kParseNoError; + return BufferSyncInterface::kParseNoError; } - return gapi_->SetVertexBufferData(args.id, args.offset, + return gapi_->SetVertexBufferData(args.vertex_buffer_id, args.offset, size, AddressAfterStruct(args)); } @@ -209,7 +210,8 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexBufferData( args.shared_memory.offset, size); if (!data) return BufferSyncInterface::kParseInvalidArguments; - return gapi_->SetVertexBufferData(args.id, args.offset, size, data); + return gapi_->SetVertexBufferData( + args.vertex_buffer_id, args.offset, size, data); } BufferSyncInterface::ParseError GAPIDecoder::HandleGetVertexBufferData( @@ -222,19 +224,20 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleGetVertexBufferData( args.shared_memory.offset, size); if (!data) return BufferSyncInterface::kParseInvalidArguments; - return gapi_->GetVertexBufferData(args.id, args.offset, size, data); + return gapi_->GetVertexBufferData( + args.vertex_buffer_id, args.offset, size, data); } BufferSyncInterface::ParseError GAPIDecoder::HandleCreateIndexBuffer( uint32 arg_count, const cmd::CreateIndexBuffer& args) { - return gapi_->CreateIndexBuffer(args.id, args.size, args.flags); + return gapi_->CreateIndexBuffer(args.index_buffer_id, args.size, args.flags); } BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyIndexBuffer( uint32 arg_count, const cmd::DestroyIndexBuffer& args) { - return gapi_->DestroyIndexBuffer(args.id); + return gapi_->DestroyIndexBuffer(args.index_buffer_id); } BufferSyncInterface::ParseError GAPIDecoder::HandleSetIndexBufferDataImmediate( @@ -242,9 +245,9 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleSetIndexBufferDataImmediate( const cmd::SetIndexBufferDataImmediate& args) { uint32 size = ImmediateDataSize(arg_count, args); if (size == 0) { - return ParseError::kParseNoError; + return BufferSyncInterface::kParseNoError; } - return gapi_->SetIndexBufferData(args.id, args.offset, size, + return gapi_->SetIndexBufferData(args.index_buffer_id, args.offset, size, AddressAfterStruct(args)); } @@ -258,7 +261,8 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleSetIndexBufferData( args.shared_memory.offset, size); if (!data) return BufferSyncInterface::kParseInvalidArguments; - return gapi_->SetIndexBufferData(args.id, args.offset, size, data); + return gapi_->SetIndexBufferData( + args.index_buffer_id, args.offset, size, data); } BufferSyncInterface::ParseError GAPIDecoder::HandleGetIndexBufferData( @@ -271,32 +275,36 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleGetIndexBufferData( args.shared_memory.offset, size); if (!data) return BufferSyncInterface::kParseInvalidArguments; - return gapi_->GetIndexBufferData(args.id, args.offset, size, data); + return gapi_->GetIndexBufferData( + args.index_buffer_id, args.offset, size, data); } BufferSyncInterface::ParseError GAPIDecoder::HandleCreateVertexStruct( uint32 arg_count, const cmd::CreateVertexStruct& args) { - return gapi_->CreateVertexStruct(args.id, args.input_count); + return gapi_->CreateVertexStruct(args.vertex_struct_id, args.input_count); } BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyVertexStruct( uint32 arg_count, const cmd::DestroyVertexStruct& args) { - return gapi_->DestroyVertexStruct(args.id); + return gapi_->DestroyVertexStruct(args.vertex_struct_id); } BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexInput( uint32 arg_count, const cmd::SetVertexInput& args) { - namespace cmd = set_vertex_input_cmd; - unsigned int type_stride_semantic = args.fixme4; - unsigned int semantic_index = cmd::SemanticIndex::Get(type_stride_semantic); - unsigned int semantic = cmd::Semantic::Get(type_stride_semantic); - unsigned int type = cmd::Type::Get(type_stride_semantic); - unsigned int stride = cmd::Stride::Get(type_stride_semantic); - if (semantic >= vertex_struct::NUM_SEMANTICS || - type >= vertex_struct::NUM_TYPES || stride == 0) + unsigned int type_stride_semantic = args.type_stride_semantic; + unsigned int semantic_index = + cmd::SetVertexInput::SemanticIndex::Get(type_stride_semantic); + unsigned int semantic = + cmd::SetVertexInput::Semantic::Get(type_stride_semantic); + unsigned int type = + cmd::SetVertexInput::Type::Get(type_stride_semantic); + unsigned int stride = + cmd::SetVertexInput::Stride::Get(type_stride_semantic); + if (semantic >= vertex_struct::kNumSemantics || + type >= vertex_struct::kNumTypes || stride == 0) return BufferSyncInterface::kParseInvalidArguments; return gapi_->SetVertexInput( args.vertex_struct_id, args.input_index, args.vertex_buffer_id, @@ -309,7 +317,7 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexInput( BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexStruct( uint32 arg_count, const cmd::SetVertexStruct& args) { - return gapi_->SetVertexStruct(args.id); + return gapi_->SetVertexStruct(args.vertex_struct_id); } BufferSyncInterface::ParseError GAPIDecoder::HandleDraw( @@ -318,10 +326,10 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleDraw( // Pull out some values so they can't be changed by another thread after we've // validated them. uint32 primitive_type = args.primitive_type; - if (primitive_type >= GAPIInterface::MAX_PRIMITIVE_TYPE) + if (primitive_type >= command_buffer::kMaxPrimitiveType) return BufferSyncInterface::kParseInvalidArguments; return gapi_->Draw( - static_cast<GAPIInterface::PrimitiveType>(primitive_type), + static_cast<command_buffer::PrimitiveType>(primitive_type), args.first, args.count); } @@ -331,10 +339,10 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleDrawIndexed( // Pull out some values so they can't be changed by another thread after we've // validated them. uint32 primitive_type = args.primitive_type; - if (primitive_type >= GAPIInterface::MAX_PRIMITIVE_TYPE) + if (primitive_type >= command_buffer::kMaxPrimitiveType) return BufferSyncInterface::kParseInvalidArguments; return gapi_->DrawIndexed( - static_cast<GAPIInterface::PrimitiveType>(primitive_type), + static_cast<command_buffer::PrimitiveType>(primitive_type), args.index_buffer_id, args.first, args.count, args.min_index, args.max_index); } @@ -349,7 +357,7 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleCreateEffect( args.shared_memory.offset, size); if (!data) return BufferSyncInterface::kParseInvalidArguments; - return gapi_->CreateEffect(args.id, size, data); + return gapi_->CreateEffect(args.effect_id, size, data); } BufferSyncInterface::ParseError GAPIDecoder::HandleCreateEffectImmediate( @@ -359,24 +367,25 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleCreateEffectImmediate( // validated them. uint32 size = args.size; uint32 data_size = ImmediateDataSize(arg_count, args); - if (size > data_size) + if (size > data_size) { return BufferSyncInterface::kParseInvalidArguments; + } if (data_size == 0) { - return ParseError::kParseNoError; + return BufferSyncInterface::kParseNoError; } - return gapi_->CreateEffect(args.id, size, AddressAfterStruct(args)); + return gapi_->CreateEffect(args.effect_id, size, AddressAfterStruct(args)); } BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyEffect( uint32 arg_count, const cmd::DestroyEffect& args) { - return gapi_->DestroyEffect(args.id); + return gapi_->DestroyEffect(args.effect_id); } BufferSyncInterface::ParseError GAPIDecoder::HandleSetEffect( uint32 arg_count, const cmd::SetEffect& args) { - return gapi_->SetEffect(args.id); + return gapi_->SetEffect(args.effect_id); } BufferSyncInterface::ParseError GAPIDecoder::HandleGetParamCount( @@ -389,7 +398,7 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleGetParamCount( args.shared_memory.offset, size); if (!data) return BufferSyncInterface::kParseInvalidArguments; - return gapi_->GetParamCount(args.id, size, data); + return gapi_->GetParamCount(args.effect_id, size, data); } BufferSyncInterface::ParseError GAPIDecoder::HandleCreateParam( @@ -422,7 +431,7 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleCreateParamByNameImmediate( if (size > data_size) return BufferSyncInterface::kParseInvalidArguments; if (data_size == 0) { - return ParseError::kParseNoError; + return BufferSyncInterface::kParseNoError; } return gapi_->CreateParamByName(args.param_id, args.effect_id, size, AddressAfterStruct(args)); @@ -431,7 +440,7 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleCreateParamByNameImmediate( BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyParam( uint32 arg_count, const cmd::DestroyParam& args) { - return gapi_->DestroyParam(args.id); + return gapi_->DestroyParam(args.param_id); } BufferSyncInterface::ParseError GAPIDecoder::HandleSetParamData( @@ -444,7 +453,7 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleSetParamData( args.shared_memory.offset, size); if (!data) return BufferSyncInterface::kParseInvalidArguments; - return gapi_->SetParamData(args.id, size, data); + return gapi_->SetParamData(args.param_id, size, data); } BufferSyncInterface::ParseError GAPIDecoder::HandleSetParamDataImmediate( @@ -454,12 +463,13 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleSetParamDataImmediate( // validated them. uint32 size = args.size; uint32 data_size = ImmediateDataSize(arg_count, args); - if (size > data_size) + if (size > data_size) { return BufferSyncInterface::kParseInvalidArguments; + } if (data_size == 0) { - return ParseError::kParseNoError; + return BufferSyncInterface::kParseNoError; } - return gapi_->SetParamData(args.id, size, AddressAfterStruct(args)); + return gapi_->SetParamData(args.param_id, size, AddressAfterStruct(args)); } BufferSyncInterface::ParseError GAPIDecoder::HandleGetParamDesc( @@ -472,7 +482,7 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleGetParamDesc( args.shared_memory.offset, size); if (!data) return BufferSyncInterface::kParseInvalidArguments; - return gapi_->GetParamDesc(args.id, size, data); + return gapi_->GetParamDesc(args.param_id, size, data); } BufferSyncInterface::ParseError GAPIDecoder::HandleGetStreamCount( @@ -485,7 +495,7 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleGetStreamCount( args.shared_memory.offset, size); if (!data) return BufferSyncInterface::kParseInvalidArguments; - return gapi_->GetStreamCount(args.id, size, data); + return gapi_->GetStreamCount(args.effect_id, size, data); } BufferSyncInterface::ParseError GAPIDecoder::HandleGetStreamDesc( @@ -498,31 +508,30 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleGetStreamDesc( args.shared_memory.offset, size); if (!data) return BufferSyncInterface::kParseInvalidArguments; - return gapi_->GetStreamDesc(args.id, args.index, size, data); + return gapi_->GetStreamDesc(args.effect_id, args.index, size, data); } BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyTexture( uint32 arg_count, const cmd::DestroyTexture& args) { - return gapi_->DestroyTexture(args.id); + return gapi_->DestroyTexture(args.texture_id); } BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTexture2d( uint32 arg_count, const cmd::CreateTexture2d& args) { - namespace cmd = create_texture_2d_cmd; - unsigned int width_height = args.fixme1; - unsigned int levels_format_flags = args.fixme2; - unsigned int width = cmd::Width::Get(width_height); - unsigned int height = cmd::Height::Get(width_height); - unsigned int levels = cmd::Levels::Get(levels_format_flags); - unsigned int unused = cmd::Unused::Get(levels_format_flags); - unsigned int format = cmd::Format::Get(levels_format_flags); - unsigned int flags = cmd::Flags::Get(levels_format_flags); + unsigned int width_height = args.width_height; + unsigned int levels_format_flags = args.levels_format_flags; + unsigned int width = cmd::CreateTexture2d::Width::Get(width_height); + unsigned int height = cmd::CreateTexture2d::Height::Get(width_height); + unsigned int levels = cmd::CreateTexture2d::Levels::Get(levels_format_flags); + unsigned int unused = cmd::CreateTexture2d::Unused::Get(levels_format_flags); + unsigned int format = cmd::CreateTexture2d::Format::Get(levels_format_flags); + unsigned int flags = cmd::CreateTexture2d::Flags::Get(levels_format_flags); unsigned int max_levels = 1 + base::bits::Log2Ceiling(std::max(width, height)); if ((width == 0) || (height == 0) || (levels > max_levels) || - (unused != 0) || (format >= texture::NUM_FORMATS) || (levels == 0)) + (unused != 0) || (format >= texture::kNumFormats) || (levels == 0)) return BufferSyncInterface::kParseInvalidArguments; bool enable_render_surfaces = !!flags; return gapi_->CreateTexture2D(args.texture_id, width, height, levels, @@ -533,23 +542,23 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTexture2d( BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTexture3d( uint32 arg_count, const cmd::CreateTexture3d& args) { - namespace cmd = create_texture_3d_cmd; - unsigned int width_height = args.fixme1; - unsigned int depth_unused = args.fixme2; - unsigned int levels_format_flags = args.fixme3; - unsigned int width = cmd::Width::Get(width_height); - unsigned int height = cmd::Height::Get(width_height); - unsigned int depth = cmd::Depth::Get(depth_unused); - unsigned int unused1 = cmd::Unused1::Get(depth_unused); - unsigned int levels = cmd::Levels::Get(levels_format_flags); - unsigned int unused2 = cmd::Unused2::Get(levels_format_flags); - unsigned int format = cmd::Format::Get(levels_format_flags); - unsigned int flags = cmd::Flags::Get(levels_format_flags); + unsigned int width_height = args.width_height; + unsigned int depth_unused = args.depth_unused; + unsigned int levels_format_flags = args.levels_format_flags; + unsigned int width = cmd::CreateTexture3d::Width::Get(width_height); + unsigned int height = cmd::CreateTexture3d::Height::Get(width_height); + unsigned int depth = cmd::CreateTexture3d::Depth::Get(depth_unused); + unsigned int unused1 = cmd::CreateTexture3d::Unused1::Get(depth_unused); + unsigned int levels = cmd::CreateTexture3d::Levels::Get(levels_format_flags); + unsigned int unused2 = + cmd::CreateTexture3d::Unused2::Get(levels_format_flags); + unsigned int format = cmd::CreateTexture3d::Format::Get(levels_format_flags); + unsigned int flags = cmd::CreateTexture3d::Flags::Get(levels_format_flags); unsigned int max_levels = 1 + base::bits::Log2Ceiling(std::max(depth, std::max(width, height))); if ((width == 0) || (height == 0) || (depth == 0) || (levels > max_levels) || (unused1 != 0) || (unused2 != 0) || - (format >= texture::NUM_FORMATS) || (levels == 0)) + (format >= texture::kNumFormats) || (levels == 0)) return BufferSyncInterface::kParseInvalidArguments; bool enable_render_surfaces = !!flags; return gapi_->CreateTexture3D(args.texture_id, width, height, depth, levels, @@ -560,18 +569,20 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTexture3d( BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTextureCube( uint32 arg_count, const cmd::CreateTextureCube& args) { - namespace cmd = create_texture_cube_cmd; unsigned int side_unused = args.edge_length; - unsigned int levels_format_flags = args.fixme2; - unsigned int side = cmd::Side::Get(side_unused); - unsigned int unused1 = cmd::Unused1::Get(side_unused); - unsigned int levels = cmd::Levels::Get(levels_format_flags); - unsigned int unused2 = cmd::Unused2::Get(levels_format_flags); - unsigned int format = cmd::Format::Get(levels_format_flags); - unsigned int flags = cmd::Flags::Get(levels_format_flags); + unsigned int levels_format_flags = args.levels_format_flags; + unsigned int side = cmd::CreateTextureCube::Side::Get(side_unused); + unsigned int unused1 = cmd::CreateTextureCube::Unused1::Get(side_unused); + unsigned int levels = + cmd::CreateTextureCube::Levels::Get(levels_format_flags); + unsigned int unused2 = + cmd::CreateTextureCube::Unused2::Get(levels_format_flags); + unsigned int format = + cmd::CreateTextureCube::Format::Get(levels_format_flags); + unsigned int flags = cmd::CreateTextureCube::Flags::Get(levels_format_flags); unsigned int max_levels = 1 + base::bits::Log2Ceiling(side); if ((side == 0) || (levels > max_levels) || (unused1 != 0) || - (unused2 != 0) || (format >= texture::NUM_FORMATS) || (levels == 0)) + (unused2 != 0) || (format >= texture::kNumFormats) || (levels == 0)) return BufferSyncInterface::kParseInvalidArguments; bool enable_render_surfaces = !!flags; return gapi_->CreateTextureCube(args.texture_id, side, levels, @@ -582,21 +593,20 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTextureCube( BufferSyncInterface::ParseError GAPIDecoder::HandleSetTextureData( uint32 arg_count, const cmd::SetTextureData& args) { - namespace cmd = set_texture_data_cmd; - unsigned int x_y = args.fixme1; - unsigned int width_height = args.fixme2; - unsigned int z_depth = args.fixme3; - unsigned int level_face = args.fixme4; + unsigned int x_y = args.x_y; + unsigned int width_height = args.width_height; + unsigned int z_depth = args.z_depth; + unsigned int level_face = args.level_face; unsigned int size = args.size; - unsigned int x = cmd::X::Get(x_y); - unsigned int y = cmd::Y::Get(x_y); - unsigned int width = cmd::Width::Get(width_height); - unsigned int height = cmd::Height::Get(width_height); - unsigned int z = cmd::Z::Get(z_depth); - unsigned int depth = cmd::Depth::Get(z_depth); - unsigned int level = cmd::Level::Get(level_face); - unsigned int face = cmd::Face::Get(level_face); - unsigned int unused = cmd::Unused::Get(level_face); + unsigned int x = cmd::SetTextureData::X::Get(x_y); + unsigned int y = cmd::SetTextureData::Y::Get(x_y); + unsigned int width = cmd::SetTextureData::Width::Get(width_height); + unsigned int height = cmd::SetTextureData::Height::Get(width_height); + unsigned int z = cmd::SetTextureData::Z::Get(z_depth); + unsigned int depth = cmd::SetTextureData::Depth::Get(z_depth); + unsigned int level = cmd::SetTextureData::Level::Get(level_face); + unsigned int face = cmd::SetTextureData::Face::Get(level_face); + unsigned int unused = cmd::SetTextureData::Unused::Get(level_face); const void *data = GetAddressAndCheckSize(args.shared_memory.id, args.shared_memory.offset, size); if (face >= 6 || unused != 0 || !data) @@ -610,27 +620,26 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleSetTextureData( BufferSyncInterface::ParseError GAPIDecoder::HandleSetTextureDataImmediate( uint32 arg_count, const cmd::SetTextureDataImmediate& args) { - namespace cmd = set_texture_data_immediate_cmd; - unsigned int x_y = args.fixme1; - unsigned int width_height = args.fixme2; - unsigned int z_depth = args.fixme3; - unsigned int level_face = args.fixme4; + unsigned int x_y = args.x_y; + unsigned int width_height = args.width_height; + unsigned int z_depth = args.z_depth; + unsigned int level_face = args.level_face; unsigned int size = args.size; - unsigned int x = cmd::X::Get(x_y); - unsigned int y = cmd::Y::Get(x_y); - unsigned int width = cmd::Width::Get(width_height); - unsigned int height = cmd::Height::Get(width_height); - unsigned int z = cmd::Z::Get(z_depth); - unsigned int depth = cmd::Depth::Get(z_depth); - unsigned int level = cmd::Level::Get(level_face); - unsigned int face = cmd::Face::Get(level_face); - unsigned int unused = cmd::Unused::Get(level_face); + unsigned int x = cmd::SetTextureDataImmediate::X::Get(x_y); + unsigned int y = cmd::SetTextureDataImmediate::Y::Get(x_y); + unsigned int width = cmd::SetTextureDataImmediate::Width::Get(width_height); + unsigned int height = cmd::SetTextureDataImmediate::Height::Get(width_height); + unsigned int z = cmd::SetTextureDataImmediate::Z::Get(z_depth); + unsigned int depth = cmd::SetTextureDataImmediate::Depth::Get(z_depth); + unsigned int level = cmd::SetTextureDataImmediate::Level::Get(level_face); + unsigned int face = cmd::SetTextureDataImmediate::Face::Get(level_face); + unsigned int unused = cmd::SetTextureDataImmediate::Unused::Get(level_face); uint32 data_size = ImmediateDataSize(arg_count, args); if (face >= 6 || unused != 0 || size > data_size) return BufferSyncInterface::kParseInvalidArguments; if (data_size == 0) { - return ParseError::kParseNoError; + return BufferSyncInterface::kParseNoError; } return gapi_->SetTextureData( args.texture_id, x, y, z, width, height, depth, level, @@ -641,21 +650,20 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleSetTextureDataImmediate( BufferSyncInterface::ParseError GAPIDecoder::HandleGetTextureData( uint32 arg_count, const cmd::GetTextureData& args) { - namespace cmd = get_texture_data_cmd; - unsigned int x_y = args.fixme1; - unsigned int width_height = args.fixme2; - unsigned int z_depth = args.fixme3; - unsigned int level_face = args.fixme4; + unsigned int x_y = args.x_y; + unsigned int width_height = args.width_height; + unsigned int z_depth = args.z_depth; + unsigned int level_face = args.level_face; unsigned int size = args.size; - unsigned int x = cmd::X::Get(x_y); - unsigned int y = cmd::Y::Get(x_y); - unsigned int width = cmd::Width::Get(width_height); - unsigned int height = cmd::Height::Get(width_height); - unsigned int z = cmd::Z::Get(z_depth); - unsigned int depth = cmd::Depth::Get(z_depth); - unsigned int level = cmd::Level::Get(level_face); - unsigned int face = cmd::Face::Get(level_face); - unsigned int unused = cmd::Unused::Get(level_face); + unsigned int x = cmd::GetTextureData::X::Get(x_y); + unsigned int y = cmd::GetTextureData::Y::Get(x_y); + unsigned int width = cmd::GetTextureData::Width::Get(width_height); + unsigned int height = cmd::GetTextureData::Height::Get(width_height); + unsigned int z = cmd::GetTextureData::Z::Get(z_depth); + unsigned int depth = cmd::GetTextureData::Depth::Get(z_depth); + unsigned int level = cmd::GetTextureData::Level::Get(level_face); + unsigned int face = cmd::GetTextureData::Face::Get(level_face); + unsigned int unused = cmd::GetTextureData::Unused::Get(level_face); void *data = GetAddressAndCheckSize(args.shared_memory.id, args.shared_memory.offset, size); if (face >= 6 || unused != 0 || !data) @@ -669,42 +677,41 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleGetTextureData( BufferSyncInterface::ParseError GAPIDecoder::HandleCreateSampler( uint32 arg_count, const cmd::CreateSampler& args) { - return gapi_->CreateSampler(args.id); + return gapi_->CreateSampler(args.sampler_id); } BufferSyncInterface::ParseError GAPIDecoder::HandleDestroySampler( uint32 arg_count, const cmd::DestroySampler& args) { - return gapi_->DestroySampler(args.id); + return gapi_->DestroySampler(args.sampler_id); } BufferSyncInterface::ParseError GAPIDecoder::HandleSetSamplerStates( uint32 arg_count, const cmd::SetSamplerStates& args) { - namespace cmd = set_sampler_states; - Uint32 arg = args.fixme1; - if (cmd::Unused::Get(arg) != 0) + Uint32 arg = args.sampler_states; + if (cmd::SetSamplerStates::Unused::Get(arg) != 0) return BufferSyncInterface::kParseInvalidArguments; - unsigned int address_u_value = cmd::AddressingU::Get(arg); - unsigned int address_v_value = cmd::AddressingV::Get(arg); - unsigned int address_w_value = cmd::AddressingW::Get(arg); - unsigned int mag_filter_value = cmd::MagFilter::Get(arg); - unsigned int min_filter_value = cmd::MinFilter::Get(arg); - unsigned int mip_filter_value = cmd::MipFilter::Get(arg); - unsigned int max_anisotropy = cmd::MaxAnisotropy::Get(arg); - if (address_u_value >= sampler::NUM_ADDRESSING_MODE || - address_v_value >= sampler::NUM_ADDRESSING_MODE || - address_w_value >= sampler::NUM_ADDRESSING_MODE || - mag_filter_value >= sampler::NUM_FILTERING_MODE || - min_filter_value >= sampler::NUM_FILTERING_MODE || - mip_filter_value >= sampler::NUM_FILTERING_MODE || - mag_filter_value == sampler::NONE || - min_filter_value == sampler::NONE || + unsigned int address_u_value = cmd::SetSamplerStates::AddressingU::Get(arg); + unsigned int address_v_value = cmd::SetSamplerStates::AddressingV::Get(arg); + unsigned int address_w_value = cmd::SetSamplerStates::AddressingW::Get(arg); + unsigned int mag_filter_value = cmd::SetSamplerStates::MagFilter::Get(arg); + unsigned int min_filter_value = cmd::SetSamplerStates::MinFilter::Get(arg); + unsigned int mip_filter_value = cmd::SetSamplerStates::MipFilter::Get(arg); + unsigned int max_anisotropy = cmd::SetSamplerStates::MaxAnisotropy::Get(arg); + if (address_u_value >= sampler::kNumAddressingMode || + address_v_value >= sampler::kNumAddressingMode || + address_w_value >= sampler::kNumAddressingMode || + mag_filter_value >= sampler::kNumFilteringMode || + min_filter_value >= sampler::kNumFilteringMode || + mip_filter_value >= sampler::kNumFilteringMode || + mag_filter_value == sampler::kNone || + min_filter_value == sampler::kNone || max_anisotropy == 0) { return BufferSyncInterface::kParseInvalidArguments; } gapi_->SetSamplerStates( - args.id, + args.sampler_id, static_cast<sampler::AddressingMode>(address_u_value), static_cast<sampler::AddressingMode>(address_v_value), static_cast<sampler::AddressingMode>(address_w_value), @@ -723,28 +730,27 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleSetSamplerBorderColor( rgba.green = args.green; rgba.blue = args.blue; rgba.alpha = args.alpha; - return gapi_->SetSamplerBorderColor(args.id, rgba); + return gapi_->SetSamplerBorderColor(args.sampler_id, rgba); } BufferSyncInterface::ParseError GAPIDecoder::HandleSetSamplerTexture( uint32 arg_count, const cmd::SetSamplerTexture& args) { - return gapi_->SetSamplerTexture(args.id, args.texture_id); + return gapi_->SetSamplerTexture(args.sampler_id, args.texture_id); } BufferSyncInterface::ParseError GAPIDecoder::HandleSetScissor( uint32 arg_count, const cmd::SetScissor& args) { - namespace cmd = set_scissor; - Uint32 x_y_enable = args.fixme0; - if (cmd::Unused::Get(x_y_enable) != 0) + Uint32 x_y_enable = args.x_y_enable; + if (cmd::SetScissor::Unused::Get(x_y_enable) != 0) return BufferSyncInterface::kParseInvalidArguments; - unsigned int x = cmd::X::Get(x_y_enable); - unsigned int y = cmd::Y::Get(x_y_enable); - bool enable = cmd::Enable::Get(x_y_enable) != 0; - Uint32 width_height = args.fixme1; - unsigned int width = cmd::Width::Get(width_height); - unsigned int height = cmd::Height::Get(width_height); + unsigned int x = cmd::SetScissor::X::Get(x_y_enable); + unsigned int y = cmd::SetScissor::Y::Get(x_y_enable); + bool enable = cmd::SetScissor::Enable::Get(x_y_enable) != 0; + Uint32 width_height = args.width_height; + unsigned int width = cmd::SetScissor::Width::Get(width_height); + unsigned int height = cmd::SetScissor::Height::Get(width_height); gapi_->SetScissor(enable, x, y, width, height); return BufferSyncInterface::kParseNoError; } @@ -759,12 +765,12 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleSetPolygonOffset( BufferSyncInterface::ParseError GAPIDecoder::HandleSetPointLineRaster( uint32 arg_count, const cmd::SetPointLineRaster& args) { - namespace cmd = set_point_line_raster; - Uint32 enables = args.fixme0; - if (cmd::Unused::Get(enables) != 0) + Uint32 enables = args.enables; + if (cmd::SetPointLineRaster::Unused::Get(enables) != 0) return BufferSyncInterface::kParseInvalidArguments; - bool line_smooth = !!cmd::LineSmoothEnable::Get(enables); - bool point_sprite = !!cmd::PointSpriteEnable::Get(enables); + bool line_smooth = !!cmd::SetPointLineRaster::LineSmoothEnable::Get(enables); + bool point_sprite = + !!cmd::SetPointLineRaster::PointSpriteEnable::Get(enables); gapi_->SetPointLineRaster(line_smooth, point_sprite, args.point_size); return BufferSyncInterface::kParseNoError; } @@ -772,34 +778,33 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleSetPointLineRaster( BufferSyncInterface::ParseError GAPIDecoder::HandleSetPolygonRaster( uint32 arg_count, const cmd::SetPolygonRaster& args) { - namespace cmd = set_polygon_raster; - Uint32 fill_cull = args.fixme0; - unsigned int fill_value = cmd::FillMode::Get(fill_cull); - unsigned int cull_value = cmd::CullMode::Get(fill_cull); - if (cmd::Unused::Get(fill_cull) != 0 || - fill_value >= GAPIInterface::NUM_POLYGON_MODE || - cull_value >= GAPIInterface::NUM_FACE_CULL_MODE) + Uint32 fill_cull = args.fill_cull; + unsigned int fill_value = cmd::SetPolygonRaster::FillMode::Get(fill_cull); + unsigned int cull_value = cmd::SetPolygonRaster::CullMode::Get(fill_cull); + if (cmd::SetPolygonRaster::Unused::Get(fill_cull) != 0 || + fill_value >= command_buffer::kNumPolygonMode || + cull_value >= command_buffer::kNumFaceCullMode) return BufferSyncInterface::kParseInvalidArguments; gapi_->SetPolygonRaster( - static_cast<GAPIInterface::PolygonMode>(fill_value), - static_cast<GAPIInterface::FaceCullMode>(cull_value)); + static_cast<command_buffer::PolygonMode>(fill_value), + static_cast<command_buffer::FaceCullMode>(cull_value)); return BufferSyncInterface::kParseNoError; } BufferSyncInterface::ParseError GAPIDecoder::HandleSetAlphaTest( uint32 arg_count, const cmd::SetAlphaTest& args) { - namespace cmd = set_alpha_test; - Uint32 func_enable = args.fixme0; - if (cmd::Unused::Get(func_enable) != 0) + Uint32 func_enable = args.func_enable; + if (cmd::SetAlphaTest::Unused::Get(func_enable) != 0) return BufferSyncInterface::kParseInvalidArguments; // Check that the bitmask get cannot generate values outside of the // allowed range. - COMPILE_ASSERT(cmd::Func::kMask < GAPIInterface::NUM_COMPARISON, + COMPILE_ASSERT(cmd::SetAlphaTest::Func::kMask < + command_buffer::kNumComparison, set_alpha_test_Func_may_produce_invalid_values); - GAPIInterface::Comparison comp = - static_cast<GAPIInterface::Comparison>(cmd::Func::Get(func_enable)); - bool enable = cmd::Enable::Get(func_enable) != 0; + command_buffer::Comparison comp = static_cast<command_buffer::Comparison>( + cmd::SetAlphaTest::Func::Get(func_enable)); + bool enable = cmd::SetAlphaTest::Enable::Get(func_enable) != 0; gapi_->SetAlphaTest(enable, args.value, comp); return BufferSyncInterface::kParseNoError; } @@ -807,18 +812,18 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleSetAlphaTest( BufferSyncInterface::ParseError GAPIDecoder::HandleSetDepthTest( uint32 arg_count, const cmd::SetDepthTest& args) { - namespace cmd = set_depth_test; - Uint32 func_enable = args.fixme0; - if (cmd::Unused::Get(func_enable) != 0) + Uint32 func_enable = args.func_enable; + if (cmd::SetDepthTest::Unused::Get(func_enable) != 0) return BufferSyncInterface::kParseInvalidArguments; // Check that the bitmask get cannot generate values outside of the // allowed range. - COMPILE_ASSERT(cmd::Func::kMask < GAPIInterface::NUM_COMPARISON, + COMPILE_ASSERT(cmd::SetDepthTest::Func::kMask < + command_buffer::kNumComparison, set_alpha_test_Func_may_produce_invalid_values); - GAPIInterface::Comparison comp = - static_cast<GAPIInterface::Comparison>(cmd::Func::Get(func_enable)); - bool write_enable = cmd::WriteEnable::Get(func_enable) != 0; - bool enable = cmd::Enable::Get(func_enable) != 0; + command_buffer::Comparison comp = static_cast<command_buffer::Comparison>( + cmd::SetDepthTest::Func::Get(func_enable)); + bool write_enable = cmd::SetDepthTest::WriteEnable::Get(func_enable) != 0; + bool enable = cmd::SetDepthTest::Enable::Get(func_enable) != 0; gapi_->SetDepthTest(enable, write_enable, comp); return BufferSyncInterface::kParseNoError; } @@ -826,18 +831,17 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleSetDepthTest( BufferSyncInterface::ParseError GAPIDecoder::HandleSetStencilTest( uint32 arg_count, const cmd::SetStencilTest& args) { - namespace cmd = set_stencil_test; - Uint32 arg0 = args.fixme0; - Uint32 arg1 = args.fixme1; - if (cmd::Unused0::Get(arg0) != 0 || - cmd::Unused1::Get(arg1) != 0 || - cmd::Unused2::Get(arg1) != 0) + Uint32 arg0 = args.stencil_args0; + Uint32 arg1 = args.stencil_args1; + if (cmd::SetStencilTest::Unused0::Get(arg0) != 0 || + cmd::SetStencilTest::Unused1::Get(arg1) != 0 || + cmd::SetStencilTest::Unused2::Get(arg1) != 0) return BufferSyncInterface::kParseInvalidArguments; - unsigned int write_mask = cmd::WriteMask::Get(arg0); - unsigned int compare_mask = cmd::CompareMask::Get(arg0); - unsigned int ref = cmd::ReferenceValue::Get(arg0); - bool enable = cmd::Enable::Get(arg0) != 0; - bool separate_ccw = cmd::SeparateCCW::Get(arg0) != 0; + unsigned int write_mask = cmd::SetStencilTest::WriteMask::Get(arg0); + unsigned int compare_mask = cmd::SetStencilTest::CompareMask::Get(arg0); + unsigned int ref = cmd::SetStencilTest::ReferenceValue::Get(arg0); + bool enable = cmd::SetStencilTest::Enable::Get(arg0) != 0; + bool separate_ccw = cmd::SetStencilTest::SeparateCCW::Get(arg0) != 0; gapi_->SetStencilTest(enable, separate_ccw, write_mask, compare_mask, ref, arg1); return BufferSyncInterface::kParseNoError; @@ -846,15 +850,14 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleSetStencilTest( BufferSyncInterface::ParseError GAPIDecoder::HandleSetColorWrite( uint32 arg_count, const cmd::SetColorWrite& args) { - namespace cmd = set_color_write; Uint32 enables = args.flags; - if (cmd::Unused::Get(enables) != 0) + if (cmd::SetColorWrite::Unused::Get(enables) != 0) return BufferSyncInterface::kParseInvalidArguments; - bool red = cmd::RedMask::Get(enables) != 0; - bool green = cmd::GreenMask::Get(enables) != 0; - bool blue = cmd::BlueMask::Get(enables) != 0; - bool alpha = cmd::AlphaMask::Get(enables) != 0; - bool dither = cmd::DitherEnable::Get(enables) != 0; + bool red = cmd::SetColorWrite::RedMask::Get(enables) != 0; + bool green = cmd::SetColorWrite::GreenMask::Get(enables) != 0; + bool blue = cmd::SetColorWrite::BlueMask::Get(enables) != 0; + bool alpha = cmd::SetColorWrite::AlphaMask::Get(enables) != 0; + bool dither = cmd::SetColorWrite::DitherEnable::Get(enables) != 0; gapi_->SetColorWrite(red, green, blue, alpha, dither); return BufferSyncInterface::kParseNoError; } @@ -862,33 +865,32 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleSetColorWrite( BufferSyncInterface::ParseError GAPIDecoder::HandleSetBlending( uint32 arg_count, const cmd::SetBlending& args) { - namespace cmd = set_blending; - Uint32 arg = args.fixme0; - bool enable = cmd::Enable::Get(arg) != 0; - bool separate_alpha = cmd::SeparateAlpha::Get(arg) != 0; - unsigned int color_eq = cmd::ColorEq::Get(arg); - unsigned int color_src = cmd::ColorSrcFunc::Get(arg); - unsigned int color_dst = cmd::ColorDstFunc::Get(arg); - unsigned int alpha_eq = cmd::AlphaEq::Get(arg); - unsigned int alpha_src = cmd::AlphaSrcFunc::Get(arg); - unsigned int alpha_dst = cmd::AlphaDstFunc::Get(arg); - if (cmd::Unused0::Get(arg) != 0 || - cmd::Unused1::Get(arg) != 0 || - color_eq >= GAPIInterface::NUM_BLEND_EQ || - color_src >= GAPIInterface::NUM_BLEND_FUNC || - color_dst >= GAPIInterface::NUM_BLEND_FUNC || - alpha_eq >= GAPIInterface::NUM_BLEND_EQ || - alpha_src >= GAPIInterface::NUM_BLEND_FUNC || - alpha_dst >= GAPIInterface::NUM_BLEND_FUNC) + Uint32 arg = args.blend_settings; + bool enable = cmd::SetBlending::Enable::Get(arg) != 0; + bool separate_alpha = cmd::SetBlending::SeparateAlpha::Get(arg) != 0; + unsigned int color_eq = cmd::SetBlending::ColorEq::Get(arg); + unsigned int color_src = cmd::SetBlending::ColorSrcFunc::Get(arg); + unsigned int color_dst = cmd::SetBlending::ColorDstFunc::Get(arg); + unsigned int alpha_eq = cmd::SetBlending::AlphaEq::Get(arg); + unsigned int alpha_src = cmd::SetBlending::AlphaSrcFunc::Get(arg); + unsigned int alpha_dst = cmd::SetBlending::AlphaDstFunc::Get(arg); + if (cmd::SetBlending::Unused0::Get(arg) != 0 || + cmd::SetBlending::Unused1::Get(arg) != 0 || + color_eq >= command_buffer::kNumBlendEq || + color_src >= command_buffer::kNumBlendFunc || + color_dst >= command_buffer::kNumBlendFunc || + alpha_eq >= command_buffer::kNumBlendEq || + alpha_src >= command_buffer::kNumBlendFunc || + alpha_dst >= command_buffer::kNumBlendFunc) return BufferSyncInterface::kParseInvalidArguments; gapi_->SetBlending(enable, separate_alpha, - static_cast<GAPIInterface::BlendEq>(color_eq), - static_cast<GAPIInterface::BlendFunc>(color_src), - static_cast<GAPIInterface::BlendFunc>(color_dst), - static_cast<GAPIInterface::BlendEq>(alpha_eq), - static_cast<GAPIInterface::BlendFunc>(alpha_src), - static_cast<GAPIInterface::BlendFunc>(alpha_dst)); + static_cast<command_buffer::BlendEq>(color_eq), + static_cast<command_buffer::BlendFunc>(color_src), + static_cast<command_buffer::BlendFunc>(color_dst), + static_cast<command_buffer::BlendEq>(alpha_eq), + static_cast<command_buffer::BlendFunc>(alpha_src), + static_cast<command_buffer::BlendFunc>(alpha_dst)); return BufferSyncInterface::kParseNoError; } @@ -907,37 +909,36 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleSetBlendingColor( BufferSyncInterface::ParseError GAPIDecoder::HandleCreateRenderSurface( uint32 arg_count, const cmd::CreateRenderSurface& args) { - namespace cmd = create_render_surface_cmd; - unsigned int width_height = args.fixme1; - unsigned int width = cmd::Width::Get(width_height); - unsigned int height = cmd::Height::Get(width_height); - unsigned int levels_side = args.fixme2; - unsigned int mip_level = cmd::Levels::Get(levels_side); - unsigned int side = cmd::Side::Get(levels_side); - return gapi_->CreateRenderSurface(args.id, width, height, mip_level, + unsigned int width_height = args.width_height; + unsigned int width = cmd::CreateRenderSurface::Width::Get(width_height); + unsigned int height = cmd::CreateRenderSurface::Height::Get(width_height); + unsigned int levels_side = args.levels_side; + unsigned int mip_level = cmd::CreateRenderSurface::Levels::Get(levels_side); + unsigned int side = cmd::CreateRenderSurface::Side::Get(levels_side); + return gapi_->CreateRenderSurface(args.render_surface_id, + width, height, mip_level, side, args.texture_id); } BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyRenderSurface( uint32 arg_count, const cmd::DestroyRenderSurface& args) { - return gapi_->DestroyRenderSurface(args.id); + return gapi_->DestroyRenderSurface(args.render_surface_id); } BufferSyncInterface::ParseError GAPIDecoder::HandleCreateDepthSurface( uint32 arg_count, const cmd::CreateDepthSurface& args) { - namespace cmd = create_depth_surface_cmd; - unsigned int width_height = args.fixme1; - unsigned int width = cmd::Width::Get(width_height); - unsigned int height = cmd::Height::Get(width_height); - return gapi_->CreateDepthSurface(args.id, width, height); + unsigned int width_height = args.width_height; + unsigned int width = cmd::CreateDepthSurface::Width::Get(width_height); + unsigned int height = cmd::CreateDepthSurface::Height::Get(width_height); + return gapi_->CreateDepthSurface(args.depth_surface_id, width, height); } BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyDepthSurface( uint32 arg_count, const cmd::DestroyDepthSurface& args) { - return gapi_->DestroyDepthSurface(args.id); + return gapi_->DestroyDepthSurface(args.depth_surface_id); } BufferSyncInterface::ParseError GAPIDecoder::HandleSetRenderSurface( diff --git a/o3d/command_buffer/service/cross/gl/effect_gl.cc b/o3d/command_buffer/service/cross/gl/effect_gl.cc index 41701ac..21c0e04 100644 --- a/o3d/command_buffer/service/cross/gl/effect_gl.cc +++ b/o3d/command_buffer/service/cross/gl/effect_gl.cc @@ -62,34 +62,34 @@ static effect_param::DataType CgTypeToCBType(CGtype cg_type) { switch (cg_type) { case CG_FLOAT: case CG_FLOAT1: - return effect_param::FLOAT1; + return effect_param::kFloat1; case CG_FLOAT2: - return effect_param::FLOAT2; + return effect_param::kFloat2; case CG_FLOAT3: - return effect_param::FLOAT3; + return effect_param::kFloat3; case CG_FLOAT4: - return effect_param::FLOAT4; + return effect_param::kFloat4; case CG_INT: case CG_INT1: - return effect_param::INT; + return effect_param::kInt; case CG_BOOL: case CG_BOOL1: - return effect_param::BOOL; + return effect_param::kBool; case CG_FLOAT4x4: - return effect_param::MATRIX4; + return effect_param::kMatrix4; case CG_SAMPLER: case CG_SAMPLER1D: case CG_SAMPLER2D: case CG_SAMPLER3D: case CG_SAMPLERCUBE: - return effect_param::SAMPLER; + return effect_param::kSampler; case CG_TEXTURE: - return effect_param::TEXTURE; + return effect_param::kTexture; default : { DLOG(INFO) << "Cannot convert CGtype " << cgGetTypeString(cg_type) << " to a Param type."; - return effect_param::UNKNOWN; + return effect_param::kUnknown; } } } @@ -106,7 +106,7 @@ EffectParamGL *EffectParamGL::Create(EffectGL *effect, } effect_param::DataType type = CgTypeToCBType(cg_type); - if (type == effect_param::UNKNOWN) + if (type == effect_param::kUnknown) return NULL; return new EffectParamGL(type, effect, index); } @@ -177,49 +177,49 @@ bool EffectParamGL::SetData(GAPIGL *gapi, return false; switch (type) { - case effect_param::FLOAT1: + case effect_param::kFloat1: if (vp_param) cgSetParameter1f(vp_param, *static_cast<const float *>(data)); if (fp_param) cgSetParameter1f(fp_param, *static_cast<const float *>(data)); break; - case effect_param::FLOAT2: + case effect_param::kFloat2: if (vp_param) cgSetParameter2fv(vp_param, static_cast<const float *>(data)); if (fp_param) cgSetParameter2fv(fp_param, static_cast<const float *>(data)); break; - case effect_param::FLOAT3: + case effect_param::kFloat3: if (vp_param) cgSetParameter3fv(vp_param, static_cast<const float *>(data)); if (fp_param) cgSetParameter3fv(fp_param, static_cast<const float *>(data)); break; - case effect_param::FLOAT4: + case effect_param::kFloat4: if (vp_param) cgSetParameter4fv(vp_param, static_cast<const float *>(data)); if (fp_param) cgSetParameter4fv(fp_param, static_cast<const float *>(data)); break; - case effect_param::MATRIX4: + case effect_param::kMatrix4: if (vp_param) cgSetMatrixParameterfr(vp_param, static_cast<const float *>(data)); if (fp_param) cgSetMatrixParameterfr(fp_param, static_cast<const float *>(data)); break; - case effect_param::INT: + case effect_param::kInt: if (vp_param) cgSetParameter1i(vp_param, *static_cast<const int *>(data)); if (fp_param) cgSetParameter1i(fp_param, *static_cast<const int *>(data)); break; - case effect_param::BOOL: { + case effect_param::kBool: { int bool_value = *static_cast<const bool *>(data)?1:0; if (vp_param) cgSetParameter1i(vp_param, bool_value); if (fp_param) cgSetParameter1i(fp_param, bool_value); break; } - case effect_param::SAMPLER: { + case effect_param::kSampler: { DCHECK_GE(low_level_param.sampler_ids.size(), 1U); - low_level_param.sampler_ids[0] = *static_cast<const ResourceID *>(data); + low_level_param.sampler_ids[0] = *static_cast<const ResourceId *>(data); if (effect_ == gapi->current_effect()) { gapi->DirtyEffect(); } @@ -470,7 +470,7 @@ void EffectGL::AddLowLevelParams(CGprogram prog, CGenum name_space, bool vp) { param.sampler_ids.push_back(kInvalidResource); } else { param.sampler_ids.resize(num_elements); - std::vector<ResourceID>::iterator iter; + std::vector<ResourceId>::iterator iter; for (iter = param.sampler_ids.begin(); iter != param.sampler_ids.end(); ++iter) { @@ -494,81 +494,82 @@ typedef std::map<String, effect_stream::Desc> SemanticMap; // The map batween the semantics on vertex program varying parameters names // and vertex attribute indices under the VP_30 profile. +// TODO(gman): remove this. SemanticMapElement semantic_map_array[] = { SemanticMapElement("POSITION", - effect_stream::Desc(vertex_struct::POSITION, 0)), + effect_stream::Desc(vertex_struct::kPosition, 0)), SemanticMapElement("ATTR0", - effect_stream::Desc(vertex_struct::POSITION, 0)), + effect_stream::Desc(vertex_struct::kPosition, 0)), SemanticMapElement("BLENDWEIGHT", - effect_stream::Desc(vertex_struct::UNKNOWN_SEMANTIC, 0)), + effect_stream::Desc(vertex_struct::kUnknownSemantic, 0)), SemanticMapElement("ATTR1", - effect_stream::Desc(vertex_struct::UNKNOWN_SEMANTIC, 0)), + effect_stream::Desc(vertex_struct::kUnknownSemantic, 0)), SemanticMapElement("NORMAL", - effect_stream::Desc(vertex_struct::NORMAL, 0)), + effect_stream::Desc(vertex_struct::kNormal, 0)), SemanticMapElement("ATTR2", - effect_stream::Desc(vertex_struct::NORMAL, 0)), + effect_stream::Desc(vertex_struct::kNormal, 0)), SemanticMapElement("COLOR0", - effect_stream::Desc(vertex_struct::COLOR, 0)), + effect_stream::Desc(vertex_struct::kColor, 0)), SemanticMapElement("DIFFUSE", - effect_stream::Desc(vertex_struct::COLOR, 0)), + effect_stream::Desc(vertex_struct::kColor, 0)), SemanticMapElement("ATTR3", - effect_stream::Desc(vertex_struct::COLOR, 0)), + effect_stream::Desc(vertex_struct::kColor, 0)), SemanticMapElement("COLOR1", - effect_stream::Desc(vertex_struct::COLOR, 1)), + effect_stream::Desc(vertex_struct::kColor, 1)), SemanticMapElement("SPECULAR", - effect_stream::Desc(vertex_struct::COLOR, 1)), + effect_stream::Desc(vertex_struct::kColor, 1)), SemanticMapElement("ATTR4", - effect_stream::Desc(vertex_struct::COLOR, 1)), + effect_stream::Desc(vertex_struct::kColor, 1)), SemanticMapElement("TESSFACTOR", - effect_stream::Desc(vertex_struct::UNKNOWN_SEMANTIC, 0)), + effect_stream::Desc(vertex_struct::kUnknownSemantic, 0)), SemanticMapElement("FOGCOORD", - effect_stream::Desc(vertex_struct::UNKNOWN_SEMANTIC, 0)), + effect_stream::Desc(vertex_struct::kUnknownSemantic, 0)), SemanticMapElement("ATTR5", - effect_stream::Desc(vertex_struct::UNKNOWN_SEMANTIC, 0)), + effect_stream::Desc(vertex_struct::kUnknownSemantic, 0)), SemanticMapElement("PSIZE", - effect_stream::Desc(vertex_struct::UNKNOWN_SEMANTIC, 0)), + effect_stream::Desc(vertex_struct::kUnknownSemantic, 0)), SemanticMapElement("ATTR6", - effect_stream::Desc(vertex_struct::UNKNOWN_SEMANTIC, 0)), + effect_stream::Desc(vertex_struct::kUnknownSemantic, 0)), SemanticMapElement("BLENDINDICES", - effect_stream::Desc(vertex_struct::UNKNOWN_SEMANTIC, 0)), + effect_stream::Desc(vertex_struct::kUnknownSemantic, 0)), SemanticMapElement("ATTR7", - effect_stream::Desc(vertex_struct::UNKNOWN_SEMANTIC, 0)), + effect_stream::Desc(vertex_struct::kUnknownSemantic, 0)), SemanticMapElement("TEXCOORD0", - effect_stream::Desc(vertex_struct::TEX_COORD, 0)), + effect_stream::Desc(vertex_struct::kTexCoord, 0)), SemanticMapElement("ATTR8", - effect_stream::Desc(vertex_struct::TEX_COORD, 0)), + effect_stream::Desc(vertex_struct::kTexCoord, 0)), SemanticMapElement("TEXCOORD1", - effect_stream::Desc(vertex_struct::TEX_COORD, 1)), + effect_stream::Desc(vertex_struct::kTexCoord, 1)), SemanticMapElement("ATTR9", - effect_stream::Desc(vertex_struct::TEX_COORD, 1)), + effect_stream::Desc(vertex_struct::kTexCoord, 1)), SemanticMapElement("TEXCOORD2", - effect_stream::Desc(vertex_struct::TEX_COORD, 2)), + effect_stream::Desc(vertex_struct::kTexCoord, 2)), SemanticMapElement("ATTR10", - effect_stream::Desc(vertex_struct::TEX_COORD, 2)), + effect_stream::Desc(vertex_struct::kTexCoord, 2)), SemanticMapElement("TEXCOORD3", - effect_stream::Desc(vertex_struct::TEX_COORD, 3)), + effect_stream::Desc(vertex_struct::kTexCoord, 3)), SemanticMapElement("ATTR11", - effect_stream::Desc(vertex_struct::TEX_COORD, 3)), + effect_stream::Desc(vertex_struct::kTexCoord, 3)), SemanticMapElement("TEXCOORD4", - effect_stream::Desc(vertex_struct::TEX_COORD, 4)), + effect_stream::Desc(vertex_struct::kTexCoord, 4)), SemanticMapElement("ATTR12", - effect_stream::Desc(vertex_struct::TEX_COORD, 4)), + effect_stream::Desc(vertex_struct::kTexCoord, 4)), SemanticMapElement("TEXCOORD5", - effect_stream::Desc(vertex_struct::TEX_COORD, 5)), + effect_stream::Desc(vertex_struct::kTexCoord, 5)), SemanticMapElement("ATTR13", - effect_stream::Desc(vertex_struct::TEX_COORD, 5)), + effect_stream::Desc(vertex_struct::kTexCoord, 5)), SemanticMapElement("TEXCOORD6", - effect_stream::Desc(vertex_struct::TEX_COORD, 6)), + effect_stream::Desc(vertex_struct::kTexCoord, 6)), SemanticMapElement("TANGENT", - effect_stream::Desc(vertex_struct::TEX_COORD, 6)), + effect_stream::Desc(vertex_struct::kTexCoord, 6)), SemanticMapElement("ATTR14", - effect_stream::Desc(vertex_struct::TEX_COORD, 7)), + effect_stream::Desc(vertex_struct::kTexCoord, 7)), SemanticMapElement("TEXCOORD7", - effect_stream::Desc(vertex_struct::TEX_COORD, 7)), + effect_stream::Desc(vertex_struct::kTexCoord, 7)), SemanticMapElement("BINORMAL", - effect_stream::Desc(vertex_struct::TEX_COORD, 8)), + effect_stream::Desc(vertex_struct::kTexCoord, 8)), SemanticMapElement("ATTR15", - effect_stream::Desc(vertex_struct::TEX_COORD, 8)) + effect_stream::Desc(vertex_struct::kTexCoord, 8)) }; static SemanticMap semantic_map(semantic_map_array, @@ -604,7 +605,7 @@ void EffectGL::AddStreams(CGprogram prog, CGenum name_space) { SemanticMap::iterator iter = semantic_map.find(String(cg_semantic)); if (iter == semantic_map.end()) { streams_.push_back(effect_stream::Desc( - vertex_struct::UNKNOWN_SEMANTIC, 0)); + vertex_struct::kUnknownSemantic, 0)); } else { streams_.push_back(iter->second); } @@ -621,11 +622,11 @@ bool EffectGL::Begin(GAPIGL *gapi) { // First to set the sampler states on the texture for (unsigned int i = 0; i < sampler_params_.size(); ++i) { unsigned int param_index = sampler_params_[i]; - std::vector<ResourceID> &ids = low_level_params_[param_index].sampler_ids; - for (std::vector<ResourceID>::iterator iter = ids.begin(); + std::vector<ResourceId> &ids = low_level_params_[param_index].sampler_ids; + for (std::vector<ResourceId>::iterator iter = ids.begin(); iter != ids.end(); ++iter) { - ResourceID id = *iter; + ResourceId id = *iter; if (id != kInvalidResource) { SamplerGL *sampler = gapi->GetSampler(id); if (!sampler->ApplyStates(gapi)) { @@ -638,15 +639,15 @@ bool EffectGL::Begin(GAPIGL *gapi) { for (unsigned int i = 0; i < sampler_params_.size(); ++i) { unsigned int param_index = sampler_params_[i]; const LowLevelParam &ll_param = low_level_params_[param_index]; - std::vector<ResourceID> &ids = low_level_params_[param_index].sampler_ids; + std::vector<ResourceId> &ids = low_level_params_[param_index].sampler_ids; // TODO(petersont): Rewrite the following so it handles arrays of samplers // instead of simply bailing. if (cgGetParameterType(ll_param.fp_param) == CG_ARRAY) return false; - for (std::vector<ResourceID>::iterator iter = ids.begin(); + for (std::vector<ResourceId>::iterator iter = ids.begin(); iter != ids.end(); ++iter) { - ResourceID id = *iter; + ResourceId id = *iter; if (id != kInvalidResource) { SamplerGL *sampler = gapi->GetSampler(id); GLuint gl_texture = sampler->gl_texture(); @@ -705,7 +706,7 @@ EffectParamGL *EffectGL::CreateParamByName(const char *name) { return EffectParamGL::Create(this, index); } -BufferSyncInterface::ParseError GAPIGL::CreateEffect(ResourceID id, +BufferSyncInterface::ParseError GAPIGL::CreateEffect(ResourceId id, unsigned int size, const void *data) { if (id == current_effect_id_) DirtyEffect(); @@ -730,20 +731,20 @@ BufferSyncInterface::ParseError GAPIGL::CreateEffect(ResourceID id, return BufferSyncInterface::kParseNoError; } -BufferSyncInterface::ParseError GAPIGL::DestroyEffect(ResourceID id) { +BufferSyncInterface::ParseError GAPIGL::DestroyEffect(ResourceId id) { if (id == current_effect_id_) DirtyEffect(); return effects_.Destroy(id) ? BufferSyncInterface::kParseNoError : BufferSyncInterface::kParseInvalidArguments; } -BufferSyncInterface::ParseError GAPIGL::SetEffect(ResourceID id) { +BufferSyncInterface::ParseError GAPIGL::SetEffect(ResourceId id) { DirtyEffect(); current_effect_id_ = id; return BufferSyncInterface::kParseNoError; } -BufferSyncInterface::ParseError GAPIGL::GetParamCount(ResourceID id, +BufferSyncInterface::ParseError GAPIGL::GetParamCount(ResourceId id, unsigned int size, void *data) { EffectGL *effect = effects_.Get(id); @@ -753,8 +754,8 @@ BufferSyncInterface::ParseError GAPIGL::GetParamCount(ResourceID id, return BufferSyncInterface::kParseNoError; } -BufferSyncInterface::ParseError GAPIGL::CreateParam(ResourceID param_id, - ResourceID effect_id, +BufferSyncInterface::ParseError GAPIGL::CreateParam(ResourceId param_id, + ResourceId effect_id, unsigned int index) { EffectGL *effect = effects_.Get(effect_id); if (!effect) return BufferSyncInterface::kParseInvalidArguments; @@ -764,8 +765,8 @@ BufferSyncInterface::ParseError GAPIGL::CreateParam(ResourceID param_id, return BufferSyncInterface::kParseNoError; } -BufferSyncInterface::ParseError GAPIGL::CreateParamByName(ResourceID param_id, - ResourceID effect_id, +BufferSyncInterface::ParseError GAPIGL::CreateParamByName(ResourceId param_id, + ResourceId effect_id, unsigned int size, const void *name) { EffectGL *effect = effects_.Get(effect_id); @@ -777,13 +778,13 @@ BufferSyncInterface::ParseError GAPIGL::CreateParamByName(ResourceID param_id, return BufferSyncInterface::kParseNoError; } -BufferSyncInterface::ParseError GAPIGL::DestroyParam(ResourceID id) { +BufferSyncInterface::ParseError GAPIGL::DestroyParam(ResourceId id) { return effect_params_.Destroy(id) ? BufferSyncInterface::kParseNoError : BufferSyncInterface::kParseInvalidArguments; } -BufferSyncInterface::ParseError GAPIGL::SetParamData(ResourceID id, +BufferSyncInterface::ParseError GAPIGL::SetParamData(ResourceId id, unsigned int size, const void *data) { EffectParamGL *param = effect_params_.Get(id); @@ -793,7 +794,7 @@ BufferSyncInterface::ParseError GAPIGL::SetParamData(ResourceID id, BufferSyncInterface::kParseInvalidArguments; } -BufferSyncInterface::ParseError GAPIGL::GetParamDesc(ResourceID id, +BufferSyncInterface::ParseError GAPIGL::GetParamDesc(ResourceId id, unsigned int size, void *data) { EffectParamGL *param = effect_params_.Get(id); @@ -804,7 +805,7 @@ BufferSyncInterface::ParseError GAPIGL::GetParamDesc(ResourceID id, } BufferSyncInterface::ParseError GAPIGL::GetStreamCount( - ResourceID id, + ResourceId id, unsigned int size, void *data) { EffectGL *effect = effects_.Get(id); @@ -814,7 +815,7 @@ BufferSyncInterface::ParseError GAPIGL::GetStreamCount( return BufferSyncInterface::kParseNoError; } -BufferSyncInterface::ParseError GAPIGL::GetStreamDesc(ResourceID id, +BufferSyncInterface::ParseError GAPIGL::GetStreamDesc(ResourceId id, unsigned int index, unsigned int size, void *data) { diff --git a/o3d/command_buffer/service/cross/gl/effect_gl.h b/o3d/command_buffer/service/cross/gl/effect_gl.h index 8bc8c51..8ffd6cf 100644 --- a/o3d/command_buffer/service/cross/gl/effect_gl.h +++ b/o3d/command_buffer/service/cross/gl/effect_gl.h @@ -114,7 +114,7 @@ class EffectGL : public Effect { CGparameter vp_param; CGparameter fp_param; int num_elements; - std::vector<ResourceID> sampler_ids; + std::vector<ResourceId> sampler_ids; }; typedef std::vector<LowLevelParam> LowLevelParamList; typedef std::vector<EffectParamGL *> ParamList; diff --git a/o3d/command_buffer/service/cross/gl/gapi_gl.cc b/o3d/command_buffer/service/cross/gl/gapi_gl.cc index fd5c6d3..345e2384 100644 --- a/o3d/command_buffer/service/cross/gl/gapi_gl.cc +++ b/o3d/command_buffer/service/cross/gl/gapi_gl.cc @@ -403,9 +403,9 @@ void GAPIGL::Clear(unsigned int buffers, glClearColor(color.red, color.green, color.blue, color.alpha); glClearDepth(depth); glClearStencil(stencil); - glClear((buffers & COLOR ? GL_COLOR_BUFFER_BIT : 0) | - (buffers & DEPTH ? GL_DEPTH_BUFFER_BIT : 0) | - (buffers & STENCIL ? GL_STENCIL_BUFFER_BIT : 0)); + glClear((buffers & kColor ? GL_COLOR_BUFFER_BIT : 0) | + (buffers & kDepth ? GL_DEPTH_BUFFER_BIT : 0) | + (buffers & kStencil ? GL_STENCIL_BUFFER_BIT : 0)); CHECK_GL_ERROR(); } diff --git a/o3d/command_buffer/service/cross/gl/gapi_gl.h b/o3d/command_buffer/service/cross/gl/gapi_gl.h index d4602c2..324638b 100644 --- a/o3d/command_buffer/service/cross/gl/gapi_gl.h +++ b/o3d/command_buffer/service/cross/gl/gapi_gl.h @@ -98,56 +98,56 @@ class GAPIGL : public GAPIInterface { float z_max); // Implements the CreateVertexBuffer function for GL. - virtual ParseError CreateVertexBuffer(ResourceID id, + virtual ParseError CreateVertexBuffer(ResourceId id, unsigned int size, unsigned int flags); // Implements the DestroyVertexBuffer function for GL. - virtual ParseError DestroyVertexBuffer(ResourceID id); + virtual ParseError DestroyVertexBuffer(ResourceId id); // Implements the SetVertexBufferData function for GL. - virtual ParseError SetVertexBufferData(ResourceID id, + virtual ParseError SetVertexBufferData(ResourceId id, unsigned int offset, unsigned int size, const void *data); // Implements the GetVertexBufferData function for GL. - virtual ParseError GetVertexBufferData(ResourceID id, + virtual ParseError GetVertexBufferData(ResourceId id, unsigned int offset, unsigned int size, void *data); // Implements the CreateIndexBuffer function for GL. - virtual ParseError CreateIndexBuffer(ResourceID id, + virtual ParseError CreateIndexBuffer(ResourceId id, unsigned int size, unsigned int flags); // Implements the DestroyIndexBuffer function for GL. - virtual ParseError DestroyIndexBuffer(ResourceID id); + virtual ParseError DestroyIndexBuffer(ResourceId id); // Implements the SetIndexBufferData function for GL. - virtual ParseError SetIndexBufferData(ResourceID id, + virtual ParseError SetIndexBufferData(ResourceId id, unsigned int offset, unsigned int size, const void *data); // Implements the GetIndexBufferData function for GL. - virtual ParseError GetIndexBufferData(ResourceID id, + virtual ParseError GetIndexBufferData(ResourceId id, unsigned int offset, unsigned int size, void *data); // Implements the CreateVertexStruct function for GL. - virtual ParseError CreateVertexStruct(ResourceID id, + virtual ParseError CreateVertexStruct(ResourceId id, unsigned int input_count); // Implements the DestroyVertexStruct function for GL. - virtual ParseError DestroyVertexStruct(ResourceID id); + virtual ParseError DestroyVertexStruct(ResourceId id); // Implements the SetVertexInput function for GL. - virtual ParseError SetVertexInput(ResourceID vertex_struct_id, + virtual ParseError SetVertexInput(ResourceId vertex_struct_id, unsigned int input_index, - ResourceID vertex_buffer_id, + ResourceId vertex_buffer_id, unsigned int offset, unsigned int stride, vertex_struct::Type type, @@ -155,7 +155,7 @@ class GAPIGL : public GAPIInterface { unsigned int semantic_index); // Implements the SetVertexStruct function for GL. - virtual ParseError SetVertexStruct(ResourceID id); + virtual ParseError SetVertexStruct(ResourceId id); // Implements the Draw function for GL. virtual ParseError Draw(PrimitiveType primitive_type, @@ -164,65 +164,65 @@ class GAPIGL : public GAPIInterface { // Implements the DrawIndexed function for GL. virtual ParseError DrawIndexed(PrimitiveType primitive_type, - ResourceID index_buffer_id, + ResourceId index_buffer_id, unsigned int first, unsigned int count, unsigned int min_index, unsigned int max_index); // Implements the CreateEffect function for GL. - virtual ParseError CreateEffect(ResourceID id, + virtual ParseError CreateEffect(ResourceId id, unsigned int size, const void *data); // Implements the DestroyEffect function for GL. - virtual ParseError DestroyEffect(ResourceID id); + virtual ParseError DestroyEffect(ResourceId id); // Implements the SetEffect function for GL. - virtual ParseError SetEffect(ResourceID id); + virtual ParseError SetEffect(ResourceId id); // Implements the GetParamCount function for GL. - virtual ParseError GetParamCount(ResourceID id, + virtual ParseError GetParamCount(ResourceId id, unsigned int size, void *data); // Implements the CreateParam function for GL. - virtual ParseError CreateParam(ResourceID param_id, - ResourceID effect_id, + virtual ParseError CreateParam(ResourceId param_id, + ResourceId effect_id, unsigned int index); // Implements the CreateParamByName function for GL. - virtual ParseError CreateParamByName(ResourceID param_id, - ResourceID effect_id, + virtual ParseError CreateParamByName(ResourceId param_id, + ResourceId effect_id, unsigned int size, const void *name); // Implements the DestroyParam function for GL. - virtual ParseError DestroyParam(ResourceID id); + virtual ParseError DestroyParam(ResourceId id); // Implements the SetParamData function for GL. - virtual ParseError SetParamData(ResourceID id, + virtual ParseError SetParamData(ResourceId id, unsigned int size, const void *data); // Implements the GetParamDesc function for GL. - virtual ParseError GetParamDesc(ResourceID id, + virtual ParseError GetParamDesc(ResourceId id, unsigned int size, void *data); // Implements the GetStreamCount function for GL. - virtual ParseError GetStreamCount(ResourceID id, + virtual ParseError GetStreamCount(ResourceId id, unsigned int size, void *data); // Implements the GetStreamDesc function for GL. - virtual ParseError GetStreamDesc(ResourceID id, + virtual ParseError GetStreamDesc(ResourceId id, unsigned int index, unsigned int size, void *data); // Implements the CreateTexture2D function for GL. - virtual ParseError CreateTexture2D(ResourceID id, + virtual ParseError CreateTexture2D(ResourceId id, unsigned int width, unsigned int height, unsigned int levels, @@ -231,7 +231,7 @@ class GAPIGL : public GAPIInterface { bool enable_render_surfaces); // Implements the CreateTexture3D function for GL. - virtual ParseError CreateTexture3D(ResourceID id, + virtual ParseError CreateTexture3D(ResourceId id, unsigned int width, unsigned int height, unsigned int depth, @@ -241,7 +241,7 @@ class GAPIGL : public GAPIInterface { bool enable_render_surfaces); // Implements the CreateTextureCube function for GL. - virtual ParseError CreateTextureCube(ResourceID id, + virtual ParseError CreateTextureCube(ResourceId id, unsigned int side, unsigned int levels, texture::Format format, @@ -249,7 +249,7 @@ class GAPIGL : public GAPIInterface { bool enable_render_surfaces); // Implements the SetTextureData function for GL. - virtual ParseError SetTextureData(ResourceID id, + virtual ParseError SetTextureData(ResourceId id, unsigned int x, unsigned int y, unsigned int z, @@ -264,7 +264,7 @@ class GAPIGL : public GAPIInterface { const void *data); // Implements the GetTextureData function for GL. - virtual ParseError GetTextureData(ResourceID id, + virtual ParseError GetTextureData(ResourceId id, unsigned int x, unsigned int y, unsigned int z, @@ -279,16 +279,16 @@ class GAPIGL : public GAPIInterface { void *data); // Implements the DestroyTexture function for GL. - virtual ParseError DestroyTexture(ResourceID id); + virtual ParseError DestroyTexture(ResourceId id); // Implements the CreateSampler function for GL. - virtual ParseError CreateSampler(ResourceID id); + virtual ParseError CreateSampler(ResourceId id); // Implements the DestroySampler function for GL. - virtual ParseError DestroySampler(ResourceID id); + virtual ParseError DestroySampler(ResourceId id); // Implements the SetSamplerStates function for GL. - virtual ParseError SetSamplerStates(ResourceID id, + virtual ParseError SetSamplerStates(ResourceId id, sampler::AddressingMode addressing_u, sampler::AddressingMode addressing_v, sampler::AddressingMode addressing_w, @@ -298,10 +298,10 @@ class GAPIGL : public GAPIInterface { unsigned int max_anisotropy); // Implements the SetSamplerBorderColor function for GL. - virtual ParseError SetSamplerBorderColor(ResourceID id, const RGBA &color); + virtual ParseError SetSamplerBorderColor(ResourceId id, const RGBA &color); // Implements the SetSamplerTexture function for GL. - virtual ParseError SetSamplerTexture(ResourceID id, ResourceID texture_id); + virtual ParseError SetSamplerTexture(ResourceId id, ResourceId texture_id); // Implements the SetScissor function for GL. virtual void SetScissor(bool enable, @@ -361,43 +361,43 @@ class GAPIGL : public GAPIInterface { virtual void SetBlendingColor(const RGBA &color); // Implements the CreateRenderSurface function for GL. - virtual ParseError CreateRenderSurface(ResourceID id, + virtual ParseError CreateRenderSurface(ResourceId id, unsigned int width, unsigned int height, unsigned int mip_level, unsigned int side, - ResourceID texture_id); + ResourceId texture_id); // Implements the DestroyRenderSurface function for GL. - virtual ParseError DestroyRenderSurface(ResourceID id); + virtual ParseError DestroyRenderSurface(ResourceId id); // Implements the CreateDepthSurface function for GL. - virtual ParseError CreateDepthSurface(ResourceID id, + virtual ParseError CreateDepthSurface(ResourceId id, unsigned int width, unsigned int height); // Implements the DestroyDepthSurface function for GL. - virtual ParseError DestroyDepthSurface(ResourceID id); + virtual ParseError DestroyDepthSurface(ResourceId id); // Implements the SetRenderSurface function for GL. - virtual ParseError SetRenderSurface(ResourceID render_surface_id, - ResourceID depth_stencil_id); + virtual ParseError SetRenderSurface(ResourceId render_surface_id, + ResourceId depth_stencil_id); // Implements the SetBackSurfaces function for GL. virtual void SetBackSurfaces(); // Gets a vertex buffer by resource ID. - VertexBufferGL *GetVertexBuffer(ResourceID id) { + VertexBufferGL *GetVertexBuffer(ResourceId id) { return vertex_buffers_.Get(id); } // Gets a texture by resource ID. - TextureGL *GetTexture(ResourceID id) { + TextureGL *GetTexture(ResourceId id) { return textures_.Get(id); } // Gets a sampler by resource ID. - SamplerGL *GetSampler(ResourceID id) { + SamplerGL *GetSampler(ResourceId id) { return samplers_.Get(id); } void set_anti_aliased(bool anti_aliased) { anti_aliased_ = anti_aliased; } @@ -431,14 +431,14 @@ class GAPIGL : public GAPIInterface { CGcontext cg_context_; bool anti_aliased_; - ResourceID current_vertex_struct_; + ResourceId current_vertex_struct_; bool validate_streams_; unsigned int max_vertices_; - ResourceID current_effect_id_; + ResourceId current_effect_id_; bool validate_effect_; EffectGL *current_effect_; - ResourceID current_surface_id_; - ResourceID current_depth_surface_id_; + ResourceId current_surface_id_; + ResourceId current_depth_surface_id_; GLuint render_surface_framebuffer_; ResourceMap<VertexBufferGL> vertex_buffers_; diff --git a/o3d/command_buffer/service/cross/gl/geometry_gl.cc b/o3d/command_buffer/service/cross/gl/geometry_gl.cc index 8452d04..b290472 100644 --- a/o3d/command_buffer/service/cross/gl/geometry_gl.cc +++ b/o3d/command_buffer/service/cross/gl/geometry_gl.cc @@ -49,7 +49,7 @@ void VertexBufferGL::Create() { glGenBuffers(1, &gl_buffer_); glBindBuffer(GL_ARRAY_BUFFER, gl_buffer_); GLenum usage = - (flags() & vertex_buffer::DYNAMIC) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW; + (flags() & vertex_buffer::kDynamic) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW; glBufferData(GL_ARRAY_BUFFER, size(), NULL, usage); CHECK_GL_ERROR(); } @@ -99,7 +99,7 @@ void IndexBufferGL::Create() { glGenBuffers(1, &gl_buffer_); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, gl_buffer_); GLenum usage = - (flags() & vertex_buffer::DYNAMIC) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW; + (flags() & vertex_buffer::kDynamic) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW; glBufferData(GL_ELEMENT_ARRAY_BUFFER, size(), NULL, usage); CHECK_GL_ERROR(); } @@ -142,7 +142,7 @@ bool IndexBufferGL::GetData(unsigned int offset, // Sets the input element in the VertexStruct resource. void VertexStructGL::SetInput(unsigned int input_index, - ResourceID vertex_buffer_id, + ResourceId vertex_buffer_id, unsigned int offset, unsigned int stride, vertex_struct::Type type, @@ -235,16 +235,16 @@ namespace { inline unsigned int GetAttribIndex(vertex_struct::Semantic semantic, unsigned int semantic_index) { switch (semantic) { - case vertex_struct::POSITION: + case vertex_struct::kPosition: DCHECK_EQ(semantic_index, 0); return 0; - case vertex_struct::NORMAL: + case vertex_struct::kNormal: DCHECK_EQ(semantic_index, 0); return 2; - case vertex_struct::COLOR: + case vertex_struct::kColor: DCHECK_LT(semantic_index, 2U); return 3 + semantic_index; - case vertex_struct::TEX_COORD: + case vertex_struct::kTexCoord: DCHECK_LT(semantic_index, 8U); return 8 + semantic_index; default: @@ -258,15 +258,15 @@ inline void ExtractSizeTypeNormalized(vertex_struct::Type type, GLenum *gl_type, GLboolean *normalized) { switch (type) { - case vertex_struct::FLOAT1: - case vertex_struct::FLOAT2: - case vertex_struct::FLOAT3: - case vertex_struct::FLOAT4: - *size = type - vertex_struct::FLOAT1 + 1; + case vertex_struct::kFloat1: + case vertex_struct::kFloat2: + case vertex_struct::kFloat3: + case vertex_struct::kFloat4: + *size = type - vertex_struct::kFloat1 + 1; *gl_type = GL_FLOAT; *normalized = false; break; - case vertex_struct::UCHAR4N: + case vertex_struct::kUChar4N: *size = 4; *gl_type = GL_UNSIGNED_BYTE; *normalized = true; @@ -305,7 +305,7 @@ void VertexStructGL::Compile() { dirty_ = false; } -BufferSyncInterface::ParseError GAPIGL::CreateVertexBuffer(ResourceID id, +BufferSyncInterface::ParseError GAPIGL::CreateVertexBuffer(ResourceId id, unsigned int size, unsigned int flags) { VertexBufferGL *vertex_buffer = new VertexBufferGL(size, flags); @@ -314,13 +314,13 @@ BufferSyncInterface::ParseError GAPIGL::CreateVertexBuffer(ResourceID id, return BufferSyncInterface::kParseNoError; } -BufferSyncInterface::ParseError GAPIGL::DestroyVertexBuffer(ResourceID id) { +BufferSyncInterface::ParseError GAPIGL::DestroyVertexBuffer(ResourceId id) { return vertex_buffers_.Destroy(id) ? BufferSyncInterface::kParseNoError : BufferSyncInterface::kParseInvalidArguments; } -BufferSyncInterface::ParseError GAPIGL::SetVertexBufferData(ResourceID id, +BufferSyncInterface::ParseError GAPIGL::SetVertexBufferData(ResourceId id, unsigned int offset, unsigned int size, const void *data) { @@ -331,7 +331,7 @@ BufferSyncInterface::ParseError GAPIGL::SetVertexBufferData(ResourceID id, BufferSyncInterface::kParseInvalidArguments; } -BufferSyncInterface::ParseError GAPIGL::GetVertexBufferData(ResourceID id, +BufferSyncInterface::ParseError GAPIGL::GetVertexBufferData(ResourceId id, unsigned int offset, unsigned int size, void *data) { @@ -342,7 +342,7 @@ BufferSyncInterface::ParseError GAPIGL::GetVertexBufferData(ResourceID id, BufferSyncInterface::kParseInvalidArguments; } -BufferSyncInterface::ParseError GAPIGL::CreateIndexBuffer(ResourceID id, +BufferSyncInterface::ParseError GAPIGL::CreateIndexBuffer(ResourceId id, unsigned int size, unsigned int flags) { IndexBufferGL *index_buffer = new IndexBufferGL(size, flags); @@ -351,13 +351,13 @@ BufferSyncInterface::ParseError GAPIGL::CreateIndexBuffer(ResourceID id, return BufferSyncInterface::kParseNoError; } -BufferSyncInterface::ParseError GAPIGL::DestroyIndexBuffer(ResourceID id) { +BufferSyncInterface::ParseError GAPIGL::DestroyIndexBuffer(ResourceId id) { return index_buffers_.Destroy(id) ? BufferSyncInterface::kParseNoError : BufferSyncInterface::kParseInvalidArguments; } -BufferSyncInterface::ParseError GAPIGL::SetIndexBufferData(ResourceID id, +BufferSyncInterface::ParseError GAPIGL::SetIndexBufferData(ResourceId id, unsigned int offset, unsigned int size, const void *data) { @@ -368,7 +368,7 @@ BufferSyncInterface::ParseError GAPIGL::SetIndexBufferData(ResourceID id, BufferSyncInterface::kParseInvalidArguments; } -BufferSyncInterface::ParseError GAPIGL::GetIndexBufferData(ResourceID id, +BufferSyncInterface::ParseError GAPIGL::GetIndexBufferData(ResourceId id, unsigned int offset, unsigned int size, void *data) { @@ -380,7 +380,7 @@ BufferSyncInterface::ParseError GAPIGL::GetIndexBufferData(ResourceID id, } BufferSyncInterface::ParseError GAPIGL::CreateVertexStruct( - ResourceID id, + ResourceId id, unsigned int input_count) { if (id == current_vertex_struct_) validate_streams_ = true; VertexStructGL *vertex_struct = new VertexStructGL(input_count); @@ -388,7 +388,7 @@ BufferSyncInterface::ParseError GAPIGL::CreateVertexStruct( return BufferSyncInterface::kParseNoError; } -BufferSyncInterface::ParseError GAPIGL::DestroyVertexStruct(ResourceID id) { +BufferSyncInterface::ParseError GAPIGL::DestroyVertexStruct(ResourceId id) { if (id == current_vertex_struct_) validate_streams_ = true; return vertex_structs_.Destroy(id) ? BufferSyncInterface::kParseNoError : @@ -396,31 +396,31 @@ BufferSyncInterface::ParseError GAPIGL::DestroyVertexStruct(ResourceID id) { } BufferSyncInterface::ParseError GAPIGL::SetVertexInput( - ResourceID vertex_struct_id, + ResourceId vertex_struct_id, unsigned int input_index, - ResourceID vertex_buffer_id, + ResourceId vertex_buffer_id, unsigned int offset, unsigned int stride, vertex_struct::Type type, vertex_struct::Semantic semantic, unsigned int semantic_index) { switch (semantic) { - case vertex_struct::POSITION: + case vertex_struct::kPosition: if (semantic_index != 0) { return BufferSyncInterface::kParseInvalidArguments; } break; - case vertex_struct::NORMAL: + case vertex_struct::kNormal: if (semantic_index != 0) { return BufferSyncInterface::kParseInvalidArguments; } break; - case vertex_struct::COLOR: + case vertex_struct::kColor: if (semantic_index >= 2) { return BufferSyncInterface::kParseInvalidArguments; } break; - case vertex_struct::TEX_COORD: + case vertex_struct::kTexCoord: if (semantic_index >= 8) { return BufferSyncInterface::kParseInvalidArguments; } @@ -438,7 +438,7 @@ BufferSyncInterface::ParseError GAPIGL::SetVertexInput( return BufferSyncInterface::kParseNoError; } -BufferSyncInterface::ParseError GAPIGL::SetVertexStruct(ResourceID id) { +BufferSyncInterface::ParseError GAPIGL::SetVertexStruct(ResourceId id) { current_vertex_struct_ = id; validate_streams_ = true; return BufferSyncInterface::kParseNoError; @@ -458,30 +458,30 @@ bool GAPIGL::ValidateStreams() { namespace { -void PrimitiveTypeToGL(GAPIInterface::PrimitiveType primitive_type, +void PrimitiveTypeToGL(command_buffer::PrimitiveType primitive_type, GLenum *gl_mode, unsigned int *count) { switch (primitive_type) { - case GAPIInterface::POINTS: + case command_buffer::kPoints: *gl_mode = GL_POINTS; break; - case GAPIInterface::LINES: + case command_buffer::kLines: *gl_mode = GL_LINES; *count *= 2; break; - case GAPIInterface::LINE_STRIPS: + case command_buffer::kLineStrips: *gl_mode = GL_LINE_STRIP; ++*count; break; - case GAPIInterface::TRIANGLES: + case command_buffer::kTriangles: *gl_mode = GL_TRIANGLES; *count *= 3; break; - case GAPIInterface::TRIANGLE_STRIPS: + case command_buffer::kTriangleStrips: *gl_mode = GL_TRIANGLE_STRIP; *count += 2; break; - case GAPIInterface::TRIANGLE_FANS: + case command_buffer::kTriangleFans: *gl_mode = GL_TRIANGLE_FAN; *count += 2; break; @@ -515,7 +515,7 @@ BufferSyncInterface::ParseError GAPIGL::Draw(PrimitiveType primitive_type, BufferSyncInterface::ParseError GAPIGL::DrawIndexed( PrimitiveType primitive_type, - ResourceID index_buffer_id, + ResourceId index_buffer_id, unsigned int first, unsigned int count, unsigned int min_index, @@ -535,9 +535,9 @@ BufferSyncInterface::ParseError GAPIGL::DrawIndexed( GLenum gl_mode = GL_POINTS; PrimitiveTypeToGL(primitive_type, &gl_mode, &count); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_buffer->gl_buffer()); - GLenum index_type = (index_buffer->flags() & index_buffer::INDEX_32BIT) ? + GLenum index_type = (index_buffer->flags() & index_buffer::kIndex32Bit) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT; - GLuint index_size = (index_buffer->flags() & index_buffer::INDEX_32BIT) ? + GLuint index_size = (index_buffer->flags() & index_buffer::kIndex32Bit) ? sizeof(GLuint) : sizeof(GLushort); // NOLINT GLuint offset = first * index_size; if (offset + count * index_size > index_buffer->size()) { diff --git a/o3d/command_buffer/service/cross/gl/geometry_gl.h b/o3d/command_buffer/service/cross/gl/geometry_gl.h index d83e7b5..563653a 100644 --- a/o3d/command_buffer/service/cross/gl/geometry_gl.h +++ b/o3d/command_buffer/service/cross/gl/geometry_gl.h @@ -105,7 +105,7 @@ class VertexStructGL : public VertexStruct { // Adds an input to the vertex struct. void SetInput(unsigned int input_index, - ResourceID vertex_buffer_id, + ResourceId vertex_buffer_id, unsigned int offset, unsigned int stride, vertex_struct::Type type, @@ -121,7 +121,7 @@ class VertexStructGL : public VertexStruct { // This struct describes the parameters that are passed to // glVertexAttribPointer. struct AttribDesc { - ResourceID vertex_buffer_id; + ResourceId vertex_buffer_id; GLint size; GLenum type; GLboolean normalized; diff --git a/o3d/command_buffer/service/cross/gl/gl_utils.h b/o3d/command_buffer/service/cross/gl/gl_utils.h index 6b160d4b..36dfbf6 100644 --- a/o3d/command_buffer/service/cross/gl/gl_utils.h +++ b/o3d/command_buffer/service/cross/gl/gl_utils.h @@ -36,6 +36,8 @@ #ifndef O3D_COMMAND_BUFFER_SERVICE_CROSS_GL_GL_UTILS_H_ #define O3D_COMMAND_BUFFER_SERVICE_CROSS_GL_GL_UTILS_H_ +#include <Cg/cg.h> +#include <Cg/cgGL.h> #include <build/build_config.h> #define GL_GLEXT_PROTOTYPES diff --git a/o3d/command_buffer/service/cross/gl/render_surface_gl.cc b/o3d/command_buffer/service/cross/gl/render_surface_gl.cc index 73ae73f..c7ed2d7 100644 --- a/o3d/command_buffer/service/cross/gl/render_surface_gl.cc +++ b/o3d/command_buffer/service/cross/gl/render_surface_gl.cc @@ -110,12 +110,12 @@ RenderDepthStencilSurfaceGL* RenderDepthStencilSurfaceGL::Create( // Copies the data from a texture resource. BufferSyncInterface::ParseError GAPIGL::CreateRenderSurface( - ResourceID id, + ResourceId id, unsigned int width, unsigned int height, unsigned int mip_level, unsigned int side, - ResourceID texture_id) { + ResourceId texture_id) { if (id == current_surface_id_) { // This will delete the current surface which would be bad. return BufferSyncInterface::kParseInvalidArguments; @@ -137,7 +137,7 @@ BufferSyncInterface::ParseError GAPIGL::CreateRenderSurface( return BufferSyncInterface::kParseNoError; } -BufferSyncInterface::ParseError GAPIGL::DestroyRenderSurface(ResourceID id) { +BufferSyncInterface::ParseError GAPIGL::DestroyRenderSurface(ResourceId id) { if (id == current_surface_id_) { return BufferSyncInterface::kParseInvalidArguments; } @@ -147,7 +147,7 @@ BufferSyncInterface::ParseError GAPIGL::DestroyRenderSurface(ResourceID id) { } BufferSyncInterface::ParseError GAPIGL::CreateDepthSurface( - ResourceID id, + ResourceId id, unsigned int width, unsigned int height) { if (id == current_depth_surface_id_) { @@ -163,7 +163,7 @@ BufferSyncInterface::ParseError GAPIGL::CreateDepthSurface( return BufferSyncInterface::kParseNoError; } -BufferSyncInterface::ParseError GAPIGL::DestroyDepthSurface(ResourceID id) { +BufferSyncInterface::ParseError GAPIGL::DestroyDepthSurface(ResourceId id) { if (id == current_depth_surface_id_) { return BufferSyncInterface::kParseInvalidArguments; } @@ -220,8 +220,8 @@ bool BindDepthStencilBuffer(const RenderDepthStencilSurfaceGL* gl_surface) { } BufferSyncInterface::ParseError GAPIGL::SetRenderSurface( - ResourceID render_surface_id, - ResourceID depth_stencil_id) { + ResourceId render_surface_id, + ResourceId depth_stencil_id) { if (render_surfaces_.Get(render_surface_id) == NULL && depth_surfaces_.Get(depth_stencil_id) == NULL) { return BufferSyncInterface::kParseInvalidArguments; diff --git a/o3d/command_buffer/service/cross/gl/sampler_gl.cc b/o3d/command_buffer/service/cross/gl/sampler_gl.cc index 28ba324..159e131 100644 --- a/o3d/command_buffer/service/cross/gl/sampler_gl.cc +++ b/o3d/command_buffer/service/cross/gl/sampler_gl.cc @@ -43,13 +43,13 @@ namespace { // Gets the GL enum corresponding to an addressing mode. GLenum GLAddressMode(sampler::AddressingMode o3d_mode) { switch (o3d_mode) { - case sampler::WRAP: + case sampler::kWrap: return GL_REPEAT; - case sampler::MIRROR_REPEAT: + case sampler::kMirrorRepeat: return GL_MIRRORED_REPEAT; - case sampler::CLAMP_TO_EDGE: + case sampler::kClampToEdge: return GL_CLAMP_TO_EDGE; - case sampler::CLAMP_TO_BORDER: + case sampler::kClampToBorder: return GL_CLAMP_TO_BORDER; default: DLOG(FATAL) << "Not Reached"; @@ -62,19 +62,19 @@ GLenum GLAddressMode(sampler::AddressingMode o3d_mode) { GLenum GLMinFilter(sampler::FilteringMode min_filter, sampler::FilteringMode mip_filter) { switch (min_filter) { - case sampler::POINT: - if (mip_filter == sampler::NONE) + case sampler::kPoint: + if (mip_filter == sampler::kNone) return GL_NEAREST; - else if (mip_filter == sampler::POINT) + else if (mip_filter == sampler::kPoint) return GL_NEAREST_MIPMAP_NEAREST; - else if (mip_filter == sampler::LINEAR) + else if (mip_filter == sampler::kLinear) return GL_NEAREST_MIPMAP_LINEAR; - case sampler::LINEAR: - if (mip_filter == sampler::NONE) + case sampler::kLinear: + if (mip_filter == sampler::kNone) return GL_LINEAR; - else if (mip_filter == sampler::POINT) + else if (mip_filter == sampler::kPoint) return GL_LINEAR_MIPMAP_NEAREST; - else if (mip_filter == sampler::LINEAR) + else if (mip_filter == sampler::kLinear) return GL_LINEAR_MIPMAP_LINEAR; default: DLOG(FATAL) << "Not Reached"; @@ -86,9 +86,9 @@ GLenum GLMinFilter(sampler::FilteringMode min_filter, // filtering mode. GLenum GLMagFilter(sampler::FilteringMode mag_filter) { switch (mag_filter) { - case sampler::POINT: + case sampler::kPoint: return GL_NEAREST; - case sampler::LINEAR: + case sampler::kLinear: return GL_LINEAR; default: DLOG(FATAL) << "Not Reached"; @@ -99,11 +99,11 @@ GLenum GLMagFilter(sampler::FilteringMode mag_filter) { // Gets the GL enum representing the GL target based on the texture type. GLenum GLTextureTarget(texture::Type type) { switch (type) { - case texture::TEXTURE_2D: + case texture::kTexture2d: return GL_TEXTURE_2D; - case texture::TEXTURE_3D: + case texture::kTexture3d: return GL_TEXTURE_3D; - case texture::TEXTURE_CUBE: + case texture::kTextureCube: return GL_TEXTURE_CUBE_MAP; default: DLOG(FATAL) << "Not Reached"; @@ -116,12 +116,12 @@ GLenum GLTextureTarget(texture::Type type) { SamplerGL::SamplerGL() : texture_id_(kInvalidResource), gl_texture_(0) { - SetStates(sampler::CLAMP_TO_EDGE, - sampler::CLAMP_TO_EDGE, - sampler::CLAMP_TO_EDGE, - sampler::LINEAR, - sampler::LINEAR, - sampler::POINT, + SetStates(sampler::kClampToEdge, + sampler::kClampToEdge, + sampler::kClampToEdge, + sampler::kLinear, + sampler::kLinear, + sampler::kPoint, 1); RGBA black = {0, 0, 0, 1}; SetBorderColor(black); @@ -155,8 +155,8 @@ void SamplerGL::SetStates(sampler::AddressingMode addressing_u, sampler::FilteringMode mip_filter, unsigned int max_anisotropy) { // These are validated in GAPIDecoder.cc - DCHECK_NE(mag_filter, sampler::NONE); - DCHECK_NE(min_filter, sampler::NONE); + DCHECK_NE(mag_filter, sampler::kNone); + DCHECK_NE(min_filter, sampler::kNone); DCHECK_GT(max_anisotropy, 0U); gl_wrap_s_ = GLAddressMode(addressing_u); gl_wrap_t_ = GLAddressMode(addressing_v); @@ -174,7 +174,7 @@ void SamplerGL::SetBorderColor(const RGBA &color) { } BufferSyncInterface::ParseError GAPIGL::CreateSampler( - ResourceID id) { + ResourceId id) { // Dirty effect, because this sampler id may be used. DirtyEffect(); samplers_.Assign(id, new SamplerGL()); @@ -182,7 +182,7 @@ BufferSyncInterface::ParseError GAPIGL::CreateSampler( } // Destroys the Sampler resource. -BufferSyncInterface::ParseError GAPIGL::DestroySampler(ResourceID id) { +BufferSyncInterface::ParseError GAPIGL::DestroySampler(ResourceId id) { // Dirty effect, because this sampler id may be used. DirtyEffect(); return samplers_.Destroy(id) ? @@ -191,7 +191,7 @@ BufferSyncInterface::ParseError GAPIGL::DestroySampler(ResourceID id) { } BufferSyncInterface::ParseError GAPIGL::SetSamplerStates( - ResourceID id, + ResourceId id, sampler::AddressingMode addressing_u, sampler::AddressingMode addressing_v, sampler::AddressingMode addressing_w, @@ -210,7 +210,7 @@ BufferSyncInterface::ParseError GAPIGL::SetSamplerStates( } BufferSyncInterface::ParseError GAPIGL::SetSamplerBorderColor( - ResourceID id, + ResourceId id, const RGBA &color) { SamplerGL *sampler = samplers_.Get(id); if (!sampler) @@ -222,8 +222,8 @@ BufferSyncInterface::ParseError GAPIGL::SetSamplerBorderColor( } BufferSyncInterface::ParseError GAPIGL::SetSamplerTexture( - ResourceID id, - ResourceID texture_id) { + ResourceId id, + ResourceId texture_id) { SamplerGL *sampler = samplers_.Get(id); if (!sampler) return BufferSyncInterface::kParseInvalidArguments; diff --git a/o3d/command_buffer/service/cross/gl/sampler_gl.h b/o3d/command_buffer/service/cross/gl/sampler_gl.h index dc84b4f..07fd079 100644 --- a/o3d/command_buffer/service/cross/gl/sampler_gl.h +++ b/o3d/command_buffer/service/cross/gl/sampler_gl.h @@ -65,7 +65,7 @@ class SamplerGL : public Sampler { void SetBorderColor(const RGBA &color); // Sets the texture. - void SetTexture(ResourceID texture) { texture_id_ = texture; } + void SetTexture(ResourceId texture) { texture_id_ = texture; } GLuint gl_texture() const { return gl_texture_; } @@ -78,7 +78,7 @@ class SamplerGL : public Sampler { GLuint gl_max_anisotropy_; GLfloat gl_border_color_[4]; GLuint gl_texture_; - ResourceID texture_id_; + ResourceId texture_id_; }; } // namespace command_buffer diff --git a/o3d/command_buffer/service/cross/gl/states_gl.cc b/o3d/command_buffer/service/cross/gl/states_gl.cc index 4acc96c..625b3e3 100644 --- a/o3d/command_buffer/service/cross/gl/states_gl.cc +++ b/o3d/command_buffer/service/cross/gl/states_gl.cc @@ -45,8 +45,8 @@ GLenum kGLPolygonModes[] = { GL_LINE, GL_FILL, }; -COMPILE_ASSERT(GAPIInterface::NUM_POLYGON_MODE == arraysize(kGLPolygonModes), - kGLPolygonModes_does_not_match_GAPIInterface_PolygonMode); +COMPILE_ASSERT(command_buffer::kNumPolygonMode == arraysize(kGLPolygonModes), + kGLPolygonModes_does_not_match_command_buffer_PolygonMode); GLenum kGLComparison[] = { GL_NEVER, @@ -58,8 +58,8 @@ GLenum kGLComparison[] = { GL_GEQUAL, GL_ALWAYS, }; -COMPILE_ASSERT(GAPIInterface::NUM_COMPARISON == arraysize(kGLComparison), - kGLComparison_does_not_match_GAPIInterface_Comparison); +COMPILE_ASSERT(command_buffer::kNumComparison == arraysize(kGLComparison), + kGLComparison_does_not_match_command_buffer_Comparison); GLenum kGLBlendFunc[] = { GL_ZERO, @@ -76,8 +76,8 @@ GLenum kGLBlendFunc[] = { GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR, }; -COMPILE_ASSERT(GAPIInterface::NUM_BLEND_FUNC == arraysize(kGLBlendFunc), - kGLBlendFunc_does_not_match_GAPIInterface_BlendFunc); +COMPILE_ASSERT(command_buffer::kNumBlendFunc == arraysize(kGLBlendFunc), + kGLBlendFunc_does_not_match_command_buffer_BlendFunc); GLenum kGLBlendEq[] = { GL_FUNC_ADD, @@ -86,8 +86,8 @@ GLenum kGLBlendEq[] = { GL_MIN, GL_MAX, }; -COMPILE_ASSERT(GAPIInterface::NUM_BLEND_EQ == arraysize(kGLBlendEq), - kGLBlendEq_does_not_match_GAPIInterface_BlendEq); +COMPILE_ASSERT(command_buffer::kNumBlendEq == arraysize(kGLBlendEq), + kGLBlendEq_does_not_match_command_buffer_BlendEq); GLenum kGLStencilOp[] = { GL_KEEP, @@ -99,18 +99,18 @@ GLenum kGLStencilOp[] = { GL_INCR_WRAP, GL_DECR_WRAP, }; -COMPILE_ASSERT(GAPIInterface::NUM_STENCIL_OP == arraysize(kGLStencilOp), - kGLStencilOp_does_not_match_GAPIInterface_StencilOp); +COMPILE_ASSERT(command_buffer::kNumStencilOp == arraysize(kGLStencilOp), + kGLStencilOp_does_not_match_command_buffer_StencilOp); // Check that the definition of the counter-clockwise func/ops match the // clockwise ones, just shifted by 16 bits, so that we can use // DecodeStencilFuncOps on both of them. #define CHECK_CCW_MATCHES_CW(FIELD) \ - COMPILE_ASSERT(set_stencil_test::CW ## FIELD::kLength == \ - set_stencil_test::CCW ## FIELD::kLength, \ + COMPILE_ASSERT(cmd::SetStencilTest::CW ## FIELD::kLength == \ + cmd::SetStencilTest::CCW ## FIELD::kLength, \ CCW ## FIELD ## _length_does_not_match_ ## CW ## FIELD); \ - COMPILE_ASSERT(set_stencil_test::CW ## FIELD::kShift + 16 == \ - set_stencil_test::CCW ## FIELD::kShift, \ + COMPILE_ASSERT(cmd::SetStencilTest::CW ## FIELD::kShift + 16 == \ + cmd::SetStencilTest::CCW ## FIELD::kShift, \ CCW ## FIELD ## _shift_does_not_match_ ## CW ## FIELD) CHECK_CCW_MATCHES_CW(Func); @@ -126,27 +126,30 @@ void DecodeStencilFuncOps(Uint32 params, GLenum *pass, GLenum *fail, GLenum *zfail) { - namespace cmd = set_stencil_test; // Sanity check. The value has already been tested in // GAPIDecoder::DecodeSetStencilTest in gapi_decoder.cc. - DCHECK_EQ(cmd::Unused1::Get(params), 0); + DCHECK_EQ(cmd::SetStencilTest::Unused1::Get(params), 0); // Check that the bitmask get cannot generate values outside of the allowed // range. - COMPILE_ASSERT(cmd::CWFunc::kMask < GAPIInterface::NUM_COMPARISON, + COMPILE_ASSERT(cmd::SetStencilTest::CWFunc::kMask < + command_buffer::kNumComparison, set_stencil_test_CWFunc_may_produce_invalid_values); - *func = kGLComparison[cmd::CWFunc::Get(params)]; + *func = kGLComparison[cmd::SetStencilTest::CWFunc::Get(params)]; - COMPILE_ASSERT(cmd::CWPassOp::kMask < GAPIInterface::NUM_STENCIL_OP, + COMPILE_ASSERT(cmd::SetStencilTest::CWPassOp::kMask < + command_buffer::kNumStencilOp, set_stencil_test_CWPassOp_may_produce_invalid_values); - *pass = kGLStencilOp[cmd::CWPassOp::Get(params)]; + *pass = kGLStencilOp[cmd::SetStencilTest::CWPassOp::Get(params)]; - COMPILE_ASSERT(cmd::CWFailOp::kMask < GAPIInterface::NUM_STENCIL_OP, + COMPILE_ASSERT(cmd::SetStencilTest::CWFailOp::kMask < + command_buffer::kNumStencilOp, set_stencil_test_CWFailOp_may_produce_invalid_values); - *fail = kGLStencilOp[cmd::CWFailOp::Get(params)]; + *fail = kGLStencilOp[cmd::SetStencilTest::CWFailOp::Get(params)]; - COMPILE_ASSERT(cmd::CWZFailOp::kMask < GAPIInterface::NUM_STENCIL_OP, + COMPILE_ASSERT(cmd::SetStencilTest::CWZFailOp::kMask < + command_buffer::kNumStencilOp, set_stencil_test_CWZFailOp_may_produce_invalid_values); - *zfail = kGLStencilOp[cmd::CWZFailOp::Get(params)]; + *zfail = kGLStencilOp[cmd::SetStencilTest::CWZFailOp::Get(params)]; } } // anonymous namespace @@ -206,15 +209,15 @@ void GAPIGL::SetPolygonOffset(float slope_factor, float units) { void GAPIGL::SetPolygonRaster(PolygonMode fill_mode, FaceCullMode cull_mode) { - DCHECK_LT(fill_mode, NUM_POLYGON_MODE); + DCHECK_LT(fill_mode, kNumPolygonMode); glPolygonMode(GL_FRONT_AND_BACK, kGLPolygonModes[fill_mode]); - DCHECK_LT(cull_mode, NUM_FACE_CULL_MODE); + DCHECK_LT(cull_mode, kNumFaceCullMode); switch (cull_mode) { - case CULL_CW: + case kCullCW: glEnable(GL_CULL_FACE); glCullFace(GL_BACK); break; - case CULL_CCW: + case kCullCCW: glEnable(GL_CULL_FACE); glCullFace(GL_FRONT); break; @@ -227,7 +230,7 @@ void GAPIGL::SetPolygonRaster(PolygonMode fill_mode, void GAPIGL::SetAlphaTest(bool enable, float reference, Comparison comp) { - DCHECK_LT(comp, NUM_COMPARISON); + DCHECK_LT(comp, kNumComparison); if (enable) { glEnable(GL_ALPHA_TEST); glAlphaFunc(kGLComparison[comp], reference); @@ -239,7 +242,7 @@ void GAPIGL::SetAlphaTest(bool enable, void GAPIGL::SetDepthTest(bool enable, bool write_enable, Comparison comp) { - DCHECK_LT(comp, NUM_COMPARISON); + DCHECK_LT(comp, kNumComparison); if (enable) { glEnable(GL_DEPTH_TEST); glDepthFunc(kGLComparison[comp]); @@ -307,12 +310,12 @@ void GAPIGL::SetBlending(bool enable, BlendEq alpha_eq, BlendFunc alpha_src_func, BlendFunc alpha_dst_func) { - DCHECK_LT(color_eq, NUM_BLEND_EQ); - DCHECK_LT(color_src_func, NUM_BLEND_FUNC); - DCHECK_LT(color_dst_func, NUM_BLEND_FUNC); - DCHECK_LT(alpha_eq, NUM_BLEND_EQ); - DCHECK_LT(alpha_src_func, NUM_BLEND_FUNC); - DCHECK_LT(alpha_dst_func, NUM_BLEND_FUNC); + DCHECK_LT(color_eq, kNumBlendEq); + DCHECK_LT(color_src_func, kNumBlendFunc); + DCHECK_LT(color_dst_func, kNumBlendFunc); + DCHECK_LT(alpha_eq, kNumBlendEq); + DCHECK_LT(alpha_src_func, kNumBlendFunc); + DCHECK_LT(alpha_dst_func, kNumBlendFunc); if (enable) { glEnable(GL_BLEND); GLenum gl_color_eq = kGLBlendEq[color_eq]; diff --git a/o3d/command_buffer/service/cross/gl/texture_gl.cc b/o3d/command_buffer/service/cross/gl/texture_gl.cc index 96a5771..68a471a 100644 --- a/o3d/command_buffer/service/cross/gl/texture_gl.cc +++ b/o3d/command_buffer/service/cross/gl/texture_gl.cc @@ -47,22 +47,22 @@ bool GetGLFormatType(texture::Format format, GLenum *gl_format, GLenum *gl_type) { switch (format) { - case texture::XRGB8: + case texture::kXRGB8: *internal_format = GL_RGB; *gl_format = GL_BGRA; *gl_type = GL_UNSIGNED_BYTE; return true; - case texture::ARGB8: + case texture::kARGB8: *internal_format = GL_RGBA; *gl_format = GL_BGRA; *gl_type = GL_UNSIGNED_BYTE; return true; - case texture::ABGR16F: + case texture::kABGR16F: *internal_format = GL_RGBA16F_ARB; *gl_format = GL_RGBA; *gl_type = GL_HALF_FLOAT_ARB; return true; - case texture::DXT1: + case texture::kDXT1: *internal_format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; *gl_format = 0; *gl_type = 0; @@ -520,17 +520,17 @@ TextureCubeGL *TextureCubeGL::Create(unsigned int side, } // Check that GL_TEXTURE_CUBE_MAP_POSITIVE_X + face yields the correct GLenum. -COMPILE_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_X + texture::FACE_POSITIVE_X == +COMPILE_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_X + texture::kFacePositiveX == GL_TEXTURE_CUBE_MAP_POSITIVE_X, POSITIVE_X_ENUMS_DO_NOT_MATCH); -COMPILE_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_X + texture::FACE_NEGATIVE_X == +COMPILE_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_X + texture::kFaceNegativeX == GL_TEXTURE_CUBE_MAP_NEGATIVE_X, NEGATIVE_X_ENUMS_DO_NOT_MATCH); -COMPILE_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_X + texture::FACE_POSITIVE_Y == +COMPILE_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_X + texture::kFacePositiveY == GL_TEXTURE_CUBE_MAP_POSITIVE_Y, POSITIVE_Y_ENUMS_DO_NOT_MATCH); -COMPILE_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_X + texture::FACE_NEGATIVE_Y == +COMPILE_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_X + texture::kFaceNegativeY == GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, NEGATIVE_Y_ENUMS_DO_NOT_MATCH); -COMPILE_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_X + texture::FACE_POSITIVE_Z == +COMPILE_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_X + texture::kFacePositiveZ == GL_TEXTURE_CUBE_MAP_POSITIVE_Z, POSITIVE_Z_ENUMS_DO_NOT_MATCH); -COMPILE_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_X + texture::FACE_NEGATIVE_Z == +COMPILE_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_X + texture::kFaceNegativeZ == GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, NEGATIVE_Z_ENUMS_DO_NOT_MATCH); bool TextureCubeGL::SetData(const Volume& volume, @@ -627,7 +627,7 @@ bool TextureCubeGL::InstallFrameBufferObjects( // GAPIGL functions. // Destroys a texture resource. -BufferSyncInterface::ParseError GAPIGL::DestroyTexture(ResourceID id) { +BufferSyncInterface::ParseError GAPIGL::DestroyTexture(ResourceId id) { // Dirty effect, because this texture id may be used. DirtyEffect(); return textures_.Destroy(id) ? @@ -637,7 +637,7 @@ BufferSyncInterface::ParseError GAPIGL::DestroyTexture(ResourceID id) { // Creates a 2D texture resource. BufferSyncInterface::ParseError GAPIGL::CreateTexture2D( - ResourceID id, + ResourceId id, unsigned int width, unsigned int height, unsigned int levels, @@ -655,7 +655,7 @@ BufferSyncInterface::ParseError GAPIGL::CreateTexture2D( // Creates a 3D texture resource. BufferSyncInterface::ParseError GAPIGL::CreateTexture3D( - ResourceID id, + ResourceId id, unsigned int width, unsigned int height, unsigned int depth, @@ -674,7 +674,7 @@ BufferSyncInterface::ParseError GAPIGL::CreateTexture3D( // Creates a cube map texture resource. BufferSyncInterface::ParseError GAPIGL::CreateTextureCube( - ResourceID id, + ResourceId id, unsigned int side, unsigned int levels, texture::Format format, @@ -691,7 +691,7 @@ BufferSyncInterface::ParseError GAPIGL::CreateTextureCube( // Copies the data into a texture resource. BufferSyncInterface::ParseError GAPIGL::SetTextureData( - ResourceID id, + ResourceId id, unsigned int x, unsigned int y, unsigned int z, @@ -719,7 +719,7 @@ BufferSyncInterface::ParseError GAPIGL::SetTextureData( // Copies the data from a texture resource. BufferSyncInterface::ParseError GAPIGL::GetTextureData( - ResourceID id, + ResourceId id, unsigned int x, unsigned int y, unsigned int z, diff --git a/o3d/command_buffer/service/cross/gl/texture_gl.h b/o3d/command_buffer/service/cross/gl/texture_gl.h index db7d9ed..938b216 100644 --- a/o3d/command_buffer/service/cross/gl/texture_gl.h +++ b/o3d/command_buffer/service/cross/gl/texture_gl.h @@ -108,7 +108,7 @@ class Texture2DGL : public TextureGL { unsigned int width, unsigned int height, GLuint gl_texture) - : TextureGL(texture::TEXTURE_2D, + : TextureGL(texture::kTexture2d, levels, format, enable_render_surfaces, @@ -169,7 +169,7 @@ class Texture3DGL : public TextureGL { unsigned int height, unsigned int depth, GLuint gl_texture) - : TextureGL(texture::TEXTURE_2D, + : TextureGL(texture::kTexture3d, levels, format, enable_render_surfaces, @@ -231,7 +231,7 @@ class TextureCubeGL : public TextureGL { unsigned int flags, unsigned int side, GLuint gl_texture) - : TextureGL(texture::TEXTURE_CUBE, + : TextureGL(texture::kTextureCube, levels, format, render_surface_enabled, diff --git a/o3d/command_buffer/service/cross/resource.cc b/o3d/command_buffer/service/cross/resource.cc index 00a9f86..5810c70 100644 --- a/o3d/command_buffer/service/cross/resource.cc +++ b/o3d/command_buffer/service/cross/resource.cc @@ -40,7 +40,7 @@ namespace command_buffer { // Assigns a resource to a resource ID, by setting it at the right location // into the list, resizing the list if necessary, and destroying an existing // resource if one existed already. -void ResourceMapBase::Assign(ResourceID id, Resource *resource) { +void ResourceMapBase::Assign(ResourceId id, Resource *resource) { if (id >= resources_.size()) { resources_.resize(id + 1, NULL); } else { @@ -56,7 +56,7 @@ void ResourceMapBase::Assign(ResourceID id, Resource *resource) { // Destroys a resource contained in the map, setting its entry to NULL. If // necessary, this will trim the list. -bool ResourceMapBase::Destroy(ResourceID id) { +bool ResourceMapBase::Destroy(ResourceId id) { if (id >= resources_.size()) { return false; } diff --git a/o3d/command_buffer/service/cross/resource.h b/o3d/command_buffer/service/cross/resource.h index dd2fa52..fccfce8 100644 --- a/o3d/command_buffer/service/cross/resource.h +++ b/o3d/command_buffer/service/cross/resource.h @@ -103,7 +103,7 @@ class VertexStruct: public Resource { public: // The representation of an input data stream. struct Element { - ResourceID vertex_buffer; + ResourceId vertex_buffer; unsigned int offset; unsigned int stride; vertex_struct::Type type; @@ -222,13 +222,13 @@ class ResourceMapBase { // Assigns a resource to a resource ID. Assigning a resource to an ID that // already has an existing resource will destroy that existing resource. The // map takes ownership of the resource. - void Assign(ResourceID id, Resource* resource); + void Assign(ResourceId id, Resource* resource); // Destroys a resource. - bool Destroy(ResourceID id); + bool Destroy(ResourceId id); // Destroy all resources. void DestroyAllResources(); // Gets a resource by ID. - Resource *Get(ResourceID id) { + Resource *Get(ResourceId id) { return (id < resources_.size()) ? resources_[id] : NULL; } private: @@ -246,11 +246,11 @@ template<class T> class ResourceMap { // Assigns a resource to a resource ID. Assigning a resource to an ID that // already has an existing resource will destroy that existing resource. The // map takes ownership of the resource. - void Assign(ResourceID id, T* resource) { + void Assign(ResourceId id, T* resource) { container_.Assign(id, resource); } // Destroys a resource. - bool Destroy(ResourceID id) { + bool Destroy(ResourceId id) { return container_.Destroy(id); } // Destroy all resources. @@ -258,7 +258,7 @@ template<class T> class ResourceMap { return container_.DestroyAllResources(); } // Gets a resource by ID. - T *Get(ResourceID id) { + T *Get(ResourceId id) { return down_cast<T*>(container_.Get(id)); } private: diff --git a/o3d/command_buffer/service/win/d3d9/d3d9_utils.h b/o3d/command_buffer/service/win/d3d9/d3d9_utils.h index ff1e8f3..1057715 100644 --- a/o3d/command_buffer/service/win/d3d9/d3d9_utils.h +++ b/o3d/command_buffer/service/win/d3d9/d3d9_utils.h @@ -104,34 +104,37 @@ static bool D3DSemanticToCBSemantic( // TODO: what meaning do we really want to put to our semantics ? How // do they match the semantics that are set in the effect ? What combination // of (semantic, index) are supposed to work ? + // TODO(gman): This is just plain wrong! Fix it. Converting binormal to + // texcoord 7 means there will be conflicts if I have both a Binormal and a + // texcoord 7 or 2 binormals both of which we have examples of already in O3D! switch (semantic) { case D3DDECLUSAGE_POSITION: if (semantic_index != 0) return false; - *out_semantic = vertex_struct::POSITION; + *out_semantic = vertex_struct::kPosition; *out_semantic_index = 0; return true; case D3DDECLUSAGE_NORMAL: if (semantic_index != 0) return false; - *out_semantic = vertex_struct::NORMAL; + *out_semantic = vertex_struct::kNormal; *out_semantic_index = 0; return true; case D3DDECLUSAGE_TANGENT: if (semantic_index != 0) return false; - *out_semantic = vertex_struct::TEX_COORD; + *out_semantic = vertex_struct::kTexCoord; *out_semantic_index = 6; return true; case D3DDECLUSAGE_BINORMAL: if (semantic_index != 0) return false; - *out_semantic = vertex_struct::TEX_COORD; + *out_semantic = vertex_struct::kTexCoord; *out_semantic_index = 7; return true; case D3DDECLUSAGE_COLOR: if (semantic_index > 1) return false; - *out_semantic = vertex_struct::COLOR; + *out_semantic = vertex_struct::kColor; *out_semantic_index = semantic_index; return true; case D3DDECLUSAGE_TEXCOORD: - *out_semantic = vertex_struct::TEX_COORD; + *out_semantic = vertex_struct::kTexCoord; *out_semantic_index = semantic_index; return true; default: diff --git a/o3d/command_buffer/service/win/d3d9/effect_d3d9.cc b/o3d/command_buffer/service/win/d3d9/effect_d3d9.cc index 3268ab2..e2a9720 100644 --- a/o3d/command_buffer/service/win/d3d9/effect_d3d9.cc +++ b/o3d/command_buffer/service/win/d3d9/effect_d3d9.cc @@ -206,48 +206,48 @@ static effect_param::DataType GetDataTypeFromD3D( case D3DXPT_FLOAT: switch (desc.Class) { case D3DXPC_SCALAR: - return effect_param::FLOAT1; + return effect_param::kFloat1; case D3DXPC_VECTOR: switch (desc.Columns) { case 2: - return effect_param::FLOAT2; + return effect_param::kFloat2; case 3: - return effect_param::FLOAT3; + return effect_param::kFloat3; case 4: - return effect_param::FLOAT4; + return effect_param::kFloat4; default: - return effect_param::UNKNOWN; + return effect_param::kUnknown; } case D3DXPC_MATRIX_ROWS: case D3DXPC_MATRIX_COLUMNS: if (desc.Columns == 4 && desc.Rows == 4) { - return effect_param::MATRIX4; + return effect_param::kMatrix4; } else { - return effect_param::UNKNOWN; + return effect_param::kUnknown; } default: - return effect_param::UNKNOWN; + return effect_param::kUnknown; } case D3DXPT_INT: if (desc.Class == D3DXPC_SCALAR) { - return effect_param::INT; + return effect_param::kInt; } else { - return effect_param::UNKNOWN; + return effect_param::kUnknown; } case D3DXPT_BOOL: if (desc.Class == D3DXPC_SCALAR) { - return effect_param::BOOL; + return effect_param::kBool; } else { - return effect_param::UNKNOWN; + return effect_param::kUnknown; } case D3DXPT_SAMPLER: case D3DXPT_SAMPLER2D: case D3DXPT_SAMPLER3D: case D3DXPT_SAMPLERCUBE: if (desc.Class == D3DXPC_OBJECT) { - return effect_param::SAMPLER; + return effect_param::kSampler; } else { - return effect_param::UNKNOWN; + return effect_param::kUnknown; } case D3DXPT_TEXTURE: case D3DXPT_TEXTURE1D: @@ -255,12 +255,12 @@ static effect_param::DataType GetDataTypeFromD3D( case D3DXPT_TEXTURE3D: case D3DXPT_TEXTURECUBE: if (desc.Class == D3DXPC_OBJECT) { - return effect_param::TEXTURE; + return effect_param::kTexture; } else { - return effect_param::UNKNOWN; + return effect_param::kUnknown; } default: - return effect_param::UNKNOWN; + return effect_param::kUnknown; } } @@ -381,7 +381,7 @@ EffectParamD3D9 *EffectParamD3D9::Create(EffectD3D9 *effect, HR(effect->d3d_effect_->GetParameterDesc(handle, &desc)); effect_param::DataType data_type = GetDataTypeFromD3D(desc); EffectParamD3D9 *param = new EffectParamD3D9(data_type, effect, handle); - if (data_type == effect_param::SAMPLER) { + if (data_type == effect_param::kSampler) { ID3DXConstantTable *table = effect->fs_constant_table_; DCHECK(table); D3DXHANDLE sampler_handle = table->GetConstantByName(NULL, desc.Name); @@ -472,39 +472,39 @@ bool EffectParamD3D9::SetData(GAPID3D9 *gapi, effect_param::DataType type = data_type(); if (size < effect_param::GetDataSize(type)) return false; switch (type) { - case effect_param::FLOAT1: + case effect_param::kFloat1: HR(d3d_effect->SetFloat(handle_, *static_cast<const float *>(data))); break; - case effect_param::FLOAT2: + case effect_param::kFloat2: HR(d3d_effect->SetFloatArray(handle_, static_cast<const float *>(data), 2)); break; - case effect_param::FLOAT3: + case effect_param::kFloat3: HR(d3d_effect->SetFloatArray(handle_, static_cast<const float *>(data), 3)); break; - case effect_param::FLOAT4: + case effect_param::kFloat4: HR(d3d_effect->SetFloatArray(handle_, static_cast<const float *>(data), 4)); break; - case effect_param::MATRIX4: + case effect_param::kMatrix4: HR(d3d_effect->SetMatrix(handle_, reinterpret_cast<const D3DXMATRIX *>(data))); break; - case effect_param::INT: + case effect_param::kInt: HR(d3d_effect->SetInt(handle_, *static_cast<const int *>(data))); break; - case effect_param::BOOL: + case effect_param::kBool: HR(d3d_effect->SetBool(handle_, *static_cast<const bool *>(data)?1:0)); break; - case effect_param::SAMPLER: { - ResourceID id = *static_cast<const ResourceID *>(data); + case effect_param::kSampler: { + ResourceId id = *static_cast<const ResourceId *>(data); for (unsigned int i = 0; i < sampler_unit_count_; ++i) { effect_->samplers_[sampler_units_[i]] = id; } break; } - case effect_param::TEXTURE: { + case effect_param::kTexture: { // TODO(rlp): finish break; } @@ -521,7 +521,7 @@ bool EffectParamD3D9::SetData(GAPID3D9 *gapi, // Calls EffectD3D9::Create, and assign the result to the resource ID. // If changing the current effect, dirty it. BufferSyncInterface::ParseError GAPID3D9::CreateEffect( - ResourceID id, + ResourceId id, unsigned int size, const void *data) { if (id == current_effect_id_) DirtyEffect(); @@ -548,7 +548,7 @@ BufferSyncInterface::ParseError GAPID3D9::CreateEffect( // Destroys the Effect resource. // If destroying the current effect, dirty it. -BufferSyncInterface::ParseError GAPID3D9::DestroyEffect(ResourceID id) { +BufferSyncInterface::ParseError GAPID3D9::DestroyEffect(ResourceId id) { if (id == current_effect_id_) DirtyEffect(); return effects_.Destroy(id) ? BufferSyncInterface::kParseNoError : @@ -556,7 +556,7 @@ BufferSyncInterface::ParseError GAPID3D9::DestroyEffect(ResourceID id) { } // Sets the current effect ID, dirtying the current effect. -BufferSyncInterface::ParseError GAPID3D9::SetEffect(ResourceID id) { +BufferSyncInterface::ParseError GAPID3D9::SetEffect(ResourceId id) { DirtyEffect(); current_effect_id_ = id; return BufferSyncInterface::kParseNoError; @@ -564,7 +564,7 @@ BufferSyncInterface::ParseError GAPID3D9::SetEffect(ResourceID id) { // Gets the param count from the effect and store it in the memory buffer. BufferSyncInterface::ParseError GAPID3D9::GetParamCount( - ResourceID id, + ResourceId id, unsigned int size, void *data) { EffectD3D9 *effect = effects_.Get(id); @@ -575,8 +575,8 @@ BufferSyncInterface::ParseError GAPID3D9::GetParamCount( } BufferSyncInterface::ParseError GAPID3D9::CreateParam( - ResourceID param_id, - ResourceID effect_id, + ResourceId param_id, + ResourceId effect_id, unsigned int index) { EffectD3D9 *effect = effects_.Get(effect_id); if (!effect) return BufferSyncInterface::kParseInvalidArguments; @@ -587,8 +587,8 @@ BufferSyncInterface::ParseError GAPID3D9::CreateParam( } BufferSyncInterface::ParseError GAPID3D9::CreateParamByName( - ResourceID param_id, - ResourceID effect_id, + ResourceId param_id, + ResourceId effect_id, unsigned int size, const void *name) { EffectD3D9 *effect = effects_.Get(effect_id); @@ -600,14 +600,14 @@ BufferSyncInterface::ParseError GAPID3D9::CreateParamByName( return BufferSyncInterface::kParseNoError; } -BufferSyncInterface::ParseError GAPID3D9::DestroyParam(ResourceID id) { +BufferSyncInterface::ParseError GAPID3D9::DestroyParam(ResourceId id) { return effect_params_.Destroy(id) ? BufferSyncInterface::kParseNoError : BufferSyncInterface::kParseInvalidArguments; } BufferSyncInterface::ParseError GAPID3D9::SetParamData( - ResourceID id, + ResourceId id, unsigned int size, const void *data) { EffectParamD3D9 *param = effect_params_.Get(id); @@ -618,7 +618,7 @@ BufferSyncInterface::ParseError GAPID3D9::SetParamData( } BufferSyncInterface::ParseError GAPID3D9::GetParamDesc( - ResourceID id, + ResourceId id, unsigned int size, void *data) { EffectParamD3D9 *param = effect_params_.Get(id); @@ -630,7 +630,7 @@ BufferSyncInterface::ParseError GAPID3D9::GetParamDesc( // Gets the stream count from the effect and stores it in the memory buffer. BufferSyncInterface::ParseError GAPID3D9::GetStreamCount( - ResourceID id, + ResourceId id, unsigned int size, void *data) { EffectD3D9 *effect = effects_.Get(id); @@ -641,7 +641,7 @@ BufferSyncInterface::ParseError GAPID3D9::GetStreamCount( } BufferSyncInterface::ParseError GAPID3D9::GetStreamDesc( - ResourceID id, + ResourceId id, unsigned int index, unsigned int size, void *data) { diff --git a/o3d/command_buffer/service/win/d3d9/effect_d3d9.h b/o3d/command_buffer/service/win/d3d9/effect_d3d9.h index bdccc72..a37f895 100644 --- a/o3d/command_buffer/service/win/d3d9/effect_d3d9.h +++ b/o3d/command_buffer/service/win/d3d9/effect_d3d9.h @@ -127,7 +127,7 @@ class EffectD3D9 : public Effect { ParamList params_; StreamList streams_; bool sync_parameters_; - ResourceID samplers_[kMaxSamplerUnits]; + ResourceId samplers_[kMaxSamplerUnits]; friend class EffectParamD3D9; DISALLOW_COPY_AND_ASSIGN(EffectD3D9); diff --git a/o3d/command_buffer/service/win/d3d9/gapi_d3d9.cc b/o3d/command_buffer/service/win/d3d9/gapi_d3d9.cc index 8b20707..df9cb46 100644 --- a/o3d/command_buffer/service/win/d3d9/gapi_d3d9.cc +++ b/o3d/command_buffer/service/win/d3d9/gapi_d3d9.cc @@ -207,9 +207,9 @@ void GAPID3D9::Clear(unsigned int buffers, const RGBA &color, float depth, unsigned int stencil) { - DWORD flags = (buffers & COLOR ? D3DCLEAR_TARGET : 0) | - (buffers & DEPTH ? D3DCLEAR_ZBUFFER : 0) | - (buffers & STENCIL ? D3DCLEAR_STENCIL : 0); + DWORD flags = (buffers & kColor ? D3DCLEAR_TARGET : 0) | + (buffers & kDepth ? D3DCLEAR_ZBUFFER : 0) | + (buffers & kStencil ? D3DCLEAR_STENCIL : 0); HR(d3d_device_->Clear(0, NULL, flags, @@ -239,7 +239,7 @@ static unsigned int RGBAToARGB(unsigned int rgba) { } // Sets the current VertexStruct. Just keep track of the ID. -BufferSyncInterface::ParseError GAPID3D9::SetVertexStruct(ResourceID id) { +BufferSyncInterface::ParseError GAPID3D9::SetVertexStruct(ResourceId id) { current_vertex_struct_ = id; validate_streams_ = true; return BufferSyncInterface::kParseNoError; @@ -308,19 +308,20 @@ bool GAPID3D9::ValidateStreams() { } // Converts a GAPID3D9::PrimitiveType to a D3DPRIMITIVETYPE. -static D3DPRIMITIVETYPE D3DPrimitive(GAPID3D9::PrimitiveType primitive_type) { +static D3DPRIMITIVETYPE D3DPrimitive( + command_buffer::PrimitiveType primitive_type) { switch (primitive_type) { - case GAPID3D9::POINTS: + case command_buffer::kPoints: return D3DPT_POINTLIST; - case GAPID3D9::LINES: + case command_buffer::kLines: return D3DPT_LINELIST; - case GAPID3D9::LINE_STRIPS: + case command_buffer::kLineStrips: return D3DPT_LINESTRIP; - case GAPID3D9::TRIANGLES: + case command_buffer::kTriangles: return D3DPT_TRIANGLELIST; - case GAPID3D9::TRIANGLE_STRIPS: + case command_buffer::kTriangleStrips: return D3DPT_TRIANGLESTRIP; - case GAPID3D9::TRIANGLE_FANS: + case command_buffer::kTriangleFans: return D3DPT_TRIANGLEFAN; default: LOG(FATAL) << "Invalid primitive type"; @@ -356,7 +357,7 @@ BufferSyncInterface::ParseError GAPID3D9::Draw( // Draws with the current vertex struct. BufferSyncInterface::ParseError GAPID3D9::DrawIndexed( PrimitiveType primitive_type, - ResourceID index_buffer_id, + ResourceId index_buffer_id, unsigned int first, unsigned int count, unsigned int min_index, diff --git a/o3d/command_buffer/service/win/d3d9/gapi_d3d9.h b/o3d/command_buffer/service/win/d3d9/gapi_d3d9.h index 7f6e97e..ca1adce 100644 --- a/o3d/command_buffer/service/win/d3d9/gapi_d3d9.h +++ b/o3d/command_buffer/service/win/d3d9/gapi_d3d9.h @@ -85,56 +85,56 @@ class GAPID3D9 : public GAPIInterface { float z_max);
// Implements the CreateVertexBuffer function for D3D9.
- virtual ParseError CreateVertexBuffer(ResourceID id,
+ virtual ParseError CreateVertexBuffer(ResourceId id,
unsigned int size,
unsigned int flags);
// Implements the DestroyVertexBuffer function for D3D9.
- virtual ParseError DestroyVertexBuffer(ResourceID id);
+ virtual ParseError DestroyVertexBuffer(ResourceId id);
// Implements the SetVertexBufferData function for D3D9.
- virtual ParseError SetVertexBufferData(ResourceID id,
+ virtual ParseError SetVertexBufferData(ResourceId id,
unsigned int offset,
unsigned int size,
const void *data);
// Implements the GetVertexBufferData function for D3D9.
- virtual ParseError GetVertexBufferData(ResourceID id,
+ virtual ParseError GetVertexBufferData(ResourceId id,
unsigned int offset,
unsigned int size,
void *data);
// Implements the CreateIndexBuffer function for D3D9.
- virtual ParseError CreateIndexBuffer(ResourceID id,
+ virtual ParseError CreateIndexBuffer(ResourceId id,
unsigned int size,
unsigned int flags);
// Implements the DestroyIndexBuffer function for D3D9.
- virtual ParseError DestroyIndexBuffer(ResourceID id);
+ virtual ParseError DestroyIndexBuffer(ResourceId id);
// Implements the SetIndexBufferData function for D3D9.
- virtual ParseError SetIndexBufferData(ResourceID id,
+ virtual ParseError SetIndexBufferData(ResourceId id,
unsigned int offset,
unsigned int size,
const void *data);
// Implements the GetIndexBufferData function for D3D9.
- virtual ParseError GetIndexBufferData(ResourceID id,
+ virtual ParseError GetIndexBufferData(ResourceId id,
unsigned int offset,
unsigned int size,
void *data);
// Implements the CreateVertexStruct function for D3D9.
- virtual ParseError CreateVertexStruct(ResourceID id,
+ virtual ParseError CreateVertexStruct(ResourceId id,
unsigned int input_count);
// Implements the DestroyVertexStruct function for D3D9.
- virtual ParseError DestroyVertexStruct(ResourceID id);
+ virtual ParseError DestroyVertexStruct(ResourceId id);
// Implements the SetVertexInput function for D3D9.
- virtual ParseError SetVertexInput(ResourceID vertex_struct_id,
+ virtual ParseError SetVertexInput(ResourceId vertex_struct_id,
unsigned int input_index,
- ResourceID vertex_buffer_id,
+ ResourceId vertex_buffer_id,
unsigned int offset,
unsigned int stride,
vertex_struct::Type type,
@@ -142,7 +142,7 @@ class GAPID3D9 : public GAPIInterface { unsigned int semantic_index);
// Implements the SetVertexStruct function for D3D9.
- virtual ParseError SetVertexStruct(ResourceID id);
+ virtual ParseError SetVertexStruct(ResourceId id);
// Implements the Draw function for D3D9.
virtual ParseError Draw(PrimitiveType primitive_type,
@@ -151,65 +151,65 @@ class GAPID3D9 : public GAPIInterface { // Implements the DrawIndexed function for D3D9.
virtual ParseError DrawIndexed(PrimitiveType primitive_type,
- ResourceID index_buffer_id,
+ ResourceId index_buffer_id,
unsigned int first,
unsigned int count,
unsigned int min_index,
unsigned int max_index);
// Implements the CreateEffect function for D3D9.
- virtual ParseError CreateEffect(ResourceID id,
+ virtual ParseError CreateEffect(ResourceId id,
unsigned int size,
const void *data);
// Implements the DestroyEffect function for D3D9.
- virtual ParseError DestroyEffect(ResourceID id);
+ virtual ParseError DestroyEffect(ResourceId id);
// Implements the SetEffect function for D3D9.
- virtual ParseError SetEffect(ResourceID id);
+ virtual ParseError SetEffect(ResourceId id);
// Implements the GetParamCount function for D3D9.
- virtual ParseError GetParamCount(ResourceID id,
+ virtual ParseError GetParamCount(ResourceId id,
unsigned int size,
void *data);
// Implements the CreateParam function for D3D9.
- virtual ParseError CreateParam(ResourceID param_id,
- ResourceID effect_id,
+ virtual ParseError CreateParam(ResourceId param_id,
+ ResourceId effect_id,
unsigned int index);
// Implements the CreateParamByName function for D3D9.
- virtual ParseError CreateParamByName(ResourceID param_id,
- ResourceID effect_id,
+ virtual ParseError CreateParamByName(ResourceId param_id,
+ ResourceId effect_id,
unsigned int size,
const void *name);
// Implements the DestroyParam function for D3D9.
- virtual ParseError DestroyParam(ResourceID id);
+ virtual ParseError DestroyParam(ResourceId id);
// Implements the SetParamData function for D3D9.
- virtual ParseError SetParamData(ResourceID id,
+ virtual ParseError SetParamData(ResourceId id,
unsigned int size,
const void *data);
// Implements the GetParamDesc function for D3D9.
- virtual ParseError GetParamDesc(ResourceID id,
+ virtual ParseError GetParamDesc(ResourceId id,
unsigned int size,
void *data);
// Implements the GetStreamCount function for D3D9.
- virtual ParseError GetStreamCount(ResourceID id,
+ virtual ParseError GetStreamCount(ResourceId id,
unsigned int size,
void *data);
// Implements the GetStreamDesc function for D3D9.
- virtual ParseError GetStreamDesc(ResourceID id,
+ virtual ParseError GetStreamDesc(ResourceId id,
unsigned int index,
unsigned int size,
void *data);
// Implements the CreateTexture2D function for D3D9.
- virtual ParseError CreateTexture2D(ResourceID id,
+ virtual ParseError CreateTexture2D(ResourceId id,
unsigned int width,
unsigned int height,
unsigned int levels,
@@ -218,7 +218,7 @@ class GAPID3D9 : public GAPIInterface { bool enable_render_surfaces);
// Implements the CreateTexture3D function for D3D9.
- virtual ParseError CreateTexture3D(ResourceID id,
+ virtual ParseError CreateTexture3D(ResourceId id,
unsigned int width,
unsigned int height,
unsigned int depth,
@@ -228,7 +228,7 @@ class GAPID3D9 : public GAPIInterface { bool enable_render_surfaces);
// Implements the CreateTextureCube function for D3D9.
- virtual ParseError CreateTextureCube(ResourceID id,
+ virtual ParseError CreateTextureCube(ResourceId id,
unsigned int side,
unsigned int levels,
texture::Format format,
@@ -236,7 +236,7 @@ class GAPID3D9 : public GAPIInterface { bool enable_render_surfaces);
// Implements the SetTextureData function for D3D9.
- virtual ParseError SetTextureData(ResourceID id,
+ virtual ParseError SetTextureData(ResourceId id,
unsigned int x,
unsigned int y,
unsigned int z,
@@ -251,7 +251,7 @@ class GAPID3D9 : public GAPIInterface { const void *data);
// Implements the GetTextureData function for D3D9.
- virtual ParseError GetTextureData(ResourceID id,
+ virtual ParseError GetTextureData(ResourceId id,
unsigned int x,
unsigned int y,
unsigned int z,
@@ -266,16 +266,16 @@ class GAPID3D9 : public GAPIInterface { void *data);
// Implements the DestroyTexture function for D3D9.
- virtual ParseError DestroyTexture(ResourceID id);
+ virtual ParseError DestroyTexture(ResourceId id);
// Implements the CreateSampler function for D3D9.
- virtual ParseError CreateSampler(ResourceID id);
+ virtual ParseError CreateSampler(ResourceId id);
// Implements the DestroySampler function for D3D9.
- virtual ParseError DestroySampler(ResourceID id);
+ virtual ParseError DestroySampler(ResourceId id);
// Implements the SetSamplerStates function for D3D9.
- virtual ParseError SetSamplerStates(ResourceID id,
+ virtual ParseError SetSamplerStates(ResourceId id,
sampler::AddressingMode addressing_u,
sampler::AddressingMode addressing_v,
sampler::AddressingMode addressing_w,
@@ -285,10 +285,10 @@ class GAPID3D9 : public GAPIInterface { unsigned int max_anisotropy);
// Implements the SetSamplerBorderColor function for D3D9.
- virtual ParseError SetSamplerBorderColor(ResourceID id, const RGBA &color);
+ virtual ParseError SetSamplerBorderColor(ResourceId id, const RGBA &color);
// Implements the SetSamplerTexture function for D3D9.
- virtual ParseError SetSamplerTexture(ResourceID id, ResourceID texture_id);
+ virtual ParseError SetSamplerTexture(ResourceId id, ResourceId texture_id);
// Implements the SetScissor function for D3D9.
virtual void SetScissor(bool enable,
@@ -348,27 +348,27 @@ class GAPID3D9 : public GAPIInterface { virtual void SetBlendingColor(const RGBA &color);
// Implements the CreateRenderSurface function for D3D9.
- virtual ParseError CreateRenderSurface(ResourceID id,
+ virtual ParseError CreateRenderSurface(ResourceId id,
unsigned int width,
unsigned int height,
unsigned int mip_level,
unsigned int side,
- ResourceID texture_id);
+ ResourceId texture_id);
// Implements the DestroyRenderSurface function for D3D9.
- virtual ParseError DestroyRenderSurface(ResourceID id);
+ virtual ParseError DestroyRenderSurface(ResourceId id);
// Implements the CreateDepthSurface function for D3D9.
- virtual ParseError CreateDepthSurface(ResourceID id,
+ virtual ParseError CreateDepthSurface(ResourceId id,
unsigned int width,
unsigned int height);
// Implements teh DestroyDepthSurface function for D3D9.
- virtual ParseError DestroyDepthSurface(ResourceID id);
+ virtual ParseError DestroyDepthSurface(ResourceId id);
// Implements the SetRenderSurface function for D3D9.
- virtual ParseError SetRenderSurface(ResourceID render_surface_id,
- ResourceID depth_stencil_id);
+ virtual ParseError SetRenderSurface(ResourceId render_surface_id,
+ ResourceId depth_stencil_id);
// Implements the SetBackSurfaces function for D3D9.
virtual void SetBackSurfaces();
@@ -377,17 +377,17 @@ class GAPID3D9 : public GAPIInterface { IDirect3DDevice9 *d3d_device() const { return d3d_device_; }
// Gets a vertex buffer by resource ID.
- VertexBufferD3D9 *GetVertexBuffer(ResourceID id) {
+ VertexBufferD3D9 *GetVertexBuffer(ResourceId id) {
return vertex_buffers_.Get(id);
}
// Gets a texture by resource ID.
- TextureD3D9 *GetTexture(ResourceID id) {
+ TextureD3D9 *GetTexture(ResourceId id) {
return textures_.Get(id);
}
// Gets a sampler by resource ID.
- SamplerD3D9 *GetSampler(ResourceID id) {
+ SamplerD3D9 *GetSampler(ResourceId id) {
return samplers_.Get(id);
}
@@ -453,16 +453,16 @@ class GAPID3D9 : public GAPIInterface { LPDIRECT3D9 d3d_;
LPDIRECT3DDEVICE9 d3d_device_;
HWND hwnd_;
- ResourceID current_vertex_struct_;
+ ResourceId current_vertex_struct_;
bool validate_streams_;
unsigned int max_vertices_;
- ResourceID current_effect_id_;
+ ResourceId current_effect_id_;
bool validate_effect_;
EffectD3D9 *current_effect_; IDirect3DSurface9* back_buffer_surface_; IDirect3DSurface9* back_buffer_depth_surface_;
- ResourceID current_surface_id_;
- ResourceID current_depth_surface_id_;
+ ResourceId current_surface_id_;
+ ResourceId current_depth_surface_id_;
ResourceMap<VertexBufferD3D9> vertex_buffers_;
ResourceMap<IndexBufferD3D9> index_buffers_;
diff --git a/o3d/command_buffer/service/win/d3d9/geometry_d3d9.cc b/o3d/command_buffer/service/win/d3d9/geometry_d3d9.cc index deeab89..0123d49 100644 --- a/o3d/command_buffer/service/win/d3d9/geometry_d3d9.cc +++ b/o3d/command_buffer/service/win/d3d9/geometry_d3d9.cc @@ -55,7 +55,7 @@ VertexBufferD3D9::~VertexBufferD3D9() { void VertexBufferD3D9::Create(GAPID3D9 *gapi) { DCHECK(d3d_vertex_buffer_ == NULL); - DWORD d3d_usage = (flags() & vertex_buffer::DYNAMIC) ? D3DUSAGE_DYNAMIC : 0; + DWORD d3d_usage = (flags() & vertex_buffer::kDynamic) ? D3DUSAGE_DYNAMIC : 0; D3DPOOL d3d_pool = D3DPOOL_MANAGED; HR(gapi->d3d_device()->CreateVertexBuffer(size(), d3d_usage, 0, d3d_pool, &d3d_vertex_buffer_, NULL)); @@ -78,7 +78,7 @@ bool VertexBufferD3D9::SetData(unsigned int offset, // If we are setting the full buffer, discard the old data. That's only // possible to do for a dynamic d3d vertex buffer. if ((offset == 0) && (size == this->size()) && - (flags() & vertex_buffer::DYNAMIC)) + (flags() & vertex_buffer::kDynamic)) lock_flags = D3DLOCK_DISCARD; HR(d3d_vertex_buffer_->Lock(offset, size, &ptr, lock_flags)); memcpy(ptr, data, size); @@ -119,9 +119,9 @@ IndexBufferD3D9::~IndexBufferD3D9() { void IndexBufferD3D9::Create(GAPID3D9 *gapi) { DCHECK(d3d_index_buffer_ == NULL); - DWORD d3d_usage = (flags() & index_buffer::DYNAMIC) ? D3DUSAGE_DYNAMIC : 0; + DWORD d3d_usage = (flags() & index_buffer::kDynamic) ? D3DUSAGE_DYNAMIC : 0; D3DFORMAT d3d_format = - (flags() & index_buffer::INDEX_32BIT) ? D3DFMT_INDEX32 : D3DFMT_INDEX16; + (flags() & index_buffer::kIndex32Bit) ? D3DFMT_INDEX32 : D3DFMT_INDEX16; D3DPOOL d3d_pool = D3DPOOL_MANAGED; HR(gapi->d3d_device()->CreateIndexBuffer(size(), d3d_usage, d3d_format, d3d_pool, &d3d_index_buffer_, @@ -145,7 +145,7 @@ bool IndexBufferD3D9::SetData(unsigned int offset, // If we are setting the full buffer, discard the old data. That's only // possible to do for a dynamic d3d index buffer. if ((offset == 0) && (size == this->size()) && - (flags() & index_buffer::DYNAMIC)) + (flags() & index_buffer::kDynamic)) lock_flags = D3DLOCK_DISCARD; HR(d3d_index_buffer_->Lock(offset, size, &ptr, lock_flags)); memcpy(ptr, data, size); @@ -175,7 +175,7 @@ bool IndexBufferD3D9::GetData(unsigned int offset, // Sets the input element in the VertexStruct resource. void VertexStructD3D9::SetInput(unsigned int input_index, - ResourceID vertex_buffer_id, + ResourceId vertex_buffer_id, unsigned int offset, unsigned int stride, vertex_struct::Type type, @@ -222,17 +222,17 @@ unsigned int VertexStructD3D9::SetStreams(GAPID3D9 *gapi) { // Converts a vertex_struct::Type to a D3DDECLTYPE. static D3DDECLTYPE D3DType(vertex_struct::Type type) { switch (type) { - case vertex_struct::FLOAT1: + case vertex_struct::kFloat1: return D3DDECLTYPE_FLOAT1; - case vertex_struct::FLOAT2: + case vertex_struct::kFloat2: return D3DDECLTYPE_FLOAT2; - case vertex_struct::FLOAT3: + case vertex_struct::kFloat3: return D3DDECLTYPE_FLOAT3; - case vertex_struct::FLOAT4: + case vertex_struct::kFloat4: return D3DDECLTYPE_FLOAT4; - case vertex_struct::UCHAR4N: + case vertex_struct::kUChar4N: return D3DDECLTYPE_UBYTE4N; - case vertex_struct::NUM_TYPES: + case vertex_struct::kNumTypes: break; } LOG(FATAL) << "Invalid type"; @@ -242,15 +242,15 @@ static D3DDECLTYPE D3DType(vertex_struct::Type type) { // Converts a vertex_struct::Semantic to a D3DDECLUSAGE. static D3DDECLUSAGE D3DUsage(vertex_struct::Semantic semantic) { switch (semantic) { - case vertex_struct::POSITION: + case vertex_struct::kPosition: return D3DDECLUSAGE_POSITION; - case vertex_struct::NORMAL: + case vertex_struct::kNormal: return D3DDECLUSAGE_NORMAL; - case vertex_struct::COLOR: + case vertex_struct::kColor: return D3DDECLUSAGE_COLOR; - case vertex_struct::TEX_COORD: + case vertex_struct::kTexCoord: return D3DDECLUSAGE_TEXCOORD; - case vertex_struct::NUM_SEMANTICS: + case vertex_struct::kNumSemantics: break; } LOG(FATAL) << "Invalid type"; @@ -310,7 +310,7 @@ void VertexStructD3D9::Compile(IDirect3DDevice9 *d3d_device) { // Creates and assigns a VertexBufferD3D9 resource. BufferSyncInterface::ParseError GAPID3D9::CreateVertexBuffer( - ResourceID id, + ResourceId id, unsigned int size, unsigned int flags) { VertexBufferD3D9 *vertex_buffer = new VertexBufferD3D9(size, flags); @@ -320,7 +320,7 @@ BufferSyncInterface::ParseError GAPID3D9::CreateVertexBuffer( } // Destroys a VertexBufferD3D9 resource. -BufferSyncInterface::ParseError GAPID3D9::DestroyVertexBuffer(ResourceID id) { +BufferSyncInterface::ParseError GAPID3D9::DestroyVertexBuffer(ResourceId id) { return vertex_buffers_.Destroy(id) ? BufferSyncInterface::kParseNoError : BufferSyncInterface::kParseInvalidArguments; @@ -328,7 +328,7 @@ BufferSyncInterface::ParseError GAPID3D9::DestroyVertexBuffer(ResourceID id) { // Copies the data into the VertexBufferD3D9 resource. BufferSyncInterface::ParseError GAPID3D9::SetVertexBufferData( - ResourceID id, + ResourceId id, unsigned int offset, unsigned int size, const void *data) { @@ -341,7 +341,7 @@ BufferSyncInterface::ParseError GAPID3D9::SetVertexBufferData( // Copies the data from the VertexBufferD3D9 resource. BufferSyncInterface::ParseError GAPID3D9::GetVertexBufferData( - ResourceID id, + ResourceId id, unsigned int offset, unsigned int size, void *data) { @@ -354,7 +354,7 @@ BufferSyncInterface::ParseError GAPID3D9::GetVertexBufferData( // Creates and assigns an IndexBufferD3D9 resource. BufferSyncInterface::ParseError GAPID3D9::CreateIndexBuffer( - ResourceID id, + ResourceId id, unsigned int size, unsigned int flags) { IndexBufferD3D9 *index_buffer = new IndexBufferD3D9(size, flags); @@ -364,7 +364,7 @@ BufferSyncInterface::ParseError GAPID3D9::CreateIndexBuffer( } // Destroys an IndexBufferD3D9 resource. -BufferSyncInterface::ParseError GAPID3D9::DestroyIndexBuffer(ResourceID id) { +BufferSyncInterface::ParseError GAPID3D9::DestroyIndexBuffer(ResourceId id) { return index_buffers_.Destroy(id) ? BufferSyncInterface::kParseNoError : BufferSyncInterface::kParseInvalidArguments; @@ -372,7 +372,7 @@ BufferSyncInterface::ParseError GAPID3D9::DestroyIndexBuffer(ResourceID id) { // Copies the data into the IndexBufferD3D9 resource. BufferSyncInterface::ParseError GAPID3D9::SetIndexBufferData( - ResourceID id, + ResourceId id, unsigned int offset, unsigned int size, const void *data) { @@ -385,7 +385,7 @@ BufferSyncInterface::ParseError GAPID3D9::SetIndexBufferData( // Copies the data from the IndexBufferD3D9 resource. BufferSyncInterface::ParseError GAPID3D9::GetIndexBufferData( - ResourceID id, + ResourceId id, unsigned int offset, unsigned int size, void *data) { @@ -398,7 +398,7 @@ BufferSyncInterface::ParseError GAPID3D9::GetIndexBufferData( // Creates and assigns a VertexStructD3D9 resource. BufferSyncInterface::ParseError GAPID3D9::CreateVertexStruct( - ResourceID id, unsigned int input_count) { + ResourceId id, unsigned int input_count) { if (id == current_vertex_struct_) validate_streams_ = true; VertexStructD3D9 *vertex_struct = new VertexStructD3D9(input_count); vertex_structs_.Assign(id, vertex_struct); @@ -406,7 +406,7 @@ BufferSyncInterface::ParseError GAPID3D9::CreateVertexStruct( } // Destroys a VertexStructD3D9 resource. -BufferSyncInterface::ParseError GAPID3D9::DestroyVertexStruct(ResourceID id) { +BufferSyncInterface::ParseError GAPID3D9::DestroyVertexStruct(ResourceId id) { if (id == current_vertex_struct_) validate_streams_ = true; return vertex_structs_.Destroy(id) ? BufferSyncInterface::kParseNoError : @@ -415,9 +415,9 @@ BufferSyncInterface::ParseError GAPID3D9::DestroyVertexStruct(ResourceID id) { // Sets an input into a VertexStructD3D9 resource. BufferSyncInterface::ParseError GAPID3D9::SetVertexInput( - ResourceID vertex_struct_id, + ResourceId vertex_struct_id, unsigned int input_index, - ResourceID vertex_buffer_id, + ResourceId vertex_buffer_id, unsigned int offset, unsigned int stride, vertex_struct::Type type, diff --git a/o3d/command_buffer/service/win/d3d9/geometry_d3d9.h b/o3d/command_buffer/service/win/d3d9/geometry_d3d9.h index 46d722f..14ba2c2 100644 --- a/o3d/command_buffer/service/win/d3d9/geometry_d3d9.h +++ b/o3d/command_buffer/service/win/d3d9/geometry_d3d9.h @@ -99,7 +99,7 @@ class VertexStructD3D9 : public VertexStruct { virtual ~VertexStructD3D9(); // Adds an input to the vertex struct. void SetInput(unsigned int input_index, - ResourceID vertex_buffer_id, + ResourceId vertex_buffer_id, unsigned int offset, unsigned int stride, vertex_struct::Type type, @@ -114,7 +114,7 @@ class VertexStructD3D9 : public VertexStruct { void Compile(IDirect3DDevice9 *d3d_device); bool dirty_; - typedef std::pair<ResourceID, unsigned int> StreamPair; + typedef std::pair<ResourceId, unsigned int> StreamPair; std::vector<StreamPair> streams_; IDirect3DVertexDeclaration9 *d3d_vertex_decl_; DISALLOW_COPY_AND_ASSIGN(VertexStructD3D9); diff --git a/o3d/command_buffer/service/win/d3d9/render_surface_d3d9.cc b/o3d/command_buffer/service/win/d3d9/render_surface_d3d9.cc index a26d0dc..bf2281f 100644 --- a/o3d/command_buffer/service/win/d3d9/render_surface_d3d9.cc +++ b/o3d/command_buffer/service/win/d3d9/render_surface_d3d9.cc @@ -128,12 +128,12 @@ RenderDepthStencilSurfaceD3D9* RenderDepthStencilSurfaceD3D9::Create( // Copies the data from a texture resource. BufferSyncInterface::ParseError GAPID3D9::CreateRenderSurface( - ResourceID id, + ResourceId id, unsigned int width, unsigned int height, unsigned int mip_level, unsigned int side, - ResourceID texture_id) { + ResourceId texture_id) { if (id == current_surface_id_) { // This will delete the current surface which would be bad. return BufferSyncInterface::kParseInvalidArguments; @@ -156,7 +156,7 @@ BufferSyncInterface::ParseError GAPID3D9::CreateRenderSurface( return BufferSyncInterface::kParseNoError; } -BufferSyncInterface::ParseError GAPID3D9::DestroyRenderSurface(ResourceID id) { +BufferSyncInterface::ParseError GAPID3D9::DestroyRenderSurface(ResourceId id) { if (id == current_surface_id_) { return BufferSyncInterface::kParseInvalidArguments; } @@ -166,7 +166,7 @@ BufferSyncInterface::ParseError GAPID3D9::DestroyRenderSurface(ResourceID id) { } BufferSyncInterface::ParseError GAPID3D9::CreateDepthSurface( - ResourceID id, + ResourceId id, unsigned int width, unsigned int height) { if (id == current_depth_surface_id_) { @@ -182,7 +182,7 @@ BufferSyncInterface::ParseError GAPID3D9::CreateDepthSurface( return BufferSyncInterface::kParseNoError; } -BufferSyncInterface::ParseError GAPID3D9::DestroyDepthSurface(ResourceID id) { +BufferSyncInterface::ParseError GAPID3D9::DestroyDepthSurface(ResourceId id) { if (id == current_depth_surface_id_) { return BufferSyncInterface::kParseInvalidArguments; } @@ -192,8 +192,8 @@ BufferSyncInterface::ParseError GAPID3D9::DestroyDepthSurface(ResourceID id) { } BufferSyncInterface::ParseError GAPID3D9::SetRenderSurface( - ResourceID render_surface_id, - ResourceID depth_stencil_id) { + ResourceId render_surface_id, + ResourceId depth_stencil_id) { RenderSurfaceD3D9 *d3d_render_surface = render_surfaces_.Get(render_surface_id); RenderDepthStencilSurfaceD3D9 *d3d_render_depth_surface = diff --git a/o3d/command_buffer/service/win/d3d9/sampler_d3d9.cc b/o3d/command_buffer/service/win/d3d9/sampler_d3d9.cc index e37c37f..1e9be7b 100644 --- a/o3d/command_buffer/service/win/d3d9/sampler_d3d9.cc +++ b/o3d/command_buffer/service/win/d3d9/sampler_d3d9.cc @@ -44,13 +44,13 @@ namespace { // Converts an addressing mode to corresponding D3D values. D3DTEXTUREADDRESS AddressModeToD3D(sampler::AddressingMode mode) { switch (mode) { - case sampler::WRAP: + case sampler::kWrap: return D3DTADDRESS_WRAP; - case sampler::MIRROR_REPEAT: + case sampler::kMirrorRepeat: return D3DTADDRESS_MIRROR; - case sampler::CLAMP_TO_EDGE: + case sampler::kClampToEdge: return D3DTADDRESS_CLAMP; - case sampler::CLAMP_TO_BORDER: + case sampler::kClampToBorder: return D3DTADDRESS_BORDER; } DLOG(FATAL) << "Not reached"; @@ -60,11 +60,11 @@ D3DTEXTUREADDRESS AddressModeToD3D(sampler::AddressingMode mode) { // Converts a filtering mode to corresponding D3D values. D3DTEXTUREFILTERTYPE FilteringModeToD3D(sampler::FilteringMode mode) { switch (mode) { - case sampler::NONE: + case sampler::kNone: return D3DTEXF_NONE; - case sampler::POINT: + case sampler::kPoint: return D3DTEXF_POINT; - case sampler::LINEAR: + case sampler::kLinear: return D3DTEXF_LINEAR; } DLOG(FATAL) << "Not reached"; @@ -75,12 +75,12 @@ D3DTEXTUREFILTERTYPE FilteringModeToD3D(sampler::FilteringMode mode) { SamplerD3D9::SamplerD3D9() : texture_id_(kInvalidResource) { - SetStates(sampler::CLAMP_TO_EDGE, - sampler::CLAMP_TO_EDGE, - sampler::CLAMP_TO_EDGE, - sampler::LINEAR, - sampler::LINEAR, - sampler::POINT, + SetStates(sampler::kClampToEdge, + sampler::kClampToEdge, + sampler::kClampToEdge, + sampler::kLinear, + sampler::kLinear, + sampler::kPoint, 1); RGBA black = {0, 0, 0, 1}; SetBorderColor(black); @@ -114,8 +114,8 @@ void SamplerD3D9::SetStates(sampler::AddressingMode addressing_u, sampler::FilteringMode mip_filter, unsigned int max_anisotropy) { // These are validated in GAPIDecoder.cc - DCHECK_NE(mag_filter, sampler::NONE); - DCHECK_NE(min_filter, sampler::NONE); + DCHECK_NE(mag_filter, sampler::kNone); + DCHECK_NE(min_filter, sampler::kNone); DCHECK_GT(max_anisotropy, 0U); d3d_address_u_ = AddressModeToD3D(addressing_u); d3d_address_v_ = AddressModeToD3D(addressing_v); @@ -135,7 +135,7 @@ void SamplerD3D9::SetBorderColor(const RGBA &color) { } BufferSyncInterface::ParseError GAPID3D9::CreateSampler( - ResourceID id) { + ResourceId id) { // Dirty effect, because this sampler id may be used DirtyEffect(); samplers_.Assign(id, new SamplerD3D9()); @@ -143,7 +143,7 @@ BufferSyncInterface::ParseError GAPID3D9::CreateSampler( } // Destroys the Sampler resource. -BufferSyncInterface::ParseError GAPID3D9::DestroySampler(ResourceID id) { +BufferSyncInterface::ParseError GAPID3D9::DestroySampler(ResourceId id) { // Dirty effect, because this sampler id may be used DirtyEffect(); return samplers_.Destroy(id) ? @@ -152,7 +152,7 @@ BufferSyncInterface::ParseError GAPID3D9::DestroySampler(ResourceID id) { } BufferSyncInterface::ParseError GAPID3D9::SetSamplerStates( - ResourceID id, + ResourceId id, sampler::AddressingMode addressing_u, sampler::AddressingMode addressing_v, sampler::AddressingMode addressing_w, @@ -171,7 +171,7 @@ BufferSyncInterface::ParseError GAPID3D9::SetSamplerStates( } BufferSyncInterface::ParseError GAPID3D9::SetSamplerBorderColor( - ResourceID id, + ResourceId id, const RGBA &color) { SamplerD3D9 *sampler = samplers_.Get(id); if (!sampler) @@ -183,8 +183,8 @@ BufferSyncInterface::ParseError GAPID3D9::SetSamplerBorderColor( } BufferSyncInterface::ParseError GAPID3D9::SetSamplerTexture( - ResourceID id, - ResourceID texture_id) { + ResourceId id, + ResourceId texture_id) { SamplerD3D9 *sampler = samplers_.Get(id); if (!sampler) return BufferSyncInterface::kParseInvalidArguments; diff --git a/o3d/command_buffer/service/win/d3d9/sampler_d3d9.h b/o3d/command_buffer/service/win/d3d9/sampler_d3d9.h index e029963..cbc348a 100644 --- a/o3d/command_buffer/service/win/d3d9/sampler_d3d9.h +++ b/o3d/command_buffer/service/win/d3d9/sampler_d3d9.h @@ -66,7 +66,7 @@ class SamplerD3D9 : public Sampler { void SetBorderColor(const RGBA &color); // Sets the texture. - void SetTexture(ResourceID texture) { texture_id_ = texture; } + void SetTexture(ResourceId texture) { texture_id_ = texture; } private: D3DTEXTUREADDRESS d3d_address_u_; D3DTEXTUREADDRESS d3d_address_v_; @@ -76,7 +76,7 @@ class SamplerD3D9 : public Sampler { D3DTEXTUREFILTERTYPE d3d_mip_filter_; DWORD d3d_max_anisotropy_; D3DCOLOR d3d_border_color_; - ResourceID texture_id_; + ResourceId texture_id_; }; } // namespace command_buffer diff --git a/o3d/command_buffer/service/win/d3d9/states_d3d9.cc b/o3d/command_buffer/service/win/d3d9/states_d3d9.cc index 4a28db9..f6292e3 100644 --- a/o3d/command_buffer/service/win/d3d9/states_d3d9.cc +++ b/o3d/command_buffer/service/win/d3d9/states_d3d9.cc @@ -42,109 +42,109 @@ namespace command_buffer { namespace { -// Checks that a GAPIInterface enum matches a D3D enum so that it can be +// Checks that a command_buffer enum matches a D3D enum so that it can be // converted quickly. -#define CHECK_GAPI_ENUM_MATCHES_D3D(GAPI_ENUM, D3D_ENUM) \ - COMPILE_ASSERT(GAPIInterface::GAPI_ENUM + 1 == D3D_ENUM, \ - GAPI_ENUM ## _plus_1_not_ ## D3D_ENUM) +#define CHECK_CB_ENUM_MATCHES_D3D(CB_ENUM, D3D_ENUM) \ + COMPILE_ASSERT(command_buffer::CB_ENUM + 1 == D3D_ENUM, \ + CB_ENUM ## _plus_1_not_ ## D3D_ENUM) // Converts values from the PolygonMode enum to corresponding D3D values -inline D3DFILLMODE PolygonModeToD3D(GAPIInterface::PolygonMode fill_mode) { - DCHECK_LT(fill_mode, GAPIInterface::NUM_POLYGON_MODE); +inline D3DFILLMODE PolygonModeToD3D(command_buffer::PolygonMode fill_mode) { + DCHECK_LT(fill_mode, command_buffer::kNumPolygonMode); // Check that all acceptable values translate to D3D values by adding 1. - CHECK_GAPI_ENUM_MATCHES_D3D(POLYGON_MODE_POINTS, D3DFILL_POINT); - CHECK_GAPI_ENUM_MATCHES_D3D(POLYGON_MODE_LINES, D3DFILL_WIREFRAME); - CHECK_GAPI_ENUM_MATCHES_D3D(POLYGON_MODE_FILL, D3DFILL_SOLID); + CHECK_CB_ENUM_MATCHES_D3D(kPolygonModePoints, D3DFILL_POINT); + CHECK_CB_ENUM_MATCHES_D3D(kPolygonModeLines, D3DFILL_WIREFRAME); + CHECK_CB_ENUM_MATCHES_D3D(kPolygonModeFill, D3DFILL_SOLID); return static_cast<D3DFILLMODE>(fill_mode + 1); } // Converts values from the FaceCullMode enum to corresponding D3D values -inline D3DCULL FaceCullModeToD3D(GAPIInterface::FaceCullMode cull_mode) { - DCHECK_LT(cull_mode, GAPIInterface::NUM_FACE_CULL_MODE); +inline D3DCULL FaceCullModeToD3D(command_buffer::FaceCullMode cull_mode) { + DCHECK_LT(cull_mode, command_buffer::kNumFaceCullMode); // Check that all acceptable values translate to D3D values by adding 1. - CHECK_GAPI_ENUM_MATCHES_D3D(CULL_NONE, D3DCULL_NONE); - CHECK_GAPI_ENUM_MATCHES_D3D(CULL_CW, D3DCULL_CW); - CHECK_GAPI_ENUM_MATCHES_D3D(CULL_CCW, D3DCULL_CCW); + CHECK_CB_ENUM_MATCHES_D3D(kCullNone, D3DCULL_NONE); + CHECK_CB_ENUM_MATCHES_D3D(kCullCW, D3DCULL_CW); + CHECK_CB_ENUM_MATCHES_D3D(kCullCCW, D3DCULL_CCW); return static_cast<D3DCULL>(cull_mode + 1); } // Converts values from the Comparison enum to corresponding D3D values -inline D3DCMPFUNC ComparisonToD3D(GAPIInterface::Comparison comp) { - DCHECK_LT(comp, GAPIInterface::NUM_COMPARISON); +inline D3DCMPFUNC ComparisonToD3D(command_buffer::Comparison comp) { + DCHECK_LT(comp, command_buffer::kNumComparison); // Check that all acceptable values translate to D3D values by adding 1. - CHECK_GAPI_ENUM_MATCHES_D3D(NEVER, D3DCMP_NEVER); - CHECK_GAPI_ENUM_MATCHES_D3D(LESS, D3DCMP_LESS); - CHECK_GAPI_ENUM_MATCHES_D3D(EQUAL, D3DCMP_EQUAL); - CHECK_GAPI_ENUM_MATCHES_D3D(LEQUAL, D3DCMP_LESSEQUAL); - CHECK_GAPI_ENUM_MATCHES_D3D(GREATER, D3DCMP_GREATER); - CHECK_GAPI_ENUM_MATCHES_D3D(NOT_EQUAL, D3DCMP_NOTEQUAL); - CHECK_GAPI_ENUM_MATCHES_D3D(GEQUAL, D3DCMP_GREATEREQUAL); - CHECK_GAPI_ENUM_MATCHES_D3D(ALWAYS, D3DCMP_ALWAYS); + CHECK_CB_ENUM_MATCHES_D3D(kNever, D3DCMP_NEVER); + CHECK_CB_ENUM_MATCHES_D3D(kLess, D3DCMP_LESS); + CHECK_CB_ENUM_MATCHES_D3D(kEqual, D3DCMP_EQUAL); + CHECK_CB_ENUM_MATCHES_D3D(kLEqual, D3DCMP_LESSEQUAL); + CHECK_CB_ENUM_MATCHES_D3D(kGreater, D3DCMP_GREATER); + CHECK_CB_ENUM_MATCHES_D3D(kNotEqual, D3DCMP_NOTEQUAL); + CHECK_CB_ENUM_MATCHES_D3D(kGEqual, D3DCMP_GREATEREQUAL); + CHECK_CB_ENUM_MATCHES_D3D(kAlways, D3DCMP_ALWAYS); return static_cast<D3DCMPFUNC>(comp + 1); } // Converts values from the StencilOp enum to corresponding D3D values -inline D3DSTENCILOP StencilOpToD3D(GAPIInterface::StencilOp stencil_op) { - DCHECK_LT(stencil_op, GAPIInterface::NUM_STENCIL_OP); +inline D3DSTENCILOP StencilOpToD3D(command_buffer::StencilOp stencil_op) { + DCHECK_LT(stencil_op, command_buffer::kNumStencilOp); // Check that all acceptable values translate to D3D values by adding 1. - CHECK_GAPI_ENUM_MATCHES_D3D(KEEP, D3DSTENCILOP_KEEP); - CHECK_GAPI_ENUM_MATCHES_D3D(ZERO, D3DSTENCILOP_ZERO); - CHECK_GAPI_ENUM_MATCHES_D3D(REPLACE, D3DSTENCILOP_REPLACE); - CHECK_GAPI_ENUM_MATCHES_D3D(INC_NO_WRAP, D3DSTENCILOP_INCRSAT); - CHECK_GAPI_ENUM_MATCHES_D3D(DEC_NO_WRAP, D3DSTENCILOP_DECRSAT); - CHECK_GAPI_ENUM_MATCHES_D3D(INVERT, D3DSTENCILOP_INVERT); - CHECK_GAPI_ENUM_MATCHES_D3D(INC_WRAP, D3DSTENCILOP_INCR); - CHECK_GAPI_ENUM_MATCHES_D3D(DEC_WRAP, D3DSTENCILOP_DECR); + CHECK_CB_ENUM_MATCHES_D3D(kKeep, D3DSTENCILOP_KEEP); + CHECK_CB_ENUM_MATCHES_D3D(kZero, D3DSTENCILOP_ZERO); + CHECK_CB_ENUM_MATCHES_D3D(kReplace, D3DSTENCILOP_REPLACE); + CHECK_CB_ENUM_MATCHES_D3D(kIncNoWrap, D3DSTENCILOP_INCRSAT); + CHECK_CB_ENUM_MATCHES_D3D(kDecNoWrap, D3DSTENCILOP_DECRSAT); + CHECK_CB_ENUM_MATCHES_D3D(kInvert, D3DSTENCILOP_INVERT); + CHECK_CB_ENUM_MATCHES_D3D(kIncWrap, D3DSTENCILOP_INCR); + CHECK_CB_ENUM_MATCHES_D3D(kDecWrap, D3DSTENCILOP_DECR); return static_cast<D3DSTENCILOP>(stencil_op + 1); } // Converts values from the BlendEq enum to corresponding D3D values -inline D3DBLENDOP BlendEqToD3D(GAPIInterface::BlendEq blend_eq) { - DCHECK_LT(blend_eq, GAPIInterface::NUM_BLEND_EQ); +inline D3DBLENDOP BlendEqToD3D(command_buffer::BlendEq blend_eq) { + DCHECK_LT(blend_eq, command_buffer::kNumBlendEq); // Check that all acceptable values translate to D3D values by adding 1. - CHECK_GAPI_ENUM_MATCHES_D3D(BLEND_EQ_ADD, D3DBLENDOP_ADD); - CHECK_GAPI_ENUM_MATCHES_D3D(BLEND_EQ_SUB, D3DBLENDOP_SUBTRACT); - CHECK_GAPI_ENUM_MATCHES_D3D(BLEND_EQ_REV_SUB, D3DBLENDOP_REVSUBTRACT); - CHECK_GAPI_ENUM_MATCHES_D3D(BLEND_EQ_MIN, D3DBLENDOP_MIN); - CHECK_GAPI_ENUM_MATCHES_D3D(BLEND_EQ_MAX, D3DBLENDOP_MAX); + CHECK_CB_ENUM_MATCHES_D3D(kBlendEqAdd, D3DBLENDOP_ADD); + CHECK_CB_ENUM_MATCHES_D3D(kBlendEqSub, D3DBLENDOP_SUBTRACT); + CHECK_CB_ENUM_MATCHES_D3D(kBlendEqRevSub, D3DBLENDOP_REVSUBTRACT); + CHECK_CB_ENUM_MATCHES_D3D(kBlendEqMin, D3DBLENDOP_MIN); + CHECK_CB_ENUM_MATCHES_D3D(kBlendEqMax, D3DBLENDOP_MAX); return static_cast<D3DBLENDOP>(blend_eq + 1); } // Converts values from the BlendFunc enum to corresponding D3D values -D3DBLEND BlendFuncToD3D(GAPIInterface::BlendFunc blend_func) { +D3DBLEND BlendFuncToD3D(command_buffer::BlendFunc blend_func) { // The D3DBLEND enum values don't map 1-to-1 to BlendFunc, so we use a switch // here. switch (blend_func) { - case GAPIInterface::BLEND_FUNC_ZERO: + case command_buffer::kBlendFuncZero: return D3DBLEND_ZERO; - case GAPIInterface::BLEND_FUNC_ONE: + case command_buffer::kBlendFuncOne: return D3DBLEND_ONE; - case GAPIInterface::BLEND_FUNC_SRC_COLOR: + case command_buffer::kBlendFuncSrcColor: return D3DBLEND_SRCCOLOR; - case GAPIInterface::BLEND_FUNC_INV_SRC_COLOR: + case command_buffer::kBlendFuncInvSrcColor: return D3DBLEND_INVSRCCOLOR; - case GAPIInterface::BLEND_FUNC_SRC_ALPHA: + case command_buffer::kBlendFuncSrcAlpha: return D3DBLEND_SRCALPHA; - case GAPIInterface::BLEND_FUNC_INV_SRC_ALPHA: + case command_buffer::kBlendFuncInvSrcAlpha: return D3DBLEND_INVSRCALPHA; - case GAPIInterface::BLEND_FUNC_DST_ALPHA: + case command_buffer::kBlendFuncDstAlpha: return D3DBLEND_DESTALPHA; - case GAPIInterface::BLEND_FUNC_INV_DST_ALPHA: + case command_buffer::kBlendFuncInvDstAlpha: return D3DBLEND_INVDESTALPHA; - case GAPIInterface::BLEND_FUNC_DST_COLOR: + case command_buffer::kBlendFuncDstColor: return D3DBLEND_DESTCOLOR; - case GAPIInterface::BLEND_FUNC_INV_DST_COLOR: + case command_buffer::kBlendFuncInvDstColor: return D3DBLEND_INVDESTCOLOR; - case GAPIInterface::BLEND_FUNC_SRC_ALPHA_SATUTRATE: + case command_buffer::kBlendFuncSrcAlphaSaturate: return D3DBLEND_SRCALPHASAT; - case GAPIInterface::BLEND_FUNC_BLEND_COLOR: + case command_buffer::kBlendFuncBlendColor: return D3DBLEND_BLENDFACTOR; - case GAPIInterface::BLEND_FUNC_INV_BLEND_COLOR: + case command_buffer::kBlendFuncInvBlendColor: return D3DBLEND_INVBLENDFACTOR; default: DLOG(FATAL) << "Invalid BlendFunc"; @@ -154,31 +154,38 @@ D3DBLEND BlendFuncToD3D(GAPIInterface::BlendFunc blend_func) { // Decodes stencil test function and operations from the bitfield. void DecodeStencilFuncOps(Uint32 params, - GAPIInterface::Comparison *func, - GAPIInterface::StencilOp *pass, - GAPIInterface::StencilOp *fail, - GAPIInterface::StencilOp *zfail) { - namespace cmd = set_stencil_test; + command_buffer::Comparison *func, + command_buffer::StencilOp *pass, + command_buffer::StencilOp *fail, + command_buffer::StencilOp *zfail) { // Sanity check. The value has already been tested in // GAPIDecoder::DecodeSetStencilTest in gapi_decoder.cc. - DCHECK_EQ(cmd::Unused1::Get(params), 0); + DCHECK_EQ(cmd::SetStencilTest::Unused1::Get(params), 0); // Check that the bitmask get cannot generate values outside of the allowed // range. - COMPILE_ASSERT(cmd::CWFunc::kMask < GAPIInterface::NUM_COMPARISON, + COMPILE_ASSERT(cmd::SetStencilTest::CWFunc::kMask < + command_buffer::kNumComparison, set_stencil_test_CWFunc_may_produce_invalid_values); - *func = static_cast<GAPIInterface::Comparison>(cmd::CWFunc::Get(params)); + *func = static_cast<command_buffer::Comparison>( + cmd::SetStencilTest::CWFunc::Get(params)); - COMPILE_ASSERT(cmd::CWPassOp::kMask < GAPIInterface::NUM_STENCIL_OP, + COMPILE_ASSERT(cmd::SetStencilTest::CWPassOp::kMask < + command_buffer::kNumStencilOp, set_stencil_test_CWPassOp_may_produce_invalid_values); - *pass = static_cast<GAPIInterface::StencilOp>(cmd::CWPassOp::Get(params)); + *pass = static_cast<command_buffer::StencilOp>( + cmd::SetStencilTest::CWPassOp::Get(params)); - COMPILE_ASSERT(cmd::CWFailOp::kMask < GAPIInterface::NUM_STENCIL_OP, + COMPILE_ASSERT(cmd::SetStencilTest::CWFailOp::kMask < + command_buffer::kNumStencilOp, set_stencil_test_CWFailOp_may_produce_invalid_values); - *fail = static_cast<GAPIInterface::StencilOp>(cmd::CWFailOp::Get(params)); + *fail = static_cast<command_buffer::StencilOp>( + cmd::SetStencilTest::CWFailOp::Get(params)); - COMPILE_ASSERT(cmd::CWZFailOp::kMask < GAPIInterface::NUM_STENCIL_OP, + COMPILE_ASSERT(cmd::SetStencilTest::CWZFailOp::kMask < + command_buffer::kNumStencilOp, set_stencil_test_CWZFailOp_may_produce_invalid_values); - *zfail = static_cast<GAPIInterface::StencilOp>(cmd::CWZFailOp::Get(params)); + *zfail = static_cast<command_buffer::StencilOp>( + cmd::SetStencilTest::CWZFailOp::Get(params)); } } // anonymous namespace @@ -273,11 +280,11 @@ void GAPID3D9::SetStencilTest(bool enable, // clockwise ones, just shifted by 16 bits, so that we can use // DecodeStencilFuncOps on both of them. #define CHECK_CCW_MATCHES_CW(FIELD) \ - COMPILE_ASSERT(set_stencil_test::CW ## FIELD::kLength == \ - set_stencil_test::CCW ## FIELD::kLength, \ + COMPILE_ASSERT(cmd::SetStencilTest::CW ## FIELD::kLength == \ + cmd::SetStencilTest::CCW ## FIELD::kLength, \ CCW ## FIELD ## _length_does_not_match_ ## CW ## FIELD); \ - COMPILE_ASSERT(set_stencil_test::CW ## FIELD::kShift + 16 == \ - set_stencil_test::CCW ## FIELD::kShift, \ + COMPILE_ASSERT(cmd::SetStencilTest::CW ## FIELD::kShift + 16 == \ + cmd::SetStencilTest::CCW ## FIELD::kShift, \ CCW ## FIELD ## _shift_does_not_match_ ## CW ## FIELD) CHECK_CCW_MATCHES_CW(Func); CHECK_CCW_MATCHES_CW(PassOp); diff --git a/o3d/command_buffer/service/win/d3d9/texture_d3d9.cc b/o3d/command_buffer/service/win/d3d9/texture_d3d9.cc index cb220f8..db723d5 100644 --- a/o3d/command_buffer/service/win/d3d9/texture_d3d9.cc +++ b/o3d/command_buffer/service/win/d3d9/texture_d3d9.cc @@ -42,10 +42,10 @@ namespace command_buffer { // Converts a texture format to a D3D texture format. D3DFORMAT TextureD3D9::D3DFormat(texture::Format format) { switch (format) { - case texture::XRGB8: return D3DFMT_X8R8G8B8; - case texture::ARGB8: return D3DFMT_A8R8G8B8; - case texture::ABGR16F: return D3DFMT_A16B16G16R16F; - case texture::DXT1: return D3DFMT_DXT1; + case texture::kXRGB8: return D3DFMT_X8R8G8B8; + case texture::kARGB8: return D3DFMT_A8R8G8B8; + case texture::kABGR16F: return D3DFMT_A16B16G16R16F; + case texture::kDXT1: return D3DFMT_DXT1; default: return D3DFMT_UNKNOWN; }; } @@ -53,17 +53,17 @@ D3DFORMAT TextureD3D9::D3DFormat(texture::Format format) { // Converts a cube map face to a D3D face. D3DCUBEMAP_FACES TextureD3D9::D3DFace(texture::Face face) { switch (face) { - case texture::FACE_POSITIVE_X: + case texture::kFacePositiveX: return D3DCUBEMAP_FACE_POSITIVE_X; - case texture::FACE_NEGATIVE_X: + case texture::kFaceNegativeX: return D3DCUBEMAP_FACE_NEGATIVE_X; - case texture::FACE_POSITIVE_Y: + case texture::kFacePositiveY: return D3DCUBEMAP_FACE_POSITIVE_Y; - case texture::FACE_NEGATIVE_Y: + case texture::kFaceNegativeY: return D3DCUBEMAP_FACE_NEGATIVE_Y; - case texture::FACE_POSITIVE_Z: + case texture::kFacePositiveZ: return D3DCUBEMAP_FACE_POSITIVE_Z; - case texture::FACE_NEGATIVE_Z: + case texture::kFaceNegativeZ: return D3DCUBEMAP_FACE_NEGATIVE_Z; } LOG(FATAL) << "Not reached."; @@ -110,7 +110,7 @@ Texture2DD3D9 *Texture2DD3D9::Create(GAPID3D9 *gapi, } return new Texture2DD3D9(levels, format, flags, width, height, d3d_texture, NULL, enable_render_surfaces); - } else if (flags & texture::DYNAMIC) { + } else if (flags & texture::kDynamic) { CComPtr<IDirect3DTexture9> d3d_texture = NULL; HRESULT result = device->CreateTexture(width, height, levels, D3DUSAGE_DYNAMIC, d3d_format, @@ -174,7 +174,7 @@ bool Texture2DD3D9::SetData(GAPID3D9 *gapi, RECT rect = {volume.x, volume.y, volume.x+volume.width, volume.y+volume.height}; DWORD lock_flags = - full_rect && (flags() & texture::DYNAMIC) ? D3DLOCK_DISCARD : 0; + full_rect && (flags() & texture::kDynamic) ? D3DLOCK_DISCARD : 0; HR(lock_texture->LockRect(level, &locked_rect, full_rect ? NULL : &rect, lock_flags)); @@ -288,7 +288,7 @@ Texture3DD3D9 *Texture3DD3D9::Create(GAPID3D9 *gapi, } return new Texture3DD3D9(levels, format, flags, width, height, depth, d3d_texture, NULL, enable_render_surfaces); - } else if (flags & texture::DYNAMIC) { + } else if (flags & texture::kDynamic) { CComPtr<IDirect3DVolumeTexture9> d3d_texture = NULL; HRESULT result = device->CreateVolumeTexture(width, height, depth, levels, D3DUSAGE_DYNAMIC, d3d_format, @@ -355,7 +355,7 @@ bool Texture3DD3D9::SetData(GAPID3D9 *gapi, D3DBOX box = {volume.x, volume.y, volume.z, volume.x+volume.width, volume.y+volume.height, volume.z+volume.depth}; DWORD lock_flags = - full_box && (flags() & texture::DYNAMIC) ? D3DLOCK_DISCARD : 0; + full_box && (flags() & texture::kDynamic) ? D3DLOCK_DISCARD : 0; HR(lock_texture->LockBox(level, &locked_box, full_box ? NULL : &box, lock_flags)); @@ -461,7 +461,7 @@ TextureCubeD3D9 *TextureCubeD3D9::Create(GAPID3D9 *gapi, } return new TextureCubeD3D9(levels, format, flags, side, d3d_texture, NULL, enable_render_surfaces); - } else if (flags & texture::DYNAMIC) { + } else if (flags & texture::kDynamic) { CComPtr<IDirect3DCubeTexture9> d3d_texture = NULL; HRESULT result = device->CreateCubeTexture(side, levels, D3DUSAGE_DYNAMIC, d3d_format, D3DPOOL_DEFAULT, @@ -526,7 +526,7 @@ bool TextureCubeD3D9::SetData(GAPID3D9 *gapi, RECT rect = {volume.x, volume.y, volume.x+volume.width, volume.y+volume.height}; DWORD lock_flags = - full_rect && (flags() & texture::DYNAMIC) ? D3DLOCK_DISCARD : 0; + full_rect && (flags() & texture::kDynamic) ? D3DLOCK_DISCARD : 0; HR(lock_texture->LockRect(d3d_face, level, &locked_rect, full_rect ? NULL : &rect, lock_flags)); @@ -608,7 +608,7 @@ bool TextureCubeD3D9::CreateRenderSurface( // GAPID3D9 functions. // Destroys a texture resource. -BufferSyncInterface::ParseError GAPID3D9::DestroyTexture(ResourceID id) { +BufferSyncInterface::ParseError GAPID3D9::DestroyTexture(ResourceId id) { // Dirty effect, because this texture id may be used DirtyEffect(); return textures_.Destroy(id) ? @@ -618,7 +618,7 @@ BufferSyncInterface::ParseError GAPID3D9::DestroyTexture(ResourceID id) { // Creates a 2D texture resource. BufferSyncInterface::ParseError GAPID3D9::CreateTexture2D( - ResourceID id, + ResourceId id, unsigned int width, unsigned int height, unsigned int levels, @@ -637,7 +637,7 @@ BufferSyncInterface::ParseError GAPID3D9::CreateTexture2D( // Creates a 3D texture resource. BufferSyncInterface::ParseError GAPID3D9::CreateTexture3D( - ResourceID id, + ResourceId id, unsigned int width, unsigned int height, unsigned int depth, @@ -657,7 +657,7 @@ BufferSyncInterface::ParseError GAPID3D9::CreateTexture3D( // Creates a cube map texture resource. BufferSyncInterface::ParseError GAPID3D9::CreateTextureCube( - ResourceID id, + ResourceId id, unsigned int side, unsigned int levels, texture::Format format, @@ -675,7 +675,7 @@ BufferSyncInterface::ParseError GAPID3D9::CreateTextureCube( // Copies the data into a texture resource. BufferSyncInterface::ParseError GAPID3D9::SetTextureData( - ResourceID id, + ResourceId id, unsigned int x, unsigned int y, unsigned int z, @@ -700,7 +700,7 @@ BufferSyncInterface::ParseError GAPID3D9::SetTextureData( // Copies the data from a texture resource. BufferSyncInterface::ParseError GAPID3D9::GetTextureData( - ResourceID id, + ResourceId id, unsigned int x, unsigned int y, unsigned int z, diff --git a/o3d/command_buffer/service/win/d3d9/texture_d3d9.h b/o3d/command_buffer/service/win/d3d9/texture_d3d9.h index 48f93e7..332cc68 100644 --- a/o3d/command_buffer/service/win/d3d9/texture_d3d9.h +++ b/o3d/command_buffer/service/win/d3d9/texture_d3d9.h @@ -100,7 +100,7 @@ class Texture2DD3D9 : public TextureD3D9 { IDirect3DTexture9 *texture, IDirect3DTexture9 *shadow, bool enable_render_surfaces) - : TextureD3D9(texture::TEXTURE_2D, levels, format, + : TextureD3D9(texture::kTexture2d, levels, format, enable_render_surfaces, flags), width_(width), height_(height), @@ -164,7 +164,7 @@ class Texture3DD3D9 : public TextureD3D9 { IDirect3DVolumeTexture9 *texture, IDirect3DVolumeTexture9 *shadow, bool enable_render_surfaces) - : TextureD3D9(texture::TEXTURE_2D, levels, format, + : TextureD3D9(texture::kTexture3d, levels, format, enable_render_surfaces, flags), width_(width), height_(height), @@ -228,7 +228,7 @@ class TextureCubeD3D9 : public TextureD3D9 { IDirect3DCubeTexture9 *texture, IDirect3DCubeTexture9 *shadow, bool enable_render_surfaces) - : TextureD3D9(texture::TEXTURE_CUBE, levels, format, + : TextureD3D9(texture::kTextureCube, levels, format, enable_render_surfaces, flags), side_(side), d3d_texture_(texture), diff --git a/o3d/core/cross/command_buffer/buffer_cb.cc b/o3d/core/cross/command_buffer/buffer_cb.cc index 32adbc9..2809d7f 100644 --- a/o3d/core/cross/command_buffer/buffer_cb.cc +++ b/o3d/core/cross/command_buffer/buffer_cb.cc @@ -72,7 +72,8 @@ bool VertexBufferCB::ConcreteAllocate(size_t size_in_bytes) { if (size_in_bytes > 0) { resource_id_ = renderer_->vertex_buffer_ids().AllocateID(); CommandBufferHelper *helper = renderer_->helper(); - helper->CreateVertexBuffer(resource_id_, size_in_bytes, 0); + helper->CreateVertexBuffer(resource_id_, size_in_bytes, + command_buffer::vertex_buffer::kNone); has_data_ = false; } return true; @@ -149,7 +150,7 @@ bool IndexBufferCB::ConcreteAllocate(size_t size_in_bytes) { CommandBufferHelper *helper = renderer_->helper(); helper->CreateIndexBuffer( resource_id_, size_in_bytes, - command_buffer::index_buffer::INDEX_32BIT); + command_buffer::index_buffer::kIndex32Bit); has_data_ = false; } return true; diff --git a/o3d/core/cross/command_buffer/buffer_cb.h b/o3d/core/cross/command_buffer/buffer_cb.h index 87cbb19..7a6f567 100644 --- a/o3d/core/cross/command_buffer/buffer_cb.h +++ b/o3d/core/cross/command_buffer/buffer_cb.h @@ -54,7 +54,7 @@ class VertexBufferCB : public VertexBuffer { ~VertexBufferCB(); // Returns the resource ID for this vertex buffer. - command_buffer::ResourceID resource_id() const { return resource_id_; } + command_buffer::ResourceId resource_id() const { return resource_id_; } protected: // Allocates a vertex buffer resource. @@ -95,7 +95,7 @@ class VertexBufferCB : public VertexBuffer { bool has_data_; // The command buffer resource ID for the vertex buffer. - command_buffer::ResourceID resource_id_; + command_buffer::ResourceId resource_id_; // The renderer that created this vertex buffer. RendererCB *renderer_; @@ -113,7 +113,7 @@ class IndexBufferCB : public IndexBuffer { ~IndexBufferCB(); // Returns the resource ID for this vertex buffer. - command_buffer::ResourceID resource_id() const { return resource_id_; } + command_buffer::ResourceId resource_id() const { return resource_id_; } protected: // Allocates an index buffer resource. @@ -157,7 +157,7 @@ class IndexBufferCB : public IndexBuffer { bool has_data_; // The command buffer resource ID for the index buffer. - command_buffer::ResourceID resource_id_; + command_buffer::ResourceId resource_id_; // The renderer that created this index buffer. RendererCB *renderer_; diff --git a/o3d/core/cross/command_buffer/effect_cb.cc b/o3d/core/cross/command_buffer/effect_cb.cc index 332da8f..b69be352 100644 --- a/o3d/core/cross/command_buffer/effect_cb.cc +++ b/o3d/core/cross/command_buffer/effect_cb.cc @@ -47,7 +47,7 @@ namespace o3d { using command_buffer::BufferSyncInterface; using command_buffer::CommandBufferEntry; using command_buffer::CommandBufferHelper; -using command_buffer::ResourceID; +using command_buffer::ResourceId; namespace effect_param = command_buffer::effect_param; namespace vertex_struct = command_buffer::vertex_struct; @@ -89,7 +89,7 @@ bool EffectCB::LoadFromFXString(const String& source) { memcpy(buffer_data + vp_main.size() + 1 + fp_main.size() + 1, source.data(), source.size()); - ResourceID resource_id = renderer_->effect_ids().AllocateID(); + ResourceId resource_id = renderer_->effect_ids().AllocateID(); CommandBufferHelper *helper = renderer_->helper(); helper->CreateEffect( @@ -154,21 +154,21 @@ void EffectCB::Destroy() { static const ObjectBase::Class* CBTypeToParamType( effect_param::DataType type) { switch (type) { - case effect_param::FLOAT1: + case effect_param::kFloat1: return ParamFloat::GetApparentClass(); - case effect_param::FLOAT2: + case effect_param::kFloat2: return ParamFloat2::GetApparentClass(); - case effect_param::FLOAT3: + case effect_param::kFloat3: return ParamFloat3::GetApparentClass(); - case effect_param::FLOAT4: + case effect_param::kFloat4: return ParamFloat4::GetApparentClass(); - case effect_param::INT: + case effect_param::kInt: return ParamInteger::GetApparentClass(); - case effect_param::MATRIX4: + case effect_param::kMatrix4: return ParamMatrix4::GetApparentClass(); - case effect_param::SAMPLER: + case effect_param::kSampler: return ParamSampler::GetApparentClass(); - case effect_param::TEXTURE: + case effect_param::kTexture: return ParamTexture::GetApparentClass(); default : { DLOG(ERROR) << "Cannot convert command buffer type " @@ -209,22 +209,22 @@ static bool CBSemanticToO3DSemantic( Stream::Semantic *out_semantic, unsigned int *out_semantic_index) { switch (semantic) { - case vertex_struct::POSITION: + case vertex_struct::kPosition: if (semantic_index != 0) return false; *out_semantic = Stream::POSITION; *out_semantic_index = 0; return true; - case vertex_struct::NORMAL: + case vertex_struct::kNormal: if (semantic_index != 0) return false; *out_semantic = Stream::NORMAL; *out_semantic_index = 0; return true; - case vertex_struct::COLOR: + case vertex_struct::kColor: if (semantic_index > 1) return false; *out_semantic = Stream::COLOR; *out_semantic_index = semantic_index; return true; - case vertex_struct::TEX_COORD: + case vertex_struct::kTexCoord: if (semantic_index == 6) { *out_semantic = Stream::TANGENT; *out_semantic_index = 0; diff --git a/o3d/core/cross/command_buffer/effect_cb.h b/o3d/core/cross/command_buffer/effect_cb.h index 3d310bc..1b511fd 100644 --- a/o3d/core/cross/command_buffer/effect_cb.h +++ b/o3d/core/cross/command_buffer/effect_cb.h @@ -57,8 +57,8 @@ class EffectCB : public Effect { // a DirectX FX description. virtual bool LoadFromFXString(const String& effect); - // Gets the ResourceID of the effect. - command_buffer::ResourceID resource_id() { return resource_id_; } + // Gets the ResourceId of the effect. + command_buffer::ResourceId resource_id() { return resource_id_; } protected: // Gets info about the parameters this effect needs. @@ -73,7 +73,7 @@ class EffectCB : public Effect { private: void Destroy(); // The command buffer resource ID for the effect. - command_buffer::ResourceID resource_id_; + command_buffer::ResourceId resource_id_; std::vector<EffectHelper::EffectParamDesc> param_descs_; std::vector<EffectHelper::EffectStreamDesc> stream_descs_; // A generation counter to dirty ParamCacheCBs. diff --git a/o3d/core/cross/command_buffer/param_cache_cb.cc b/o3d/core/cross/command_buffer/param_cache_cb.cc index e6351dc..297be90 100644 --- a/o3d/core/cross/command_buffer/param_cache_cb.cc +++ b/o3d/core/cross/command_buffer/param_cache_cb.cc @@ -47,7 +47,7 @@ namespace o3d { using command_buffer::CommandBufferEntry; using command_buffer::CommandBufferHelper; using command_buffer::EffectHelper; -using command_buffer::ResourceID; +using command_buffer::ResourceId; namespace effect_param = command_buffer::effect_param; // Base class for ParamHandlers. @@ -61,7 +61,7 @@ class ParamHandlerCB { template <typename T> class TypedParamHandlerCB : public ParamHandlerCB { public: - TypedParamHandlerCB(T* param, ResourceID id) + TypedParamHandlerCB(T* param, ResourceId id) : param_(param), id_(id) { } @@ -75,7 +75,7 @@ class TypedParamHandlerCB : public ParamHandlerCB { } private: T* param_; - ResourceID id_; + ResourceId id_; }; // Matrices are expected in row major order in the command buffer, so @@ -85,7 +85,7 @@ typedef TypedParamHandlerCB<ParamMatrix4> MatrixParamHandlerRowsCB; class MatrixParamHandlerColumnsCB : public ParamHandlerCB { public: - MatrixParamHandlerColumnsCB(ParamMatrix4* param, ResourceID id) + MatrixParamHandlerColumnsCB(ParamMatrix4* param, ResourceId id) : param_(param), id_(id) { } @@ -97,12 +97,12 @@ class MatrixParamHandlerColumnsCB : public ParamHandlerCB { } private: ParamMatrix4* param_; - ResourceID id_; + ResourceId id_; }; class SamplerParamHandlerCB : public ParamHandlerCB { public: - SamplerParamHandlerCB(ParamSampler* param, ResourceID id) + SamplerParamHandlerCB(ParamSampler* param, ResourceId id) : param_(param), id_(id) { } @@ -122,7 +122,7 @@ class SamplerParamHandlerCB : public ParamHandlerCB { } private: ParamSampler* param_; - ResourceID id_; + ResourceId id_; }; static ParamHandlerCB *GetHandlerFromParamAndDesc( @@ -130,7 +130,7 @@ static ParamHandlerCB *GetHandlerFromParamAndDesc( const EffectHelper::EffectParamDesc &desc, Effect::MatrixLoadOrder matrix_load_order) { switch (desc.data_type) { - case effect_param::MATRIX4: + case effect_param::kMatrix4: if (param->IsA(ParamMatrix4::GetApparentClass())) { DCHECK_EQ(sizeof(ParamMatrix4::DataType), desc.data_size); ParamMatrix4 *matrix_param = down_cast<ParamMatrix4*>(param); @@ -141,51 +141,51 @@ static ParamHandlerCB *GetHandlerFromParamAndDesc( } } break; - case effect_param::FLOAT1: + case effect_param::kFloat1: if (param->IsA(ParamFloat::GetApparentClass())) { DCHECK_EQ(sizeof(ParamFloat::DataType), desc.data_size); return new TypedParamHandlerCB<ParamFloat>( down_cast<ParamFloat*>(param), desc.id); } break; - case effect_param::FLOAT2: + case effect_param::kFloat2: if (param->IsA(ParamFloat2::GetApparentClass())) { DCHECK_EQ(sizeof(ParamFloat2::DataType), desc.data_size); return new TypedParamHandlerCB<ParamFloat2>( down_cast<ParamFloat2*>(param), desc.id); } break; - case effect_param::FLOAT3: + case effect_param::kFloat3: if (param->IsA(ParamFloat3::GetApparentClass())) { DCHECK_EQ(sizeof(ParamFloat3::DataType), desc.data_size); return new TypedParamHandlerCB<ParamFloat3>( down_cast<ParamFloat3*>(param), desc.id); } break; - case effect_param::FLOAT4: + case effect_param::kFloat4: if (param->IsA(ParamFloat4::GetApparentClass())) { DCHECK_EQ(sizeof(ParamFloat4::DataType), desc.data_size); return new TypedParamHandlerCB<ParamFloat4>( down_cast<ParamFloat4*>(param), desc.id); } break; - case effect_param::INT: + case effect_param::kInt: if (param->IsA(ParamInteger::GetApparentClass())) { DCHECK_EQ(sizeof(ParamInteger::DataType), desc.data_size); return new TypedParamHandlerCB<ParamInteger>( down_cast<ParamInteger*>(param), desc.id); } break; - case effect_param::BOOL: + case effect_param::kBool: if (param->IsA(ParamBoolean::GetApparentClass())) { DCHECK_EQ(sizeof(ParamBoolean::DataType), desc.data_size); return new TypedParamHandlerCB<ParamBoolean>( down_cast<ParamBoolean*>(param), desc.id); } break; - case effect_param::SAMPLER: + case effect_param::kSampler: if (param->IsA(ParamSampler::GetApparentClass())) { - DCHECK_EQ(sizeof(ResourceID), desc.data_size); + DCHECK_EQ(sizeof(ResourceId), desc.data_size); return new SamplerParamHandlerCB(down_cast<ParamSampler*>(param), desc.id); } diff --git a/o3d/core/cross/command_buffer/param_cache_cb.h b/o3d/core/cross/command_buffer/param_cache_cb.h index 35e2f9d..b8fd536 100644 --- a/o3d/core/cross/command_buffer/param_cache_cb.h +++ b/o3d/core/cross/command_buffer/param_cache_cb.h @@ -44,7 +44,7 @@ namespace o3d { class ParamHandlerCB; // This class is the command-buffer implementation of the ParamCache class. It -// keeps a list of Param * -> param ResourceID associations handlers. +// keeps a list of Param * -> param ResourceId associations handlers. class ParamCacheCB : public ParamCache { public: ParamCacheCB(); diff --git a/o3d/core/cross/command_buffer/primitive_cb.cc b/o3d/core/cross/command_buffer/primitive_cb.cc index 208a1b0..a451662 100644 --- a/o3d/core/cross/command_buffer/primitive_cb.cc +++ b/o3d/core/cross/command_buffer/primitive_cb.cc @@ -47,7 +47,7 @@ namespace o3d { -using command_buffer::ResourceID; +using command_buffer::ResourceId; using command_buffer::CommandBufferHelper; using command_buffer::CommandBufferEntry; using command_buffer::GAPIInterface; @@ -63,22 +63,22 @@ PrimitiveCB::~PrimitiveCB() { } // Converts an O3D primitive type to a command-buffer one. -static GAPIInterface::PrimitiveType GetCBPrimitiveType( +static command_buffer::PrimitiveType GetCBPrimitiveType( Primitive::PrimitiveType primitive_type) { switch (primitive_type) { case Primitive::LINELIST: - return GAPIInterface::LINES; + return command_buffer::kLines; case Primitive::LINESTRIP: - return GAPIInterface::LINE_STRIPS; + return command_buffer::kLineStrips; case Primitive::TRIANGLELIST: - return GAPIInterface::TRIANGLES; + return command_buffer::kTriangles; case Primitive::TRIANGLESTRIP: - return GAPIInterface::TRIANGLE_STRIPS; + return command_buffer::kTriangleStrips; case Primitive::TRIANGLEFAN: - return GAPIInterface::TRIANGLE_FANS; + return command_buffer::kTriangleFans; default: // Note that POINTLIST falls into this case, for compatibility with D3D. - return GAPIInterface::MAX_PRIMITIVE_TYPE; + return command_buffer::kMaxPrimitiveType; } } @@ -116,9 +116,9 @@ void PrimitiveCB::PlatformSpecificRender(Renderer* renderer, DLOG(INFO) << "Trying to draw with an empty index buffer."; return; } - GAPIInterface::PrimitiveType cb_primitive_type = + command_buffer::PrimitiveType cb_primitive_type = GetCBPrimitiveType(primitive_type_); - if (cb_primitive_type == GAPIInterface::MAX_PRIMITIVE_TYPE) { + if (cb_primitive_type == command_buffer::kMaxPrimitiveType) { DLOG(INFO) << "Invalid primitive type (" << primitive_type_ << ")."; return; } diff --git a/o3d/core/cross/command_buffer/render_surface_cb.cc b/o3d/core/cross/command_buffer/render_surface_cb.cc index 443cc2f..df90b49 100644 --- a/o3d/core/cross/command_buffer/render_surface_cb.cc +++ b/o3d/core/cross/command_buffer/render_surface_cb.cc @@ -35,10 +35,9 @@ namespace o3d { -using command_buffer::ResourceID; +using command_buffer::ResourceId; using command_buffer::CommandBufferEntry; using command_buffer::CommandBufferHelper; -namespace create_render_surface_cmd = command_buffer::create_render_surface_cmd; RenderSurfaceCB::RenderSurfaceCB(ServiceLocator *service_locator, int width, @@ -56,7 +55,7 @@ RenderSurfaceCB::RenderSurfaceCB(ServiceLocator *service_locator, DCHECK(texture); DCHECK(renderer); - ResourceID id = renderer_->render_surface_ids().AllocateID(); + ResourceId id = renderer_->render_surface_ids().AllocateID(); resource_id_ = id; CommandBufferHelper *helper = renderer_->helper(); helper->CreateRenderSurface( @@ -90,7 +89,7 @@ RenderDepthStencilSurfaceCB::RenderDepthStencilSurfaceCB( DCHECK_GT(width, 0); DCHECK_GT(height, 0); DCHECK(renderer); - ResourceID id = renderer_->depth_surface_ids().AllocateID(); + ResourceId id = renderer_->depth_surface_ids().AllocateID(); resource_id_ = id; CommandBufferHelper *helper = renderer_->helper(); helper->CreateDepthSurface(id, width, height); diff --git a/o3d/core/cross/command_buffer/render_surface_cb.h b/o3d/core/cross/command_buffer/render_surface_cb.h index 357d0f7..ee22e3b 100644 --- a/o3d/core/cross/command_buffer/render_surface_cb.h +++ b/o3d/core/cross/command_buffer/render_surface_cb.h @@ -90,10 +90,10 @@ class RenderSurfaceCB : public RenderSurface { virtual void Destroy();
// Returns the render surface resource ID.
- command_buffer::ResourceID resource_id() const { return resource_id_; }
+ command_buffer::ResourceId resource_id() const { return resource_id_; }
private:
- command_buffer::ResourceID resource_id_;
+ command_buffer::ResourceId resource_id_;
RendererCB *renderer_;
DISALLOW_COPY_AND_ASSIGN(RenderSurfaceCB);
};
@@ -127,10 +127,10 @@ class RenderDepthStencilSurfaceCB : public RenderDepthStencilSurface { virtual void Destroy();
// Returns the render depth stencil surface resource ID.
- command_buffer::ResourceID resource_id() const { return resource_id_; }
+ command_buffer::ResourceId resource_id() const { return resource_id_; }
private:
- command_buffer::ResourceID resource_id_;
+ command_buffer::ResourceId resource_id_;
RendererCB *renderer_;
DISALLOW_COPY_AND_ASSIGN(RenderDepthStencilSurfaceCB);
};
diff --git a/o3d/core/cross/command_buffer/renderer_cb.cc b/o3d/core/cross/command_buffer/renderer_cb.cc index f2d919b5..d576874 100644 --- a/o3d/core/cross/command_buffer/renderer_cb.cc +++ b/o3d/core/cross/command_buffer/renderer_cb.cc @@ -184,9 +184,9 @@ void RendererCB::PlatformSpecificClear(const Float4 &color, bool depth_flag, int stencil, bool stencil_flag) { - uint32 buffers = (color_flag ? GAPIInterface::COLOR : 0) | - (depth_flag ? GAPIInterface::DEPTH : 0) | - (stencil_flag ? GAPIInterface::STENCIL : 0); + uint32 buffers = (color_flag ? command_buffer::kColor : 0) | + (depth_flag ? command_buffer::kDepth : 0) | + (stencil_flag ? command_buffer::kStencil : 0); helper_->Clear(buffers, color[0], color[1], color[2], color[3], depth, stencil); } diff --git a/o3d/core/cross/command_buffer/sampler_cb.cc b/o3d/core/cross/command_buffer/sampler_cb.cc index b185076..a327595 100644 --- a/o3d/core/cross/command_buffer/sampler_cb.cc +++ b/o3d/core/cross/command_buffer/sampler_cb.cc @@ -43,8 +43,7 @@ namespace o3d { using command_buffer::CommandBufferEntry; using command_buffer::CommandBufferHelper; -using command_buffer::ResourceID; -namespace set_sampler_states = command_buffer::set_sampler_states; +using command_buffer::ResourceId; namespace sampler = command_buffer::sampler; namespace { @@ -52,30 +51,30 @@ namespace { sampler::AddressingMode AddressModeToCB(Sampler::AddressMode o3d_mode) { switch (o3d_mode) { case Sampler::WRAP: - return sampler::WRAP; + return sampler::kWrap; case Sampler::MIRROR: - return sampler::MIRROR_REPEAT; + return sampler::kMirrorRepeat; case Sampler::CLAMP: - return sampler::CLAMP_TO_EDGE; + return sampler::kClampToEdge; case Sampler::BORDER: - return sampler::CLAMP_TO_BORDER; + return sampler::kClampToBorder; default: DLOG(ERROR) << "Unknown Address mode " << static_cast<int>(o3d_mode); - return sampler::WRAP; + return sampler::kWrap; } } sampler::FilteringMode FilterTypeToCB(Sampler::FilterType o3d_mode) { switch (o3d_mode) { case Sampler::NONE: - return sampler::NONE; + return sampler::kNone; case Sampler::POINT: - return sampler::POINT; + return sampler::kPoint; case Sampler::LINEAR: case Sampler::ANISOTROPIC: - return sampler::LINEAR; + return sampler::kLinear; default: - return sampler::NONE; + return sampler::kNone; } } @@ -102,9 +101,10 @@ void SamplerCB::SetTextureAndStates() { sampler::FilteringMode mag_filter_cb = FilterTypeToCB(mag_filter()); sampler::FilteringMode min_filter_cb = FilterTypeToCB(min_filter()); sampler::FilteringMode mip_filter_cb = FilterTypeToCB(mip_filter()); - if (mag_filter_cb == sampler::NONE) mag_filter_cb = sampler::POINT; - if (min_filter_cb == sampler::NONE) min_filter_cb = sampler::POINT; - int max_max_anisotropy = set_sampler_states::MaxAnisotropy::kMask; + if (mag_filter_cb == sampler::kNone) mag_filter_cb = sampler::kPoint; + if (min_filter_cb == sampler::kNone) min_filter_cb = sampler::kPoint; + int max_max_anisotropy = + command_buffer::cmd::SetSamplerStates::MaxAnisotropy::kMask; unsigned int max_anisotropy_cb = std::max(1, std::min(max_max_anisotropy, max_anisotropy())); if (min_filter() != Sampler::ANISOTROPIC) { @@ -122,7 +122,7 @@ void SamplerCB::SetTextureAndStates() { Float4 color = border_color(); helper->SetSamplerBorderColor(resource_id_, - color[0], color[1], color[2], color[3]); + color[0], color[1], color[2], color[3]); Texture *texture_object = texture(); if (!texture_object) { diff --git a/o3d/core/cross/command_buffer/sampler_cb.h b/o3d/core/cross/command_buffer/sampler_cb.h index b60241e..103c595 100644 --- a/o3d/core/cross/command_buffer/sampler_cb.h +++ b/o3d/core/cross/command_buffer/sampler_cb.h @@ -54,11 +54,11 @@ class SamplerCB : public Sampler { void SetTextureAndStates(); // Gets the resource ID for this sampler. - command_buffer::ResourceID resource_id() const { return resource_id_; } + command_buffer::ResourceId resource_id() const { return resource_id_; } private: RendererCB* renderer_; - command_buffer::ResourceID resource_id_; + command_buffer::ResourceId resource_id_; DISALLOW_COPY_AND_ASSIGN(SamplerCB); }; diff --git a/o3d/core/cross/command_buffer/states_cb.cc b/o3d/core/cross/command_buffer/states_cb.cc index c6d4818..ab04583 100644 --- a/o3d/core/cross/command_buffer/states_cb.cc +++ b/o3d/core/cross/command_buffer/states_cb.cc @@ -42,137 +42,136 @@ namespace o3d { using command_buffer::CommandBufferEntry; using command_buffer::CommandBufferHelper; -using command_buffer::GAPIInterface; namespace { // Converts values meant to represent a Cull Mode to the corresponding // command-buffer value. // Default: CULL_NONE. -GAPIInterface::FaceCullMode CullModeToCB(int cull) { +command_buffer::FaceCullMode CullModeToCB(int cull) { switch (cull) { default: case State::CULL_NONE: - return GAPIInterface::CULL_NONE; + return command_buffer::kCullNone; case State::CULL_CW: - return GAPIInterface::CULL_CW; + return command_buffer::kCullCW; case State::CULL_CCW: - return GAPIInterface::CULL_CCW; + return command_buffer::kCullCCW; } } // Converts values meant to represent a Polygon Fill Mode to the corresponding // command-buffer value. -// Default: POLYGON_MODE_FILL. -GAPIInterface::PolygonMode FillModeToCB(int fill) { +// Default: kPolygonModeFill. +command_buffer::PolygonMode FillModeToCB(int fill) { switch (fill) { case State::POINT: - return GAPIInterface::POLYGON_MODE_POINTS; + return command_buffer::kPolygonModePoints; case State::WIREFRAME: - return GAPIInterface::POLYGON_MODE_LINES; + return command_buffer::kPolygonModeLines; default: case State::SOLID: - return GAPIInterface::POLYGON_MODE_FILL; + return command_buffer::kPolygonModeFill; } } // Converts values meant to represent a Comparison Function to the corresponding // command-buffer value. -// Default: ALWAYS. -GAPIInterface::Comparison ComparisonToCB(int comparison) { +// Default: kAlways. +command_buffer::Comparison ComparisonToCB(int comparison) { switch (comparison) { case State::CMP_NEVER: - return GAPIInterface::NEVER; + return command_buffer::kNever; case State::CMP_LESS: - return GAPIInterface::LESS; + return command_buffer::kLess; case State::CMP_EQUAL: - return GAPIInterface::EQUAL; + return command_buffer::kEqual; case State::CMP_LEQUAL: - return GAPIInterface::LEQUAL; + return command_buffer::kLEqual; case State::CMP_GREATER: - return GAPIInterface::GREATER; + return command_buffer::kGreater; case State::CMP_NOTEQUAL: - return GAPIInterface::NOT_EQUAL; + return command_buffer::kNotEqual; case State::CMP_GEQUAL: - return GAPIInterface::GEQUAL; + return command_buffer::kGEqual; case State::CMP_ALWAYS: default: - return GAPIInterface::ALWAYS; + return command_buffer::kAlways; } } // Converts values meant to represent a Stencil Operation to the corresponding // command-buffer value. -// Default: KEEP. -GAPIInterface::StencilOp StencilOpToCB(int op) { +// Default: kKeep. +command_buffer::StencilOp StencilOpToCB(int op) { switch (op) { default: case State::STENCIL_KEEP: - return GAPIInterface::KEEP; + return command_buffer::kKeep; case State::STENCIL_ZERO: - return GAPIInterface::ZERO; + return command_buffer::kZero; case State::STENCIL_REPLACE: - return GAPIInterface::REPLACE; + return command_buffer::kReplace; case State::STENCIL_INCREMENT_SATURATE: - return GAPIInterface::INC_NO_WRAP; + return command_buffer::kIncNoWrap; case State::STENCIL_DECREMENT_SATURATE: - return GAPIInterface::DEC_NO_WRAP; + return command_buffer::kDecNoWrap; case State::STENCIL_INVERT: - return GAPIInterface::INVERT; + return command_buffer::kInvert; case State::STENCIL_INCREMENT: - return GAPIInterface::INC_WRAP; + return command_buffer::kIncWrap; case State::STENCIL_DECREMENT: - return GAPIInterface::DEC_WRAP; + return command_buffer::kDecWrap; } } // Converts values meant to represent a Blending Function to the corresponding // command-buffer value. -// Default: BLEND_FUNC_ONE. -GAPIInterface::BlendFunc BlendFuncToCB(int func) { +// Default: kBlendFuncOne. +command_buffer::BlendFunc BlendFuncToCB(int func) { switch (func) { case State::BLENDFUNC_ZERO: - return GAPIInterface::BLEND_FUNC_ZERO; + return command_buffer::kBlendFuncZero; default: case State::BLENDFUNC_ONE: - return GAPIInterface::BLEND_FUNC_ONE; + return command_buffer::kBlendFuncOne; case State::BLENDFUNC_SOURCE_COLOR: - return GAPIInterface::BLEND_FUNC_SRC_COLOR; + return command_buffer::kBlendFuncSrcColor; case State::BLENDFUNC_INVERSE_SOURCE_COLOR: - return GAPIInterface::BLEND_FUNC_INV_SRC_COLOR; + return command_buffer::kBlendFuncInvSrcColor; case State::BLENDFUNC_SOURCE_ALPHA: - return GAPIInterface::BLEND_FUNC_SRC_ALPHA; + return command_buffer::kBlendFuncSrcAlpha; case State::BLENDFUNC_INVERSE_SOURCE_ALPHA: - return GAPIInterface::BLEND_FUNC_INV_SRC_ALPHA; + return command_buffer::kBlendFuncInvSrcAlpha; case State::BLENDFUNC_DESTINATION_ALPHA: - return GAPIInterface::BLEND_FUNC_DST_ALPHA; + return command_buffer::kBlendFuncDstAlpha; case State::BLENDFUNC_INVERSE_DESTINATION_ALPHA: - return GAPIInterface::BLEND_FUNC_INV_DST_ALPHA; + return command_buffer::kBlendFuncInvDstAlpha; case State::BLENDFUNC_DESTINATION_COLOR: - return GAPIInterface::BLEND_FUNC_DST_COLOR; + return command_buffer::kBlendFuncDstColor; case State::BLENDFUNC_INVERSE_DESTINATION_COLOR: - return GAPIInterface::BLEND_FUNC_INV_DST_COLOR; + return command_buffer::kBlendFuncInvDstColor; case State::BLENDFUNC_SOURCE_ALPHA_SATUTRATE: - return GAPIInterface::BLEND_FUNC_SRC_ALPHA_SATUTRATE; + return command_buffer::kBlendFuncSrcAlphaSaturate; } } // Converts values meant to represent a Blending Equation to the corresponding // command-buffer value. -// Default: BLEND_EQ_ADD. -GAPIInterface::BlendEq BlendEqToCB(int eq) { +// Default: kBlendEqAdd. +command_buffer::BlendEq BlendEqToCB(int eq) { switch (eq) { default: case State::BLEND_ADD: - return GAPIInterface::BLEND_EQ_ADD; + return command_buffer::kBlendEqAdd; case State::BLEND_SUBTRACT: - return GAPIInterface::BLEND_EQ_SUB; + return command_buffer::kBlendEqSub; case State::BLEND_REVERSE_SUBTRACT: - return GAPIInterface::BLEND_EQ_REV_SUB; + return command_buffer::kBlendEqRevSub; case State::BLEND_MIN: - return GAPIInterface::BLEND_EQ_MIN; + return command_buffer::kBlendEqMin; case State::BLEND_MAX: - return GAPIInterface::BLEND_EQ_MAX; + return command_buffer::kBlendEqMax; } } @@ -265,8 +264,9 @@ class ColorWriteStateHandler : public TypedStateHandler<ParamInteger> { virtual void SetStateFromTypedParam(RendererCB* renderer, ParamInteger* param) const { + using command_buffer::cmd::SetColorWrite; int mask = param->value(); - o3d::command_buffer::set_color_write::AllColorsMask::Set(value_, mask); + SetColorWrite::AllColorsMask::Set(value_, mask); renderer->SetWriteMask(mask); *dirty_ = true; } @@ -314,8 +314,8 @@ class CullModeStateHandler : public TypedStateHandler<ParamInteger> { virtual void SetStateFromTypedParam(RendererCB* renderer, ParamInteger* param) const { - using command_buffer::set_polygon_raster::CullMode; - CullMode::Set(value_, CullModeToCB(param->value())); + using command_buffer::cmd::SetPolygonRaster; + SetPolygonRaster::CullMode::Set(value_, CullModeToCB(param->value())); *dirty_ = true; } private: @@ -336,8 +336,8 @@ class FillModeStateHandler : public TypedStateHandler<ParamInteger> { virtual void SetStateFromTypedParam(RendererCB* renderer, ParamInteger* param) const { - using command_buffer::set_polygon_raster::FillMode; - FillMode::Set(value_, FillModeToCB(param->value())); + using command_buffer::cmd::SetPolygonRaster; + SetPolygonRaster::FillMode::Set(value_, FillModeToCB(param->value())); *dirty_ = true; } private: @@ -447,17 +447,17 @@ class BlendEqStateHandler : public TypedStateHandler<ParamInteger> { void RendererCB::StateManager::AddStateHandlers(RendererCB *renderer) { // Point/Line raster { - using command_buffer::set_point_line_raster::LineSmoothEnable; - using command_buffer::set_point_line_raster::PointSpriteEnable; bool *dirty = point_line_helper_.dirty_ptr(); - command_buffer::cmd::SetPointLineRaster& cmd = - point_line_helper_.command(); + using command_buffer::cmd::SetPointLineRaster; + SetPointLineRaster& cmd = point_line_helper_.command(); renderer->AddStateHandler( State::kLineSmoothEnableParamName, - new EnableStateHandler<LineSmoothEnable>(&cmd.fixme0, dirty)); + new EnableStateHandler< + SetPointLineRaster::LineSmoothEnable>(&cmd.enables, dirty)); renderer->AddStateHandler( State::kPointSpriteEnableParamName, - new EnableStateHandler<PointSpriteEnable>(&cmd.fixme0, dirty)); + new EnableStateHandler< + SetPointLineRaster::PointSpriteEnable>(&cmd.enables, dirty)); renderer->AddStateHandler(State::kPointSizeParamName, new ValueStateHandler<ParamFloat>( &cmd.point_size, dirty)); @@ -466,12 +466,12 @@ void RendererCB::StateManager::AddStateHandlers(RendererCB *renderer) { // Polygon Raster { bool *dirty = poly_raster_helper_.dirty_ptr(); - command_buffer::cmd::SetPolygonRaster& cmd = - poly_raster_helper_.command(); + using command_buffer::cmd::SetPolygonRaster; + SetPolygonRaster& cmd = poly_raster_helper_.command(); renderer->AddStateHandler(State::kCullModeParamName, - new CullModeStateHandler(&cmd.fixme0, dirty)); + new CullModeStateHandler(&cmd.fill_cull, dirty)); renderer->AddStateHandler(State::kFillModeParamName, - new FillModeStateHandler(&cmd.fixme0, dirty)); + new FillModeStateHandler(&cmd.fill_cull, dirty)); } // Polygon Offset @@ -489,16 +489,15 @@ void RendererCB::StateManager::AddStateHandlers(RendererCB *renderer) { // 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(); + using command_buffer::cmd::SetAlphaTest; + SetAlphaTest& cmd = alpha_test_helper_.command(); bool *dirty = alpha_test_helper_.dirty_ptr(); renderer->AddStateHandler( State::kAlphaTestEnableParamName, - new EnableStateHandler<Enable>(&cmd.fixme0, dirty)); + new EnableStateHandler<SetAlphaTest::Enable>(&cmd.func_enable, dirty)); renderer->AddStateHandler( State::kAlphaComparisonFunctionParamName, - new ComparisonStateHandler<Func>(&cmd.fixme0, dirty)); + new ComparisonStateHandler<SetAlphaTest::Func>(&cmd.func_enable, dirty)); renderer->AddStateHandler( State::kAlphaReferenceParamName, new ValueStateHandler<ParamFloat>(&cmd.value, dirty)); @@ -506,131 +505,127 @@ void RendererCB::StateManager::AddStateHandlers(RendererCB *renderer) { // Depth Test { - using command_buffer::set_depth_test::Enable; - using command_buffer::set_depth_test::WriteEnable; - using command_buffer::set_depth_test::Func; bool *dirty = depth_test_helper_.dirty_ptr(); - command_buffer::cmd::SetDepthTest& cmd = depth_test_helper_.command(); + using command_buffer::cmd::SetDepthTest; + SetDepthTest& cmd = depth_test_helper_.command(); renderer->AddStateHandler( State::kZWriteEnableParamName, - new EnableStateHandler<WriteEnable>(&cmd.fixme0, dirty)); + new EnableStateHandler<SetDepthTest::WriteEnable>(&cmd.func_enable, dirty)); renderer->AddStateHandler( State::kZEnableParamName, - new EnableStateHandler<Enable>(&cmd.fixme0, dirty)); + new EnableStateHandler<SetDepthTest::Enable>(&cmd.func_enable, dirty)); renderer->AddStateHandler( State::kZComparisonFunctionParamName, - new ComparisonStateHandler<Func>(&cmd.fixme0, dirty)); + new ComparisonStateHandler<SetDepthTest::Func>(&cmd.func_enable, dirty)); } // Stencil Test { - using command_buffer::set_stencil_test::Enable; - using command_buffer::set_stencil_test::SeparateCCW; - using command_buffer::set_stencil_test::WriteMask; - using command_buffer::set_stencil_test::CompareMask; - using command_buffer::set_stencil_test::ReferenceValue; - using command_buffer::set_stencil_test::CWFunc; - using command_buffer::set_stencil_test::CWPassOp; - using command_buffer::set_stencil_test::CWFailOp; - using command_buffer::set_stencil_test::CWZFailOp; - using command_buffer::set_stencil_test::CCWFunc; - using command_buffer::set_stencil_test::CCWPassOp; - using command_buffer::set_stencil_test::CCWFailOp; - using command_buffer::set_stencil_test::CCWZFailOp; bool *dirty = stencil_test_helper_.dirty_ptr(); - command_buffer::cmd::SetStencilTest& cmd = stencil_test_helper_.command(); + using command_buffer::cmd::SetStencilTest; + SetStencilTest& cmd = stencil_test_helper_.command(); renderer->AddStateHandler( State::kStencilEnableParamName, - new EnableStateHandler<Enable>(&cmd.fixme0, dirty)); + new EnableStateHandler<SetStencilTest::Enable>(&cmd.stencil_args0, dirty)); renderer->AddStateHandler( State::kTwoSidedStencilEnableParamName, - new EnableStateHandler<SeparateCCW>(&cmd.fixme0, dirty)); + new EnableStateHandler< + SetStencilTest::SeparateCCW>(&cmd.stencil_args0, dirty)); renderer->AddStateHandler( State::kStencilReferenceParamName, - new BitFieldStateHandler<ReferenceValue>(&cmd.fixme0, dirty)); + new BitFieldStateHandler< + SetStencilTest::ReferenceValue>(&cmd.stencil_args0, dirty)); renderer->AddStateHandler( State::kStencilMaskParamName, - new BitFieldStateHandler<CompareMask>(&cmd.fixme0, dirty)); + new BitFieldStateHandler< + SetStencilTest::CompareMask>(&cmd.stencil_args0, dirty)); renderer->AddStateHandler( State::kStencilWriteMaskParamName, - new BitFieldStateHandler<WriteMask>(&cmd.fixme0, dirty)); + new BitFieldStateHandler< + SetStencilTest::WriteMask>(&cmd.stencil_args0, dirty)); renderer->AddStateHandler( State::kStencilComparisonFunctionParamName, - new ComparisonStateHandler<CWFunc>(&cmd.fixme1, dirty)); + new ComparisonStateHandler< + SetStencilTest::CWFunc>(&cmd.stencil_args1, dirty)); renderer->AddStateHandler( State::kStencilPassOperationParamName, - new StencilOpStateHandler<CWPassOp>(&cmd.fixme1, dirty)); + new StencilOpStateHandler< + SetStencilTest::CWPassOp>(&cmd.stencil_args1, dirty)); renderer->AddStateHandler( State::kStencilFailOperationParamName, - new StencilOpStateHandler<CWFailOp>(&cmd.fixme1, dirty)); + new StencilOpStateHandler< + SetStencilTest::CWFailOp>(&cmd.stencil_args1, dirty)); renderer->AddStateHandler( State::kStencilZFailOperationParamName, - new StencilOpStateHandler<CWZFailOp>(&cmd.fixme1, dirty)); + new StencilOpStateHandler< + SetStencilTest::CWZFailOp>(&cmd.stencil_args1, dirty)); renderer->AddStateHandler( State::kCCWStencilComparisonFunctionParamName, - new ComparisonStateHandler<CCWFunc>(&cmd.fixme1, dirty)); + new ComparisonStateHandler< + SetStencilTest::CCWFunc>(&cmd.stencil_args1, dirty)); renderer->AddStateHandler( State::kCCWStencilPassOperationParamName, - new StencilOpStateHandler<CCWPassOp>(&cmd.fixme1, dirty)); + new StencilOpStateHandler< + SetStencilTest::CCWPassOp>(&cmd.stencil_args1, dirty)); renderer->AddStateHandler( State::kCCWStencilFailOperationParamName, - new StencilOpStateHandler<CCWFailOp>(&cmd.fixme1, dirty)); + new StencilOpStateHandler< + SetStencilTest::CCWFailOp>(&cmd.stencil_args1, dirty)); renderer->AddStateHandler( State::kCCWStencilZFailOperationParamName, - new StencilOpStateHandler<CCWZFailOp>(&cmd.fixme1, dirty)); + new StencilOpStateHandler< + SetStencilTest::CCWZFailOp>(&cmd.stencil_args1, dirty)); } // Blending { - using command_buffer::set_blending::Enable; - using command_buffer::set_blending::SeparateAlpha; - using command_buffer::set_blending::ColorEq; - using command_buffer::set_blending::ColorSrcFunc; - using command_buffer::set_blending::ColorDstFunc; - using command_buffer::set_blending::AlphaEq; - using command_buffer::set_blending::AlphaSrcFunc; - using command_buffer::set_blending::AlphaDstFunc; bool *dirty = blending_helper_.dirty_ptr(); - command_buffer::cmd::SetBlending& cmd = blending_helper_.command(); + using command_buffer::cmd::SetBlending; + SetBlending& cmd = blending_helper_.command(); renderer->AddStateHandler( State::kAlphaBlendEnableParamName, - new EnableStateHandler<Enable>(&cmd.fixme0, dirty)); + new EnableStateHandler<SetBlending::Enable>(&cmd.blend_settings, dirty)); renderer->AddStateHandler( State::kSeparateAlphaBlendEnableParamName, - new EnableStateHandler<SeparateAlpha>(&cmd.fixme0, dirty)); + new EnableStateHandler<SetBlending::SeparateAlpha>(&cmd.blend_settings, dirty)); renderer->AddStateHandler( State::kSourceBlendFunctionParamName, - new BlendFuncStateHandler<ColorSrcFunc>(&cmd.fixme0, dirty)); + new BlendFuncStateHandler< + SetBlending::ColorSrcFunc>(&cmd.blend_settings, dirty)); renderer->AddStateHandler( State::kDestinationBlendFunctionParamName, - new BlendFuncStateHandler<ColorDstFunc>(&cmd.fixme0, dirty)); + new BlendFuncStateHandler< + SetBlending::ColorDstFunc>(&cmd.blend_settings, dirty)); renderer->AddStateHandler( State::kBlendEquationParamName, - new BlendEqStateHandler<ColorEq>(&cmd.fixme0, dirty)); + new BlendEqStateHandler< + SetBlending::ColorEq>(&cmd.blend_settings, dirty)); renderer->AddStateHandler( State::kSourceBlendAlphaFunctionParamName, - new BlendFuncStateHandler<AlphaSrcFunc>(&cmd.fixme0, dirty)); + new BlendFuncStateHandler< + SetBlending::AlphaSrcFunc>(&cmd.blend_settings, dirty)); renderer->AddStateHandler( State::kDestinationBlendAlphaFunctionParamName, - new BlendFuncStateHandler<AlphaDstFunc>(&cmd.fixme0, dirty)); + new BlendFuncStateHandler< + SetBlending::AlphaDstFunc>(&cmd.blend_settings, dirty)); renderer->AddStateHandler( State::kBlendAlphaEquationParamName, - new BlendEqStateHandler<AlphaEq>(&cmd.fixme0, dirty)); + new BlendEqStateHandler< + SetBlending::AlphaEq>(&cmd.blend_settings, dirty)); } // Color Write { - using command_buffer::set_color_write::DitherEnable; - using command_buffer::set_color_write::AllColorsMask; bool *dirty = color_write_helper_.dirty_ptr(); - command_buffer::cmd::SetColorWrite& cmd = color_write_helper_.command(); + using command_buffer::cmd::SetColorWrite; + SetColorWrite& cmd = color_write_helper_.command(); renderer->AddStateHandler( State::kDitherEnableParamName, - new EnableStateHandler<DitherEnable>(&cmd.flags, dirty)); + new EnableStateHandler<SetColorWrite::DitherEnable>(&cmd.flags, dirty)); renderer->AddStateHandler( State::kColorWriteEnableParamName, new ColorWriteStateHandler(&cmd.flags, dirty)); diff --git a/o3d/core/cross/command_buffer/stream_bank_cb.cc b/o3d/core/cross/command_buffer/stream_bank_cb.cc index 1ddca52..ade0c4a 100644 --- a/o3d/core/cross/command_buffer/stream_bank_cb.cc +++ b/o3d/core/cross/command_buffer/stream_bank_cb.cc @@ -46,7 +46,7 @@ namespace o3d { -using command_buffer::ResourceID; +using command_buffer::ResourceId; using command_buffer::CommandBufferHelper; using command_buffer::CommandBufferEntry; using command_buffer::GAPIInterface; @@ -77,31 +77,31 @@ static bool GetCBSemantic( switch (semantic) { case Stream::POSITION: if (semantic_index != 0) return false; - *out_semantic = vertex_struct::POSITION; + *out_semantic = vertex_struct::kPosition; *out_semantic_index = 0; return true; case Stream::NORMAL: if (semantic_index != 0) return false; - *out_semantic = vertex_struct::NORMAL; + *out_semantic = vertex_struct::kNormal; *out_semantic_index = 0; return true; case Stream::TANGENT: if (semantic_index != 0) return false; - *out_semantic = vertex_struct::TEX_COORD; + *out_semantic = vertex_struct::kTexCoord; *out_semantic_index = 6; return true; case Stream::BINORMAL: if (semantic_index != 0) return false; - *out_semantic = vertex_struct::TEX_COORD; + *out_semantic = vertex_struct::kTexCoord; *out_semantic_index = 7; return true; case Stream::COLOR: if (semantic_index > 1) return false; - *out_semantic = vertex_struct::COLOR; + *out_semantic = vertex_struct::kColor; *out_semantic_index = semantic_index; return true; case Stream::TEXCOORD: - *out_semantic = vertex_struct::TEX_COORD; + *out_semantic = vertex_struct::kTexCoord; *out_semantic_index = semantic_index; return true; default: @@ -114,22 +114,22 @@ static vertex_struct::Type GetCBType(const Field& field) { if (field.IsA(FloatField::GetApparentClass())) { switch (field.num_components()) { case 1: - return vertex_struct::FLOAT1; + return vertex_struct::kFloat1; case 2: - return vertex_struct::FLOAT2; + return vertex_struct::kFloat3; case 3: - return vertex_struct::FLOAT3; + return vertex_struct::kFloat3; case 4: - return vertex_struct::FLOAT4; + return vertex_struct::kFloat4; } } else if (field.IsA(UByteNField::GetApparentClass())) { switch (field.num_components()) { case 4: - return vertex_struct::UCHAR4N; + return vertex_struct::kUChar4N; } } DLOG(ERROR) << "Unknown Stream DataType"; - return vertex_struct::NUM_TYPES; + return vertex_struct::kNumTypes; } // This function is overridden so that we can invalidate the vertex struct any @@ -159,7 +159,7 @@ void StreamBankCB::CreateVertexStruct() { continue; } vertex_struct::Type cb_type = GetCBType(stream.field()); - if (cb_type == vertex_struct::NUM_TYPES) { + if (cb_type == vertex_struct::kNumTypes) { DLOG(INFO) << "Invalid type (" << stream.field().num_components() << ") - ignoring stream."; continue; diff --git a/o3d/core/cross/command_buffer/stream_bank_cb.h b/o3d/core/cross/command_buffer/stream_bank_cb.h index 81b258f..015ff2d 100644 --- a/o3d/core/cross/command_buffer/stream_bank_cb.h +++ b/o3d/core/cross/command_buffer/stream_bank_cb.h @@ -70,7 +70,7 @@ class StreamBankCB : public StreamBank { // The resource ID for the vertex struct representing the input vertex // streams, or kInvalidResource if it hasn't been created yet. - command_buffer::ResourceID vertex_struct_id_; + command_buffer::ResourceId 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 d00a094..91791df 100644 --- a/o3d/core/cross/command_buffer/texture_cb.cc +++ b/o3d/core/cross/command_buffer/texture_cb.cc @@ -48,12 +48,8 @@ namespace o3d { using command_buffer::CommandBufferEntry; using command_buffer::CommandBufferHelper; using command_buffer::FencedAllocatorWrapper; -using command_buffer::ResourceID; +using command_buffer::ResourceId; namespace texture = command_buffer::texture; -namespace set_texture_data_cmd = command_buffer::set_texture_data_cmd; -namespace get_texture_data_cmd = command_buffer::get_texture_data_cmd; -namespace create_texture_2d_cmd = command_buffer::create_texture_2d_cmd; -namespace create_texture_cube_cmd = command_buffer::create_texture_cube_cmd; namespace { @@ -64,13 +60,13 @@ const Texture::RGBASwizzleIndices g_cb_abgr32f_swizzle_indices = texture::Format CBFormatFromO3DFormat(Texture::Format format) { switch (format) { case Texture::XRGB8: - return texture::XRGB8; + return texture::kXRGB8; case Texture::ARGB8: - return texture::ARGB8; + return texture::kARGB8; case Texture::ABGR16F: - return texture::ABGR16F; + return texture::kABGR16F; case Texture::DXT1: - return texture::DXT1; + return texture::kDXT1; // TODO: DXT3/5. It's not yet supported by the command buffer // renderer, though it would be a simple addition. default: @@ -78,22 +74,22 @@ texture::Format CBFormatFromO3DFormat(Texture::Format format) { } // failed to find a matching format LOG(ERROR) << "Unrecognized Texture format type."; - return texture::NUM_FORMATS; + return texture::kNumFormats; } // Checks that enums match in value, so that they can be directly used in -// set_texture_data_cmd::Face bitfields. -COMPILE_ASSERT(TextureCUBE::FACE_POSITIVE_X == texture::FACE_POSITIVE_X, +// SetTextureData::Face bitfields. +COMPILE_ASSERT(TextureCUBE::FACE_POSITIVE_X == texture::kFacePositiveX, FACE_POSITIVE_X_enums_don_t_match); -COMPILE_ASSERT(TextureCUBE::FACE_NEGATIVE_X == texture::FACE_NEGATIVE_X, +COMPILE_ASSERT(TextureCUBE::FACE_NEGATIVE_X == texture::kFaceNegativeX, FACE_NEGATIVE_X_enums_don_t_match); -COMPILE_ASSERT(TextureCUBE::FACE_POSITIVE_Y == texture::FACE_POSITIVE_Y, +COMPILE_ASSERT(TextureCUBE::FACE_POSITIVE_Y == texture::kFacePositiveY, FACE_POSITIVE_Y_enums_don_t_match); -COMPILE_ASSERT(TextureCUBE::FACE_NEGATIVE_Y == texture::FACE_NEGATIVE_Y, +COMPILE_ASSERT(TextureCUBE::FACE_NEGATIVE_Y == texture::kFaceNegativeY, FACE_NEGATIVE_Y_enums_don_t_match); -COMPILE_ASSERT(TextureCUBE::FACE_POSITIVE_Z == texture::FACE_POSITIVE_Z, +COMPILE_ASSERT(TextureCUBE::FACE_POSITIVE_Z == texture::kFacePositiveZ, FACE_POSITIVE_Z_enums_don_t_match); -COMPILE_ASSERT(TextureCUBE::FACE_NEGATIVE_Z == texture::FACE_NEGATIVE_Z, +COMPILE_ASSERT(TextureCUBE::FACE_NEGATIVE_Z == texture::kFaceNegativeZ, FACE_NEGATIVE_Z_enums_don_t_match); // Writes the data information into a buffer to be sent to the server side. @@ -122,7 +118,7 @@ void SetTextureDataBuffer(Texture::Format format, // Sends the SetTextureData command after formatting the args properly. void SetTextureData(RendererCB *renderer, - ResourceID texture_id, + ResourceId texture_id, unsigned int x, unsigned int y, unsigned int mip_width, @@ -140,7 +136,7 @@ void SetTextureData(RendererCB *renderer, texture_id, x, y, z, mip_width, mip_height, depth, - level, face, + level, static_cast<texture::Face>(face), pitch, 0, // slice_pitch mip_size, @@ -151,7 +147,7 @@ void SetTextureData(RendererCB *renderer, // Updates a command buffer texture resource from a bitmap, rescaling if // necessary. void UpdateResourceFromBitmap(RendererCB *renderer, - ResourceID texture_id, + ResourceId texture_id, unsigned int level, TextureCUBE::CubeFace face, const Bitmap &bitmap) { @@ -186,7 +182,7 @@ void UpdateResourceFromBitmap(RendererCB *renderer, // Copies back texture resource data into a bitmap. void CopyBackResourceToBitmap(RendererCB *renderer, - ResourceID texture_id, + ResourceId texture_id, unsigned int level, TextureCUBE::CubeFace face, const Bitmap &bitmap) { @@ -211,7 +207,7 @@ void CopyBackResourceToBitmap(RendererCB *renderer, mip_height, 1, level, - face, + static_cast<texture::Face>(face), pitch, 0, mip_size, @@ -233,7 +229,7 @@ static const unsigned int kMaxTextureSize = 2048; // NOTE: the Texture2DCB now owns the texture resource and will destroy it on // exit. Texture2DCB::Texture2DCB(ServiceLocator* service_locator, - ResourceID resource_id, + ResourceId resource_id, Texture::Format format, int levels, int width, @@ -271,7 +267,7 @@ Texture2DCB* Texture2DCB::Create(ServiceLocator* service_locator, RendererCB *renderer = static_cast<RendererCB *>( service_locator->GetService<Renderer>()); texture::Format cb_format = CBFormatFromO3DFormat(format); - if (cb_format == texture::NUM_FORMATS) { + if (cb_format == texture::kNumFormats) { O3D_ERROR(service_locator) << "Unsupported format in Texture2DCB::Create."; return NULL; @@ -282,7 +278,7 @@ Texture2DCB* Texture2DCB::Create(ServiceLocator* service_locator, return NULL; } - ResourceID texture_id = renderer->texture_ids().AllocateID(); + ResourceId texture_id = renderer->texture_ids().AllocateID(); renderer->helper()->CreateTexture2d( texture_id, width, height, @@ -450,7 +446,7 @@ const Texture::RGBASwizzleIndices& Texture2DCB::GetABGR32FSwizzleIndices() { // Creates a texture from a pre-existing texture resource. TextureCUBECB::TextureCUBECB(ServiceLocator* service_locator, - ResourceID resource_id, + ResourceId resource_id, Texture::Format format, int levels, int edge_length, @@ -486,7 +482,7 @@ TextureCUBECB* TextureCUBECB::Create(ServiceLocator* service_locator, RendererCB *renderer = static_cast<RendererCB *>( service_locator->GetService<Renderer>()); texture::Format cb_format = CBFormatFromO3DFormat(format); - if (cb_format == texture::NUM_FORMATS) { + if (cb_format == texture::kNumFormats) { O3D_ERROR(service_locator) << "Unsupported format in Texture2DCB::Create."; return NULL; @@ -497,7 +493,7 @@ TextureCUBECB* TextureCUBECB::Create(ServiceLocator* service_locator, return NULL; } - ResourceID texture_id = renderer->texture_ids().AllocateID(); + ResourceId texture_id = renderer->texture_ids().AllocateID(); renderer->helper()->CreateTextureCube( texture_id, edge_length, diff --git a/o3d/core/cross/command_buffer/texture_cb.h b/o3d/core/cross/command_buffer/texture_cb.h index 31bbb69..3c710fa 100644 --- a/o3d/core/cross/command_buffer/texture_cb.h +++ b/o3d/core/cross/command_buffer/texture_cb.h @@ -81,7 +81,7 @@ class Texture2DCB : public Texture2D { } // Gets the texture resource ID. - command_buffer::ResourceID resource_id() const { return 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. @@ -103,7 +103,7 @@ class Texture2DCB : public Texture2D { // and raw Bitmap data. // The texture takes ownership of the bitmap data. Texture2DCB(ServiceLocator* service_locator, - command_buffer::ResourceID resource_id, + command_buffer::ResourceId resource_id, Texture::Format format, int levels, int width, @@ -117,7 +117,7 @@ class Texture2DCB : public Texture2D { } RendererCB* renderer_; - command_buffer::ResourceID resource_id_; + command_buffer::ResourceId resource_id_; // A bitmap used to back the NPOT textures on POT-only hardware, and to back // the pixel buffer for Lock(). @@ -162,7 +162,7 @@ class TextureCUBECB : public TextureCUBE { } // Gets the texture resource ID. - command_buffer::ResourceID resource_id() const { return 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. @@ -183,7 +183,7 @@ class TextureCUBECB : public TextureCUBE { private: // Creates a texture from a pre-existing texture resource. TextureCUBECB(ServiceLocator* service_locator, - command_buffer::ResourceID texture, + command_buffer::ResourceId texture, Texture::Format format, int levels, int edge_length, @@ -197,7 +197,7 @@ class TextureCUBECB : public TextureCUBE { } RendererCB* renderer_; - command_buffer::ResourceID resource_id_; + command_buffer::ResourceId resource_id_; // Bitmaps used to back the NPOT textures on POT-only hardware. Bitmap::Ref backing_bitmaps_[NUMBER_OF_FACES]; |