Mir

Merge lp:~kdub/mir/mir-buffer-get-stride into lp:mir

Proposed by Kevin DuBois
Status: Rejected
Rejected by: Kevin DuBois
Proposed branch: lp:~kdub/mir/mir-buffer-get-stride
Merge into: lp:mir
Diff against target: 173 lines (+43/-0)
11 files modified
src/client/buffer.cpp (+6/-0)
src/client/buffer.h (+1/-0)
src/client/error_buffer.cpp (+1/-0)
src/client/error_buffer.h (+1/-0)
src/client/mir_buffer.h (+2/-0)
src/client/mir_buffer_api.cpp (+13/-0)
src/client/symbols.map (+1/-0)
src/include/client/mir_toolkit/mir_buffer.h (+7/-0)
tests/acceptance-tests/throwback/test_presentation_chain.cpp (+2/-0)
tests/include/mir/test/doubles/mock_mir_buffer.h (+1/-0)
tests/unit-tests/client/test_mir_buffer.cpp (+8/-0)
To merge this branch: bzr merge lp:~kdub/mir/mir-buffer-get-stride
Reviewer Review Type Date Requested Status
Mir CI Bot continuous-integration Needs Fixing
Daniel van Vugt Approve
Chris Halse Rogers Needs Information
Cemil Azizoglu (community) Approve
Review via email: mp+303135@code.launchpad.net

Commit message

client: add mir_buffer_get_stride() to the MirBuffer api.

Description of the change

client: add mir_buffer_get_stride() to the MirBuffer api.

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3656
https://mir-jenkins.ubuntu.com/job/mir-ci/1475/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/1827/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/1881
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1872
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/1872
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/1872
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/1851
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/1851/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/1851
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/1851/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/1851
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/1851/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/1851
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/1851/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/1851
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/1851/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/1851/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/1475/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3656
https://mir-jenkins.ubuntu.com/job/mir-ci/1477/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/1829
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/1883
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1874
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/1874
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/1874
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/1853
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/1853/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/1853
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/1853/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/1853
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/1853/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/1853
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/1853/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/1853
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/1853/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/1853
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/1853/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/1477/rebuild

review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Does this make sense? Stride is usually only meaningful to clients using linear software buffers. And they already get the stride from MirGraphicsRegion.

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

The driver for the addition is https://code.launchpad.net/~kdub/mir/nested-buffer/+merge/303251, where we have a need to know the stride to implement mg::Buffer.

Stride could be hidden behind linear/software buffers only, but as things stand now, its a core buffer property thats used in different parts of the code.

Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

ok

review: Approve
Revision history for this message
Chris Halse Rogers (raof) wrote :

Not blocking, but how much effort would it be to do the right thing here and remove stride(), write() and read() from the mg::Buffer API and move it to the appropriate NativeBuffer interfaces? These things really only apply to (a currently hypothetical) mg::SoftwareTexture.

review: Needs Information
Revision history for this message
Chris Halse Rogers (raof) wrote :

A quick search of where those functions are used suggests that we have exactly two users of write() and *no* users of stride()‽

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Theoretically stride() only really is applicable to ShmBuffer and even that doesn't use the stride() interface, just provides it.

The reason is that an arbitrary stride is not supported by OpenGL when uploading textures. We resolve this by calling glPixelStorei to tell GL to round to single pixels, so that everyone then agrees stride==width*bpp in ShmBuffer.

I don't mind it existing, but it seems to be an Android-specific requirement.

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

moving stride() from mg::Buffer to mir::renderer::software::PixelSource is the right thing to do. It could be a bit of work (seems a bit entrenched though in our ipc and platform-specific code), will spike around moving it.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Absolutely. I didn't realise that a software renderer was coming. That's definitely a use case requiring stride().

review: Approve
Revision history for this message
Chris Halse Rogers (raof) wrote :

A putative software renderer will dynamically cast to PixelSource and use that interface; it won't use mg::Buffer::stride() (which, like read() and write() don't make sense for non-software buffers).

Revision history for this message
Chris Halse Rogers (raof) wrote :

So I *think* this is work-in-progress, pending Kevin's PixelSource spike that will completely remove the need for it?

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
https://mir-jenkins.ubuntu.com/job/mir-autolanding/519/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/1867/console
    None: https://mir-jenkins.ubuntu.com/job/generic-land-mp/553/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/1921
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1912
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/1912
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/1912
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/1891/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/1891
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/1891/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/1891/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/1891/console
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/1891/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/1891
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/1891/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/1891
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/1891/artifact/output/*zip*/output.zip

review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

> So I *think* this is work-in-progress, pending Kevin's PixelSource spike that
> will completely remove the need for it?
I think it can be rejected

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/client/buffer.cpp'
2--- src/client/buffer.cpp 2016-08-01 07:24:32 +0000
3+++ src/client/buffer.cpp 2016-08-17 14:06:24 +0000
4@@ -129,6 +129,12 @@
5 {
6 return buffer->size();
7 }
8+
9+mir::geometry::Stride mcl::Buffer::stride() const
10+{
11+ return buffer->stride();
12+}
13+
14 std::shared_ptr<mcl::ClientBuffer> mcl::Buffer::client_buffer() const
15 {
16 return buffer;
17
18=== modified file 'src/client/buffer.h'
19--- src/client/buffer.h 2016-08-01 07:24:32 +0000
20+++ src/client/buffer.h 2016-08-17 14:06:24 +0000
21@@ -60,6 +60,7 @@
22 MirBufferUsage buffer_usage() const override;
23 MirPixelFormat pixel_format() const override;
24 geometry::Size size() const override;
25+ geometry::Stride stride() const override;
26
27 MirConnection* allocating_connection() const override;
28
29
30=== modified file 'src/client/error_buffer.cpp'
31--- src/client/error_buffer.cpp 2016-08-01 07:24:32 +0000
32+++ src/client/error_buffer.cpp 2016-08-17 14:06:24 +0000
33@@ -74,5 +74,6 @@
34 MirBufferUsage mcl::ErrorBuffer::buffer_usage() const THROW_EXCEPTION
35 MirPixelFormat mcl::ErrorBuffer::pixel_format() const THROW_EXCEPTION
36 geom::Size mcl::ErrorBuffer::size() const THROW_EXCEPTION
37+geom::Stride mcl::ErrorBuffer::stride() const THROW_EXCEPTION
38 void mcl::ErrorBuffer::increment_age() THROW_EXCEPTION
39 void mcl::ErrorBuffer::set_callback(mir_buffer_callback, void*) THROW_EXCEPTION
40
41=== modified file 'src/client/error_buffer.h'
42--- src/client/error_buffer.h 2016-08-01 07:24:32 +0000
43+++ src/client/error_buffer.h 2016-08-17 14:06:24 +0000
44@@ -45,6 +45,7 @@
45 MirBufferUsage buffer_usage() const override;
46 MirPixelFormat pixel_format() const override;
47 geometry::Size size() const override;
48+ geometry::Stride stride() const override;
49 MirConnection* allocating_connection() const override;
50 void increment_age() override;
51 void set_callback(mir_buffer_callback callback, void* context) override;
52
53=== modified file 'src/client/mir_buffer.h'
54--- src/client/mir_buffer.h 2016-08-01 07:24:32 +0000
55+++ src/client/mir_buffer.h 2016-08-17 14:06:24 +0000
56@@ -50,6 +50,8 @@
57 virtual MirBufferUsage buffer_usage() const = 0;
58 virtual MirPixelFormat pixel_format() const = 0;
59 virtual geometry::Size size() const = 0;
60+ virtual geometry::Stride stride() const = 0;
61+
62 virtual MirConnection* allocating_connection() const = 0;
63 virtual void increment_age() = 0;
64 virtual bool valid() const = 0;
65
66=== modified file 'src/client/mir_buffer_api.cpp'
67--- src/client/mir_buffer_api.cpp 2016-08-01 07:24:32 +0000
68+++ src/client/mir_buffer_api.cpp 2016-08-17 14:06:24 +0000
69@@ -142,6 +142,19 @@
70 return 0;
71 }
72
73+unsigned int mir_buffer_get_stride(MirBuffer* b)
74+try
75+{
76+ mir::require(b);
77+ auto buffer = reinterpret_cast<mcl::MirBuffer*>(b);
78+ return buffer->stride().as_uint32_t();
79+}
80+catch (std::exception const& ex)
81+{
82+ MIR_LOG_UNCAUGHT_EXCEPTION(ex);
83+ return 0;
84+}
85+
86 unsigned int mir_buffer_get_height(MirBuffer* b)
87 try
88 {
89
90=== modified file 'src/client/symbols.map'
91--- src/client/symbols.map 2016-08-09 06:44:52 +0000
92+++ src/client/symbols.map 2016-08-17 14:06:24 +0000
93@@ -381,6 +381,7 @@
94 mir_buffer_get_height;
95 mir_buffer_get_pixel_format;
96 mir_buffer_get_buffer_usage;
97+ mir_buffer_get_stride;
98 mir_buffer_is_valid;
99 mir_buffer_get_error_message;
100 local:
101
102=== modified file 'src/include/client/mir_toolkit/mir_buffer.h'
103--- src/include/client/mir_toolkit/mir_buffer.h 2016-08-01 07:24:32 +0000
104+++ src/include/client/mir_toolkit/mir_buffer.h 2016-08-17 14:06:24 +0000
105@@ -170,6 +170,13 @@
106 **/
107 unsigned int mir_buffer_get_height(MirBuffer* buffer);
108
109+/** Retrieve the stride of the buffer in bytes.
110+ *
111+ * \param [in] buffer The buffer
112+ * \return The stride of the buffer in bytes
113+ **/
114+unsigned int mir_buffer_get_stride(MirBuffer* buffer);
115+
116 /** Retrieve the pixel format of the buffer.
117 *
118 * \param [in] buffer The buffer
119
120=== modified file 'tests/acceptance-tests/throwback/test_presentation_chain.cpp'
121--- tests/acceptance-tests/throwback/test_presentation_chain.cpp 2016-07-05 12:40:56 +0000
122+++ tests/acceptance-tests/throwback/test_presentation_chain.cpp 2016-08-17 14:06:24 +0000
123@@ -343,6 +343,7 @@
124 geom::Height height { 33 };
125 auto format = mir_pixel_format_abgr_8888;
126 auto usage = mir_buffer_usage_software;
127+ auto stride = geom::Stride { width.as_int() * MIR_BYTES_PER_PIXEL(format) };
128
129 SurfaceWithChainFromStart surface(connection, size, pf);
130 mir_connection_allocate_buffer(
131@@ -354,6 +355,7 @@
132 EXPECT_THAT(mir_buffer_get_height(buffer), Eq(height.as_uint32_t()));
133 EXPECT_THAT(mir_buffer_get_buffer_usage(buffer), Eq(usage));
134 EXPECT_THAT(mir_buffer_get_pixel_format(buffer), Eq(format));
135+ EXPECT_THAT(mir_buffer_get_stride(buffer), Eq(stride.as_uint32_t()));
136 }
137
138 TEST_F(PresentationChain, can_check_valid_buffers)
139
140=== modified file 'tests/include/mir/test/doubles/mock_mir_buffer.h'
141--- tests/include/mir/test/doubles/mock_mir_buffer.h 2016-08-01 07:24:32 +0000
142+++ tests/include/mir/test/doubles/mock_mir_buffer.h 2016-08-17 14:06:24 +0000
143@@ -53,6 +53,7 @@
144 MOCK_CONST_METHOD0(buffer_usage, MirBufferUsage());
145 MOCK_CONST_METHOD0(pixel_format, MirPixelFormat());
146 MOCK_CONST_METHOD0(size, geometry::Size());
147+ MOCK_CONST_METHOD0(stride, geometry::Stride());
148 MOCK_CONST_METHOD0(allocating_connection, MirConnection*());
149 MOCK_METHOD0(increment_age, void());
150 MOCK_CONST_METHOD0(valid, bool());
151
152=== modified file 'tests/unit-tests/client/test_mir_buffer.cpp'
153--- tests/unit-tests/client/test_mir_buffer.cpp 2016-06-24 11:41:37 +0000
154+++ tests/unit-tests/client/test_mir_buffer.cpp 2016-08-17 14:06:24 +0000
155@@ -43,6 +43,8 @@
156 .WillByDefault(Return(geom::Size{width, height}));
157 ON_CALL(*mock_client_buffer, pixel_format())
158 .WillByDefault(Return(format));
159+ ON_CALL(*mock_client_buffer, stride())
160+ .WillByDefault(Return(stride));
161 }
162 MirGraphicsRegion region;
163 int buffer_id { 32 };
164@@ -228,3 +230,9 @@
165 EXPECT_THAT(buffer.size().height, Eq(height));
166 EXPECT_THAT(buffer.size().width, Eq(width));
167 }
168+
169+TEST_F(MirBufferTest, returns_correct_stride)
170+{
171+ mcl::Buffer buffer(cb, nullptr, buffer_id, mock_client_buffer, nullptr, usage);
172+ EXPECT_THAT(buffer.stride(), Eq(stride));
173+}

Subscribers

People subscribed via source and target branches