This commit improves bound checking by more accurately calculating
the expected transfer size. This improvement is achieved in two ways:
1. Using the image level (layer_)stride when the (layer_)stride is 0,
which matches the interpretation we use for performing the actual
read/write.
2. Calculating the transfer size by using the exact end offset in
the image, instead of using multiples of whole image rows.
The increased accuracy increases safety, and also allows us to support
some transfers with explicit strides that were previously rejected (see
added test).
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
testvirgl_encode.c: In function »virgl_emit_shader_streamout«:
testvirgl_encode.c:219:21: warning: comparison between signed
and unsigned integer expressions [-Wsign-
compare]
for (i = 0; i < so_info->num_outputs; i++) {
^
testvirgl_encode.c: In function »virgl_encode_clear«:
testvirgl_encode.c:315:4: Warning: Dereferenzing a type-punned
pointer violates strict-aliasing-rules [-Wstrict-aliasing]
virgl_encoder_write_qword(ctx->cbuf, *(uint64_t *)&depth);
^~~~~~~~~~~~~~~~~~~~~~~~~
testvirgl_encode.c: In function »virgl_encoder_set_framebuffer_state«:
testvirgl_encode.c:329:18: warning: comparison between signed
and unsigned integer expressions [-Wsign-
compare]
for (i = 0; i < state->nr_cbufs; i++) {
^
testvirgl_encode.c: In function »virgl_encoder_create_vertex_elements«:
testvirgl_encode.c:362:18: warning: comparison between signed
and unsigned integer expressions [-Wsign-
compare]
for (i = 0; i < num_elements; i++) {
^
testvirgl_encode.c: In function »virgl_encoder_set_vertex_buffers«:
testvirgl_encode.c:377:18: warning: comparison between signed
and unsigned integer expressions [-Wsign-
compare]
for (i = 0; i < num_buffers; i++) {
^
testvirgl_encode.c: In function »virgl_encoder_inline_write«:
testvirgl_encode.c:531:26: warning: comparison between signed
and unsigned integer expressions [-Wsign-
compare]
for (layer = 0; layer < box->depth; layer++) {
^
testvirgl_encode.c:537:24: warning: comparison between signed
and unsigned integer expressions [-Wsign-
compare]
for (row = 0; row < box->height; row++) {
^
testvirgl_encode.c: In function »virgl_encoder_flush_frontbuffer«:
testvirgl_encode.c:566:59: Warning: unused parameter »ctx« [-Wunused-
parameter]
int virgl_encoder_flush_frontbuffer(struct virgl_context *ctx,
^~~
testvirgl_encode.c:567:59: Warning: unused parameter »res« [-Wunused-
parameter]
struct virgl_resource *res)
^~~
testvirgl_encode.c: In function »virgl_encode_set_sampler_views«:
testvirgl_encode.c:637:18: warning: comparison between signed
and unsigned integer expressions [-Wsign-
compare]
for (i = 0; i < num_views; i++) {
^
testvirgl_encode.c: In function »virgl_encode_bind_sampler_states«:
testvirgl_encode.c:654:18: warning: comparison between signed
and unsigned integer expressions [-Wsign-
compare]
for (i = 0; i < num_handles; i++)
^
testvirgl_encode.c: In function »virgl_encoder_set_so_targets«:
testvirgl_encode.c:872:18: warning: comparison between signed
and unsigned integer expressions [-Wsign-
compare]
for (i = 0; i < num_targets; i++) {
v2: - use mesa style UNUSED annotation of unused parameters
- correct language of warning messages
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>