1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // no-include-guard-because-multiply-included
6 // Multiply-included message file, hence no include guard here.
7 
8 #include "gpu/command_buffer/common/capabilities.h"
9 #include "gpu/command_buffer/common/command_buffer.h"
10 #include "gpu/command_buffer/common/constants.h"
11 #include "gpu/command_buffer/common/context_creation_attribs.h"
12 #include "gpu/gpu_export.h"
13 #include "ipc/ipc_message_utils.h"
14 #include "ipc/param_traits_macros.h"
15 #include "ui/gfx/ipc/buffer_types/gfx_param_traits.h"
16 #include "ui/gfx/ipc/geometry/gfx_param_traits.h"
17 #include "ui/gl/gpu_preference.h"
18 
19 #undef IPC_MESSAGE_EXPORT
20 #define IPC_MESSAGE_EXPORT GPU_EXPORT
21 
22 IPC_ENUM_TRAITS_MAX_VALUE(gpu::error::Error, gpu::error::kErrorLast)
23 IPC_ENUM_TRAITS_MAX_VALUE(gpu::error::ContextLostReason,
24                           gpu::error::kContextLostReasonLast)
25 IPC_ENUM_TRAITS_MIN_MAX_VALUE(
26     gpu::CommandBufferNamespace,
27     gpu::CommandBufferNamespace::INVALID,
28     gpu::CommandBufferNamespace::NUM_COMMAND_BUFFER_NAMESPACES - 1)
29 IPC_ENUM_TRAITS_MAX_VALUE(gl::GpuPreference, gl::GpuPreference::kMaxValue)
30 IPC_ENUM_TRAITS_MAX_VALUE(gpu::ContextType, gpu::CONTEXT_TYPE_LAST)
31 IPC_ENUM_TRAITS_MAX_VALUE(gpu::ColorSpace, gpu::COLOR_SPACE_LAST)
32 IPC_ENUM_TRAITS_MAX_VALUE(gfx::SurfaceOrigin, gfx::SurfaceOrigin::kBottomLeft)
33 
34 IPC_STRUCT_TRAITS_BEGIN(gpu::Capabilities::ShaderPrecision)
35   IPC_STRUCT_TRAITS_MEMBER(min_range)
36   IPC_STRUCT_TRAITS_MEMBER(max_range)
37   IPC_STRUCT_TRAITS_MEMBER(precision)
38 IPC_STRUCT_TRAITS_END()
39 
40 IPC_STRUCT_TRAITS_BEGIN(gpu::Capabilities::PerStagePrecisions)
41   IPC_STRUCT_TRAITS_MEMBER(low_int)
42   IPC_STRUCT_TRAITS_MEMBER(medium_int)
43   IPC_STRUCT_TRAITS_MEMBER(high_int)
44   IPC_STRUCT_TRAITS_MEMBER(low_float)
45   IPC_STRUCT_TRAITS_MEMBER(medium_float)
46   IPC_STRUCT_TRAITS_MEMBER(high_float)
47 IPC_STRUCT_TRAITS_END()
48 
49 IPC_STRUCT_TRAITS_BEGIN(gpu::Capabilities)
50   IPC_STRUCT_TRAITS_MEMBER(vertex_shader_precisions)
51   IPC_STRUCT_TRAITS_MEMBER(fragment_shader_precisions)
52   IPC_STRUCT_TRAITS_MEMBER(max_combined_texture_image_units)
53   IPC_STRUCT_TRAITS_MEMBER(max_cube_map_texture_size)
54   IPC_STRUCT_TRAITS_MEMBER(max_fragment_uniform_vectors)
55   IPC_STRUCT_TRAITS_MEMBER(max_renderbuffer_size)
56   IPC_STRUCT_TRAITS_MEMBER(max_texture_image_units)
57   IPC_STRUCT_TRAITS_MEMBER(max_texture_size)
58   IPC_STRUCT_TRAITS_MEMBER(max_varying_vectors)
59   IPC_STRUCT_TRAITS_MEMBER(max_vertex_attribs)
60   IPC_STRUCT_TRAITS_MEMBER(max_vertex_texture_image_units)
61   IPC_STRUCT_TRAITS_MEMBER(max_vertex_uniform_vectors)
62   IPC_STRUCT_TRAITS_MEMBER(num_compressed_texture_formats)
63   IPC_STRUCT_TRAITS_MEMBER(num_shader_binary_formats)
64   IPC_STRUCT_TRAITS_MEMBER(num_stencil_bits)
65   IPC_STRUCT_TRAITS_MEMBER(bind_generates_resource_chromium)
66 
67   IPC_STRUCT_TRAITS_MEMBER(max_3d_texture_size)
68   IPC_STRUCT_TRAITS_MEMBER(max_array_texture_layers)
69   IPC_STRUCT_TRAITS_MEMBER(max_color_attachments)
70   IPC_STRUCT_TRAITS_MEMBER(max_combined_fragment_uniform_components)
71   IPC_STRUCT_TRAITS_MEMBER(max_combined_uniform_blocks)
72   IPC_STRUCT_TRAITS_MEMBER(max_combined_vertex_uniform_components)
73   IPC_STRUCT_TRAITS_MEMBER(max_copy_texture_chromium_size)
74   IPC_STRUCT_TRAITS_MEMBER(max_draw_buffers)
75   IPC_STRUCT_TRAITS_MEMBER(max_element_index)
76   IPC_STRUCT_TRAITS_MEMBER(max_elements_indices)
77   IPC_STRUCT_TRAITS_MEMBER(max_elements_vertices)
78   IPC_STRUCT_TRAITS_MEMBER(max_fragment_input_components)
79   IPC_STRUCT_TRAITS_MEMBER(max_fragment_uniform_blocks)
80   IPC_STRUCT_TRAITS_MEMBER(max_fragment_uniform_components)
81   IPC_STRUCT_TRAITS_MEMBER(max_program_texel_offset)
82   IPC_STRUCT_TRAITS_MEMBER(max_samples)
83   IPC_STRUCT_TRAITS_MEMBER(max_server_wait_timeout)
84   IPC_STRUCT_TRAITS_MEMBER(max_texture_lod_bias)
85   IPC_STRUCT_TRAITS_MEMBER(max_transform_feedback_interleaved_components)
86   IPC_STRUCT_TRAITS_MEMBER(max_transform_feedback_separate_attribs)
87   IPC_STRUCT_TRAITS_MEMBER(max_transform_feedback_separate_components)
88   IPC_STRUCT_TRAITS_MEMBER(max_uniform_block_size)
89   IPC_STRUCT_TRAITS_MEMBER(max_uniform_buffer_bindings)
90   IPC_STRUCT_TRAITS_MEMBER(max_atomic_counter_buffer_bindings)
91   IPC_STRUCT_TRAITS_MEMBER(max_shader_storage_buffer_bindings)
92   IPC_STRUCT_TRAITS_MEMBER(shader_storage_buffer_offset_alignment)
93   IPC_STRUCT_TRAITS_MEMBER(max_varying_components)
94   IPC_STRUCT_TRAITS_MEMBER(max_vertex_output_components)
95   IPC_STRUCT_TRAITS_MEMBER(max_vertex_uniform_blocks)
96   IPC_STRUCT_TRAITS_MEMBER(max_vertex_uniform_components)
97   IPC_STRUCT_TRAITS_MEMBER(min_program_texel_offset)
98   IPC_STRUCT_TRAITS_MEMBER(num_extensions)
99   IPC_STRUCT_TRAITS_MEMBER(num_program_binary_formats)
100   IPC_STRUCT_TRAITS_MEMBER(uniform_buffer_offset_alignment)
101   IPC_STRUCT_TRAITS_MEMBER(num_surface_buffers)
102 
103   IPC_STRUCT_TRAITS_MEMBER(post_sub_buffer)
104   IPC_STRUCT_TRAITS_MEMBER(swap_buffers_with_bounds)
105   IPC_STRUCT_TRAITS_MEMBER(commit_overlay_planes)
106   IPC_STRUCT_TRAITS_MEMBER(egl_image_external)
107   IPC_STRUCT_TRAITS_MEMBER(texture_format_atc)
108   IPC_STRUCT_TRAITS_MEMBER(texture_format_bgra8888)
109   IPC_STRUCT_TRAITS_MEMBER(texture_format_dxt1)
110   IPC_STRUCT_TRAITS_MEMBER(texture_format_dxt5)
111   IPC_STRUCT_TRAITS_MEMBER(texture_format_etc1)
112   IPC_STRUCT_TRAITS_MEMBER(texture_format_etc1_npot)
113   IPC_STRUCT_TRAITS_MEMBER(texture_rectangle)
114   IPC_STRUCT_TRAITS_MEMBER(iosurface)
115   IPC_STRUCT_TRAITS_MEMBER(texture_usage)
116   IPC_STRUCT_TRAITS_MEMBER(texture_storage)
117   IPC_STRUCT_TRAITS_MEMBER(discard_framebuffer)
118   IPC_STRUCT_TRAITS_MEMBER(sync_query)
119   IPC_STRUCT_TRAITS_MEMBER(blend_equation_advanced)
120   IPC_STRUCT_TRAITS_MEMBER(blend_equation_advanced_coherent)
121   IPC_STRUCT_TRAITS_MEMBER(texture_rg)
122   IPC_STRUCT_TRAITS_MEMBER(texture_norm16)
123   IPC_STRUCT_TRAITS_MEMBER(texture_half_float_linear)
124   IPC_STRUCT_TRAITS_MEMBER(color_buffer_half_float_rgba)
125   IPC_STRUCT_TRAITS_MEMBER(image_ycbcr_422)
126   IPC_STRUCT_TRAITS_MEMBER(image_ycbcr_420v)
127   IPC_STRUCT_TRAITS_MEMBER(image_ycbcr_420v_disabled_for_video_frames)
128   IPC_STRUCT_TRAITS_MEMBER(image_ar30)
129   IPC_STRUCT_TRAITS_MEMBER(image_ab30)
130   IPC_STRUCT_TRAITS_MEMBER(image_ycbcr_p010)
131   IPC_STRUCT_TRAITS_MEMBER(render_buffer_format_bgra8888)
132   IPC_STRUCT_TRAITS_MEMBER(occlusion_query)
133   IPC_STRUCT_TRAITS_MEMBER(occlusion_query_boolean)
134   IPC_STRUCT_TRAITS_MEMBER(timer_queries)
135   IPC_STRUCT_TRAITS_MEMBER(surfaceless)
136   IPC_STRUCT_TRAITS_MEMBER(surface_origin)
137   IPC_STRUCT_TRAITS_MEMBER(msaa_is_slow)
138   IPC_STRUCT_TRAITS_MEMBER(disable_one_component_textures)
139   IPC_STRUCT_TRAITS_MEMBER(gpu_rasterization)
140   IPC_STRUCT_TRAITS_MEMBER(chromium_image_rgb_emulation)
141   IPC_STRUCT_TRAITS_MEMBER(dc_layers)
142   IPC_STRUCT_TRAITS_MEMBER(protected_video_swap_chain)
143   IPC_STRUCT_TRAITS_MEMBER(gpu_vsync)
144   IPC_STRUCT_TRAITS_MEMBER(shared_image_swap_chain)
145   IPC_STRUCT_TRAITS_MEMBER(avoid_stencil_buffers)
146   IPC_STRUCT_TRAITS_MEMBER(disable_2d_canvas_copy_on_write)
147   IPC_STRUCT_TRAITS_MEMBER(texture_npot)
148   IPC_STRUCT_TRAITS_MEMBER(texture_storage_image)
149   IPC_STRUCT_TRAITS_MEMBER(supports_oop_raster)
150   IPC_STRUCT_TRAITS_MEMBER(chromium_gpu_fence)
151   IPC_STRUCT_TRAITS_MEMBER(unpremultiply_and_dither_copy)
152   IPC_STRUCT_TRAITS_MEMBER(separate_stencil_ref_mask_writemask)
153   IPC_STRUCT_TRAITS_MEMBER(use_gpu_fences_for_overlay_planes)
154   IPC_STRUCT_TRAITS_MEMBER(context_supports_distance_field_text)
155   IPC_STRUCT_TRAITS_MEMBER(chromium_nonblocking_readback)
156   IPC_STRUCT_TRAITS_MEMBER(mesa_framebuffer_flip_y)
157 
158   IPC_STRUCT_TRAITS_MEMBER(major_version)
159   IPC_STRUCT_TRAITS_MEMBER(minor_version)
160 
161   IPC_STRUCT_TRAITS_MEMBER(gpu_memory_buffer_formats)
162   IPC_STRUCT_TRAITS_MEMBER(texture_target_exception_list)
163 IPC_STRUCT_TRAITS_END()
164 
165 IPC_STRUCT_TRAITS_BEGIN(gpu::CommandBuffer::State)
166   IPC_STRUCT_TRAITS_MEMBER(get_offset)
167   IPC_STRUCT_TRAITS_MEMBER(token)
168   IPC_STRUCT_TRAITS_MEMBER(release_count)
169   IPC_STRUCT_TRAITS_MEMBER(error)
170   IPC_STRUCT_TRAITS_MEMBER(context_lost_reason)
171   IPC_STRUCT_TRAITS_MEMBER(generation)
172   IPC_STRUCT_TRAITS_MEMBER(set_get_buffer_count)
173 IPC_STRUCT_TRAITS_END()
174 
175 IPC_STRUCT_TRAITS_BEGIN(gpu::ContextCreationAttribs)
176   IPC_STRUCT_TRAITS_MEMBER(offscreen_framebuffer_size)
177   IPC_STRUCT_TRAITS_MEMBER(gpu_preference)
178   IPC_STRUCT_TRAITS_MEMBER(alpha_size)
179   IPC_STRUCT_TRAITS_MEMBER(blue_size)
180   IPC_STRUCT_TRAITS_MEMBER(green_size)
181   IPC_STRUCT_TRAITS_MEMBER(red_size)
182   IPC_STRUCT_TRAITS_MEMBER(depth_size)
183   IPC_STRUCT_TRAITS_MEMBER(stencil_size)
184   IPC_STRUCT_TRAITS_MEMBER(samples)
185   IPC_STRUCT_TRAITS_MEMBER(sample_buffers)
186   IPC_STRUCT_TRAITS_MEMBER(buffer_preserved)
187   IPC_STRUCT_TRAITS_MEMBER(bind_generates_resource)
188   IPC_STRUCT_TRAITS_MEMBER(fail_if_major_perf_caveat)
189   IPC_STRUCT_TRAITS_MEMBER(lose_context_when_out_of_memory)
190   IPC_STRUCT_TRAITS_MEMBER(context_type)
191   IPC_STRUCT_TRAITS_MEMBER(should_use_native_gmb_for_backbuffer)
192   IPC_STRUCT_TRAITS_MEMBER(own_offscreen_surface)
193   IPC_STRUCT_TRAITS_MEMBER(single_buffer)
194   IPC_STRUCT_TRAITS_MEMBER(color_space)
195   IPC_STRUCT_TRAITS_MEMBER(enable_gles2_interface)
196   IPC_STRUCT_TRAITS_MEMBER(enable_grcontext)
197   IPC_STRUCT_TRAITS_MEMBER(enable_raster_interface)
198   IPC_STRUCT_TRAITS_MEMBER(enable_oop_rasterization)
199   IPC_STRUCT_TRAITS_MEMBER(enable_swap_timestamps_if_supported)
200 IPC_STRUCT_TRAITS_END()
201 
202 IPC_STRUCT_TRAITS_BEGIN(gpu::GpuMemoryBufferFormatSet)
203   IPC_STRUCT_TRAITS_MEMBER(bitfield)
204 IPC_STRUCT_TRAITS_END()
205