vkr: format with clang-format

clang-format insists on using .clang-format.  This commit adds
docs/vkr-clang-format as a doc.  To use it,

  $ cd src
  $ ln -sf ../docs/vkr-clang-format .clang-format
  $ clang-format -style file -i vkr_*

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
macos/master
Chia-I Wu 4 years ago
parent 5e2d10463d
commit f4861ea251
  1. 32
      docs/vkr-clang-format
  2. 12
      src/vkr_cs.c
  3. 20
      src/vkr_cs.h
  4. 1615
      src/vkr_renderer.c
  5. 7
      src/vkr_renderer.h
  6. 8
      src/vkr_ring.c

@ -0,0 +1,32 @@
BasedOnStyle: LLVM
AlwaysBreakAfterReturnType: TopLevel
BinPackParameters: false
BraceWrapping:
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterStruct: false
BeforeElse: false
SplitEmptyFunction: true
BreakBeforeBraces: Custom
ColumnLimit: 90
ContinuationIndentWidth: 3
Cpp11BracedListStyle: false
ForEachMacros:
- LIST_FOR_EACH_ENTRY
- LIST_FOR_EACH_ENTRY_SAFE
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^"config.h"$'
Priority: 0
- Regex: '^"vkr_'
Priority: 3
- Regex: '^"(virgl|vrend_|c11/|util/|os/|pipe/|venus-protocol/)'
Priority: 2
- Regex: '.*'
Priority: 1
IndentWidth: 3
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyExcessCharacter: 100
SpaceAfterCStyleCast: false
SpaceBeforeCpp11BracedList: false

@ -6,7 +6,6 @@
#include "vkr_cs.h"
#include "util/u_memory.h"
#include "vrend_iov.h"
void
@ -88,8 +87,8 @@ vkr_cs_encoder_seek_stream(struct vkr_cs_encoder *enc, size_t pos)
const size_t offset = enc->stream.offset + pos;
int iov_index;
size_t iov_offset;
if (pos > enc->stream.size || !vkr_cs_encoder_translate_stream_offset(
enc, offset, &iov_index, &iov_offset)) {
if (pos > enc->stream.size ||
!vkr_cs_encoder_translate_stream_offset(enc, offset, &iov_index, &iov_offset)) {
vkr_cs_encoder_set_fatal(enc);
return;
}
@ -118,9 +117,7 @@ vkr_cs_encoder_next_iov(struct vkr_cs_encoder *enc)
}
static uint8_t *
vkr_cs_encoder_get_ptr(struct vkr_cs_encoder *enc,
size_t size,
size_t *ptr_size)
vkr_cs_encoder_get_ptr(struct vkr_cs_encoder *enc, size_t size, size_t *ptr_size)
{
while (true) {
uint8_t *ptr = enc->cur;
@ -330,8 +327,7 @@ vkr_cs_decoder_alloc_temp_internal(struct vkr_cs_decoder *dec, size_t size)
}
const size_t cur_buf_size =
pool->buffer_count ? pool->end - pool->buffers[pool->buffer_count - 1]
: 0;
pool->buffer_count ? pool->end - pool->buffers[pool->buffer_count - 1] : 0;
const size_t buf_size = next_buffer_size(cur_buf_size, 4096, size);
if (!buf_size)
return false;

@ -140,9 +140,7 @@ vkr_cs_decoder_get_fatal(const struct vkr_cs_decoder *dec)
}
static inline void
vkr_cs_decoder_set_stream(struct vkr_cs_decoder *dec,
const void *data,
size_t size)
vkr_cs_decoder_set_stream(struct vkr_cs_decoder *dec, const void *data, size_t size)
{
dec->cur = data;
dec->end = dec->cur + size;
@ -180,10 +178,7 @@ vkr_cs_decoder_peek_internal(const struct vkr_cs_decoder *dec,
}
static inline void
vkr_cs_decoder_read(struct vkr_cs_decoder *dec,
size_t size,
void *val,
size_t val_size)
vkr_cs_decoder_read(struct vkr_cs_decoder *dec, size_t size, void *val, size_t val_size)
{
if (vkr_cs_decoder_peek_internal(dec, size, val, val_size))
dec->cur += size;
@ -199,16 +194,14 @@ vkr_cs_decoder_peek(const struct vkr_cs_decoder *dec,
}
static inline struct vkr_object *
vkr_cs_decoder_lookup_object(const struct vkr_cs_decoder *dec,
vkr_object_id id)
vkr_cs_decoder_lookup_object(const struct vkr_cs_decoder *dec, vkr_object_id id)
{
struct vkr_object *obj;
if (!id)
return NULL;
obj = util_hash_table_get_u64(
(struct util_hash_table_u64 *)dec->object_table, id);
obj = util_hash_table_get_u64((struct util_hash_table_u64 *)dec->object_table, id);
if (!obj)
vkr_cs_decoder_set_fatal(dec);
@ -278,9 +271,8 @@ vkr_cs_handle_load_id(const void **handle, VkObjectType type)
static inline void
vkr_cs_handle_store_id(void **handle, vkr_object_id id, VkObjectType type)
{
vkr_object_id *p = vkr_cs_handle_indirect_id(type)
? *(vkr_object_id **)handle
: (vkr_object_id *)handle;
vkr_object_id *p = vkr_cs_handle_indirect_id(type) ? *(vkr_object_id **)handle
: (vkr_object_id *)handle;
*p = id;
}

File diff suppressed because it is too large Load Diff

@ -13,8 +13,8 @@
#include "os/os_misc.h"
#define VKR_RENDERER_THREAD_SYNC (1u << 0)
#define VKR_RENDERER_MULTI_PROCESS (1u << 1)
#define VKR_RENDERER_THREAD_SYNC (1u << 0)
#define VKR_RENDERER_MULTI_PROCESS (1u << 1)
struct virgl_context;
@ -63,8 +63,7 @@ vkr_get_capset(UNUSED void *capset)
}
static inline struct virgl_context *
vkr_context_create(UNUSED size_t debug_len,
UNUSED const char *debug_name)
vkr_context_create(UNUSED size_t debug_len, UNUSED const char *debug_name)
{
return NULL;
}

@ -11,7 +11,6 @@
#include <time.h>
#include "util/u_math.h"
#include "virgl_context.h"
enum vkr_ring_status_flag {
@ -71,8 +70,8 @@ vkr_ring_create(const struct vkr_ring_layout *layout,
if (!ring)
return NULL;
#define ring_attach_shared(member) \
ring->shared.member = (void *)((uint8_t *)shared + layout->member##_offset)
#define ring_attach_shared(member) \
ring->shared.member = (void *)((uint8_t *)shared + layout->member##_offset)
ring_attach_shared(head);
ring_attach_shared(tail);
ring_attach_shared(status);
@ -260,8 +259,7 @@ vkr_ring_write_extra(struct vkr_ring *ring, size_t offset, uint32_t val)
if (offset > ring->extra_size || sizeof(val) > ring->extra_size - offset)
return false;
volatile atomic_uint *dst =
(void *)((uint8_t *)ring->shared.extra + offset);
volatile atomic_uint *dst = (void *)((uint8_t *)ring->shared.extra + offset);
atomic_store_explicit(dst, val, memory_order_release);
return true;

Loading…
Cancel
Save