Mir

Merge lp:~vanvugt/mir/scanout into lp:~mir-team/mir/trunk

Proposed by Daniel van Vugt
Status: Merged
Approved by: Alexandros Frantzis
Approved revision: no longer in the source branch.
Merged at revision: 1063
Proposed branch: lp:~vanvugt/mir/scanout
Merge into: lp:~mir-team/mir/trunk
Diff against target: 287 lines (+111/-3)
13 files modified
include/platform/mir/graphics/buffer_ipc_packer.h (+1/-0)
include/shared/mir_toolkit/mir_native_buffer.h (+10/-1)
include/test/mir_test_doubles/mock_buffer_packer.h (+1/-0)
src/client/mir_surface.cpp (+1/-0)
src/server/frontend/protobuf_buffer_packer.cpp (+6/-0)
src/server/frontend/protobuf_buffer_packer.h (+1/-0)
src/server/graphics/gbm/gbm_buffer.cpp (+1/-0)
src/server/graphics/gbm/gbm_platform.cpp (+1/-0)
src/shared/protobuf/mir_protobuf.proto (+2/-1)
tests/acceptance-tests/test_client_library.cpp (+71/-0)
tests/mir_test_framework/testing_server_options.cpp (+12/-1)
tests/unit-tests/frontend/test_protobuf_buffer_packer.cpp (+2/-0)
tests/unit-tests/graphics/gbm/test_gbm_platform.cpp (+2/-0)
To merge this branch: bzr merge lp:~vanvugt/mir/scanout
Reviewer Review Type Date Requested Status
Robert Ancell Approve
Kevin DuBois (community) Approve
Alan Griffiths Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+184961@code.launchpad.net

Commit message

Add a "flags" field to MirBufferPackage so that clients can find out if the
buffer they've been given is scanout-capable. This is normally something a
client should never need to know. However there are two specialized cases
where it's required to fix bugs in the intel and radeon X drivers:
  LP: #1218735, LP: #1218815
The intel fix (already landed) contains a hack which will be updated after
this branch lands.

Description of the change

The weird looking reshuffle in mir_native_buffer.h is necessary to avoid breaking the ABI for Mesa. It seems only Mesa is inflexible enough that we can't extend MirBufferPackage without breaking it. So we avoid growing the size of MirBufferPackage for now.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Looks messy but I guess it is justified in the description

review: Approve
Revision history for this message
Kevin DuBois (kdub) wrote :

the abi-preserving changes for the gbm buffer look good. Android has a flag on its 'usage' field in its native type that can indicate scanout surfaces

It would be nice to get rid of the #ifndef ANDROID around the test case... but looks okay otherwise.

review: Approve
Revision history for this message
Robert Ancell (robert-ancell) wrote :

The ABI preserving is a little bit unclear, it would be nice to add a big comment saying "we are stealing the last element of data[] and fd[] to use for flags - we can revert this once we bump ABI.

Otherwise makes sense to me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/platform/mir/graphics/buffer_ipc_packer.h'
--- include/platform/mir/graphics/buffer_ipc_packer.h 2013-08-28 03:41:48 +0000
+++ include/platform/mir/graphics/buffer_ipc_packer.h 2013-09-11 08:52:46 +0000
@@ -33,6 +33,7 @@
33 virtual void pack_fd(int) = 0;33 virtual void pack_fd(int) = 0;
34 virtual void pack_data(int) = 0;34 virtual void pack_data(int) = 0;
35 virtual void pack_stride(geometry::Stride) = 0;35 virtual void pack_stride(geometry::Stride) = 0;
36 virtual void pack_flags(unsigned int) = 0;
3637
37protected:38protected:
38 BufferIPCPacker() {}39 BufferIPCPacker() {}
3940
=== modified file 'include/shared/mir_toolkit/mir_native_buffer.h'
--- include/shared/mir_toolkit/mir_native_buffer.h 2013-05-06 15:38:52 +0000
+++ include/shared/mir_toolkit/mir_native_buffer.h 2013-09-11 08:52:46 +0000
@@ -20,15 +20,24 @@
20#ifndef MIR_CLIENT_MIR_NATIVE_BUFFER_H_20#ifndef MIR_CLIENT_MIR_NATIVE_BUFFER_H_
21#define MIR_CLIENT_MIR_NATIVE_BUFFER_H_21#define MIR_CLIENT_MIR_NATIVE_BUFFER_H_
2222
23enum { mir_buffer_package_max = 32 };23enum { mir_buffer_package_max = 31 };
24
25typedef enum
26{
27 mir_buffer_flag_can_scanout = 1
28} MirBufferFlag;
29
24typedef struct MirBufferPackage30typedef struct MirBufferPackage
25{31{
26 int data_items;32 int data_items;
27 int fd_items;33 int fd_items;
2834
29 int data[mir_buffer_package_max];35 int data[mir_buffer_package_max];
36 int unused1; /* Retain ABI compatibility (avoid rebuilding Mesa) */
37
30 int fd[mir_buffer_package_max];38 int fd[mir_buffer_package_max];
3139
40 unsigned int flags; /* MirBufferFlag's */
32 int stride;41 int stride;
33 int age; /**< Number of frames submitted by the client since the client has rendered to this buffer. */42 int age; /**< Number of frames submitted by the client since the client has rendered to this buffer. */
34 /**< This has the same semantics as the EGL_EXT_buffer_age extension */43 /**< This has the same semantics as the EGL_EXT_buffer_age extension */
3544
=== modified file 'include/test/mir_test_doubles/mock_buffer_packer.h'
--- include/test/mir_test_doubles/mock_buffer_packer.h 2013-08-28 03:41:48 +0000
+++ include/test/mir_test_doubles/mock_buffer_packer.h 2013-09-11 08:52:46 +0000
@@ -36,6 +36,7 @@
36 MOCK_METHOD1(pack_fd, void(int));36 MOCK_METHOD1(pack_fd, void(int));
37 MOCK_METHOD1(pack_data, void(int));37 MOCK_METHOD1(pack_data, void(int));
38 MOCK_METHOD1(pack_stride, void(geometry::Stride));38 MOCK_METHOD1(pack_stride, void(geometry::Stride));
39 MOCK_METHOD1(pack_flags, void(unsigned int));
39};40};
4041
41}42}
4243
=== modified file 'src/client/mir_surface.cpp'
--- src/client/mir_surface.cpp 2013-08-28 03:41:48 +0000
+++ src/client/mir_surface.cpp 2013-09-11 08:52:46 +0000
@@ -268,6 +268,7 @@
268 }268 }
269269
270 buffer_package.stride = buffer.stride();270 buffer_package.stride = buffer.stride();
271 buffer_package.flags = buffer.flags();
271 }272 }
272 else273 else
273 {274 {
274275
=== modified file 'src/server/frontend/protobuf_buffer_packer.cpp'
--- src/server/frontend/protobuf_buffer_packer.cpp 2013-09-06 03:46:37 +0000
+++ src/server/frontend/protobuf_buffer_packer.cpp 2013-09-11 08:52:46 +0000
@@ -107,3 +107,9 @@
107{107{
108 buffer_response->set_stride(stride.as_uint32_t());108 buffer_response->set_stride(stride.as_uint32_t());
109}109}
110
111void mfd::ProtobufBufferPacker::pack_flags(unsigned int flags)
112{
113 buffer_response->set_flags(flags);
114}
115
110116
=== modified file 'src/server/frontend/protobuf_buffer_packer.h'
--- src/server/frontend/protobuf_buffer_packer.h 2013-08-28 03:41:48 +0000
+++ src/server/frontend/protobuf_buffer_packer.h 2013-09-11 08:52:46 +0000
@@ -43,6 +43,7 @@
43 void pack_fd(int);43 void pack_fd(int);
44 void pack_data(int);44 void pack_data(int);
45 void pack_stride(geometry::Stride);45 void pack_stride(geometry::Stride);
46 void pack_flags(unsigned int);
46private:47private:
47 protobuf::Buffer* buffer_response;48 protobuf::Buffer* buffer_response;
48};49};
4950
=== modified file 'src/server/graphics/gbm/gbm_buffer.cpp'
--- src/server/graphics/gbm/gbm_buffer.cpp 2013-08-28 03:41:48 +0000
+++ src/server/graphics/gbm/gbm_buffer.cpp 2013-09-11 08:52:46 +0000
@@ -130,6 +130,7 @@
130 temp->fd_items = 1;130 temp->fd_items = 1;
131 temp->fd[0] = prime_fd;131 temp->fd[0] = prime_fd;
132 temp->stride = stride().as_uint32_t();132 temp->stride = stride().as_uint32_t();
133 temp->flags = can_bypass() ? mir_buffer_flag_can_scanout : 0;
133 temp->bo = gbm_handle.get();134 temp->bo = gbm_handle.get();
134135
135 return temp;136 return temp;
136137
=== modified file 'src/server/graphics/gbm/gbm_platform.cpp'
--- src/server/graphics/gbm/gbm_platform.cpp 2013-08-30 07:47:16 +0000
+++ src/server/graphics/gbm/gbm_platform.cpp 2013-09-11 08:52:46 +0000
@@ -146,6 +146,7 @@
146 }146 }
147147
148 packer->pack_stride(buffer->stride()); 148 packer->pack_stride(buffer->stride());
149 packer->pack_flags(native_handle->flags);
149}150}
150151
151void mgg::GBMPlatform::drm_auth_magic(drm_magic_t magic)152void mgg::GBMPlatform::drm_auth_magic(drm_magic_t magic)
152153
=== modified file 'src/shared/protobuf/mir_protobuf.proto'
--- src/shared/protobuf/mir_protobuf.proto 2013-09-06 03:46:37 +0000
+++ src/shared/protobuf/mir_protobuf.proto 2013-09-11 08:52:46 +0000
@@ -29,7 +29,8 @@
29 repeated sint32 fd = 2;29 repeated sint32 fd = 2;
30 repeated int32 data = 3;30 repeated int32 data = 3;
31 optional int32 fds_on_side_channel = 4;31 optional int32 fds_on_side_channel = 4;
32 optional int32 stride = 5;32 optional int32 stride = 5;
33 optional uint32 flags = 6;
3334
34 optional string error = 127;35 optional string error = 127;
35}36}
3637
=== modified file 'tests/acceptance-tests/test_client_library.cpp'
--- tests/acceptance-tests/test_client_library.cpp 2013-09-02 09:54:31 +0000
+++ tests/acceptance-tests/test_client_library.cpp 2013-09-11 08:52:46 +0000
@@ -456,6 +456,77 @@
456 launch_client_process(client_config);456 launch_client_process(client_config);
457}457}
458458
459#ifndef ANDROID
460TEST_F(DefaultDisplayServerTestFixture, surface_scanout_flag_toggles)
461{
462 struct ClientConfig : ClientConfigCommon
463 {
464 void exec()
465 {
466 connection = mir_connect_sync(mir_test_socket, __PRETTY_FUNCTION__);
467 ASSERT_TRUE(connection != NULL);
468 EXPECT_TRUE(mir_connection_is_valid(connection));
469 EXPECT_STREQ(mir_connection_get_error_message(connection), "");
470
471 MirSurfaceParameters parm =
472 {
473 __PRETTY_FUNCTION__,
474 1280, 1024,
475 mir_pixel_format_abgr_8888,
476 mir_buffer_usage_hardware,
477 mir_display_output_id_invalid
478 };
479
480 surface = mir_connection_create_surface_sync(connection, &parm);
481 ASSERT_TRUE(mir_surface_is_valid(surface));
482 MirNativeBuffer *native;
483 mir_surface_get_current_buffer(surface, &native);
484 EXPECT_TRUE(native->flags & mir_buffer_flag_can_scanout);
485 mir_surface_swap_buffers_sync(surface);
486 EXPECT_TRUE(native->flags & mir_buffer_flag_can_scanout);
487 mir_surface_release_sync(surface);
488
489 parm.width = 100;
490 parm.height = 100;
491
492 surface = mir_connection_create_surface_sync(connection, &parm);
493 ASSERT_TRUE(mir_surface_is_valid(surface));
494 mir_surface_get_current_buffer(surface, &native);
495 EXPECT_FALSE(native->flags & mir_buffer_flag_can_scanout);
496 mir_surface_swap_buffers_sync(surface);
497 EXPECT_FALSE(native->flags & mir_buffer_flag_can_scanout);
498 mir_surface_release_sync(surface);
499
500 parm.width = 800;
501 parm.height = 600;
502 parm.buffer_usage = mir_buffer_usage_software;
503
504 surface = mir_connection_create_surface_sync(connection, &parm);
505 ASSERT_TRUE(mir_surface_is_valid(surface));
506 mir_surface_get_current_buffer(surface, &native);
507 EXPECT_FALSE(native->flags & mir_buffer_flag_can_scanout);
508 mir_surface_swap_buffers_sync(surface);
509 EXPECT_FALSE(native->flags & mir_buffer_flag_can_scanout);
510 mir_surface_release_sync(surface);
511
512 parm.buffer_usage = mir_buffer_usage_hardware;
513
514 surface = mir_connection_create_surface_sync(connection, &parm);
515 ASSERT_TRUE(mir_surface_is_valid(surface));
516 mir_surface_get_current_buffer(surface, &native);
517 EXPECT_TRUE(native->flags & mir_buffer_flag_can_scanout);
518 mir_surface_swap_buffers_sync(surface);
519 EXPECT_TRUE(native->flags & mir_buffer_flag_can_scanout);
520 mir_surface_release_sync(surface);
521
522 mir_connection_release(connection);
523 }
524 } client_config;
525
526 launch_client_process(client_config);
527}
528#endif
529
459TEST_F(DefaultDisplayServerTestFixture, client_library_creates_multiple_surfaces)530TEST_F(DefaultDisplayServerTestFixture, client_library_creates_multiple_surfaces)
460{531{
461 int const n_surfaces = 13;532 int const n_surfaces = 13;
462533
=== modified file 'tests/mir_test_framework/testing_server_options.cpp'
--- tests/mir_test_framework/testing_server_options.cpp 2013-09-06 03:46:37 +0000
+++ tests/mir_test_framework/testing_server_options.cpp 2013-09-11 08:52:46 +0000
@@ -65,7 +65,8 @@
65{65{
66public:66public:
67 StubFDBuffer(mg::BufferProperties const& properties)67 StubFDBuffer(mg::BufferProperties const& properties)
68 : StubBuffer(properties)68 : StubBuffer(properties),
69 properties{properties}
69 {70 {
70 fd = open("/dev/zero", O_RDONLY);71 fd = open("/dev/zero", O_RDONLY);
71 if (fd < 0)72 if (fd < 0)
@@ -82,6 +83,14 @@
82 native_buffer->data[0] = 0xDEADBEEF;83 native_buffer->data[0] = 0xDEADBEEF;
83 native_buffer->fd_items = 1;84 native_buffer->fd_items = 1;
84 native_buffer->fd[0] = fd;85 native_buffer->fd[0] = fd;
86
87 native_buffer->flags = 0;
88 if (properties.size.width.as_int() >= 800 &&
89 properties.size.height.as_int() >= 600 &&
90 properties.usage == mg::BufferUsage::hardware)
91 {
92 native_buffer->flags |= mir_buffer_flag_can_scanout;
93 }
85 return native_buffer;94 return native_buffer;
86#else95#else
87 return std::shared_ptr<MirNativeBuffer>();96 return std::shared_ptr<MirNativeBuffer>();
@@ -94,6 +103,7 @@
94 }103 }
95private:104private:
96 int fd;105 int fd;
106 const mg::BufferProperties properties;
97};107};
98108
99class StubGraphicBufferAllocator : public mg::GraphicBufferAllocator109class StubGraphicBufferAllocator : public mg::GraphicBufferAllocator
@@ -180,6 +190,7 @@
180 }190 }
181191
182 packer->pack_stride(buffer->stride());192 packer->pack_stride(buffer->stride());
193 packer->pack_flags(native_handle->flags);
183#else194#else
184 (void)packer;195 (void)packer;
185 (void)buffer;196 (void)buffer;
186197
=== modified file 'tests/unit-tests/frontend/test_protobuf_buffer_packer.cpp'
--- tests/unit-tests/frontend/test_protobuf_buffer_packer.cpp 2013-08-28 03:41:48 +0000
+++ tests/unit-tests/frontend/test_protobuf_buffer_packer.cpp 2013-09-11 08:52:46 +0000
@@ -39,6 +39,7 @@
39 packer.pack_data(i);39 packer.pack_data(i);
4040
41 packer.pack_stride(dummy_stride);41 packer.pack_stride(dummy_stride);
42 packer.pack_flags(123);
4243
43 EXPECT_EQ(num_fd, response.fd_size());44 EXPECT_EQ(num_fd, response.fd_size());
44 EXPECT_EQ(num_int, response.data_size());45 EXPECT_EQ(num_int, response.data_size());
@@ -47,4 +48,5 @@
47 for (int i = 0; i < response.data_size(); ++i)48 for (int i = 0; i < response.data_size(); ++i)
48 EXPECT_EQ(i, response.data(i));49 EXPECT_EQ(i, response.data(i));
49 EXPECT_EQ(dummy_stride.as_uint32_t(), static_cast<unsigned int>(response.stride()));50 EXPECT_EQ(dummy_stride.as_uint32_t(), static_cast<unsigned int>(response.stride()));
51 EXPECT_EQ(123U, response.flags());
50}52}
5153
=== modified file 'tests/unit-tests/graphics/gbm/test_gbm_platform.cpp'
--- tests/unit-tests/graphics/gbm/test_gbm_platform.cpp 2013-08-28 03:41:48 +0000
+++ tests/unit-tests/graphics/gbm/test_gbm_platform.cpp 2013-09-11 08:52:46 +0000
@@ -171,6 +171,8 @@
171 }171 }
172 EXPECT_CALL(*mock_packer, pack_stride(dummy_stride))172 EXPECT_CALL(*mock_packer, pack_stride(dummy_stride))
173 .Times(1);173 .Times(1);
174 EXPECT_CALL(*mock_packer, pack_flags(testing::_))
175 .Times(1);
174176
175 platform->fill_ipc_package(mock_packer, mock_buffer);177 platform->fill_ipc_package(mock_packer, mock_buffer);
176}178}

Subscribers

People subscribed via source and target branches