| // Generated Code - DO NOT EDIT !! |
| // generated by 'emugen' |
| |
| |
| #include <string.h> |
| #include "magma_opcodes.h" |
| |
| #include "magma_enc.h" |
| |
| |
| #include <vector> |
| |
| #include <stdio.h> |
| |
| // TODO(fxbug.dev/42073574): Why is modification needed for these two includes? |
| #include "aemu/base/Tracing.h" |
| #include "cutils/log.h" |
| |
| #include "EncoderDebug.h" |
| |
| using gfxstream::guest::ChecksumCalculator; |
| |
| using gfxstream::guest::IOStream; |
| |
| namespace { |
| |
| void enc_unsupported() |
| { |
| ALOGE("Function is unsupported\n"); |
| } |
| |
| magma_status_t magma_device_import_enc(void *self , magma_handle_t device_channel, magma_device_t* device_out) |
| { |
| ENCODER_DEBUG_LOG("magma_device_import(device_channel:%u, device_out:%p)", device_channel, device_out); |
| AEMU_SCOPED_TRACE("magma_device_import encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_device_out = sizeof(magma_device_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 4 + 0 + 1*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_device_import;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &device_channel, 4); ptr += 4; |
| memcpy(ptr, &__size_device_out, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| stream->readback(device_out, __size_device_out); |
| if (useChecksum) checksumCalculator->addBuffer(device_out, __size_device_out); |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_device_import: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| void magma_device_release_enc(void *self , magma_device_t device) |
| { |
| ENCODER_DEBUG_LOG("magma_device_release(device:%lu)", device); |
| AEMU_SCOPED_TRACE("magma_device_release encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_device_release;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &device, 8); ptr += 8; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| } |
| |
| magma_status_t magma_device_query_enc(void *self , magma_device_t device, uint64_t id, magma_handle_t* result_buffer_out, uint64_t* result_out) |
| { |
| ENCODER_DEBUG_LOG("magma_device_query(device:%lu, id:%lu, result_buffer_out:%p, result_out:%p)", device, id, result_buffer_out, result_out); |
| AEMU_SCOPED_TRACE("magma_device_query encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_result_buffer_out = sizeof(magma_handle_t); |
| const unsigned int __size_result_out = sizeof(uint64_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 8 + 0 + 0 + 2*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_device_query;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &device, 8); ptr += 8; |
| memcpy(ptr, &id, 8); ptr += 8; |
| memcpy(ptr, &__size_result_buffer_out, 4); ptr += 4; |
| memcpy(ptr, &__size_result_out, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| stream->readback(result_buffer_out, __size_result_buffer_out); |
| if (useChecksum) checksumCalculator->addBuffer(result_buffer_out, __size_result_buffer_out); |
| stream->readback(result_out, __size_result_out); |
| if (useChecksum) checksumCalculator->addBuffer(result_out, __size_result_out); |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_device_query: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_device_query_fudge_enc(void *self , magma_device_t device, uint64_t id, magma_bool_t host_allocate, uint64_t* result_buffer_mapping_id_inout, uint64_t* result_buffer_size_inout, uint64_t* result_out) |
| { |
| ENCODER_DEBUG_LOG("magma_device_query_fudge(device:%lu, id:%lu, host_allocate:%hhu, result_buffer_mapping_id_inout:%p, result_buffer_size_inout:%p, result_out:%p)", device, id, host_allocate, result_buffer_mapping_id_inout, result_buffer_size_inout, result_out); |
| AEMU_SCOPED_TRACE("magma_device_query_fudge encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_result_buffer_mapping_id_inout = sizeof(uint64_t); |
| const unsigned int __size_result_buffer_size_inout = sizeof(uint64_t); |
| const unsigned int __size_result_out = sizeof(uint64_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 8 + 1 + __size_result_buffer_mapping_id_inout + __size_result_buffer_size_inout + 0 + 3*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_device_query_fudge;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &device, 8); ptr += 8; |
| memcpy(ptr, &id, 8); ptr += 8; |
| memcpy(ptr, &host_allocate, 1); ptr += 1; |
| memcpy(ptr, &__size_result_buffer_mapping_id_inout, 4); ptr += 4; |
| memcpy(ptr, result_buffer_mapping_id_inout, __size_result_buffer_mapping_id_inout);ptr += __size_result_buffer_mapping_id_inout; |
| memcpy(ptr, &__size_result_buffer_size_inout, 4); ptr += 4; |
| memcpy(ptr, result_buffer_size_inout, __size_result_buffer_size_inout);ptr += __size_result_buffer_size_inout; |
| memcpy(ptr, &__size_result_out, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| stream->readback(result_buffer_mapping_id_inout, __size_result_buffer_mapping_id_inout); |
| if (useChecksum) checksumCalculator->addBuffer(result_buffer_mapping_id_inout, __size_result_buffer_mapping_id_inout); |
| stream->readback(result_buffer_size_inout, __size_result_buffer_size_inout); |
| if (useChecksum) checksumCalculator->addBuffer(result_buffer_size_inout, __size_result_buffer_size_inout); |
| stream->readback(result_out, __size_result_out); |
| if (useChecksum) checksumCalculator->addBuffer(result_out, __size_result_out); |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_device_query_fudge: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_device_create_connection_enc(void *self , magma_device_t device, magma_connection_t* connection_out) |
| { |
| ENCODER_DEBUG_LOG("magma_device_create_connection(device:%lu, connection_out:%p)", device, connection_out); |
| AEMU_SCOPED_TRACE("magma_device_create_connection encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_connection_out = sizeof(magma_connection_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 0 + 1*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_device_create_connection;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &device, 8); ptr += 8; |
| memcpy(ptr, &__size_connection_out, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| stream->readback(connection_out, __size_connection_out); |
| if (useChecksum) checksumCalculator->addBuffer(connection_out, __size_connection_out); |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_device_create_connection: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| void magma_connection_release_enc(void *self , magma_connection_t connection) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_release(connection:%lu)", connection); |
| AEMU_SCOPED_TRACE("magma_connection_release encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_release;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| } |
| |
| magma_status_t magma_connection_get_error_enc(void *self , magma_connection_t connection) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_get_error(connection:%lu)", connection); |
| AEMU_SCOPED_TRACE("magma_connection_get_error encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_get_error;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_get_error: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_connection_create_context_enc(void *self , magma_connection_t connection, uint32_t* context_id_out) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_create_context(connection:%lu, context_id_out:%p)", connection, context_id_out); |
| AEMU_SCOPED_TRACE("magma_connection_create_context encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_context_id_out = sizeof(uint32_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 0 + 1*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_create_context;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &__size_context_id_out, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| stream->readback(context_id_out, __size_context_id_out); |
| if (useChecksum) checksumCalculator->addBuffer(context_id_out, __size_context_id_out); |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_create_context: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| void magma_connection_release_context_enc(void *self , magma_connection_t connection, uint32_t context_id) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_release_context(connection:%lu, context_id:%u)", connection, context_id); |
| AEMU_SCOPED_TRACE("magma_connection_release_context encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_release_context;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &context_id, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| } |
| |
| magma_status_t magma_connection_create_buffer_enc(void *self , magma_connection_t connection, uint64_t size, uint64_t* size_out, magma_buffer_t* buffer_out, magma_buffer_id_t* id_out) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_create_buffer(connection:%lu, size:%lu, size_out:%p, buffer_out:%p, id_out:%p)", connection, size, size_out, buffer_out, id_out); |
| AEMU_SCOPED_TRACE("magma_connection_create_buffer encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_size_out = sizeof(uint64_t); |
| const unsigned int __size_buffer_out = sizeof(magma_buffer_t); |
| const unsigned int __size_id_out = sizeof(magma_buffer_id_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 8 + 0 + 0 + 0 + 3*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_create_buffer;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &size, 8); ptr += 8; |
| memcpy(ptr, &__size_size_out, 4); ptr += 4; |
| memcpy(ptr, &__size_buffer_out, 4); ptr += 4; |
| memcpy(ptr, &__size_id_out, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| stream->readback(size_out, __size_size_out); |
| if (useChecksum) checksumCalculator->addBuffer(size_out, __size_size_out); |
| stream->readback(buffer_out, __size_buffer_out); |
| if (useChecksum) checksumCalculator->addBuffer(buffer_out, __size_buffer_out); |
| stream->readback(id_out, __size_id_out); |
| if (useChecksum) checksumCalculator->addBuffer(id_out, __size_id_out); |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_create_buffer: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| void magma_connection_release_buffer_enc(void *self , magma_connection_t connection, magma_buffer_t buffer) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_release_buffer(connection:%lu, buffer:%lu)", connection, buffer); |
| AEMU_SCOPED_TRACE("magma_connection_release_buffer encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 8; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_release_buffer;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &buffer, 8); ptr += 8; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| } |
| |
| magma_status_t magma_connection_import_buffer_enc(void *self , magma_connection_t connection, magma_handle_t buffer_handle, uint64_t* size_out, magma_buffer_t* buffer_out, magma_buffer_id_t* id_out) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_import_buffer(connection:%lu, buffer_handle:%u, size_out:%p, buffer_out:%p, id_out:%p)", connection, buffer_handle, size_out, buffer_out, id_out); |
| AEMU_SCOPED_TRACE("magma_connection_import_buffer encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_size_out = sizeof(uint64_t); |
| const unsigned int __size_buffer_out = sizeof(magma_buffer_t); |
| const unsigned int __size_id_out = sizeof(magma_buffer_id_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 4 + 0 + 0 + 0 + 3*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_import_buffer;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &buffer_handle, 4); ptr += 4; |
| memcpy(ptr, &__size_size_out, 4); ptr += 4; |
| memcpy(ptr, &__size_buffer_out, 4); ptr += 4; |
| memcpy(ptr, &__size_id_out, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| stream->readback(size_out, __size_size_out); |
| if (useChecksum) checksumCalculator->addBuffer(size_out, __size_size_out); |
| stream->readback(buffer_out, __size_buffer_out); |
| if (useChecksum) checksumCalculator->addBuffer(buffer_out, __size_buffer_out); |
| stream->readback(id_out, __size_id_out); |
| if (useChecksum) checksumCalculator->addBuffer(id_out, __size_id_out); |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_import_buffer: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_connection_create_semaphore_enc(void *self , magma_connection_t connection, magma_semaphore_t* semaphore_out, magma_semaphore_id_t* id_out) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_create_semaphore(connection:%lu, semaphore_out:%p, id_out:%p)", connection, semaphore_out, id_out); |
| AEMU_SCOPED_TRACE("magma_connection_create_semaphore encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_semaphore_out = sizeof(magma_semaphore_t); |
| const unsigned int __size_id_out = sizeof(magma_semaphore_id_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 0 + 0 + 2*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_create_semaphore;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &__size_semaphore_out, 4); ptr += 4; |
| memcpy(ptr, &__size_id_out, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| stream->readback(semaphore_out, __size_semaphore_out); |
| if (useChecksum) checksumCalculator->addBuffer(semaphore_out, __size_semaphore_out); |
| stream->readback(id_out, __size_id_out); |
| if (useChecksum) checksumCalculator->addBuffer(id_out, __size_id_out); |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_create_semaphore: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| void magma_connection_release_semaphore_enc(void *self , magma_connection_t connection, magma_semaphore_t semaphore) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_release_semaphore(connection:%lu, semaphore:%lu)", connection, semaphore); |
| AEMU_SCOPED_TRACE("magma_connection_release_semaphore encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 8; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_release_semaphore;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &semaphore, 8); ptr += 8; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| } |
| |
| magma_status_t magma_connection_import_semaphore_enc(void *self , magma_connection_t connection, magma_handle_t semaphore_handle, magma_semaphore_t* semaphore_out, magma_semaphore_id_t* id_out) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_import_semaphore(connection:%lu, semaphore_handle:%u, semaphore_out:%p, id_out:%p)", connection, semaphore_handle, semaphore_out, id_out); |
| AEMU_SCOPED_TRACE("magma_connection_import_semaphore encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_semaphore_out = sizeof(magma_semaphore_t); |
| const unsigned int __size_id_out = sizeof(magma_semaphore_id_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 4 + 0 + 0 + 2*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_import_semaphore;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &semaphore_handle, 4); ptr += 4; |
| memcpy(ptr, &__size_semaphore_out, 4); ptr += 4; |
| memcpy(ptr, &__size_id_out, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| stream->readback(semaphore_out, __size_semaphore_out); |
| if (useChecksum) checksumCalculator->addBuffer(semaphore_out, __size_semaphore_out); |
| stream->readback(id_out, __size_id_out); |
| if (useChecksum) checksumCalculator->addBuffer(id_out, __size_id_out); |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_import_semaphore: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_connection_perform_buffer_op_enc(void *self , magma_connection_t connection, magma_buffer_t buffer, uint32_t options, uint64_t start_offset, uint64_t length) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_perform_buffer_op(connection:%lu, buffer:%lu, options:%u, start_offset:%lu, length:%lu)", connection, buffer, options, start_offset, length); |
| AEMU_SCOPED_TRACE("magma_connection_perform_buffer_op encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 8 + 4 + 8 + 8; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_perform_buffer_op;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &buffer, 8); ptr += 8; |
| memcpy(ptr, &options, 4); ptr += 4; |
| memcpy(ptr, &start_offset, 8); ptr += 8; |
| memcpy(ptr, &length, 8); ptr += 8; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_perform_buffer_op: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_connection_map_buffer_enc(void *self , magma_connection_t connection, uint64_t hw_va, magma_buffer_t buffer, uint64_t offset, uint64_t length, uint64_t map_flags) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_map_buffer(connection:%lu, hw_va:%lu, buffer:%lu, offset:%lu, length:%lu, map_flags:%lu)", connection, hw_va, buffer, offset, length, map_flags); |
| AEMU_SCOPED_TRACE("magma_connection_map_buffer encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 8 + 8 + 8 + 8 + 8; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_map_buffer;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &hw_va, 8); ptr += 8; |
| memcpy(ptr, &buffer, 8); ptr += 8; |
| memcpy(ptr, &offset, 8); ptr += 8; |
| memcpy(ptr, &length, 8); ptr += 8; |
| memcpy(ptr, &map_flags, 8); ptr += 8; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_map_buffer: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| void magma_connection_unmap_buffer_enc(void *self , magma_connection_t connection, uint64_t hw_va, magma_buffer_t buffer) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_unmap_buffer(connection:%lu, hw_va:%lu, buffer:%lu)", connection, hw_va, buffer); |
| AEMU_SCOPED_TRACE("magma_connection_unmap_buffer encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 8 + 8; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_unmap_buffer;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &hw_va, 8); ptr += 8; |
| memcpy(ptr, &buffer, 8); ptr += 8; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| } |
| |
| magma_status_t magma_connection_execute_command_enc(void *self , magma_connection_t connection, uint32_t context_id, magma_command_descriptor_t* descriptor) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_execute_command(connection:%lu, context_id:%u, descriptor:%p)", connection, context_id, descriptor); |
| AEMU_SCOPED_TRACE("magma_connection_execute_command encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_descriptor = sizeof(magma_command_descriptor_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 4 + __size_descriptor + 1*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_execute_command;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &context_id, 4); ptr += 4; |
| memcpy(ptr, &__size_descriptor, 4); ptr += 4; |
| memcpy(ptr, descriptor, __size_descriptor);ptr += __size_descriptor; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_execute_command: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_connection_execute_command_fudge_enc(void *self , magma_connection_t connection, uint32_t context_id, void* descriptor, uint64_t descriptor_size) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_execute_command_fudge(connection:%lu, context_id:%u, descriptor:%p, descriptor_size:%lu)", connection, context_id, descriptor, descriptor_size); |
| AEMU_SCOPED_TRACE("magma_connection_execute_command_fudge encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_descriptor = descriptor_size; |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 4 + __size_descriptor + 8 + 1*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_execute_command_fudge;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &context_id, 4); ptr += 4; |
| memcpy(ptr, &__size_descriptor, 4); ptr += 4; |
| memcpy(ptr, descriptor, __size_descriptor);ptr += __size_descriptor; |
| memcpy(ptr, &descriptor_size, 8); ptr += 8; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_execute_command_fudge: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_connection_execute_immediate_commands_enc(void *self , magma_connection_t connection, uint32_t context_id, uint64_t command_count, magma_inline_command_buffer_t* command_buffers) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_execute_immediate_commands(connection:%lu, context_id:%u, command_count:%lu, command_buffers:%p)", connection, context_id, command_count, command_buffers); |
| AEMU_SCOPED_TRACE("magma_connection_execute_immediate_commands encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_command_buffers = command_count * sizeof(magma_inline_command_buffer_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 4 + 8 + __size_command_buffers + 1*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_execute_immediate_commands;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &context_id, 4); ptr += 4; |
| memcpy(ptr, &command_count, 8); ptr += 8; |
| memcpy(ptr, &__size_command_buffers, 4); ptr += 4; |
| memcpy(ptr, command_buffers, __size_command_buffers);ptr += __size_command_buffers; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_execute_immediate_commands: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_connection_execute_immediate_commands_fudge_enc(void *self , magma_connection_t connection, uint32_t context_id, uint64_t command_count, void* command_buffers, uint64_t command_buffers_size, uint64_t* command_buffer_offsets) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_execute_immediate_commands_fudge(connection:%lu, context_id:%u, command_count:%lu, command_buffers:%p, command_buffers_size:%lu, command_buffer_offsets:%p)", connection, context_id, command_count, command_buffers, command_buffers_size, command_buffer_offsets); |
| AEMU_SCOPED_TRACE("magma_connection_execute_immediate_commands_fudge encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_command_buffers = command_buffers_size; |
| const unsigned int __size_command_buffer_offsets = command_count * sizeof(uint64_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 4 + 8 + __size_command_buffers + 8 + __size_command_buffer_offsets + 2*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_execute_immediate_commands_fudge;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &context_id, 4); ptr += 4; |
| memcpy(ptr, &command_count, 8); ptr += 8; |
| memcpy(ptr, &__size_command_buffers, 4); ptr += 4; |
| memcpy(ptr, command_buffers, __size_command_buffers);ptr += __size_command_buffers; |
| memcpy(ptr, &command_buffers_size, 8); ptr += 8; |
| memcpy(ptr, &__size_command_buffer_offsets, 4); ptr += 4; |
| memcpy(ptr, command_buffer_offsets, __size_command_buffer_offsets);ptr += __size_command_buffer_offsets; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_execute_immediate_commands_fudge: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_connection_flush_enc(void *self , magma_connection_t connection) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_flush(connection:%lu)", connection); |
| AEMU_SCOPED_TRACE("magma_connection_flush encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_flush;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_flush: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_handle_t magma_connection_get_notification_channel_handle_enc(void *self , magma_connection_t connection) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_get_notification_channel_handle(connection:%lu)", connection); |
| AEMU_SCOPED_TRACE("magma_connection_get_notification_channel_handle encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_get_notification_channel_handle;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_handle_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_get_notification_channel_handle: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_connection_read_notification_channel_enc(void *self , magma_connection_t connection, void* buffer, uint64_t buffer_size, uint64_t* buffer_size_out, magma_bool_t* more_data_out) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_read_notification_channel(connection:%lu, buffer:%p, buffer_size:%lu, buffer_size_out:%p, more_data_out:%p)", connection, buffer, buffer_size, buffer_size_out, more_data_out); |
| AEMU_SCOPED_TRACE("magma_connection_read_notification_channel encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_buffer = buffer_size; |
| const unsigned int __size_buffer_size_out = sizeof(uint64_t); |
| const unsigned int __size_more_data_out = sizeof(magma_bool_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 0 + 8 + 0 + 0 + 3*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_read_notification_channel;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &__size_buffer, 4); ptr += 4; |
| memcpy(ptr, &buffer_size, 8); ptr += 8; |
| memcpy(ptr, &__size_buffer_size_out, 4); ptr += 4; |
| memcpy(ptr, &__size_more_data_out, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| stream->readback(buffer, __size_buffer); |
| if (useChecksum) checksumCalculator->addBuffer(buffer, __size_buffer); |
| stream->readback(buffer_size_out, __size_buffer_size_out); |
| if (useChecksum) checksumCalculator->addBuffer(buffer_size_out, __size_buffer_size_out); |
| stream->readback(more_data_out, __size_more_data_out); |
| if (useChecksum) checksumCalculator->addBuffer(more_data_out, __size_more_data_out); |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_read_notification_channel: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_buffer_clean_cache_enc(void *self , magma_buffer_t buffer, uint64_t offset, uint64_t size, magma_cache_operation_t operation) |
| { |
| ENCODER_DEBUG_LOG("magma_buffer_clean_cache(buffer:%lu, offset:%lu, size:%lu, operation:%u)", buffer, offset, size, operation); |
| AEMU_SCOPED_TRACE("magma_buffer_clean_cache encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 8 + 8 + 4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_buffer_clean_cache;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &buffer, 8); ptr += 8; |
| memcpy(ptr, &offset, 8); ptr += 8; |
| memcpy(ptr, &size, 8); ptr += 8; |
| memcpy(ptr, &operation, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_buffer_clean_cache: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_buffer_set_cache_policy_enc(void *self , magma_buffer_t buffer, magma_cache_policy_t policy) |
| { |
| ENCODER_DEBUG_LOG("magma_buffer_set_cache_policy(buffer:%lu, policy:%u)", buffer, policy); |
| AEMU_SCOPED_TRACE("magma_buffer_set_cache_policy encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_buffer_set_cache_policy;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &buffer, 8); ptr += 8; |
| memcpy(ptr, &policy, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_buffer_set_cache_policy: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_buffer_get_cache_policy_enc(void *self , magma_buffer_t buffer, magma_cache_policy_t* cache_policy_out) |
| { |
| ENCODER_DEBUG_LOG("magma_buffer_get_cache_policy(buffer:%lu, cache_policy_out:%p)", buffer, cache_policy_out); |
| AEMU_SCOPED_TRACE("magma_buffer_get_cache_policy encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_cache_policy_out = sizeof(magma_cache_policy_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 0 + 1*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_buffer_get_cache_policy;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &buffer, 8); ptr += 8; |
| memcpy(ptr, &__size_cache_policy_out, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| stream->readback(cache_policy_out, __size_cache_policy_out); |
| if (useChecksum) checksumCalculator->addBuffer(cache_policy_out, __size_cache_policy_out); |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_buffer_get_cache_policy: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_buffer_set_name_enc(void *self , magma_buffer_t buffer, const char* name) |
| { |
| ENCODER_DEBUG_LOG("magma_buffer_set_name(buffer:%lu, name:%p)", buffer, name); |
| AEMU_SCOPED_TRACE("magma_buffer_set_name encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_name = 1; |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + __size_name + 1*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_buffer_set_name;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &buffer, 8); ptr += 8; |
| memcpy(ptr, &__size_name, 4); ptr += 4; |
| memcpy(ptr, name, __size_name);ptr += __size_name; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_buffer_set_name: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_buffer_set_name_fudge_enc(void *self , magma_buffer_t buffer, void* name, uint64_t name_size) |
| { |
| ENCODER_DEBUG_LOG("magma_buffer_set_name_fudge(buffer:%lu, name:%p, name_size:%lu)", buffer, name, name_size); |
| AEMU_SCOPED_TRACE("magma_buffer_set_name_fudge encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_name = name_size; |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + __size_name + 8 + 1*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_buffer_set_name_fudge;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &buffer, 8); ptr += 8; |
| memcpy(ptr, &__size_name, 4); ptr += 4; |
| memcpy(ptr, name, __size_name);ptr += __size_name; |
| memcpy(ptr, &name_size, 8); ptr += 8; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_buffer_set_name_fudge: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_buffer_get_info_enc(void *self , magma_buffer_t buffer, magma_buffer_info_t* info_out) |
| { |
| ENCODER_DEBUG_LOG("magma_buffer_get_info(buffer:%lu, info_out:%p)", buffer, info_out); |
| AEMU_SCOPED_TRACE("magma_buffer_get_info encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_info_out = sizeof(magma_buffer_info); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 0 + 1*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_buffer_get_info;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &buffer, 8); ptr += 8; |
| memcpy(ptr, &__size_info_out, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| stream->readback(info_out, __size_info_out); |
| if (useChecksum) checksumCalculator->addBuffer(info_out, __size_info_out); |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_buffer_get_info: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_buffer_get_handle_enc(void *self , magma_buffer_t buffer, magma_handle_t* handle_out) |
| { |
| ENCODER_DEBUG_LOG("magma_buffer_get_handle(buffer:%lu, handle_out:%p)", buffer, handle_out); |
| AEMU_SCOPED_TRACE("magma_buffer_get_handle encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_handle_out = sizeof(magma_handle_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 0 + 1*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_buffer_get_handle;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &buffer, 8); ptr += 8; |
| memcpy(ptr, &__size_handle_out, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| stream->readback(handle_out, __size_handle_out); |
| if (useChecksum) checksumCalculator->addBuffer(handle_out, __size_handle_out); |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_buffer_get_handle: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_buffer_export_enc(void *self , magma_buffer_t buffer, magma_handle_t* buffer_handle_out) |
| { |
| ENCODER_DEBUG_LOG("magma_buffer_export(buffer:%lu, buffer_handle_out:%p)", buffer, buffer_handle_out); |
| AEMU_SCOPED_TRACE("magma_buffer_export encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_buffer_handle_out = sizeof(magma_handle_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 0 + 1*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_buffer_export;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &buffer, 8); ptr += 8; |
| memcpy(ptr, &__size_buffer_handle_out, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| stream->readback(buffer_handle_out, __size_buffer_handle_out); |
| if (useChecksum) checksumCalculator->addBuffer(buffer_handle_out, __size_buffer_handle_out); |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_buffer_export: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| void magma_semaphore_signal_enc(void *self , magma_semaphore_t semaphore) |
| { |
| ENCODER_DEBUG_LOG("magma_semaphore_signal(semaphore:%lu)", semaphore); |
| AEMU_SCOPED_TRACE("magma_semaphore_signal encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_semaphore_signal;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &semaphore, 8); ptr += 8; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| } |
| |
| void magma_semaphore_reset_enc(void *self , magma_semaphore_t semaphore) |
| { |
| ENCODER_DEBUG_LOG("magma_semaphore_reset(semaphore:%lu)", semaphore); |
| AEMU_SCOPED_TRACE("magma_semaphore_reset encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_semaphore_reset;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &semaphore, 8); ptr += 8; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| } |
| |
| magma_status_t magma_semaphore_export_enc(void *self , magma_semaphore_t semaphore, magma_handle_t* semaphore_handle_out) |
| { |
| ENCODER_DEBUG_LOG("magma_semaphore_export(semaphore:%lu, semaphore_handle_out:%p)", semaphore, semaphore_handle_out); |
| AEMU_SCOPED_TRACE("magma_semaphore_export encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_semaphore_handle_out = sizeof(magma_handle_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 0 + 1*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_semaphore_export;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &semaphore, 8); ptr += 8; |
| memcpy(ptr, &__size_semaphore_handle_out, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| stream->readback(semaphore_handle_out, __size_semaphore_handle_out); |
| if (useChecksum) checksumCalculator->addBuffer(semaphore_handle_out, __size_semaphore_handle_out); |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_semaphore_export: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_poll_enc(void *self , magma_poll_item_t* items, uint32_t count, uint64_t timeout_ns) |
| { |
| ENCODER_DEBUG_LOG("magma_poll(items:%p, count:%u, timeout_ns:%lu)", items, count, timeout_ns); |
| AEMU_SCOPED_TRACE("magma_poll encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_items = count * sizeof(magma_poll_item_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + __size_items + 4 + 8 + 1*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_poll;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &__size_items, 4); ptr += 4; |
| memcpy(ptr, items, __size_items);ptr += __size_items; |
| memcpy(ptr, &count, 4); ptr += 4; |
| memcpy(ptr, &timeout_ns, 8); ptr += 8; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| stream->readback(items, __size_items); |
| if (useChecksum) checksumCalculator->addBuffer(items, __size_items); |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_poll: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_initialize_tracing_enc(void *self , magma_handle_t channel) |
| { |
| ENCODER_DEBUG_LOG("magma_initialize_tracing(channel:%u)", channel); |
| AEMU_SCOPED_TRACE("magma_initialize_tracing encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_initialize_tracing;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &channel, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_initialize_tracing: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_initialize_logging_enc(void *self , magma_handle_t channel) |
| { |
| ENCODER_DEBUG_LOG("magma_initialize_logging(channel:%u)", channel); |
| AEMU_SCOPED_TRACE("magma_initialize_logging encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_initialize_logging;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &channel, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_initialize_logging: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_connection_enable_performance_counter_access_enc(void *self , magma_connection_t connection, magma_handle_t channel) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_enable_performance_counter_access(connection:%lu, channel:%u)", connection, channel); |
| AEMU_SCOPED_TRACE("magma_connection_enable_performance_counter_access encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_enable_performance_counter_access;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &channel, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_enable_performance_counter_access: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_connection_enable_performance_counters_enc(void *self , magma_connection_t connection, uint64_t* counters, uint64_t counters_count) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_enable_performance_counters(connection:%lu, counters:%p, counters_count:%lu)", connection, counters, counters_count); |
| AEMU_SCOPED_TRACE("magma_connection_enable_performance_counters encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_counters = counters_count * sizeof(uint64_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + __size_counters + 8 + 1*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_enable_performance_counters;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &__size_counters, 4); ptr += 4; |
| memcpy(ptr, counters, __size_counters);ptr += __size_counters; |
| memcpy(ptr, &counters_count, 8); ptr += 8; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_enable_performance_counters: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_connection_create_performance_counter_buffer_pool_enc(void *self , magma_connection_t connection, magma_perf_count_pool_t* pool_id_out, magma_handle_t* notification_handle_out) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_create_performance_counter_buffer_pool(connection:%lu, pool_id_out:%p, notification_handle_out:%p)", connection, pool_id_out, notification_handle_out); |
| AEMU_SCOPED_TRACE("magma_connection_create_performance_counter_buffer_pool encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_pool_id_out = sizeof(magma_perf_count_pool_t); |
| const unsigned int __size_notification_handle_out = sizeof(magma_handle_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 0 + 0 + 2*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_create_performance_counter_buffer_pool;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &__size_pool_id_out, 4); ptr += 4; |
| memcpy(ptr, &__size_notification_handle_out, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| stream->readback(pool_id_out, __size_pool_id_out); |
| if (useChecksum) checksumCalculator->addBuffer(pool_id_out, __size_pool_id_out); |
| stream->readback(notification_handle_out, __size_notification_handle_out); |
| if (useChecksum) checksumCalculator->addBuffer(notification_handle_out, __size_notification_handle_out); |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_create_performance_counter_buffer_pool: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_connection_release_performance_counter_buffer_pool_enc(void *self , magma_connection_t connection, magma_perf_count_pool_t pool_id) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_release_performance_counter_buffer_pool(connection:%lu, pool_id:%lu)", connection, pool_id); |
| AEMU_SCOPED_TRACE("magma_connection_release_performance_counter_buffer_pool encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 8; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_release_performance_counter_buffer_pool;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &pool_id, 8); ptr += 8; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_release_performance_counter_buffer_pool: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_connection_add_performance_counter_buffer_offsets_to_pool_enc(void *self , magma_connection_t connection, magma_perf_count_pool_t pool_id, const magma_buffer_offset_t* offsets, uint64_t offsets_count) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_add_performance_counter_buffer_offsets_to_pool(connection:%lu, pool_id:%lu, offsets:%p, offsets_count:%lu)", connection, pool_id, offsets, offsets_count); |
| AEMU_SCOPED_TRACE("magma_connection_add_performance_counter_buffer_offsets_to_pool encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_offsets = offsets_count * sizeof(magma_buffer_offset_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 8 + __size_offsets + 8 + 1*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_add_performance_counter_buffer_offsets_to_pool;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &pool_id, 8); ptr += 8; |
| memcpy(ptr, &__size_offsets, 4); ptr += 4; |
| memcpy(ptr, offsets, __size_offsets);ptr += __size_offsets; |
| memcpy(ptr, &offsets_count, 8); ptr += 8; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_add_performance_counter_buffer_offsets_to_pool: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_connection_remove_performance_counter_buffer_from_pool_enc(void *self , magma_connection_t connection, magma_perf_count_pool_t pool_id, magma_buffer_t buffer) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_remove_performance_counter_buffer_from_pool(connection:%lu, pool_id:%lu, buffer:%lu)", connection, pool_id, buffer); |
| AEMU_SCOPED_TRACE("magma_connection_remove_performance_counter_buffer_from_pool encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 8 + 8; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_remove_performance_counter_buffer_from_pool;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &pool_id, 8); ptr += 8; |
| memcpy(ptr, &buffer, 8); ptr += 8; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_remove_performance_counter_buffer_from_pool: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_connection_dump_performance_counters_enc(void *self , magma_connection_t connection, magma_perf_count_pool_t pool_id, uint32_t trigger_id) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_dump_performance_counters(connection:%lu, pool_id:%lu, trigger_id:%u)", connection, pool_id, trigger_id); |
| AEMU_SCOPED_TRACE("magma_connection_dump_performance_counters encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 8 + 4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_dump_performance_counters;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &pool_id, 8); ptr += 8; |
| memcpy(ptr, &trigger_id, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_dump_performance_counters: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_connection_clear_performance_counters_enc(void *self , magma_connection_t connection, uint64_t* counters, uint64_t counters_count) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_clear_performance_counters(connection:%lu, counters:%p, counters_count:%lu)", connection, counters, counters_count); |
| AEMU_SCOPED_TRACE("magma_connection_clear_performance_counters encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_counters = counters_count * sizeof(uint64_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + __size_counters + 8 + 1*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_clear_performance_counters;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &__size_counters, 4); ptr += 4; |
| memcpy(ptr, counters, __size_counters);ptr += __size_counters; |
| memcpy(ptr, &counters_count, 8); ptr += 8; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_clear_performance_counters: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_connection_read_performance_counter_completion_enc(void *self , magma_connection_t connection, magma_perf_count_pool_t pool_id, uint32_t* trigger_id_out, uint64_t* buffer_id_out, uint32_t* buffer_offset_out, uint64_t* time_out, uint32_t* result_flags_out) |
| { |
| ENCODER_DEBUG_LOG("magma_connection_read_performance_counter_completion(connection:%lu, pool_id:%lu, trigger_id_out:%p, buffer_id_out:%p, buffer_offset_out:%p, time_out:%p, result_flags_out:%p)", connection, pool_id, trigger_id_out, buffer_id_out, buffer_offset_out, time_out, result_flags_out); |
| AEMU_SCOPED_TRACE("magma_connection_read_performance_counter_completion encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_trigger_id_out = sizeof(uint32_t); |
| const unsigned int __size_buffer_id_out = sizeof(uint64_t); |
| const unsigned int __size_buffer_offset_out = sizeof(uint32_t); |
| const unsigned int __size_time_out = sizeof(uint64_t); |
| const unsigned int __size_result_flags_out = sizeof(uint32_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 8 + 0 + 0 + 0 + 0 + 0 + 5*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_connection_read_performance_counter_completion;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &pool_id, 8); ptr += 8; |
| memcpy(ptr, &__size_trigger_id_out, 4); ptr += 4; |
| memcpy(ptr, &__size_buffer_id_out, 4); ptr += 4; |
| memcpy(ptr, &__size_buffer_offset_out, 4); ptr += 4; |
| memcpy(ptr, &__size_time_out, 4); ptr += 4; |
| memcpy(ptr, &__size_result_flags_out, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| stream->readback(trigger_id_out, __size_trigger_id_out); |
| if (useChecksum) checksumCalculator->addBuffer(trigger_id_out, __size_trigger_id_out); |
| stream->readback(buffer_id_out, __size_buffer_id_out); |
| if (useChecksum) checksumCalculator->addBuffer(buffer_id_out, __size_buffer_id_out); |
| stream->readback(buffer_offset_out, __size_buffer_offset_out); |
| if (useChecksum) checksumCalculator->addBuffer(buffer_offset_out, __size_buffer_offset_out); |
| stream->readback(time_out, __size_time_out); |
| if (useChecksum) checksumCalculator->addBuffer(time_out, __size_time_out); |
| stream->readback(result_flags_out, __size_result_flags_out); |
| if (useChecksum) checksumCalculator->addBuffer(result_flags_out, __size_result_flags_out); |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_connection_read_performance_counter_completion: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_virt_connection_create_image_enc(void *self , magma_connection_t connection, magma_image_create_info_t* create_info, uint64_t* size_out, magma_buffer_t* image_out, magma_buffer_id_t* buffer_id_out) |
| { |
| ENCODER_DEBUG_LOG("magma_virt_connection_create_image(connection:%lu, create_info:%p, size_out:%p, image_out:%p, buffer_id_out:%p)", connection, create_info, size_out, image_out, buffer_id_out); |
| AEMU_SCOPED_TRACE("magma_virt_connection_create_image encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_create_info = sizeof(magma_image_create_info_t); |
| const unsigned int __size_size_out = sizeof(uint64_t); |
| const unsigned int __size_image_out = sizeof(magma_buffer_t); |
| const unsigned int __size_buffer_id_out = sizeof(magma_buffer_id_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + __size_create_info + 0 + 0 + 0 + 4*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_virt_connection_create_image;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &__size_create_info, 4); ptr += 4; |
| memcpy(ptr, create_info, __size_create_info);ptr += __size_create_info; |
| memcpy(ptr, &__size_size_out, 4); ptr += 4; |
| memcpy(ptr, &__size_image_out, 4); ptr += 4; |
| memcpy(ptr, &__size_buffer_id_out, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| stream->readback(size_out, __size_size_out); |
| if (useChecksum) checksumCalculator->addBuffer(size_out, __size_size_out); |
| stream->readback(image_out, __size_image_out); |
| if (useChecksum) checksumCalculator->addBuffer(image_out, __size_image_out); |
| stream->readback(buffer_id_out, __size_buffer_id_out); |
| if (useChecksum) checksumCalculator->addBuffer(buffer_id_out, __size_buffer_id_out); |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_virt_connection_create_image: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| magma_status_t magma_virt_connection_get_image_info_enc(void *self , magma_connection_t connection, magma_buffer_t image, magma_image_info_t* image_info_out) |
| { |
| ENCODER_DEBUG_LOG("magma_virt_connection_get_image_info(connection:%lu, image:%lu, image_info_out:%p)", connection, image, image_info_out); |
| AEMU_SCOPED_TRACE("magma_virt_connection_get_image_info encode"); |
| |
| magma_encoder_context_t *ctx = (magma_encoder_context_t *)self; |
| IOStream *stream = ctx->m_stream; |
| gfxstream::guest::ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; |
| bool useChecksum = checksumCalculator->getVersion() > 0; |
| |
| const unsigned int __size_image_info_out = sizeof(magma_image_info_t); |
| unsigned char *ptr; |
| unsigned char *buf; |
| const size_t sizeWithoutChecksum = 8 + 8 + 8 + 0 + 1*4; |
| const size_t checksumSize = checksumCalculator->checksumByteSize(); |
| const size_t totalSize = sizeWithoutChecksum + checksumSize; |
| buf = stream->alloc(totalSize); |
| ptr = buf; |
| int tmp = OP_magma_virt_connection_get_image_info;memcpy(ptr, &tmp, 4); ptr += 4; |
| memcpy(ptr, &totalSize, 4); ptr += 4; |
| |
| memcpy(ptr, &connection, 8); ptr += 8; |
| memcpy(ptr, &image, 8); ptr += 8; |
| memcpy(ptr, &__size_image_info_out, 4); ptr += 4; |
| |
| if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); |
| if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; |
| |
| stream->readback(image_info_out, __size_image_info_out); |
| if (useChecksum) checksumCalculator->addBuffer(image_info_out, __size_image_info_out); |
| |
| magma_status_t retval; |
| stream->readback(&retval, 4); |
| if (useChecksum) checksumCalculator->addBuffer(&retval, 4); |
| if (useChecksum) { |
| unsigned char *checksumBufPtr = NULL; |
| unsigned char checksumBuf[gfxstream::guest::ChecksumCalculator::kMaxChecksumSize]; |
| if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; |
| stream->readback(checksumBufPtr, checksumSize); |
| if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { |
| ALOGE("magma_virt_connection_get_image_info: GL communication error, please report this issue to b.android.com.\n"); |
| abort(); |
| } |
| } |
| return retval; |
| } |
| |
| } // namespace |
| |
| magma_encoder_context_t::magma_encoder_context_t(IOStream *stream, ChecksumCalculator *checksumCalculator) |
| { |
| m_stream = stream; |
| m_checksumCalculator = checksumCalculator; |
| |
| this->magma_device_import = &magma_device_import_enc; |
| this->magma_device_release = &magma_device_release_enc; |
| this->magma_device_query = &magma_device_query_enc; |
| this->magma_device_query_fudge = &magma_device_query_fudge_enc; |
| this->magma_device_create_connection = &magma_device_create_connection_enc; |
| this->magma_connection_release = &magma_connection_release_enc; |
| this->magma_connection_get_error = &magma_connection_get_error_enc; |
| this->magma_connection_create_context = &magma_connection_create_context_enc; |
| this->magma_connection_release_context = &magma_connection_release_context_enc; |
| this->magma_connection_create_buffer = &magma_connection_create_buffer_enc; |
| this->magma_connection_release_buffer = &magma_connection_release_buffer_enc; |
| this->magma_connection_import_buffer = &magma_connection_import_buffer_enc; |
| this->magma_connection_create_semaphore = &magma_connection_create_semaphore_enc; |
| this->magma_connection_release_semaphore = &magma_connection_release_semaphore_enc; |
| this->magma_connection_import_semaphore = &magma_connection_import_semaphore_enc; |
| this->magma_connection_perform_buffer_op = &magma_connection_perform_buffer_op_enc; |
| this->magma_connection_map_buffer = &magma_connection_map_buffer_enc; |
| this->magma_connection_unmap_buffer = &magma_connection_unmap_buffer_enc; |
| this->magma_connection_execute_command = &magma_connection_execute_command_enc; |
| this->magma_connection_execute_command_fudge = &magma_connection_execute_command_fudge_enc; |
| this->magma_connection_execute_immediate_commands = &magma_connection_execute_immediate_commands_enc; |
| this->magma_connection_execute_immediate_commands_fudge = &magma_connection_execute_immediate_commands_fudge_enc; |
| this->magma_connection_flush = &magma_connection_flush_enc; |
| this->magma_connection_get_notification_channel_handle = &magma_connection_get_notification_channel_handle_enc; |
| this->magma_connection_read_notification_channel = &magma_connection_read_notification_channel_enc; |
| this->magma_buffer_clean_cache = &magma_buffer_clean_cache_enc; |
| this->magma_buffer_set_cache_policy = &magma_buffer_set_cache_policy_enc; |
| this->magma_buffer_get_cache_policy = &magma_buffer_get_cache_policy_enc; |
| this->magma_buffer_set_name = &magma_buffer_set_name_enc; |
| this->magma_buffer_set_name_fudge = &magma_buffer_set_name_fudge_enc; |
| this->magma_buffer_get_info = &magma_buffer_get_info_enc; |
| this->magma_buffer_get_handle = &magma_buffer_get_handle_enc; |
| this->magma_buffer_export = &magma_buffer_export_enc; |
| this->magma_semaphore_signal = &magma_semaphore_signal_enc; |
| this->magma_semaphore_reset = &magma_semaphore_reset_enc; |
| this->magma_semaphore_export = &magma_semaphore_export_enc; |
| this->magma_poll = &magma_poll_enc; |
| this->magma_initialize_tracing = &magma_initialize_tracing_enc; |
| this->magma_initialize_logging = &magma_initialize_logging_enc; |
| this->magma_connection_enable_performance_counter_access = &magma_connection_enable_performance_counter_access_enc; |
| this->magma_connection_enable_performance_counters = &magma_connection_enable_performance_counters_enc; |
| this->magma_connection_create_performance_counter_buffer_pool = &magma_connection_create_performance_counter_buffer_pool_enc; |
| this->magma_connection_release_performance_counter_buffer_pool = &magma_connection_release_performance_counter_buffer_pool_enc; |
| this->magma_connection_add_performance_counter_buffer_offsets_to_pool = &magma_connection_add_performance_counter_buffer_offsets_to_pool_enc; |
| this->magma_connection_remove_performance_counter_buffer_from_pool = &magma_connection_remove_performance_counter_buffer_from_pool_enc; |
| this->magma_connection_dump_performance_counters = &magma_connection_dump_performance_counters_enc; |
| this->magma_connection_clear_performance_counters = &magma_connection_clear_performance_counters_enc; |
| this->magma_connection_read_performance_counter_completion = &magma_connection_read_performance_counter_completion_enc; |
| this->magma_virt_connection_create_image = &magma_virt_connection_create_image_enc; |
| this->magma_virt_connection_get_image_info = &magma_virt_connection_get_image_info_enc; |
| } |
| |