Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,21 @@ cc_defaults {
],
cflags: [
"-DGFXSTREAM_BUILD_WITH_SNAPSHOT_SUPPORT=1",
"-DVK_BASE_VERSION_1_0",
"-DVK_BASE_VERSION_1_1",
"-DVK_BASE_VERSION_1_2",
"-DVK_BASE_VERSION_1_3",
"-DVK_BASE_VERSION_1_4",
"-DVK_COMPUTE_VERSION_1_0",
"-DVK_COMPUTE_VERSION_1_1",
"-DVK_COMPUTE_VERSION_1_2",
"-DVK_COMPUTE_VERSION_1_3",
"-DVK_COMPUTE_VERSION_1_4",
"-DVK_GRAPHICS_VERSION_1_0",
"-DVK_GRAPHICS_VERSION_1_1",
"-DVK_GRAPHICS_VERSION_1_2",
"-DVK_GRAPHICS_VERSION_1_3",
"-DVK_GRAPHICS_VERSION_1_4",
] + select(soong_config_variable("gfxstream", "mesa3d_platforms"), {
// Android surfaceless build
"none": [
Expand Down
15 changes: 15 additions & 0 deletions build_variables.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ GFXSTREAM_HOST_DEFINES = GFXSTREAM_HOST_VK_DEFINES + [
"GFXSTREAM_ENABLE_HOST_GLES=1",
"GFXSTREAM_BUILD_WITH_SNAPSHOT_FRONTEND_SUPPORT=1",
"GFXSTREAM_BUILD_WITH_SNAPSHOT_SUPPORT=1",
"VK_BASE_VERSION_1_0",
"VK_BASE_VERSION_1_1",
"VK_BASE_VERSION_1_2",
"VK_BASE_VERSION_1_3",
"VK_BASE_VERSION_1_4",
"VK_COMPUTE_VERSION_1_0",
"VK_COMPUTE_VERSION_1_1",
"VK_COMPUTE_VERSION_1_2",
"VK_COMPUTE_VERSION_1_3",
"VK_COMPUTE_VERSION_1_4",
"VK_GRAPHICS_VERSION_1_0",
"VK_GRAPHICS_VERSION_1_1",
"VK_GRAPHICS_VERSION_1_2",
"VK_GRAPHICS_VERSION_1_3",
"VK_GRAPHICS_VERSION_1_4",
] + select({
"@platforms//os:windows": [
"WIN32_LEAN_AND_MEAN",
Expand Down
19 changes: 19 additions & 0 deletions codegen/generic-apigen/api_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ int ApiGen::genProcTypes(const std::string& filename, SideType side) {
if (j != 0 || side == CLIENT_SIDE || (side == SERVER_SIDE && e->customDecoder()))
fprintf(fp, ", ");
evars[j].printType(fp);
if (e->serverAddSizeParamForBuffers() && side == SERVER_SIDE &&
evars[j].isPointer()) {
fprintf(fp, ", uint32_t");
}
}
}
fprintf(fp, ");\n");
Expand All @@ -140,6 +144,9 @@ int ApiGen::genProcTypes(const std::string& filename, SideType side) {
if (!evars[j].isVoid()) {
if (j != 0) fprintf(fp, ", ");
evars[j].printType(fp);
if (e->serverAddSizeParamForBuffers() && evars[j].isPointer()) {
fprintf(fp, ", uint32_t");
}
}
}
fprintf(fp, ");\n");
Expand Down Expand Up @@ -1248,6 +1255,9 @@ int ApiGen::genDecoderImpl(const std::string& filename) {
fprintf(fp, "(%s)(inptr_%s.get())", var_type_name, var_name);
}
}
if (e->serverAddSizeParamForBuffers()) {
fprintf(fp, ", size_%s", var_name);
}
} else if (pass == PASS_DebugPrint && v->pointerDir() == Var::POINTER_IN) {
fprintf(fp, "(%s)(inptr_%s.get()), size_%s", var_type_name, var_name,
var_name);
Expand All @@ -1263,6 +1273,9 @@ int ApiGen::genDecoderImpl(const std::string& filename) {
} else {
fprintf(fp, "(%s)(inptr_%s)", var_type_name, var_name);
}
if (e->serverAddSizeParamForBuffers()) {
fprintf(fp, ", size_%s", var_name);
}
} else if (pass == PASS_DebugPrint && v->pointerDir() == Var::POINTER_IN) {
fprintf(fp, "(%s)(inptr_%s), size_%s", var_type_name, var_name,
var_name);
Expand Down Expand Up @@ -1310,6 +1323,9 @@ int ApiGen::genDecoderImpl(const std::string& filename) {
fprintf(fp, "(%s)(outptr_%s.get())", var_type_name, var_name);
}
}
if (e->serverAddSizeParamForBuffers()) {
fprintf(fp, ", size_%s", var_name);
}
} else if (pass == PASS_DebugPrint) {
fprintf(fp, "(%s)(outptr_%s.get()), size_%s", var_type_name, var_name,
var_name);
Expand All @@ -1335,6 +1351,9 @@ int ApiGen::genDecoderImpl(const std::string& filename) {
} else {
fprintf(fp, "(%s)(outptr_%s)", var_type_name, var_name);
}
if (e->serverAddSizeParamForBuffers()) {
fprintf(fp, ", size_%s", var_name);
}
} else if (pass == PASS_DebugPrint) {
fprintf(fp, "(%s)(outptr_%s), size_%s", var_type_name, var_name,
varoffset.c_str());
Expand Down
3 changes: 3 additions & 0 deletions codegen/generic-apigen/entry_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void EntryPoint::reset() {
m_customDecoder = false;
m_notApi = false;
m_flushOnEncode = false;
m_serverAddSizeParamForBuffers = false;
m_vars.clear();
}

Expand Down Expand Up @@ -376,6 +377,8 @@ int EntryPoint::setAttribute(const std::string& line, size_t lc) {
setNotApi(true);
} else if (flag == "flushOnEncode") {
setFlushOnEncode(true);
} else if (flag == "server_add_size_param_for_buffers") {
setServerAddSizeParamForBuffers(true);
} else {
fprintf(stderr, "WARNING: %u: unknown flag %s\n", (unsigned int)lc, flag.c_str());
}
Expand Down
3 changes: 3 additions & 0 deletions codegen/generic-apigen/entry_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class EntryPoint {
bool flushOnEncode() const { return m_flushOnEncode; }
void setFlushOnEncode(bool state) { m_flushOnEncode = state; }
void setCustomHostApi(const std::string& apiname) { m_customHostApi = apiname; }
bool serverAddSizeParamForBuffers() const { return m_serverAddSizeParamForBuffers; }
void setServerAddSizeParamForBuffers(bool state) { m_serverAddSizeParamForBuffers = state; }
int validateVarAttr(const std::string& varname, size_t lc) const;
int setAttribute(const std::string& line, size_t lc);

Expand All @@ -68,6 +70,7 @@ class EntryPoint {
bool m_customDecoder;
bool m_notApi;
bool m_flushOnEncode;
bool m_serverAddSizeParamForBuffers;
std::string m_customHostApi;

void err(unsigned int lc, const char* msg) { fprintf(stderr, "line %d: %s\n", lc, msg); }
Expand Down
1 change: 1 addition & 0 deletions codegen/renderControl/renderControl.attrib
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ rcChooseConfig
rcReadColorBuffer
dir pixels out
len pixels (((glUtilsPixelBitSize(format, type) * width) >> 3) * height)
flag server_add_size_param_for_buffers

rcReadColorBufferYUV
dir pixels out
Expand Down
1 change: 0 additions & 1 deletion guest/OpenglSystemCommon/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ cc_library_static {
"libOpenglSystemCommonDefaults",
],
static_libs: [
"libgfxstream_androidemu_static",
"libgfxstream_androidemu_static",
"mesa_gfxstream_guest_android",
"libOpenglCodecCommon_static",
Expand Down
28 changes: 22 additions & 6 deletions host/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,28 @@
# See the License for the specific language governing permissions and
# limitations under the License.


if(CONFIG_AEMU)
add_compile_definitions(GFXSTREAM_BUILD_WITH_SNAPSHOT_SUPPORT)
add_compile_definitions(CONFIG_AEMU)
endif()

add_compile_definitions(VK_BASE_VERSION_1_0)
add_compile_definitions(VK_BASE_VERSION_1_1)
add_compile_definitions(VK_BASE_VERSION_1_2)
add_compile_definitions(VK_BASE_VERSION_1_3)
add_compile_definitions(VK_BASE_VERSION_1_4)
add_compile_definitions(VK_COMPUTE_VERSION_1_0)
add_compile_definitions(VK_COMPUTE_VERSION_1_1)
add_compile_definitions(VK_COMPUTE_VERSION_1_2)
add_compile_definitions(VK_COMPUTE_VERSION_1_3)
add_compile_definitions(VK_COMPUTE_VERSION_1_4)
add_compile_definitions(VK_GRAPHICS_VERSION_1_0)
add_compile_definitions(VK_GRAPHICS_VERSION_1_1)
add_compile_definitions(VK_GRAPHICS_VERSION_1_2)
add_compile_definitions(VK_GRAPHICS_VERSION_1_3)
add_compile_definitions(VK_GRAPHICS_VERSION_1_4)

add_library(
gfxstream_backend_headers
INTERFACE)
Expand Down Expand Up @@ -54,12 +76,6 @@ add_subdirectory(gl)
add_subdirectory(renderControl_dec)
add_subdirectory(vulkan)


if(CONFIG_AEMU)
add_compile_definitions(GFXSTREAM_BUILD_WITH_SNAPSHOT_SUPPORT)
add_compile_definitions(CONFIG_AEMU)
endif()

# Stream server core
set(stream-server-core-sources
buffer.cpp
Expand Down
27 changes: 3 additions & 24 deletions host/color_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ class ColorBuffer::Impl : public LazySnapshotObj<ColorBuffer::Impl> {
bool glOpImportEglNativePixmap(void* pixmap, bool preserveContent);
bool glOpSwapYuvTexturesAndUpdate(GLenum format, GLenum type, GfxstreamFormat texturesFormat,
GLuint* textures);
bool glOpReadContents(size_t* outNumBytes, void* outContents);
bool glOpIsFastBlitSupported() const;
bool glOpPostLayer(const ComposeLayer& l, int frameWidth, int frameHeight,
const std::optional<std::array<float, 16>>& colorTransform);
Expand Down Expand Up @@ -258,7 +257,7 @@ void ColorBuffer::Impl::readToBytes(

#if GFXSTREAM_ENABLE_HOST_GLES
if (mColorBufferGl) {
mColorBufferGl->readPixels(x, y, width, height, pixelsFormat, outPixels);
mColorBufferGl->readPixels(x, y, width, height, pixelsFormat, outPixels, outPixelsSize);
return;
}
#endif
Expand Down Expand Up @@ -484,19 +483,12 @@ bool ColorBuffer::Impl::invalidateForVk() {
}

#if GFXSTREAM_ENABLE_HOST_GLES
std::size_t contentsSize = 0;
if (!mColorBufferGl->readContents(&contentsSize, nullptr)) {
std::vector<uint8_t> contents;
if (!mColorBufferGl->readContents(&contents)) {
GFXSTREAM_ERROR("Failed to get GL contents size for ColorBuffer:%d", mHandle);
return false;
}

std::vector<uint8_t> contents(contentsSize, 0);

if (!mColorBufferGl->readContents(&contentsSize, contents.data())) {
GFXSTREAM_ERROR("Failed to get GL contents for ColorBuffer:%d", mHandle);
return false;
}

if (!mColorBufferVk->updateFromBytes(contents)) {
GFXSTREAM_ERROR("Failed to set VK contents for ColorBuffer:%d", mHandle);
return false;
Expand Down Expand Up @@ -610,15 +602,6 @@ bool ColorBuffer::Impl::glOpSwapYuvTexturesAndUpdate(GLenum format, GLenum type,
return true;
}

bool ColorBuffer::Impl::glOpReadContents(size_t* outNumBytes, void* outContents) {
if (!mColorBufferGl) {
GFXSTREAM_ERROR("%s: ColorBufferGl not available", __func__);
return false;
}

return mColorBufferGl->readContents(outNumBytes, outContents);
}

bool ColorBuffer::Impl::glOpIsFastBlitSupported() const {
if (!mColorBufferGl) {
GFXSTREAM_ERROR("%s: ColorBufferGl not available", __func__);
Expand Down Expand Up @@ -777,10 +760,6 @@ bool ColorBuffer::glOpSwapYuvTexturesAndUpdate(GLenum format, GLenum type,
return mImpl->glOpSwapYuvTexturesAndUpdate(format, type, texturesFormat, textures);
}

bool ColorBuffer::glOpReadContents(size_t* outNumBytes, void* outContents) {
return mImpl->glOpReadContents(outNumBytes, outContents);
}

bool ColorBuffer::glOpIsFastBlitSupported() const { return mImpl->glOpIsFastBlitSupported(); }

bool ColorBuffer::glOpPostLayer(const ComposeLayer& l, int frameWidth, int frameHeight,
Expand Down
1 change: 0 additions & 1 deletion host/color_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ class ColorBuffer : public LazySnapshotObj<ColorBuffer> {
bool glOpImportEglNativePixmap(void* pixmap, bool preserveContent);
bool glOpSwapYuvTexturesAndUpdate(GLenum format, GLenum type, GfxstreamFormat texturesFormat,
GLuint* textures);
bool glOpReadContents(size_t* outNumBytes, void* outContents);
bool glOpIsFastBlitSupported() const;
bool glOpPostLayer(const ComposeLayer& l, int frameWidth, int frameHeight,
const std::optional<std::array<float, 16>>& colorTransform);
Expand Down
28 changes: 0 additions & 28 deletions host/frame_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,16 +757,6 @@ class FrameBuffer::Impl : public gfxstream::base::EventNotificationSupport<Frame
int height, uint32_t format, uint32_t type,
uint32_t texturesFormat, uint32_t* textures);

// Reads back the raw color buffer to |pixels|
// if |pixels| is not null.
// Always returns in |numBytes| how many bytes were
// planned to be transmitted.
// |numBytes| is not an input parameter;
// fewer or more bytes cannot be specified.
// If the framework format is YUV, it will read
// back as raw YUV data.
bool readColorBufferContents(HandleType p_colorbuffer, size_t* numBytes, void* pixels);

void asyncWaitForGpuWithCb(uint64_t eglsync, FenceCompletionCallback cb);

const gl::EGLDispatch* getEglDispatch();
Expand Down Expand Up @@ -4968,19 +4958,6 @@ void FrameBuffer::Impl::swapTexturesAndUpdateColorBuffer(uint32_t p_colorbuffer,
}
}

bool FrameBuffer::Impl::readColorBufferContents(HandleType p_colorbuffer, size_t* numBytes,
void* pixels) {
AutoLock mutex(m_lock);

ColorBufferPtr colorBuffer = findColorBuffer(p_colorbuffer);
if (!colorBuffer) {
// bad colorbuffer handle
return false;
}

return colorBuffer->glOpReadContents(numBytes, pixels);
}

void FrameBuffer::Impl::asyncWaitForGpuWithCb(uint64_t eglsync, FenceCompletionCallback cb) {
EmulatedEglFenceSync* fenceSync = EmulatedEglFenceSync::getFromHandle(eglsync);

Expand Down Expand Up @@ -5658,11 +5635,6 @@ void FrameBuffer::swapTexturesAndUpdateColorBuffer(uint32_t colorBufferHandle, i
texturesFormat, textures);
}

bool FrameBuffer::readColorBufferContents(HandleType p_colorbuffer, size_t* numBytes,
void* pixels) {
return mImpl->readColorBufferContents(p_colorbuffer, numBytes, pixels);
}

void FrameBuffer::asyncWaitForGpuWithCb(uint64_t eglsync, FenceCompletionCallback cb) {
mImpl->asyncWaitForGpuWithCb(eglsync, cb);
}
Expand Down
19 changes: 4 additions & 15 deletions host/frame_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,10 @@ class FrameBuffer : public gfxstream::base::EventNotificationSupport<FrameBuffer
// with the pixel data.
// |outPixelsSize| is the size of buffer
void readColorBuffer(HandleType p_colorbuffer, int x, int y, int width, int height,
GfxstreamFormat pixelsFormat, void* pixels,
uint64_t outPixelsSize = std::numeric_limits<uint64_t>::max());
void readColorBufferDeprecated(HandleType p_colorbuffer, int x, int y, int width,
int height, GLenum format, GLenum type,
void* pixels, uint64_t outPixelsSize = std::numeric_limits<uint64_t>::max());
GfxstreamFormat pixelsFormat, void* pixels, uint64_t outPixelsSize);
void readColorBufferDeprecated(HandleType p_colorbuffer, int x, int y, int width, int height,
GLenum format, GLenum type, void* pixels,
uint64_t outPixelsSize);

// Read the content of a given YUV420_888 ColorBuffer into client memory.
// |p_colorbuffer| is the ColorBuffer's handle value. Similar
Expand Down Expand Up @@ -582,16 +581,6 @@ class FrameBuffer : public gfxstream::base::EventNotificationSupport<FrameBuffer
int height, uint32_t format, uint32_t type,
uint32_t texturesFormat, uint32_t* textures);

// Reads back the raw color buffer to |pixels|
// if |pixels| is not null.
// Always returns in |numBytes| how many bytes were
// planned to be transmitted.
// |numBytes| is not an input parameter;
// fewer or more bytes cannot be specified.
// If the framework format is YUV, it will read
// back as raw YUV data.
bool readColorBufferContents(HandleType p_colorbuffer, size_t* numBytes, void* pixels);

void asyncWaitForGpuWithCb(uint64_t eglsync, FenceCompletionCallback cb);

const void* getEglDispatch();
Expand Down
4 changes: 2 additions & 2 deletions host/frame_buffer_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ TEST_F(FrameBufferTest, CreateOpenUpdateCloseColorBuffer_RGB565) {
constexpr const uint32_t kBpp = 2;
std::vector<uint8_t> buffer(kWidth * kHeight * kBpp);

// NOTE: historical usage did not pass a `buffer.size()`:
mFb->readColorBufferDeprecated(colorBufferHandle, 0, 0, kWidth, kHeight,
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, buffer.data());
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, buffer.data(),
buffer.size());
mFb->updateColorBufferDeprecated(colorBufferHandle, 0, 0, kWidth, kHeight,
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, buffer.data());
}
Expand Down
Loading
Loading