Refactoring of *_fill libraries
Subsystems (2)
cover Refactoring of *_fill libraries
This series is removing duplications in gpgpu_fill and media_fill libraries. As a first step I moved gpgpu and media helper functions to gpu_fill library. In second patch I adjusted code to our coding style. In the third not obvious duplications were removed (like adding in gen7 functions conditions for future gens). Last patch adds missing parameters that make GPU hang on gen9 and gen9+.
In first version of this series there was a comment about moving batch_alloc/copy etc. functions to intel_batchbuffer library. Because there is a lot of code to review already this change will be introduced in another series (rendercopy, media_fill, gpgpu_fill and media_spin code is affected by this).
It is possible that more changes around gen*_media.h and media_spin is needed, but this will be done as a next step.
v2: Removed not obvious duplications. Adjusted code to review comments.
Katarzyna Dec (4):
lib: Move common gpgpu/media functions to gpu_fill library
lib: Adjust refactored gpu_fill library to our coding style
lib: Removing duplications in gpu_fill library lib/gpgpu_fill: Add missing configuration parameters for gpgpu_fill
lib/Makefile.sources | 3 +- lib/gpgpu_fill.c | 609 ++------------------------------------------ lib/gpgpu_fill.h | 18 +- lib/gpu_fill.c | 659 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/gpu_fill.h | 123 +++++++++ lib/intel_batchbuffer.c | 4 +- lib/intel_batchbuffer.h | 3 +- lib/media_fill.h | 33 +-- lib/media_fill_gen7.c | 288 +-------------------- lib/media_fill_gen8.c | 313 ++--------------------- lib/media_fill_gen8lp.c | 367 --------------------------- lib/media_fill_gen9.c | 339 ++----------------------- lib/meson.build | 2 +- tests/gem_gpgpu_fill.c | 2 +- tests/gem_media_fill.c | 2 +- 15 files changed, 886 insertions(+), 1879 deletions(-) create mode 100644 lib/gpu_fill.c create mode 100644 lib/gpu_fill.h delete mode 100644 lib/media_fill_gen8lp.c
Signature · 6 lines
2.14.3 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 1/4 lib: Move common gpgpu/media functions to gpu_fill library
Gpgpu_fill and media_fill libraries are very similar and many functions can be shared. I have created library gpu_fill with all functions needed for implementing gpgpu_fill and media_fill tests for all Gens. Duplicates, e.g. where only name was changed, were removed. The earliest common function remained.
v2: Changed code layout. GenX_fill_media_kernel was identical to genX_fill_gpgpu_kernel so this function was unified to gen7_fill_kernel. There were 2 very similar functions gen8_emit_state_base_address for media and gpgpu, where the one for gpgpu was configured like it would be using indirect state (while we are using CURBE). I have checked if media fill version works fine in gpgpu test on Gen8 and unified them.
--- lib/Makefile.sources | 2 + lib/gpgpu_fill.c | 567 +------------------------------------ lib/gpu_fill.c | 729 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/gpu_fill.h | 141 ++++++++++ lib/media_fill_gen7.c | 271 +----------------- lib/media_fill_gen8.c | 297 +------------------- lib/media_fill_gen8lp.c | 289 +------------------ lib/media_fill_gen9.c | 304 +------------------- lib/meson.build | 1 + 9 files changed, 890 insertions(+), 1711 deletions(-) create mode 100644 lib/gpu_fill.c create mode 100644 lib/gpu_fill.h
lib/Makefile.sources +2 -0
@@ -55,6 +55,8 @@ lib_source_list = \ intel_reg.h \ ioctl_wrappers.c \ ioctl_wrappers.h \ + gpu_fill.h \ + gpu_fill.c \ media_fill.h \ media_fill_gen7.c \ media_fill_gen8.c \
lib/gpgpu_fill.c +1 -566
579 lines not on this page · raw message
lib/gpu_fill.c new file +729 -0
729 lines not on this page · raw message
lib/gpu_fill.h new file +141 -0
141 lines not on this page · raw message
lib/media_fill_gen7.c +1 -270
283 lines not on this page · raw message
lib/media_fill_gen8.c +5 -292
320 lines not on this page · raw message
lib/media_fill_gen8lp.c +5 -284
312 lines not on this page · raw message
lib/media_fill_gen9.c +5 -299
329 lines not on this page · raw message
lib/meson.build +1 -0
@@ -24,6 +24,7 @@ lib_sources = [ 'intel_os.c', 'intel_mmio.c', 'ioctl_wrappers.c', + 'gpu_fill.c', 'media_fill_gen7.c', 'media_fill_gen8.c', 'media_fill_gen8lp.c',
Signature · 6 lines
2.14.3 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 1/4] lib: Move common gpgpu/media functions to gpu_fill library
Quoted 57 lines · Katarzyna Dec
Gpgpu_fillandmedia_filllibraries are very similar and many functions can be shared. I have created librarygpu_fillwith all functions needed for implementinggpgpu_fillandmedia_filltests for all Gens. Duplicates, e.g. where only name was changed, were removed. The earliest common function remained.v2: Changed code layout.
GenX_fill_media_kernelwas identical togenX_fill_gpgpu_kernelso this function was unified togen7_fill_kernel. There were 2 very similar functionsgen8_emit_state_base_addressfor media and gpgpu, where the one for gpgpu was configured like it would be using indirect state (while we are using CURBE). I have checked if media fill version works fine in gpgpu test on Gen8 and unified them.Signed-off-by Katarzyna Dec <[email protected]>Cc Lukasz Kalamarz <[email protected]>Cc Daniele Ceraolo Spurio <[email protected]>--- lib/Makefile.sources | 2 + lib/gpgpu_fill.c | 567 +------------------------------------ lib/gpu_fill.c | 729 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/gpu_fill.h | 141 ++++++++++ lib/media_fill_gen7.c | 271 +----------------- lib/media_fill_gen8.c | 297 +------------------- lib/media_fill_gen8lp.c | 289 +------------------ lib/media_fill_gen9.c | 304 +------------------- lib/meson.build | 1 + 9 files changed, 890 insertions(+), 1711 deletions(-)create mode 100644
lib/gpu_fill.c
create mode 100644lib/gpu_fill.hlib/Makefile.sources +2
-0@@ -55,6 +55,8 @@ lib_source_list = \ intel_reg.h \ ioctl_wrappers.c \ ioctl_wrappers.h \ + gpu_fill.h \ + gpu_fill.c \ media_fill.h \ media_fill_gen7.c \ media_fill_gen8.c \lib/gpgpu_fill.c +1
-0@@ -34,6 +34,7 @@#include "gen7_media.h" #include "gen8_media.h" #include "gpgpu_fill.h" +#include "gpu_fill.h" /* shaders/gpgpu/gpgpu_fill.gxa */ static const uint32_t gen7_gpgpu_kernel[][4 ] = {
lib/gpgpu_fill.c static const uint32_t gen9_gpgpu_kernel[][4] = { · line 83
Quoted 9 lines
lib/gpgpu_fill.c +0
-6@@ -75,572 +76,6 @@ static const uint32_t gen9_gpgpu_kernel[][4] = { { 0x07800031, 0x20000a40, 0x06000e00, 0x82000010 }, }; -static uint32_t -batch_used (struct intel_batchbuffer *batch) -{ -return batch->ptr - batch->buffer; -} -
Hi,
As I mentioned on the previous review I think that the batch_* functions shouldn't go to the gpu_fill.c file and should instead go with the other intel_batchbuffer methods. I don't think that moving it to gpu_fill.c as an interim solution works because we'll have to do another patch to move everything to intel_batchbuffer.c, including the other copies of the functions from the rendercopy files. It makes more sense IMO to move the code directly to its final destination. If Lukasz is going to look at that then please sync with him so that his patch goes before this one (either as part of this series or standalone).
Thanks,
Daniele
Quoted 2,725 lines
lib/gpgpu_fill.c +0
-560-static uint32_t -batch_align (struct intel_batchbuffer *batch,uint32_t align) -{ -uint32_t offset =batch_used (batch); - offset =ALIGN (offset, align); - batch->ptr = batch->buffer + offset; -return offset; -} - -static void * -batch_alloc (struct intel_batchbuffer *batch,uint32_t size,uint32_t align) -{ -uint32_t offset =batch_align (batch, align); - batch->ptr += size; -return memset (batch->buffer + offset,0 , size); -} - -static uint32_t -batch_offset (struct intel_batchbuffer *batch,void *ptr) -{ -return (uint8_t *)ptr - batch->buffer; -} - -static uint32_t -batch_copy (struct intel_batchbuffer *batch,const void *ptr,uint32_t size, -uint32_t align) -{ -return batch_offset (batch,memcpy (batch_alloc (batch, size, align), ptr, size)); -} - -static void -gen7_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end) -{ -int ret; - - ret =drm_intel_bo_subdata (batch->bo,0 ,4096 , batch->buffer); -if (ret ==0 ) - ret =drm_intel_bo_mrb_exec (batch->bo, batch_end, -NULL ,0 ,0 ,0 ); -igt_assert (ret ==0 ); -} - -static uint32_t -gen7_fill_curbe_buffer_data (struct intel_batchbuffer *batch,uint8_t color) -{ -uint8_t *curbe_buffer; -uint32_t offset; - - curbe_buffer =batch_alloc (batch,sizeof (uint32_t ) *8 ,64 ); - offset =batch_offset (batch, curbe_buffer); - *curbe_buffer = color; - -return offset; -} - -static uint32_t -gen7_fill_surface_state (struct intel_batchbuffer *batch, -struct igt_buf *buf, -uint32_t format, -int is_dst) -{ -struct gen7_surface_state *ss; -uint32_t write_domain, read_domain, offset; -int ret; - -if (is_dst) { - write_domain = read_domain =I915_GEM_DOMAIN_RENDER ; - }else { - write_domain =0 ; - read_domain =I915_GEM_DOMAIN_SAMPLER ; - } - - ss =batch_alloc (batch,sizeof (*ss),64 ); - offset =batch_offset (batch, ss); - - ss->ss0.surface_type =GEN7_SURFACE_2D ; - ss->ss0.surface_format = format; - ss->ss0.render_cache_read_write =1 ; - -if (buf->tiling ==I915_TILING_X ) - ss->ss0.tiled_mode =2 ; -else if (buf->tiling ==I915_TILING_Y ) - ss->ss0.tiled_mode =3 ; - - ss->ss1.base_addr = buf->bo->offset; - ret =drm_intel_bo_emit_reloc (batch->bo, -batch_offset (batch, ss) +4 , - buf->bo,0 , - read_domain, write_domain); -igt_assert (ret ==0 ); - - ss->ss2.height =igt_buf_height (buf) -1 ; - ss->ss2.width =igt_buf_width (buf) -1 ; - - ss->ss3.pitch = buf->stride -1 ; - - ss->ss7.shader_chanel_select_r =4 ; - ss->ss7.shader_chanel_select_g =5 ; - ss->ss7.shader_chanel_select_b =6 ; - ss->ss7.shader_chanel_select_a =7 ; - -return offset; -} - -static uint32_t -gen8_fill_surface_state (struct intel_batchbuffer *batch, -struct igt_buf *buf, -uint32_t format, -int is_dst) -{ -struct gen8_surface_state *ss; -uint32_t write_domain, read_domain, offset; -int ret; - -if (is_dst) { - write_domain = read_domain =I915_GEM_DOMAIN_RENDER ; - }else { - write_domain =0 ; - read_domain =I915_GEM_DOMAIN_SAMPLER ; - } - - ss =batch_alloc (batch,sizeof (*ss),64 ); - offset =batch_offset (batch, ss); - - ss->ss0.surface_type =GEN8_SURFACE_2D ; - ss->ss0.surface_format = format; - ss->ss0.render_cache_read_write =1 ; - ss->ss0.vertical_alignment =1 ;/* align 4 */ - ss->ss0.horizontal_alignment =1 ;/* align 4 */ - -if (buf->tiling ==I915_TILING_X ) - ss->ss0.tiled_mode =2 ; -else if (buf->tiling ==I915_TILING_Y ) - ss->ss0.tiled_mode =3 ; - - ss->ss8.base_addr = buf->bo->offset; - - ret =drm_intel_bo_emit_reloc (batch->bo, -batch_offset (batch, ss) +8 *4 , - buf->bo,0 , - read_domain, write_domain); -igt_assert_eq (ret,0 ); - - ss->ss2.height =igt_buf_height (buf) -1 ; - ss->ss2.width =igt_buf_width (buf) -1 ; - ss->ss3.pitch = buf->stride -1 ; - - ss->ss7.shader_chanel_select_r =4 ; - ss->ss7.shader_chanel_select_g =5 ; - ss->ss7.shader_chanel_select_b =6 ; - ss->ss7.shader_chanel_select_a =7 ; - -return offset; - -} - -static uint32_t -gen7_fill_binding_table (struct intel_batchbuffer *batch, -struct igt_buf *dst) -{ -uint32_t *binding_table, offset; - - binding_table =batch_alloc (batch,32 ,64 ); - offset =batch_offset (batch, binding_table); - - binding_table[0 ] =gen7_fill_surface_state (batch, dst,GEN7_SURFACEFORMAT_R8_UNORM ,1 ); - -return offset; -} - -static uint32_t -gen8_fill_binding_table (struct intel_batchbuffer *batch, -struct igt_buf *dst) -{ -uint32_t *binding_table, offset; - - binding_table =batch_alloc (batch,32 ,64 ); - offset =batch_offset (batch, binding_table); - - binding_table[0 ] =gen8_fill_surface_state (batch, dst,GEN8_SURFACEFORMAT_R8_UNORM ,1 ); - -return offset; -} - -static uint32_t -gen7_fill_gpgpu_kernel (struct intel_batchbuffer *batch, -const uint32_t kernel[][4 ], -size_t size) -{ -uint32_t offset; - - offset =batch_copy (batch, kernel, size,64 ); - -return offset; -} - -static uint32_t -gen7_fill_interface_descriptor (struct intel_batchbuffer *batch,struct igt_buf *dst, -const uint32_t kernel[][4 ],size_t size) -{ -struct gen7_interface_descriptor_data *idd; -uint32_t offset; -uint32_t binding_table_offset, kernel_offset; - - binding_table_offset =gen7_fill_binding_table (batch, dst); - kernel_offset =gen7_fill_gpgpu_kernel (batch, kernel, size); - - idd =batch_alloc (batch,sizeof (*idd),64 ); - offset =batch_offset (batch, idd); - - idd->desc0.kernel_start_pointer = (kernel_offset >>6 ); - - idd->desc1.single_program_flow =1 ; - idd->desc1.floating_point_mode =GEN7_FLOATING_POINT_IEEE_754 ; - - idd->desc2.sampler_count =0 ;/* 0 samplers used */ - idd->desc2.sampler_state_pointer =0 ; - - idd->desc3.binding_table_entry_count =0 ; - idd->desc3.binding_table_pointer = (binding_table_offset >>5 ); - - idd->desc4.constant_urb_entry_read_offset =0 ; - idd->desc4.constant_urb_entry_read_length =1 ;/* grf 1 */ - -return offset; -} - -static uint32_t -gen8_fill_interface_descriptor (struct intel_batchbuffer *batch,struct igt_buf *dst, -const uint32_t kernel[][4 ],size_t size) -{ -struct gen8_interface_descriptor_data *idd; -uint32_t offset; -uint32_t binding_table_offset, kernel_offset; - - binding_table_offset =gen8_fill_binding_table (batch, dst); - kernel_offset =gen7_fill_gpgpu_kernel (batch, kernel, size); - - idd =batch_alloc (batch,sizeof (*idd),64 ); - offset =batch_offset (batch, idd); - - idd->desc0.kernel_start_pointer = (kernel_offset >>6 ); - - idd->desc2.single_program_flow =1 ; - idd->desc2.floating_point_mode =GEN8_FLOATING_POINT_IEEE_754 ; - - idd->desc3.sampler_count =0 ;/* 0 samplers used */ - idd->desc3.sampler_state_pointer =0 ; - - idd->desc4.binding_table_entry_count =0 ; - idd->desc4.binding_table_pointer = (binding_table_offset >>5 ); - - idd->desc5.constant_urb_entry_read_offset =0 ; - idd->desc5.constant_urb_entry_read_length =1 ;/* grf 1 */ - -return offset; -} - -static void -gen7_emit_state_base_address (struct intel_batchbuffer *batch) -{ -OUT_BATCH (GEN7_STATE_BASE_ADDRESS | (10 -2 )); - -/* general */ -OUT_BATCH (0 ); - -/* surface */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_INSTRUCTION ,0 ,BASE_ADDRESS_MODIFY ); - -/* dynamic */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_INSTRUCTION ,0 ,BASE_ADDRESS_MODIFY ); - -/* indirect */ -OUT_BATCH (0 ); - -/* instruction */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_INSTRUCTION ,0 ,BASE_ADDRESS_MODIFY ); - -/* general/dynamic/indirect/instruction access Bound */ -OUT_BATCH (0 ); -OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); -OUT_BATCH (0 ); -OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); -} - -static void -gen8_emit_state_base_address (struct intel_batchbuffer *batch) -{ -OUT_BATCH (GEN8_STATE_BASE_ADDRESS | (16 -2 )); - -/* general */ -OUT_BATCH (0 | (0x78 <<4 ) | (0 <<1 ) |BASE_ADDRESS_MODIFY ); -OUT_BATCH (0 ); - -/* stateless data port */ -OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); - -/* surface */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_SAMPLER ,0 ,BASE_ADDRESS_MODIFY ); - -/* dynamic */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_RENDER |I915_GEM_DOMAIN_INSTRUCTION , -0 ,BASE_ADDRESS_MODIFY ); - -/* indirect */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* instruction */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_INSTRUCTION ,0 ,BASE_ADDRESS_MODIFY ); - -/* general state buffer size */ -OUT_BATCH (0xfffff000 |1 ); -/* dynamic state buffer size */ -OUT_BATCH (1 <<12 |1 ); -/* indirect object buffer size */ -OUT_BATCH (0xfffff000 |1 ); -/* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */ -OUT_BATCH (1 <<12 |1 ); -} - -static void -gen9_emit_state_base_address (struct intel_batchbuffer *batch) -{ -OUT_BATCH (GEN8_STATE_BASE_ADDRESS | (19 -2 )); - -/* general */ -OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); -OUT_BATCH (0 ); - -/* stateless data port */ -OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); - -/* surface */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_SAMPLER ,0 ,BASE_ADDRESS_MODIFY ); - -/* dynamic */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_RENDER |I915_GEM_DOMAIN_INSTRUCTION , -0 ,BASE_ADDRESS_MODIFY ); - -/* indirect */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* instruction */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_INSTRUCTION ,0 ,BASE_ADDRESS_MODIFY ); - -/* general state buffer size */ -OUT_BATCH (0xfffff000 |1 ); -/* dynamic state buffer size */ -OUT_BATCH (1 <<12 |1 ); -/* indirect object buffer size */ -OUT_BATCH (0xfffff000 |1 ); -/* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */ -OUT_BATCH (1 <<12 |1 ); - -/* Bindless surface state base address */ -OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); -OUT_BATCH (0 ); -OUT_BATCH (0xfffff000 ); -} - -static void -gen7_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch) -{ -OUT_BATCH (GEN7_MEDIA_VFE_STATE | (8 -2 )); - -/* scratch buffer */ -OUT_BATCH (0 ); - -/* number of threads & urb entries */ -OUT_BATCH (1 <<16 |/* max num of threads */ -0 <<8 |/* num of URB entry */ -1 <<2 );/* GPGPU mode */ - -OUT_BATCH (0 ); - -/* urb entry size & curbe size */ -OUT_BATCH (0 <<16 |/* URB entry size in 256 bits unit */ -1 );/* CURBE entry size in 256 bits unit */ - -/* scoreboard */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); -OUT_BATCH (0 ); -} - -static void -gen8_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch) -{ -OUT_BATCH (GEN8_MEDIA_VFE_STATE | (9 -2 )); - -/* scratch buffer */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* number of threads & urb entries */ -OUT_BATCH (1 <<16 |1 <<8 ); - -OUT_BATCH (0 ); - -/* urb entry size & curbe size */ -OUT_BATCH (0 <<16 |1 ); - -/* scoreboard */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); -OUT_BATCH (0 ); -} - -static void -gen7_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer) -{ -OUT_BATCH (GEN7_MEDIA_CURBE_LOAD | (4 -2 )); -OUT_BATCH (0 ); -/* curbe total data length */ -OUT_BATCH (64 ); -/* curbe data start address, is relative to the dynamics base address */ -OUT_BATCH (curbe_buffer); -} - -static void -gen7_emit_interface_descriptor_load (struct intel_batchbuffer *batch,uint32_t interface_descriptor) -{ -OUT_BATCH (GEN7_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 -2 )); -OUT_BATCH (0 ); -/* interface descriptor data length */ -OUT_BATCH (sizeof (struct gen7_interface_descriptor_data )); -/* interface descriptor address, is relative to the dynamics base address */ -OUT_BATCH (interface_descriptor); -} - -static void -gen8_emit_interface_descriptor_load (struct intel_batchbuffer *batch,uint32_t interface_descriptor) -{ -OUT_BATCH (GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 -2 )); -OUT_BATCH (0 ); -/* interface descriptor data length */ -OUT_BATCH (sizeof (struct gen8_interface_descriptor_data )); -/* interface descriptor address, is relative to the dynamics base address */ -OUT_BATCH (interface_descriptor); -} - -static void -gen7_emit_gpgpu_walk (struct intel_batchbuffer *batch, -unsigned x,unsigned y, -unsigned width,unsigned height) -{ -uint32_t x_dim, y_dim, tmp, right_mask; - -/* -* Simply do SIMD16 based dispatch, so every thread uses -* SIMD16 channels. -* -* Define our own thread group size, e.g 16x1 for every group, then -* will have 1 thread each group in SIMD16 dispatch. So thread -* width/height/depth are all 1. -* -* Then thread group X = width / 16 (aligned to 16) -* thread group Y = height; -*/ - x_dim = (width +15 ) /16 ; - y_dim = height; - - tmp = width &15 ; -if (tmp ==0 ) - right_mask = (1 <<16 ) -1 ; -else - right_mask = (1 << tmp) -1 ; - -OUT_BATCH (GEN7_GPGPU_WALKER |9 ); - -/* interface descriptor offset */ -OUT_BATCH (0 ); - -/* SIMD size, thread w/h/d */ -OUT_BATCH (1 <<30 |/* SIMD16 */ -0 <<16 |/* depth:1 */ -0 <<8 |/* height:1 */ -0 );/* width:1 */ - -/* thread group X */ -OUT_BATCH (0 ); -OUT_BATCH (x_dim); - -/* thread group Y */ -OUT_BATCH (0 ); -OUT_BATCH (y_dim); - -/* thread group Z */ -OUT_BATCH (0 ); -OUT_BATCH (1 ); - -/* right mask */ -OUT_BATCH (right_mask); - -/* bottom mask, height 1, always 0xffffffff */ -OUT_BATCH (0xffffffff ); -} - -static void -gen8_emit_gpgpu_walk (struct intel_batchbuffer *batch, -unsigned x,unsigned y, -unsigned width,unsigned height) -{ -uint32_t x_dim, y_dim, tmp, right_mask; - -/* -* Simply do SIMD16 based dispatch, so every thread uses -* SIMD16 channels. -* -* Define our own thread group size, e.g 16x1 for every group, then -* will have 1 thread each group in SIMD16 dispatch. So thread -* width/height/depth are all 1. -* -* Then thread group X = width / 16 (aligned to 16) -* thread group Y = height; -*/ - x_dim = (width +15 ) /16 ; - y_dim = height; - - tmp = width &15 ; -if (tmp ==0 ) - right_mask = (1 <<16 ) -1 ; -else - right_mask = (1 << tmp) -1 ; - -OUT_BATCH (GEN7_GPGPU_WALKER |13 ); - -OUT_BATCH (0 );/* kernel offset */ -OUT_BATCH (0 );/* indirect data length */ -OUT_BATCH (0 );/* indirect data offset */ - -/* SIMD size, thread w/h/d */ -OUT_BATCH (1 <<30 |/* SIMD16 */ -0 <<16 |/* depth:1 */ -0 <<8 |/* height:1 */ -0 );/* width:1 */ - -/* thread group X */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); -OUT_BATCH (x_dim); - -/* thread group Y */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); -OUT_BATCH (y_dim); - -/* thread group Z */ -OUT_BATCH (0 ); -OUT_BATCH (1 ); - -/* right mask */ -OUT_BATCH (right_mask); - -/* bottom mask, height 1, always 0xffffffff */ -OUT_BATCH (0xffffffff ); -} -/* * This sets up the gpgpu pipeline, * lib/gpu_fill.c new file +729
-0@@ -0,0 +1,729 @@ +#include <intel_bufmgr.h> +#include <i915_drm.h> + +#include "intel_reg.h" +#include "drmtest.h" +#include "gpu_fill.h" +#include <assert.h> +#include "gen7_media.h" +#include "gen8_media.h" + + +uint32_t +batch_used (struct intel_batchbuffer *batch) +{ +return batch->ptr - batch->buffer; +} + +uint32_t +batch_align (struct intel_batchbuffer *batch,uint32_t align) +{ +uint32_t offset =batch_used (batch); + offset =ALIGN (offset, align); + batch->ptr = batch->buffer + offset; +return offset; +} + +void * +batch_alloc (struct intel_batchbuffer *batch,uint32_t size,uint32_t align) +{ +uint32_t offset =batch_align (batch, align); + batch->ptr += size; +return memset (batch->buffer + offset,0 , size); +} + +uint32_t +batch_offset (struct intel_batchbuffer *batch,void *ptr) +{ +return (uint8_t *)ptr - batch->buffer; +} + +uint32_t +batch_copy (struct intel_batchbuffer *batch,const void *ptr,uint32_t size,uint32_t align) +{ +return batch_offset (batch,memcpy (batch_alloc (batch, size, align), ptr, size)); +} + +void +gen7_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end) +{ +int ret; + + ret =drm_intel_bo_subdata (batch->bo,0 ,4096 , batch->buffer); +if (ret ==0 ) + ret =drm_intel_bo_mrb_exec (batch->bo, batch_end, +NULL ,0 ,0 ,0 ); +igt_assert (ret ==0 ); +} + +uint32_t +gen7_fill_curbe_buffer_data (struct intel_batchbuffer *batch, +uint8_t color) +{ +uint8_t *curbe_buffer; +uint32_t offset; + + curbe_buffer =batch_alloc (batch,sizeof (uint32_t ) *8 ,64 ); + offset =batch_offset (batch, curbe_buffer); + *curbe_buffer = color; + +return offset; +} + +uint32_t +gen7_fill_surface_state (struct intel_batchbuffer *batch, +struct igt_buf *buf, +uint32_t format, +int is_dst) +{ +struct gen7_surface_state *ss; +uint32_t write_domain, read_domain, offset; +int ret; + +if (is_dst) { + write_domain = read_domain =I915_GEM_DOMAIN_RENDER ; + }else { + write_domain =0 ; + read_domain =I915_GEM_DOMAIN_SAMPLER ; + } + + ss =batch_alloc (batch,sizeof (*ss),64 ); + offset =batch_offset (batch, ss); + + ss->ss0.surface_type =GEN7_SURFACE_2D ; + ss->ss0.surface_format = format; + ss->ss0.render_cache_read_write =1 ; + +if (buf->tiling ==I915_TILING_X ) + ss->ss0.tiled_mode =2 ; +else if (buf->tiling ==I915_TILING_Y ) + ss->ss0.tiled_mode =3 ; + + ss->ss1.base_addr = buf->bo->offset; + ret =drm_intel_bo_emit_reloc (batch->bo, +batch_offset (batch, ss) +4 , + buf->bo,0 , + read_domain, write_domain); +igt_assert (ret ==0 ); + + ss->ss2.height =igt_buf_height (buf) -1 ; + ss->ss2.width =igt_buf_width (buf) -1 ; + + ss->ss3.pitch = buf->stride -1 ; + + ss->ss7.shader_chanel_select_r =4 ; + ss->ss7.shader_chanel_select_g =5 ; + ss->ss7.shader_chanel_select_b =6 ; + ss->ss7.shader_chanel_select_a =7 ; + +return offset; +} + +uint32_t +gen7_fill_binding_table (struct intel_batchbuffer *batch, +struct igt_buf *dst) +{ +uint32_t *binding_table, offset; + + binding_table =batch_alloc (batch,32 ,64 ); + offset =batch_offset (batch, binding_table); + + binding_table[0 ] =gen7_fill_surface_state (batch, dst,GEN7_SURFACEFORMAT_R8_UNORM ,1 ); + +return offset; +} + +uint32_t +gen7_fill_kernel (struct intel_batchbuffer *batch, +const uint32_t kernel[][4 ], +size_t size) +{ +uint32_t offset; + + offset =batch_copy (batch, kernel, size,64 ); + +return offset; +} + +uint32_t +gen7_fill_interface_descriptor (struct intel_batchbuffer *batch,struct igt_buf *dst, +const uint32_t kernel[][4 ],size_t size) +{ +struct gen7_interface_descriptor_data *idd; +uint32_t offset; +uint32_t binding_table_offset, kernel_offset; + + binding_table_offset =gen7_fill_binding_table (batch, dst); + kernel_offset =gen7_fill_kernel (batch, kernel, size); + + idd =batch_alloc (batch,sizeof (*idd),64 ); + offset =batch_offset (batch, idd); + + idd->desc0.kernel_start_pointer = (kernel_offset >>6 ); + + idd->desc1.single_program_flow =1 ; + idd->desc1.floating_point_mode =GEN7_FLOATING_POINT_IEEE_754 ; + + idd->desc2.sampler_count =0 ;/* 0 samplers used */ + idd->desc2.sampler_state_pointer =0 ; + + idd->desc3.binding_table_entry_count =0 ; + idd->desc3.binding_table_pointer = (binding_table_offset >>5 ); + + idd->desc4.constant_urb_entry_read_offset =0 ; + idd->desc4.constant_urb_entry_read_length =1 ;/* grf 1 */ + +return offset; +} + +void +gen7_emit_state_base_address (struct intel_batchbuffer *batch) +{ +OUT_BATCH (GEN7_STATE_BASE_ADDRESS | (10 -2 )); + +/* general */ +OUT_BATCH (0 ); + +/* surface */ +OUT_RELOC (batch->bo,I915_GEM_DOMAIN_INSTRUCTION ,0 ,BASE_ADDRESS_MODIFY ); + +/* dynamic */ +OUT_RELOC (batch->bo,I915_GEM_DOMAIN_INSTRUCTION ,0 ,BASE_ADDRESS_MODIFY ); + +/* indirect */ +OUT_BATCH (0 ); + +/* instruction */ +OUT_RELOC (batch->bo,I915_GEM_DOMAIN_INSTRUCTION ,0 ,BASE_ADDRESS_MODIFY ); + +/* general/dynamic/indirect/instruction access Bound */ +OUT_BATCH (0 ); +OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); +OUT_BATCH (0 ); +OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); +} + +void +gen7_emit_vfe_state (struct intel_batchbuffer *batch) +{ +OUT_BATCH (GEN7_MEDIA_VFE_STATE | (8 -2 )); + +/* scratch buffer */ +OUT_BATCH (0 ); + +/* number of threads & urb entries */ +OUT_BATCH (1 <<16 | +2 <<8 ); + +OUT_BATCH (0 ); + +/* urb entry size & curbe size */ +OUT_BATCH (2 <<16 |/* in 256 bits unit */ +2 );/* in 256 bits unit */ + +/* scoreboard */ +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +} + +void +gen7_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch) +{ +OUT_BATCH (GEN7_MEDIA_VFE_STATE | (8 -2 )); + +/* scratch buffer */ +OUT_BATCH (0 ); + +/* number of threads & urb entries */ +OUT_BATCH (1 <<16 |/* max num of threads */ +0 <<8 |/* num of URB entry */ +1 <<2 );/* GPGPU mode */ + +OUT_BATCH (0 ); + +/* urb entry size & curbe size */ +OUT_BATCH (0 <<16 |/* URB entry size in 256 bits unit */ +1 );/* CURBE entry size in 256 bits unit */ + +/* scoreboard */ +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +} + +void +gen7_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer) +{ +OUT_BATCH (GEN7_MEDIA_CURBE_LOAD | (4 -2 )); +OUT_BATCH (0 ); +/* curbe total data length */ +OUT_BATCH (64 ); +/* curbe data start address, is relative to the dynamics base address */ +OUT_BATCH (curbe_buffer); +} + +void +gen7_emit_interface_descriptor_load (struct intel_batchbuffer *batch,uint32_t interface_descriptor) +{ +OUT_BATCH (GEN7_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 -2 )); +OUT_BATCH (0 ); +/* interface descriptor data length */ +OUT_BATCH (sizeof (struct gen7_interface_descriptor_data )); +/* interface descriptor address, is relative to the dynamics base address */ +OUT_BATCH (interface_descriptor); +} + +void +gen7_emit_media_objects (struct intel_batchbuffer *batch, +unsigned x,unsigned y, +unsigned width,unsigned height) +{ +int i, j; + +for (i =0 ; i < width /16 ; i++) { +for (j =0 ; j < height /16 ; j++) { +OUT_BATCH (GEN7_MEDIA_OBJECT | (8 -2 )); + +/* interface descriptor offset */ +OUT_BATCH (0 ); + +/* without indirect data */ +OUT_BATCH (0 ); +OUT_BATCH (0 ); + +/* scoreboard */ +OUT_BATCH (0 ); +OUT_BATCH (0 ); + +/* inline data (xoffset, yoffset) */ +OUT_BATCH (x + i *16 ); +OUT_BATCH (y + j *16 ); + } + } +} + +void +gen7_emit_gpgpu_walk (struct intel_batchbuffer *batch, +unsigned x,unsigned y, +unsigned width,unsigned height) +{ +uint32_t x_dim, y_dim, tmp, right_mask; + +/* +* Simply do SIMD16 based dispatch, so every thread uses +* SIMD16 channels. +* +* Define our own thread group size, e.g 16x1 for every group, then +* will have 1 thread each group in SIMD16 dispatch. So thread +* width/height/depth are all 1. +* +* Then thread group X = width / 16 (aligned to 16) +* thread group Y = height; +*/ + x_dim = (width +15 ) /16 ; + y_dim = height; + + tmp = width &15 ; +if (tmp ==0 ) + right_mask = (1 <<16 ) -1 ; +else + right_mask = (1 << tmp) -1 ; + +OUT_BATCH (GEN7_GPGPU_WALKER |9 ); + +/* interface descriptor offset */ +OUT_BATCH (0 ); + +/* SIMD size, thread w/h/d */ +OUT_BATCH (1 <<30 |/* SIMD16 */ +0 <<16 |/* depth:1 */ +0 <<8 |/* height:1 */ +0 );/* width:1 */ + +/* thread group X */ +OUT_BATCH (0 ); +OUT_BATCH (x_dim); + +/* thread group Y */ +OUT_BATCH (0 ); +OUT_BATCH (y_dim); + +/* thread group Z */ +OUT_BATCH (0 ); +OUT_BATCH (1 ); + +/* right mask */ +OUT_BATCH (right_mask); + +/* bottom mask, height 1, always 0xffffffff */ +OUT_BATCH (0xffffffff ); +} + +uint32_t +gen8_fill_surface_state (struct intel_batchbuffer *batch, +struct igt_buf *buf, +uint32_t format, +int is_dst) +{ +struct gen8_surface_state *ss; +uint32_t write_domain, read_domain, offset; +int ret; + +if (is_dst) { + write_domain = read_domain =I915_GEM_DOMAIN_RENDER ; + }else { + write_domain =0 ; + read_domain =I915_GEM_DOMAIN_SAMPLER ; + } + + ss =batch_alloc (batch,sizeof (*ss),64 ); + offset =batch_offset (batch, ss); + + ss->ss0.surface_type =GEN8_SURFACE_2D ; + ss->ss0.surface_format = format; + ss->ss0.render_cache_read_write =1 ; + ss->ss0.vertical_alignment =1 ;/* align 4 */ + ss->ss0.horizontal_alignment =1 ;/* align 4 */ + +if (buf->tiling ==I915_TILING_X ) + ss->ss0.tiled_mode =2 ; +else if (buf->tiling ==I915_TILING_Y ) + ss->ss0.tiled_mode =3 ; + + ss->ss8.base_addr = buf->bo->offset; + + ret =drm_intel_bo_emit_reloc (batch->bo, +batch_offset (batch, ss) +8 *4 , + buf->bo,0 , + read_domain, write_domain); +igt_assert (ret ==0 ); + + ss->ss2.height =igt_buf_height (buf) -1 ; + ss->ss2.width =igt_buf_width (buf) -1 ; + ss->ss3.pitch = buf->stride -1 ; + + ss->ss7.shader_chanel_select_r =4 ; + ss->ss7.shader_chanel_select_g =5 ; + ss->ss7.shader_chanel_select_b =6 ; + ss->ss7.shader_chanel_select_a =7 ; + +return offset; +} + +uint32_t +gen8_fill_binding_table (struct intel_batchbuffer *batch, +struct igt_buf *dst) +{ +uint32_t *binding_table, offset; + + binding_table =batch_alloc (batch,32 ,64 ); + offset =batch_offset (batch, binding_table); + + binding_table[0 ] =gen8_fill_surface_state (batch, dst,GEN8_SURFACEFORMAT_R8_UNORM ,1 ); + +return offset; +} + +uint32_t +gen8_fill_interface_descriptor (struct intel_batchbuffer *batch,struct igt_buf *dst,const uint32_t kernel[][4 ],size_t size) +{ +struct gen8_interface_descriptor_data *idd; +uint32_t offset; +uint32_t binding_table_offset, kernel_offset; + + binding_table_offset =gen8_fill_binding_table (batch, dst); + kernel_offset =gen7_fill_kernel (batch, kernel,sizeof (kernel)); + + idd =batch_alloc (batch,sizeof (*idd),64 ); + offset =batch_offset (batch, idd); + + idd->desc0.kernel_start_pointer = (kernel_offset >>6 ); + + idd->desc2.single_program_flow =1 ; + idd->desc2.floating_point_mode =GEN8_FLOATING_POINT_IEEE_754 ; + + idd->desc3.sampler_count =0 ;/* 0 samplers used */ + idd->desc3.sampler_state_pointer =0 ; + + idd->desc4.binding_table_entry_count =0 ; + idd->desc4.binding_table_pointer = (binding_table_offset >>5 ); + + idd->desc5.constant_urb_entry_read_offset =0 ; + idd->desc5.constant_urb_entry_read_length =1 ;/* grf 1 */ + +return offset; +} + +void +gen8_emit_state_base_address (struct intel_batchbuffer *batch) +{ +OUT_BATCH (GEN8_STATE_BASE_ADDRESS | (16 -2 )); + +/* general */ +OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); +OUT_BATCH (0 ); + +/* stateless data port */ +OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); + +/* surface */ +OUT_RELOC (batch->bo,I915_GEM_DOMAIN_SAMPLER ,0 ,BASE_ADDRESS_MODIFY ); + +/* dynamic */ +OUT_RELOC (batch->bo,I915_GEM_DOMAIN_RENDER |I915_GEM_DOMAIN_INSTRUCTION , +0 ,BASE_ADDRESS_MODIFY ); + +/* indirect */ +OUT_BATCH (0 ); +OUT_BATCH (0 ); + +/* instruction */ +OUT_RELOC (batch->bo,I915_GEM_DOMAIN_INSTRUCTION ,0 ,BASE_ADDRESS_MODIFY ); + +/* general state buffer size */ +OUT_BATCH (0xfffff000 |1 ); +/* dynamic state buffer size */ +OUT_BATCH (1 <<12 |1 ); +/* indirect object buffer size */ +OUT_BATCH (0xfffff000 |1 ); +/* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */ +OUT_BATCH (1 <<12 |1 ); +} + +void +gen8_emit_vfe_state (struct intel_batchbuffer *batch) +{ +OUT_BATCH (GEN8_MEDIA_VFE_STATE | (9 -2 )); + +/* scratch buffer */ +OUT_BATCH (0 ); +OUT_BATCH (0 ); + +/* number of threads & urb entries */ +OUT_BATCH (1 <<16 | +2 <<8 ); + +OUT_BATCH (0 ); + +/* urb entry size & curbe size */ +OUT_BATCH (2 <<16 | +2 ); + +/* scoreboard */ +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +} + +void +gen8_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch) +{ +OUT_BATCH (GEN8_MEDIA_VFE_STATE | (9 -2 )); + +/* scratch buffer */ +OUT_BATCH (0 ); +OUT_BATCH (0 ); + +/* number of threads & urb entries */ +OUT_BATCH (1 <<16 |1 <<8 ); + +OUT_BATCH (0 ); + +/* urb entry size & curbe size */ +OUT_BATCH (0 <<16 |1 ); + +/* scoreboard */ +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +} + +void +gen8_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer) +{ +OUT_BATCH (GEN8_MEDIA_CURBE_LOAD | (4 -2 )); +OUT_BATCH (0 ); +/* curbe total data length */ +OUT_BATCH (64 ); +/* curbe data start address, is relative to the dynamics base address */ +OUT_BATCH (curbe_buffer); +} + +void +gen8_emit_interface_descriptor_load (struct intel_batchbuffer *batch,uint32_t interface_descriptor) +{ +OUT_BATCH (GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 -2 )); +OUT_BATCH (0 ); +/* interface descriptor data length */ +OUT_BATCH (sizeof (struct gen8_interface_descriptor_data )); +/* interface descriptor address, is relative to the dynamics base address */ +OUT_BATCH (interface_descriptor); +} + +void +gen8_emit_media_state_flush (struct intel_batchbuffer *batch) +{ +OUT_BATCH (GEN8_MEDIA_STATE_FLUSH | (2 -2 )); +OUT_BATCH (0 ); +} + +void +gen8_emit_media_objects (struct intel_batchbuffer *batch, +unsigned x,unsigned y, +unsigned width,unsigned height) +{ +int i, j; + +for (i =0 ; i < width /16 ; i++) { +for (j =0 ; j < height /16 ; j++) { +OUT_BATCH (GEN8_MEDIA_OBJECT | (8 -2 )); + +/* interface descriptor offset */ +OUT_BATCH (0 ); + +/* without indirect data */ +OUT_BATCH (0 ); +OUT_BATCH (0 ); + +/* scoreboard */ +OUT_BATCH (0 ); +OUT_BATCH (0 ); + +/* inline data (xoffset, yoffset) */ +OUT_BATCH (x + i *16 ); +OUT_BATCH (y + j *16 ); +gen8_emit_media_state_flush (batch); + } + } +} + +void +gen8lp_emit_media_objects (struct intel_batchbuffer *batch, +unsigned x,unsigned y, +unsigned width,unsigned height) +{ +int i, j; + +for (i =0 ; i < width /16 ; i++) { +for (j =0 ; j < height /16 ; j++) { +OUT_BATCH (GEN8_MEDIA_OBJECT | (8 -2 )); + +/* interface descriptor offset */ +OUT_BATCH (0 ); + +/* without indirect data */ +OUT_BATCH (0 ); +OUT_BATCH (0 ); + +/* scoreboard */ +OUT_BATCH (0 ); +OUT_BATCH (0 ); + +/* inline data (xoffset, yoffset) */ +OUT_BATCH (x + i *16 ); +OUT_BATCH (y + j *16 ); + } + } +} + +void +gen8_emit_gpgpu_walk (struct intel_batchbuffer *batch, +unsigned x,unsigned y, +unsigned width,unsigned height) +{ +uint32_t x_dim, y_dim, tmp, right_mask; + +/* +* Simply do SIMD16 based dispatch, so every thread uses +* SIMD16 channels. +* +* Define our own thread group size, e.g 16x1 for every group, then +* will have 1 thread each group in SIMD16 dispatch. So thread +* width/height/depth are all 1. +* +* Then thread group X = width / 16 (aligned to 16) +* thread group Y = height; +*/ + x_dim = (width +15 ) /16 ; + y_dim = height; + + tmp = width &15 ; +if (tmp ==0 ) + right_mask = (1 <<16 ) -1 ; +else + right_mask = (1 << tmp) -1 ; + +OUT_BATCH (GEN7_GPGPU_WALKER |13 ); + +OUT_BATCH (0 );/* kernel offset */ +OUT_BATCH (0 );/* indirect data length */ +OUT_BATCH (0 );/* indirect data offset */ + +/* SIMD size, thread w/h/d */ +OUT_BATCH (1 <<30 |/* SIMD16 */ +0 <<16 |/* depth:1 */ +0 <<8 |/* height:1 */ +0 );/* width:1 */ + +/* thread group X */ +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (x_dim); + +/* thread group Y */ +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (y_dim); + +/* thread group Z */ +OUT_BATCH (0 ); +OUT_BATCH (1 ); + +/* right mask */ +OUT_BATCH (right_mask); + +/* bottom mask, height 1, always 0xffffffff */ +OUT_BATCH (0xffffffff ); +} + +void +gen9_emit_state_base_address (struct intel_batchbuffer *batch) +{ +OUT_BATCH (GEN8_STATE_BASE_ADDRESS | (19 -2 )); + +/* general */ +OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); +OUT_BATCH (0 ); + +/* stateless data port */ +OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); + +/* surface */ +OUT_RELOC (batch->bo,I915_GEM_DOMAIN_SAMPLER ,0 ,BASE_ADDRESS_MODIFY ); + +/* dynamic */ +OUT_RELOC (batch->bo,I915_GEM_DOMAIN_RENDER |I915_GEM_DOMAIN_INSTRUCTION , +0 ,BASE_ADDRESS_MODIFY ); + +/* indirect */ +OUT_BATCH (0 ); +OUT_BATCH (0 ); + +/* instruction */ +OUT_RELOC (batch->bo,I915_GEM_DOMAIN_INSTRUCTION ,0 ,BASE_ADDRESS_MODIFY ); + +/* general state buffer size */ +OUT_BATCH (0xfffff000 |1 ); +/* dynamic state buffer size */ +OUT_BATCH (1 <<12 |1 ); +/* indirect object buffer size */ +OUT_BATCH (0xfffff000 |1 ); +/* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */ +OUT_BATCH (1 <<12 |1 ); + +/* Bindless surface state base address */ +OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); +OUT_BATCH (0 ); +OUT_BATCH (0xfffff000 ); +}lib/gpu_fill.h new file +141
-0@@ -0,0 +1,141 @@ +/* +* Copyright © 2018 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +* +*/ + +#ifndef GPU_FILL_H +#define GPU_FILL_H + +uint32_t +batch_used (struct intel_batchbuffer *batch); + +uint32_t +batch_align (struct intel_batchbuffer *batch,uint32_t align); + +void * +batch_alloc (struct intel_batchbuffer *batch,uint32_t size,uint32_t align); + +uint32_t +batch_offset (struct intel_batchbuffer *batch,void *ptr); + +uint32_t +batch_copy (struct intel_batchbuffer *batch,const void *ptr,uint32_t size,uint32_t align); + +void +gen7_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end); + +uint32_t +gen7_fill_curbe_buffer_data (struct intel_batchbuffer *batch, +uint8_t color); + +uint32_t +gen7_fill_surface_state (struct intel_batchbuffer *batch, +struct igt_buf *buf, +uint32_t format, +int is_dst); + +uint32_t +gen7_fill_binding_table (struct intel_batchbuffer *batch, +struct igt_buf *dst); +uint32_t +gen7_fill_kernel (struct intel_batchbuffer *batch, +const uint32_t kernel[][4 ], +size_t size); + +uint32_t +gen7_fill_interface_descriptor (struct intel_batchbuffer *batch,struct igt_buf *dst, +const uint32_t kernel[][4 ],size_t size); + +void +gen7_emit_state_base_address (struct intel_batchbuffer *batch); + +void +gen7_emit_vfe_state (struct intel_batchbuffer *batch); + +void +gen7_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch); + +void +gen7_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer); + +void +gen7_emit_interface_descriptor_load (struct intel_batchbuffer *batch,uint32_t interface_descriptor); + +void +gen7_emit_media_objects (struct intel_batchbuffer *batch, +unsigned x,unsigned y, +unsigned width,unsigned height); + +uint32_t +gen8_fill_surface_state (struct intel_batchbuffer *batch, +struct igt_buf *buf, +uint32_t format, +int is_dst); + +uint32_t +gen8_fill_binding_table (struct intel_batchbuffer *batch, +struct igt_buf *dst); + +uint32_t +gen8_fill_interface_descriptor (struct intel_batchbuffer *batch,struct igt_buf *dst,const uint32_t kernel[][4 ],size_t size); + +void +gen8_emit_state_base_address (struct intel_batchbuffer *batch); + +void +gen8_emit_vfe_state (struct intel_batchbuffer *batch); + +void +gen8_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch); + +void +gen8_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer); + +void +gen8_emit_interface_descriptor_load (struct intel_batchbuffer *batch,uint32_t interface_descriptor); + +void +gen8_emit_media_state_flush (struct intel_batchbuffer *batch); + +void +gen8_emit_media_objects (struct intel_batchbuffer *batch, +unsigned x,unsigned y, +unsigned width,unsigned height); + +void +gen8lp_emit_media_objects (struct intel_batchbuffer *batch, +unsigned x,unsigned y, +unsigned width,unsigned height); + +void +gen9_emit_state_base_address (struct intel_batchbuffer *batch); + +void +gen7_emit_gpgpu_walk (struct intel_batchbuffer *batch, +unsigned x,unsigned y, +unsigned width,unsigned height); +void +gen8_emit_gpgpu_walk (struct intel_batchbuffer *batch, +unsigned x,unsigned y, +unsigned width,unsigned height); + +#endif /* GPU_FILL_H */ lib/media_fill_gen7.c +1
-270@@ -5,7 +5,7 @@#include "gen7_media.h" #include "intel_reg.h" #include "drmtest.h" - +#include "gpu_fill.h" #include <assert.h> static const uint32_t media_kernel[][4 ] = {@@ -22,275 +22,6 @@ static const uint32_t media_kernel[][4] = { { 0x07800031, 0x20001ca8, 0x00000e00, 0x82000010 }, }; -static uint32_t -batch_used (struct intel_batchbuffer *batch) -{ -return batch->ptr - batch->buffer; -} - -static uint32_t -batch_align (struct intel_batchbuffer *batch,uint32_t align) -{ -uint32_t offset =batch_used (batch); - offset =ALIGN (offset, align); - batch->ptr = batch->buffer + offset; -return offset; -} - -static void * -batch_alloc (struct intel_batchbuffer *batch,uint32_t size,uint32_t align) -{ -uint32_t offset =batch_align (batch, align); - batch->ptr += size; -return memset (batch->buffer + offset,0 , size); -} - -static uint32_t -batch_offset (struct intel_batchbuffer *batch,void *ptr) -{ -return (uint8_t *)ptr - batch->buffer; -} - -static uint32_t -batch_copy (struct intel_batchbuffer *batch,const void *ptr,uint32_t size,uint32_t align) -{ -return batch_offset (batch,memcpy (batch_alloc (batch, size, align), ptr, size)); -} - -static void -gen7_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end) -{ -int ret; - - ret =drm_intel_bo_subdata (batch->bo,0 ,4096 , batch->buffer); -if (ret ==0 ) - ret =drm_intel_bo_mrb_exec (batch->bo, batch_end, -NULL ,0 ,0 ,0 ); -igt_assert (ret ==0 ); -} - -static uint32_t -gen7_fill_curbe_buffer_data (struct intel_batchbuffer *batch, -uint8_t color) -{ -uint8_t *curbe_buffer; -uint32_t offset; - - curbe_buffer =batch_alloc (batch,sizeof (uint32_t ) *8 ,64 ); - offset =batch_offset (batch, curbe_buffer); - *curbe_buffer = color; - -return offset; -} - -static uint32_t -gen7_fill_surface_state (struct intel_batchbuffer *batch, -struct igt_buf *buf, -uint32_t format, -int is_dst) -{ -struct gen7_surface_state *ss; -uint32_t write_domain, read_domain, offset; -int ret; - -if (is_dst) { - write_domain = read_domain =I915_GEM_DOMAIN_RENDER ; - }else { - write_domain =0 ; - read_domain =I915_GEM_DOMAIN_SAMPLER ; - } - - ss =batch_alloc (batch,sizeof (*ss),64 ); - offset =batch_offset (batch, ss); - - ss->ss0.surface_type =GEN7_SURFACE_2D ; - ss->ss0.surface_format = format; - ss->ss0.render_cache_read_write =1 ; - -if (buf->tiling ==I915_TILING_X ) - ss->ss0.tiled_mode =2 ; -else if (buf->tiling ==I915_TILING_Y ) - ss->ss0.tiled_mode =3 ; - - ss->ss1.base_addr = buf->bo->offset; - ret =drm_intel_bo_emit_reloc (batch->bo, -batch_offset (batch, ss) +4 , - buf->bo,0 , - read_domain, write_domain); -igt_assert (ret ==0 ); - - ss->ss2.height =igt_buf_height (buf) -1 ; - ss->ss2.width =igt_buf_width (buf) -1 ; - - ss->ss3.pitch = buf->stride -1 ; - - ss->ss7.shader_chanel_select_r =4 ; - ss->ss7.shader_chanel_select_g =5 ; - ss->ss7.shader_chanel_select_b =6 ; - ss->ss7.shader_chanel_select_a =7 ; - -return offset; -} - -static uint32_t -gen7_fill_binding_table (struct intel_batchbuffer *batch, -struct igt_buf *dst) -{ -uint32_t *binding_table, offset; - - binding_table =batch_alloc (batch,32 ,64 ); - offset =batch_offset (batch, binding_table); - - binding_table[0 ] =gen7_fill_surface_state (batch, dst,GEN7_SURFACEFORMAT_R8_UNORM ,1 ); - -return offset; -} - -static uint32_t -gen7_fill_media_kernel (struct intel_batchbuffer *batch, -const uint32_t kernel[][4 ], -size_t size) -{ -uint32_t offset; - - offset =batch_copy (batch, kernel, size,64 ); - -return offset; -} - -static uint32_t -gen7_fill_interface_descriptor (struct intel_batchbuffer *batch,struct igt_buf *dst, -const uint32_t kernel[][4 ],size_t size) -{ -struct gen7_interface_descriptor_data *idd; -uint32_t offset; -uint32_t binding_table_offset, kernel_offset; - - binding_table_offset =gen7_fill_binding_table (batch, dst); - kernel_offset =gen7_fill_media_kernel (batch, kernel, size); - - idd =batch_alloc (batch,sizeof (*idd),64 ); - offset =batch_offset (batch, idd); - - idd->desc0.kernel_start_pointer = (kernel_offset >>6 ); - - idd->desc1.single_program_flow =1 ; - idd->desc1.floating_point_mode =GEN7_FLOATING_POINT_IEEE_754 ; - - idd->desc2.sampler_count =0 ;/* 0 samplers used */ - idd->desc2.sampler_state_pointer =0 ; - - idd->desc3.binding_table_entry_count =0 ; - idd->desc3.binding_table_pointer = (binding_table_offset >>5 ); - - idd->desc4.constant_urb_entry_read_offset =0 ; - idd->desc4.constant_urb_entry_read_length =1 ;/* grf 1 */ - -return offset; -} - -static void -gen7_emit_state_base_address (struct intel_batchbuffer *batch) -{ -OUT_BATCH (GEN7_STATE_BASE_ADDRESS | (10 -2 )); - -/* general */ -OUT_BATCH (0 ); - -/* surface */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_INSTRUCTION ,0 ,BASE_ADDRESS_MODIFY ); - -/* dynamic */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_INSTRUCTION ,0 ,BASE_ADDRESS_MODIFY ); - -/* indirect */ -OUT_BATCH (0 ); - -/* instruction */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_INSTRUCTION ,0 ,BASE_ADDRESS_MODIFY ); - -/* general/dynamic/indirect/instruction access Bound */ -OUT_BATCH (0 ); -OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); -OUT_BATCH (0 ); -OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); -} - -static void -gen7_emit_vfe_state (struct intel_batchbuffer *batch) -{ -OUT_BATCH (GEN7_MEDIA_VFE_STATE | (8 -2 )); - -/* scratch buffer */ -OUT_BATCH (0 ); - -/* number of threads & urb entries */ -OUT_BATCH (1 <<16 | -2 <<8 ); - -OUT_BATCH (0 ); - -/* urb entry size & curbe size */ -OUT_BATCH (2 <<16 |/* in 256 bits unit */ -2 );/* in 256 bits unit */ - -/* scoreboard */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); -OUT_BATCH (0 ); -} - -static void -gen7_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer) -{ -OUT_BATCH (GEN7_MEDIA_CURBE_LOAD | (4 -2 )); -OUT_BATCH (0 ); -/* curbe total data length */ -OUT_BATCH (64 ); -/* curbe data start address, is relative to the dynamics base address */ -OUT_BATCH (curbe_buffer); -} - -static void -gen7_emit_interface_descriptor_load (struct intel_batchbuffer *batch,uint32_t interface_descriptor) -{ -OUT_BATCH (GEN7_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 -2 )); -OUT_BATCH (0 ); -/* interface descriptor data length */ -OUT_BATCH (sizeof (struct gen7_interface_descriptor_data )); -/* interface descriptor address, is relative to the dynamics base address */ -OUT_BATCH (interface_descriptor); -} - -static void -gen7_emit_media_objects (struct intel_batchbuffer *batch, -unsigned x,unsigned y, -unsigned width,unsigned height) -{ -int i, j; - -for (i =0 ; i < width /16 ; i++) { -for (j =0 ; j < height /16 ; j++) { -OUT_BATCH (GEN7_MEDIA_OBJECT | (8 -2 )); - -/* interface descriptor offset */ -OUT_BATCH (0 ); - -/* without indirect data */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* scoreboard */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* inline data (xoffset, yoffset) */ -OUT_BATCH (x + i *16 ); -OUT_BATCH (y + j *16 ); - } - } -} -/* * This sets up the media pipeline, * lib/media_fill_gen8.c +5
-292@@ -5,7 +5,7 @@#include "gen8_media.h" #include "intel_reg.h" #include "drmtest.h" - +#include "gpu_fill.h" #include <assert.h> @@ -23,294 +23,6 @@ static const uint32_t media_kernel[][4] = { { 0x07800031, 0x20000a40, 0x0e000e00, 0x82000010 }, }; -static uint32_t -batch_used (struct intel_batchbuffer *batch) -{ -return batch->ptr - batch->buffer; -} - -static uint32_t -batch_align (struct intel_batchbuffer *batch,uint32_t align) -{ -uint32_t offset =batch_used (batch); - offset =ALIGN (offset, align); - batch->ptr = batch->buffer + offset; -return offset; -} - -static void * -batch_alloc (struct intel_batchbuffer *batch,uint32_t size,uint32_t align) -{ -uint32_t offset =batch_align (batch, align); - batch->ptr += size; -return memset (batch->buffer + offset,0 , size); -} - -static uint32_t -batch_offset (struct intel_batchbuffer *batch,void *ptr) -{ -return (uint8_t *)ptr - batch->buffer; -} - -static uint32_t -batch_copy (struct intel_batchbuffer *batch,const void *ptr,uint32_t size,uint32_t align) -{ -return batch_offset (batch,memcpy (batch_alloc (batch, size, align), ptr, size)); -} - -static void -gen8_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end) -{ -int ret; - - ret =drm_intel_bo_subdata (batch->bo,0 ,4096 , batch->buffer); -if (ret ==0 ) - ret =drm_intel_bo_mrb_exec (batch->bo, batch_end, -NULL ,0 ,0 ,0 ); -igt_assert (ret ==0 ); -} - -static uint32_t -gen8_fill_curbe_buffer_data (struct intel_batchbuffer *batch, -uint8_t color) -{ -uint8_t *curbe_buffer; -uint32_t offset; - - curbe_buffer =batch_alloc (batch,sizeof (uint32_t ) *8 ,64 ); - offset =batch_offset (batch, curbe_buffer); - *curbe_buffer = color; - -return offset; -} - -static uint32_t -gen8_fill_surface_state (struct intel_batchbuffer *batch, -struct igt_buf *buf, -uint32_t format, -int is_dst) -{ -struct gen8_surface_state *ss; -uint32_t write_domain, read_domain, offset; -int ret; - -if (is_dst) { - write_domain = read_domain =I915_GEM_DOMAIN_RENDER ; - }else { - write_domain =0 ; - read_domain =I915_GEM_DOMAIN_SAMPLER ; - } - - ss =batch_alloc (batch,sizeof (*ss),64 ); - offset =batch_offset (batch, ss); - - ss->ss0.surface_type =GEN8_SURFACE_2D ; - ss->ss0.surface_format = format; - ss->ss0.render_cache_read_write =1 ; - ss->ss0.vertical_alignment =1 ;/* align 4 */ - ss->ss0.horizontal_alignment =1 ;/* align 4 */ - -if (buf->tiling ==I915_TILING_X ) - ss->ss0.tiled_mode =2 ; -else if (buf->tiling ==I915_TILING_Y ) - ss->ss0.tiled_mode =3 ; - - ss->ss8.base_addr = buf->bo->offset; - - ret =drm_intel_bo_emit_reloc (batch->bo, -batch_offset (batch, ss) +8 *4 , - buf->bo,0 , - read_domain, write_domain); -igt_assert (ret ==0 ); - - ss->ss2.height =igt_buf_height (buf) -1 ; - ss->ss2.width =igt_buf_width (buf) -1 ; - ss->ss3.pitch = buf->stride -1 ; - - ss->ss7.shader_chanel_select_r =4 ; - ss->ss7.shader_chanel_select_g =5 ; - ss->ss7.shader_chanel_select_b =6 ; - ss->ss7.shader_chanel_select_a =7 ; - -return offset; -} - -static uint32_t -gen8_fill_binding_table (struct intel_batchbuffer *batch, -struct igt_buf *dst) -{ -uint32_t *binding_table, offset; - - binding_table =batch_alloc (batch,32 ,64 ); - offset =batch_offset (batch, binding_table); - - binding_table[0 ] =gen8_fill_surface_state (batch, dst,GEN8_SURFACEFORMAT_R8_UNORM ,1 ); - -return offset; -} - -static uint32_t -gen8_fill_media_kernel (struct intel_batchbuffer *batch, -const uint32_t kernel[][4 ], -size_t size) -{ -uint32_t offset; - - offset =batch_copy (batch, kernel, size,64 ); - -return offset; -} - -static uint32_t -gen8_fill_interface_descriptor (struct intel_batchbuffer *batch,struct igt_buf *dst) -{ -struct gen8_interface_descriptor_data *idd; -uint32_t offset; -uint32_t binding_table_offset, kernel_offset; - - binding_table_offset =gen8_fill_binding_table (batch, dst); - kernel_offset =gen8_fill_media_kernel (batch, media_kernel,sizeof (media_kernel)); - - idd =batch_alloc (batch,sizeof (*idd),64 ); - offset =batch_offset (batch, idd); - - idd->desc0.kernel_start_pointer = (kernel_offset >>6 ); - - idd->desc2.single_program_flow =1 ; - idd->desc2.floating_point_mode =GEN8_FLOATING_POINT_IEEE_754 ; - - idd->desc3.sampler_count =0 ;/* 0 samplers used */ - idd->desc3.sampler_state_pointer =0 ; - - idd->desc4.binding_table_entry_count =0 ; - idd->desc4.binding_table_pointer = (binding_table_offset >>5 ); - - idd->desc5.constant_urb_entry_read_offset =0 ; - idd->desc5.constant_urb_entry_read_length =1 ;/* grf 1 */ - -return offset; -} - -static void -gen8_emit_state_base_address (struct intel_batchbuffer *batch) -{ -OUT_BATCH (GEN8_STATE_BASE_ADDRESS | (16 -2 )); - -/* general */ -OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); -OUT_BATCH (0 ); - -/* stateless data port */ -OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); - -/* surface */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_SAMPLER ,0 ,BASE_ADDRESS_MODIFY ); - -/* dynamic */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_RENDER |I915_GEM_DOMAIN_INSTRUCTION , -0 ,BASE_ADDRESS_MODIFY ); - -/* indirect */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* instruction */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_INSTRUCTION ,0 ,BASE_ADDRESS_MODIFY ); - -/* general state buffer size */ -OUT_BATCH (0xfffff000 |1 ); -/* dynamic state buffer size */ -OUT_BATCH (1 <<12 |1 ); -/* indirect object buffer size */ -OUT_BATCH (0xfffff000 |1 ); -/* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */ -OUT_BATCH (1 <<12 |1 ); -} - -static void -gen8_emit_vfe_state (struct intel_batchbuffer *batch) -{ -OUT_BATCH (GEN8_MEDIA_VFE_STATE | (9 -2 )); - -/* scratch buffer */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* number of threads & urb entries */ -OUT_BATCH (1 <<16 | -2 <<8 ); - -OUT_BATCH (0 ); - -/* urb entry size & curbe size */ -OUT_BATCH (2 <<16 | -2 ); - -/* scoreboard */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); -OUT_BATCH (0 ); -} - -static void -gen8_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer) -{ -OUT_BATCH (GEN8_MEDIA_CURBE_LOAD | (4 -2 )); -OUT_BATCH (0 ); -/* curbe total data length */ -OUT_BATCH (64 ); -/* curbe data start address, is relative to the dynamics base address */ -OUT_BATCH (curbe_buffer); -} - -static void -gen8_emit_interface_descriptor_load (struct intel_batchbuffer *batch,uint32_t interface_descriptor) -{ -OUT_BATCH (GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 -2 )); -OUT_BATCH (0 ); -/* interface descriptor data length */ -OUT_BATCH (sizeof (struct gen8_interface_descriptor_data )); -/* interface descriptor address, is relative to the dynamics base address */ -OUT_BATCH (interface_descriptor); -} - -static void -gen8_emit_media_state_flush (struct intel_batchbuffer *batch) -{ -OUT_BATCH (GEN8_MEDIA_STATE_FLUSH | (2 -2 )); -OUT_BATCH (0 ); -} - -static void -gen8_emit_media_objects (struct intel_batchbuffer *batch, -unsigned x,unsigned y, -unsigned width,unsigned height) -{ -int i, j; - -for (i =0 ; i < width /16 ; i++) { -for (j =0 ; j < height /16 ; j++) { -OUT_BATCH (GEN8_MEDIA_OBJECT | (8 -2 )); - -/* interface descriptor offset */ -OUT_BATCH (0 ); - -/* without indirect data */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* scoreboard */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* inline data (xoffset, yoffset) */ -OUT_BATCH (x + i *16 ); -OUT_BATCH (y + j *16 ); -gen8_emit_media_state_flush (batch); - } - } -} -/* * This sets up the media pipeline, * @@ -348,8 +60,9 @@ gen8_media_fillfunc(struct intel_batchbuffer *batch,/* setup states */ batch->ptr = &batch->buffer[BATCH_STATE_SPLIT ]; - curbe_buffer =gen8_fill_curbe_buffer_data (batch, color); - interface_descriptor =gen8_fill_interface_descriptor (batch, dst); + curbe_buffer =gen7_fill_curbe_buffer_data (batch, color); + interface_descriptor =gen8_fill_interface_descriptor (batch, dst, + media_kernel,sizeof (media_kernel));igt_assert (batch->ptr < &batch->buffer[4095 ]);/* media pipeline */ @@ -370,6 +83,6 @@ gen8_media_fillfunc(struct intel_batchbuffer *batch, batch_end =batch_align (batch,8 );igt_assert (batch_end <BATCH_STATE_SPLIT ); -gen8_render_flush (batch, batch_end); +gen7_render_flush (batch, batch_end);intel_batchbuffer_reset (batch); }lib/media_fill_gen8lp.c +5
-284@@ -5,7 +5,7 @@#include "gen8_media.h" #include "intel_reg.h" #include "drmtest.h" - +#include "gpu_fill.h" #include <assert.h> @@ -23,286 +23,6 @@ static const uint32_t media_kernel[][4] = { { 0x07800031, 0x20000a40, 0x0e000e00, 0x82000010 }, }; -static uint32_t -batch_used (struct intel_batchbuffer *batch) -{ -return batch->ptr - batch->buffer; -} - -static uint32_t -batch_align (struct intel_batchbuffer *batch,uint32_t align) -{ -uint32_t offset =batch_used (batch); - offset =ALIGN (offset, align); - batch->ptr = batch->buffer + offset; -return offset; -} - -static void * -batch_alloc (struct intel_batchbuffer *batch,uint32_t size,uint32_t align) -{ -uint32_t offset =batch_align (batch, align); - batch->ptr += size; -return memset (batch->buffer + offset,0 , size); -} - -static uint32_t -batch_offset (struct intel_batchbuffer *batch,void *ptr) -{ -return (uint8_t *)ptr - batch->buffer; -} - -static uint32_t -batch_copy (struct intel_batchbuffer *batch,const void *ptr,uint32_t size,uint32_t align) -{ -return batch_offset (batch,memcpy (batch_alloc (batch, size, align), ptr, size)); -} - -static void -gen8_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end) -{ -int ret; - - ret =drm_intel_bo_subdata (batch->bo,0 ,4096 , batch->buffer); -if (ret ==0 ) - ret =drm_intel_bo_mrb_exec (batch->bo, batch_end, -NULL ,0 ,0 ,0 ); -igt_assert (ret ==0 ); -} - -static uint32_t -gen8_fill_curbe_buffer_data (struct intel_batchbuffer *batch, -uint8_t color) -{ -uint8_t *curbe_buffer; -uint32_t offset; - - curbe_buffer =batch_alloc (batch,sizeof (uint32_t ) *8 ,64 ); - offset =batch_offset (batch, curbe_buffer); - *curbe_buffer = color; - -return offset; -} - -static uint32_t -gen8_fill_surface_state (struct intel_batchbuffer *batch, -struct igt_buf *buf, -uint32_t format, -int is_dst) -{ -struct gen8_surface_state *ss; -uint32_t write_domain, read_domain, offset; -int ret; - -if (is_dst) { - write_domain = read_domain =I915_GEM_DOMAIN_RENDER ; - }else { - write_domain =0 ; - read_domain =I915_GEM_DOMAIN_SAMPLER ; - } - - ss =batch_alloc (batch,sizeof (*ss),64 ); - offset =batch_offset (batch, ss); - - ss->ss0.surface_type =GEN8_SURFACE_2D ; - ss->ss0.surface_format = format; - ss->ss0.render_cache_read_write =1 ; - ss->ss0.vertical_alignment =1 ;/* align 4 */ - ss->ss0.horizontal_alignment =1 ;/* align 4 */ - -if (buf->tiling ==I915_TILING_X ) - ss->ss0.tiled_mode =2 ; -else if (buf->tiling ==I915_TILING_Y ) - ss->ss0.tiled_mode =3 ; - - ss->ss8.base_addr = buf->bo->offset; - - ret =drm_intel_bo_emit_reloc (batch->bo, -batch_offset (batch, ss) +8 *4 , - buf->bo,0 , - read_domain, write_domain); -igt_assert (ret ==0 ); - - ss->ss2.height =igt_buf_height (buf) -1 ; - ss->ss2.width =igt_buf_width (buf) -1 ; - ss->ss3.pitch = buf->stride -1 ; - - ss->ss7.shader_chanel_select_r =4 ; - ss->ss7.shader_chanel_select_g =5 ; - ss->ss7.shader_chanel_select_b =6 ; - ss->ss7.shader_chanel_select_a =7 ; - -return offset; -} - -static uint32_t -gen8_fill_binding_table (struct intel_batchbuffer *batch, -struct igt_buf *dst) -{ -uint32_t *binding_table, offset; - - binding_table =batch_alloc (batch,32 ,64 ); - offset =batch_offset (batch, binding_table); - - binding_table[0 ] =gen8_fill_surface_state (batch, dst,GEN8_SURFACEFORMAT_R8_UNORM ,1 ); - -return offset; -} - -static uint32_t -gen8_fill_media_kernel (struct intel_batchbuffer *batch, -const uint32_t kernel[][4 ], -size_t size) -{ -uint32_t offset; - - offset =batch_copy (batch, kernel, size,64 ); - -return offset; -} - -static uint32_t -gen8_fill_interface_descriptor (struct intel_batchbuffer *batch,struct igt_buf *dst) -{ -struct gen8_interface_descriptor_data *idd; -uint32_t offset; -uint32_t binding_table_offset, kernel_offset; - - binding_table_offset =gen8_fill_binding_table (batch, dst); - kernel_offset =gen8_fill_media_kernel (batch, media_kernel,sizeof (media_kernel)); - - idd =batch_alloc (batch,sizeof (*idd),64 ); - offset =batch_offset (batch, idd); - - idd->desc0.kernel_start_pointer = (kernel_offset >>6 ); - - idd->desc2.single_program_flow =1 ; - idd->desc2.floating_point_mode =GEN8_FLOATING_POINT_IEEE_754 ; - - idd->desc3.sampler_count =0 ;/* 0 samplers used */ - idd->desc3.sampler_state_pointer =0 ; - - idd->desc4.binding_table_entry_count =0 ; - idd->desc4.binding_table_pointer = (binding_table_offset >>5 ); - - idd->desc5.constant_urb_entry_read_offset =0 ; - idd->desc5.constant_urb_entry_read_length =1 ;/* grf 1 */ - -return offset; -} - -static void -gen8_emit_state_base_address (struct intel_batchbuffer *batch) -{ -OUT_BATCH (GEN8_STATE_BASE_ADDRESS | (16 -2 )); - -/* general */ -OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); -OUT_BATCH (0 ); - -/* stateless data port */ -OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); - -/* surface */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_SAMPLER ,0 ,BASE_ADDRESS_MODIFY ); - -/* dynamic */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_RENDER |I915_GEM_DOMAIN_INSTRUCTION , -0 ,BASE_ADDRESS_MODIFY ); - -/* indirect */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* instruction */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_INSTRUCTION ,0 ,BASE_ADDRESS_MODIFY ); - -/* general state buffer size */ -OUT_BATCH (0xfffff000 |1 ); -/* dynamic state buffer size */ -OUT_BATCH (1 <<12 |1 ); -/* indirect object buffer size */ -OUT_BATCH (0xfffff000 |1 ); -/* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */ -OUT_BATCH (1 <<12 |1 ); -} - -static void -gen8_emit_vfe_state (struct intel_batchbuffer *batch) -{ -OUT_BATCH (GEN8_MEDIA_VFE_STATE | (9 -2 )); - -/* scratch buffer */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* number of threads & urb entries */ -OUT_BATCH (1 <<16 | -2 <<8 ); - -OUT_BATCH (0 ); - -/* urb entry size & curbe size */ -OUT_BATCH (2 <<16 | -2 ); - -/* scoreboard */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); -OUT_BATCH (0 ); -} - -static void -gen8_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer) -{ -OUT_BATCH (GEN8_MEDIA_CURBE_LOAD | (4 -2 )); -OUT_BATCH (0 ); -/* curbe total data length */ -OUT_BATCH (64 ); -/* curbe data start address, is relative to the dynamics base address */ -OUT_BATCH (curbe_buffer); -} - -static void -gen8_emit_interface_descriptor_load (struct intel_batchbuffer *batch,uint32_t interface_descriptor) -{ -OUT_BATCH (GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 -2 )); -OUT_BATCH (0 ); -/* interface descriptor data length */ -OUT_BATCH (sizeof (struct gen8_interface_descriptor_data )); -/* interface descriptor address, is relative to the dynamics base address */ -OUT_BATCH (interface_descriptor); -} - -static void -gen8lp_emit_media_objects (struct intel_batchbuffer *batch, -unsigned x,unsigned y, -unsigned width,unsigned height) -{ -int i, j; - -for (i =0 ; i < width /16 ; i++) { -for (j =0 ; j < height /16 ; j++) { -OUT_BATCH (GEN8_MEDIA_OBJECT | (8 -2 )); - -/* interface descriptor offset */ -OUT_BATCH (0 ); - -/* without indirect data */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* scoreboard */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* inline data (xoffset, yoffset) */ -OUT_BATCH (x + i *16 ); -OUT_BATCH (y + j *16 ); - } - } -} -/* * This sets up the media pipeline, * @@ -340,8 +60,9 @@ gen8lp_media_fillfunc(struct intel_batchbuffer *batch,/* setup states */ batch->ptr = &batch->buffer[BATCH_STATE_SPLIT ]; - curbe_buffer =gen8_fill_curbe_buffer_data (batch, color); - interface_descriptor =gen8_fill_interface_descriptor (batch, dst); + curbe_buffer =gen7_fill_curbe_buffer_data (batch, color); + interface_descriptor =gen8_fill_interface_descriptor (batch, dst, + media_kernel,sizeof (media_kernel));igt_assert (batch->ptr < &batch->buffer[4095 ]);/* media pipeline */ @@ -362,6 +83,6 @@ gen8lp_media_fillfunc(struct intel_batchbuffer *batch, batch_end =batch_align (batch,8 );igt_assert (batch_end <BATCH_STATE_SPLIT ); -gen8_render_flush (batch, batch_end); +gen7_render_flush (batch, batch_end);intel_batchbuffer_reset (batch); }lib/media_fill_gen9.c +5
-299@@ -4,11 +4,9 @@#include "media_fill.h" #include "gen8_media.h" #include "intel_reg.h" - +#include "gpu_fill.h" #include <assert.h> -#define ALIGN (x, y) (((x) + (y)-1) & ~((y)-1)) -static const uint32_t media_kernel[][4 ] = { {0x00400001 ,0x20202288 ,0x00000020 ,0x00000000 }, {0x00600001 ,0x20800208 ,0x008d0000 ,0x00000000 },@@ -23,299 +21,6 @@ static const uint32_t media_kernel[][4] = { { 0x07800031, 0x20000a40, 0x0e000e00, 0x82000010 }, }; -static uint32_t -batch_used (struct intel_batchbuffer *batch) -{ -return batch->ptr - batch->buffer; -} - -static uint32_t -batch_align (struct intel_batchbuffer *batch,uint32_t align) -{ -uint32_t offset =batch_used (batch); - offset =ALIGN (offset, align); - batch->ptr = batch->buffer + offset; -return offset; -} - -static void * -batch_alloc (struct intel_batchbuffer *batch,uint32_t size,uint32_t align) -{ -uint32_t offset =batch_align (batch, align); - batch->ptr += size; -return memset (batch->buffer + offset,0 , size); -} - -static uint32_t -batch_offset (struct intel_batchbuffer *batch,void *ptr) -{ -return (uint8_t *)ptr - batch->buffer; -} - -static uint32_t -batch_copy (struct intel_batchbuffer *batch,const void *ptr,uint32_t size,uint32_t align) -{ -return batch_offset (batch,memcpy (batch_alloc (batch, size, align), ptr, size)); -} - -static void -gen8_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end) -{ -int ret; - - ret =drm_intel_bo_subdata (batch->bo,0 ,4096 , batch->buffer); -if (ret ==0 ) - ret =drm_intel_bo_mrb_exec (batch->bo, batch_end, -NULL ,0 ,0 ,0 ); -assert (ret ==0 ); -} - -static uint32_t -gen8_fill_curbe_buffer_data (struct intel_batchbuffer *batch, -uint8_t color) -{ -uint8_t *curbe_buffer; -uint32_t offset; - - curbe_buffer =batch_alloc (batch,sizeof (uint32_t ) *8 ,64 ); - offset =batch_offset (batch, curbe_buffer); - *curbe_buffer = color; - -return offset; -} - -static uint32_t -gen8_fill_surface_state (struct intel_batchbuffer *batch, -struct igt_buf *buf, -uint32_t format, -int is_dst) -{ -struct gen8_surface_state *ss; -uint32_t write_domain, read_domain, offset; -int ret; - -if (is_dst) { - write_domain = read_domain =I915_GEM_DOMAIN_RENDER ; - }else { - write_domain =0 ; - read_domain =I915_GEM_DOMAIN_SAMPLER ; - } - - ss =batch_alloc (batch,sizeof (*ss),64 ); - offset =batch_offset (batch, ss); - - ss->ss0.surface_type =GEN8_SURFACE_2D ; - ss->ss0.surface_format = format; - ss->ss0.render_cache_read_write =1 ; - ss->ss0.vertical_alignment =1 ;/* align 4 */ - ss->ss0.horizontal_alignment =1 ;/* align 4 */ - -if (buf->tiling ==I915_TILING_X ) - ss->ss0.tiled_mode =2 ; -else if (buf->tiling ==I915_TILING_Y ) - ss->ss0.tiled_mode =3 ; - - ss->ss8.base_addr = buf->bo->offset; - - ret =drm_intel_bo_emit_reloc (batch->bo, -batch_offset (batch, ss) +8 *4 , - buf->bo,0 , - read_domain, write_domain); -assert (ret ==0 ); - - ss->ss2.height =igt_buf_height (buf) -1 ; - ss->ss2.width =igt_buf_width (buf) -1 ; - ss->ss3.pitch = buf->stride -1 ; - - ss->ss7.shader_chanel_select_r =4 ; - ss->ss7.shader_chanel_select_g =5 ; - ss->ss7.shader_chanel_select_b =6 ; - ss->ss7.shader_chanel_select_a =7 ; - -return offset; -} - -static uint32_t -gen8_fill_binding_table (struct intel_batchbuffer *batch, -struct igt_buf *dst) -{ -uint32_t *binding_table, offset; - - binding_table =batch_alloc (batch,32 ,64 ); - offset =batch_offset (batch, binding_table); - - binding_table[0 ] =gen8_fill_surface_state (batch, dst,GEN8_SURFACEFORMAT_R8_UNORM ,1 ); - -return offset; -} - -static uint32_t -gen8_fill_media_kernel (struct intel_batchbuffer *batch, -const uint32_t kernel[][4 ], -size_t size) -{ -uint32_t offset; - - offset =batch_copy (batch, kernel, size,64 ); - -return offset; -} - -static uint32_t -gen8_fill_interface_descriptor (struct intel_batchbuffer *batch,struct igt_buf *dst) -{ -struct gen8_interface_descriptor_data *idd; -uint32_t offset; -uint32_t binding_table_offset, kernel_offset; - - binding_table_offset =gen8_fill_binding_table (batch, dst); - kernel_offset =gen8_fill_media_kernel (batch, media_kernel,sizeof (media_kernel)); - - idd =batch_alloc (batch,sizeof (*idd),64 ); - offset =batch_offset (batch, idd); - - idd->desc0.kernel_start_pointer = (kernel_offset >>6 ); - - idd->desc2.single_program_flow =1 ; - idd->desc2.floating_point_mode =GEN8_FLOATING_POINT_IEEE_754 ; - - idd->desc3.sampler_count =0 ;/* 0 samplers used */ - idd->desc3.sampler_state_pointer =0 ; - - idd->desc4.binding_table_entry_count =0 ; - idd->desc4.binding_table_pointer = (binding_table_offset >>5 ); - - idd->desc5.constant_urb_entry_read_offset =0 ; - idd->desc5.constant_urb_entry_read_length =1 ;/* grf 1 */ - -return offset; -} - -static void -gen9_emit_state_base_address (struct intel_batchbuffer *batch) -{ -OUT_BATCH (GEN8_STATE_BASE_ADDRESS | (19 -2 )); - -/* general */ -OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); -OUT_BATCH (0 ); - -/* stateless data port */ -OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); - -/* surface */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_SAMPLER ,0 ,BASE_ADDRESS_MODIFY ); - -/* dynamic */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_RENDER |I915_GEM_DOMAIN_INSTRUCTION , -0 ,BASE_ADDRESS_MODIFY ); - -/* indirect */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* instruction */ -OUT_RELOC (batch->bo,I915_GEM_DOMAIN_INSTRUCTION ,0 ,BASE_ADDRESS_MODIFY ); - -/* general state buffer size */ -OUT_BATCH (0xfffff000 |1 ); -/* dynamic state buffer size */ -OUT_BATCH (1 <<12 |1 ); -/* indirect object buffer size */ -OUT_BATCH (0xfffff000 |1 ); -/* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */ -OUT_BATCH (1 <<12 |1 ); - -/* Bindless surface state base address */ -OUT_BATCH (0 |BASE_ADDRESS_MODIFY ); -OUT_BATCH (0 ); -OUT_BATCH (0xfffff000 ); -} - -static void -gen8_emit_vfe_state (struct intel_batchbuffer *batch) -{ -OUT_BATCH (GEN8_MEDIA_VFE_STATE | (9 -2 )); - -/* scratch buffer */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* number of threads & urb entries */ -OUT_BATCH (1 <<16 | -2 <<8 ); - -OUT_BATCH (0 ); - -/* urb entry size & curbe size */ -OUT_BATCH (2 <<16 | -2 ); - -/* scoreboard */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); -OUT_BATCH (0 ); -} - -static void -gen8_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer) -{ -OUT_BATCH (GEN8_MEDIA_CURBE_LOAD | (4 -2 )); -OUT_BATCH (0 ); -/* curbe total data length */ -OUT_BATCH (64 ); -/* curbe data start address, is relative to the dynamics base address */ -OUT_BATCH (curbe_buffer); -} - -static void -gen8_emit_interface_descriptor_load (struct intel_batchbuffer *batch,uint32_t interface_descriptor) -{ -OUT_BATCH (GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 -2 )); -OUT_BATCH (0 ); -/* interface descriptor data length */ -OUT_BATCH (sizeof (struct gen8_interface_descriptor_data )); -/* interface descriptor address, is relative to the dynamics base address */ -OUT_BATCH (interface_descriptor); -} - -static void -gen8_emit_media_state_flush (struct intel_batchbuffer *batch) -{ -OUT_BATCH (GEN8_MEDIA_STATE_FLUSH | (2 -2 )); -OUT_BATCH (0 ); -} - -static void -gen8_emit_media_objects (struct intel_batchbuffer *batch, -unsigned x,unsigned y, -unsigned width,unsigned height) -{ -int i, j; - -for (i =0 ; i < width /16 ; i++) { -for (j =0 ; j < height /16 ; j++) { -OUT_BATCH (GEN8_MEDIA_OBJECT | (8 -2 )); - -/* interface descriptor offset */ -OUT_BATCH (0 ); - -/* without indirect data */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* scoreboard */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* inline data (xoffset, yoffset) */ -OUT_BATCH (x + i *16 ); -OUT_BATCH (y + j *16 ); -gen8_emit_media_state_flush (batch); - } - } -} -/* * This sets up the media pipeline, * @@ -353,8 +58,9 @@ gen9_media_fillfunc(struct intel_batchbuffer *batch,/* setup states */ batch->ptr = &batch->buffer[BATCH_STATE_SPLIT ]; - curbe_buffer =gen8_fill_curbe_buffer_data (batch, color); - interface_descriptor =gen8_fill_interface_descriptor (batch, dst); + curbe_buffer =gen7_fill_curbe_buffer_data (batch, color); + interface_descriptor =gen8_fill_interface_descriptor (batch, dst, + media_kernel,sizeof (media_kernel));assert (batch->ptr < &batch->buffer[4095 ]);/* media pipeline */ @@ -387,6 +93,6 @@ gen9_media_fillfunc(struct intel_batchbuffer *batch, batch_end =batch_align (batch,8 );assert (batch_end <BATCH_STATE_SPLIT ); -gen8_render_flush (batch, batch_end); +gen7_render_flush (batch, batch_end);intel_batchbuffer_reset (batch); }lib/meson.build +0
-0
lib/meson.build lib_sources = [ · line 30
Quoted 7 lines
lib/meson.build +1
-0@@ -24,6 +24,7 @@ lib_sources = [ 'intel_os.c', 'intel_mmio.c', 'ioctl_wrappers.c', + 'gpu_fill.c', 'media_fill_gen7.c', 'media_fill_gen8.c', 'media_fill_gen8lp.c',
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 1/4] lib: Move common gpgpu/media functions to gpu_fill library
Quoted 71 lines · Daniele Ceraolo Spurio
Quoted 57 lines · Katarzyna Dec
Gpgpu_fillandmedia_filllibraries are very similar and many functions can be shared. I have created librarygpu_fillwith all functions needed for implementinggpgpu_fillandmedia_filltests for all Gens. Duplicates, e.g. where only name was changed, were removed. The earliest common function remained.v2: Changed code layout.
GenX_fill_media_kernelwas identical togenX_fill_gpgpu_kernelso this function was unified togen7_fill_kernel. There were 2 very similar functionsgen8_emit_state_base_addressfor media and gpgpu, where the one for gpgpu was configured like it would be using indirect state (while we are using CURBE). I have checked if media fill version works fine in gpgpu test on Gen8 and unified them.Signed-off-by Katarzyna Dec <[email protected]>Cc Lukasz Kalamarz <[email protected]>Cc Daniele Ceraolo Spurio <[email protected]>---
lib/Makefile.sources | 2 +
lib/gpgpu_fill.c | 567 +------------------------------------ lib/gpu_fill.c | 729
++++++++++++++++++++++++++++++++++++++++++++++++
lib/gpu_fill.h | 141 ++++++++++ lib/media_fill_gen7.c | 271 +----------------- lib/media_fill_gen8.c | 297 +-------------------lib/media_fill_gen8lp.c| 289 +------------------ lib/media_fill_gen9.c | 304 +------------------- lib/meson.build | 1 +9 files changed, 890 insertions(+), 1711 deletions(-)create mode 100644
lib/gpu_fill.c
create mode 100644lib/gpu_fill.hlib/Makefile.sources +2
-0@@ -55,6 +55,8 @@ lib_source_list = \ intel_reg.h \ ioctl_wrappers.c \ ioctl_wrappers.h \ + gpu_fill.h \ + gpu_fill.c \ media_fill.h \ media_fill_gen7.c \ media_fill_gen8.c \lib/gpgpu_fill.c +1
-0@@ -34,6 +34,7 @@ #include "gen7_media.h" #include "gen8_media.h" #include "gpgpu_fill.h" +#include "gpu_fill.h" /* shaders/gpgpu/gpgpu_fill.gxa */ static const uint32_t gen7_gpgpu_kernel[][4] = {lib/gpgpu_fill.c static const uint32_t gen9_gpgpu_kernel[][4] = { · line 82
Quoted 8 lines
lib/gpgpu_fill.c +0
-6@@ -75,572 +76,6 @@ static const uint32_t gen9_gpgpu_kernel[][4] = { { 0x07800031, 0x20000a40, 0x06000e00, 0x82000010 }, }; -static uint32_t -batch_used (struct intel_batchbuffer *batch) -{ - return batch->ptr - batch->buffer; -} -Hi,
Quoted 6 lines
As I mentioned on the previous review I think that the batch_* functions shouldn't go to the
gpu_fill.cfile and should instead go with the otherintel_batchbuffermethods. I don't think that moving it togpu_fill.cas an interim solution works because we'll have to do another patch to move everything tointel_batchbuffer.c, including the other copies of the functions from the rendercopy files. It makes more sense IMO to move the code directly to its final destination. If Lukasz is going to look at that then please sync with him so that his patch goes before this one (either as part of this series or standalone).Thanks,
Daniele
I've realized I've been a bit unclear here, considering that you've already said in the cover letter that your plan was to move the batch_* functions as a second step. What I wanted to express above is that I think moving the batch_* as first step is cleaner and results in overall less work (only moving things once). This isn't a blocking suggestion.
Daniele
Quoted 2,834 lines
Quoted 2,834 lines
lib/gpgpu_fill.c +0
-166-static uint32_t -batch_align (struct intel_batchbuffer *batch,uint32_t align) -{ - uint32_t offset = batch_used(batch); - offset = ALIGN(offset, align); - batch->ptr = batch->buffer + offset; - return offset; -} - -static void * -batch_alloc (struct intel_batchbuffer *batch,uint32_t size,uint32_t align) -{ - uint32_t offset = batch_align(batch, align); - batch->ptr += size; - return memset(batch->buffer + offset, 0, size); -} - -static uint32_t -batch_offset (struct intel_batchbuffer *batch,void *ptr) -{ - return (uint8_t *)ptr - batch->buffer; -} - -static uint32_t -batch_copy (struct intel_batchbuffer *batch,const void *ptr,uint32_t size, - uint32_t align) -{ - return batch_offset(batch, memcpy(batch_alloc(batch, size, align), ptr, size)); -} - -static void -gen7_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end) -{ - int ret; - - ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer); - if (ret == 0) - ret = drm_intel_bo_mrb_exec(batch->bo, batch_end, - NULL, 0, 0, 0); - igt_assert(ret == 0); -} - -static uint32_t -gen7_fill_curbe_buffer_data (struct intel_batchbuffer *batch,uint8_t color) -{ - uint8_t *curbe_buffer; - uint32_t offset; - - curbe_buffer = batch_alloc(batch, sizeof(uint32_t) * 8, 64); - offset = batch_offset(batch, curbe_buffer); - *curbe_buffer = color; - - return offset; -} - -static uint32_t -gen7_fill_surface_state (struct intel_batchbuffer *batch, - struct igt_buf *buf, - uint32_t format, - int is_dst) -{ - struct gen7_surface_state *ss; - uint32_t write_domain, read_domain, offset; - int ret; - - if (is_dst) { - write_domain = read_domain = I915_GEM_DOMAIN_RENDER; - } else { - write_domain = 0; - read_domain = I915_GEM_DOMAIN_SAMPLER; - } - - ss = batch_alloc(batch, sizeof(*ss), 64); - offset = batch_offset(batch, ss); - - ss->ss0.surface_type = GEN7_SURFACE_2D; - ss->ss0.surface_format = format; - ss->ss0.render_cache_read_write = 1; - - if (buf->tiling == I915_TILING_X) - ss->ss0.tiled_mode = 2; - else if (buf->tiling == I915_TILING_Y) - ss->ss0.tiled_mode = 3; - - ss->ss1.base_addr = buf->bo->offset; - ret = drm_intel_bo_emit_reloc(batch->bo, - batch_offset(batch, ss) + 4, - buf->bo, 0, - read_domain, write_domain); - igt_assert(ret == 0); - - ss->ss2.height = igt_buf_height(buf) - 1; - ss->ss2.width = igt_buf_width(buf) - 1; - - ss->ss3.pitch = buf->stride - 1; - - ss->ss7.shader_chanel_select_r = 4; - ss->ss7.shader_chanel_select_g = 5; - ss->ss7.shader_chanel_select_b = 6; - ss->ss7.shader_chanel_select_a = 7; - - return offset; -} - -static uint32_t -gen8_fill_surface_state (struct intel_batchbuffer *batch, - struct igt_buf *buf, - uint32_t format, - int is_dst) -{ - struct gen8_surface_state *ss; - uint32_t write_domain, read_domain, offset; - int ret; - - if (is_dst) { - write_domain = read_domain = I915_GEM_DOMAIN_RENDER; - } else { - write_domain = 0; - read_domain = I915_GEM_DOMAIN_SAMPLER; - } - - ss = batch_alloc(batch, sizeof(*ss), 64); - offset = batch_offset(batch, ss); - - ss->ss0.surface_type = GEN8_SURFACE_2D; - ss->ss0.surface_format = format; - ss->ss0.render_cache_read_write = 1; - ss->ss0.vertical_alignment = 1; /* align 4 */ - ss->ss0.horizontal_alignment = 1; /* align 4 */ - - if (buf->tiling == I915_TILING_X) - ss->ss0.tiled_mode = 2; - else if (buf->tiling == I915_TILING_Y) - ss->ss0.tiled_mode = 3; - - ss->ss8.base_addr = buf->bo->offset; - - ret = drm_intel_bo_emit_reloc(batch->bo, - batch_offset(batch, ss) + 8 * 4, - buf->bo, 0, - read_domain, write_domain); - igt_assert_eq(ret, 0); - - ss->ss2.height = igt_buf_height(buf) - 1; - ss->ss2.width = igt_buf_width(buf) - 1; - ss->ss3.pitch = buf->stride - 1; - - ss->ss7.shader_chanel_select_r = 4; - ss->ss7.shader_chanel_select_g = 5; - ss->ss7.shader_chanel_select_b = 6; - ss->ss7.shader_chanel_select_a = 7; - - return offset; - -} - -static uint32_t -gen7_fill_binding_table (struct intel_batchbuffer *batch, - struct igt_buf *dst) -{ - uint32_t *binding_table, offset; - - binding_table = batch_alloc(batch, 32, 64); - offset = batch_offset(batch, binding_table); - - binding_table[0] = gen7_fill_surface_state(batch, dst,
GEN7_SURFACEFORMAT_R8_UNORM, 1);lib/gpgpu_fill.c +0
-14- - return offset; -} - -static uint32_t -gen8_fill_binding_table (struct intel_batchbuffer *batch, - struct igt_buf *dst) -{ - uint32_t *binding_table, offset; - - binding_table = batch_alloc(batch, 32, 64); - offset = batch_offset(batch, binding_table); - - binding_table[0] = gen8_fill_surface_state(batch, dst,
GEN8_SURFACEFORMAT_R8_UNORM, 1);lib/gpgpu_fill.c +0
-18- - return offset; -} - -static uint32_t -gen7_fill_gpgpu_kernel (struct intel_batchbuffer *batch, - const uint32_t kernel[][4], - size_t size) -{ - uint32_t offset; - - offset = batch_copy(batch, kernel, size, 64); - - return offset; -} - -static uint32_t -gen7_fill_interface_descriptor(struct intel_batchbuffer *batch,struct
igt_buf*dst,
- constuint32_tkernel[][4],size_tsize)lib/gpgpu_fill.c +0
-30-{ - struct gen7_interface_descriptor_data *idd; - uint32_t offset; - uint32_t binding_table_offset, kernel_offset; - - binding_table_offset = gen7_fill_binding_table(batch, dst); - kernel_offset = gen7_fill_gpgpu_kernel(batch, kernel, size); - - idd = batch_alloc(batch, sizeof(*idd), 64); - offset = batch_offset(batch, idd); - - idd->desc0.kernel_start_pointer = (kernel_offset >> 6); - - idd->desc1.single_program_flow = 1; - idd->desc1.floating_point_mode = GEN7_FLOATING_POINT_IEEE_754; - - idd->desc2.sampler_count = 0; /* 0 samplers used */ - idd->desc2.sampler_state_pointer = 0; - - idd->desc3.binding_table_entry_count = 0; - idd->desc3.binding_table_pointer = (binding_table_offset >> 5); - - idd->desc4.constant_urb_entry_read_offset = 0; - idd->desc4.constant_urb_entry_read_length = 1; /* grf 1 */ - - return offset; -} - -static uint32_t -gen8_fill_interface_descriptor(struct intel_batchbuffer *batch,struct
igt_buf*dst,
- constuint32_tkernel[][4],size_tsize)lib/gpgpu_fill.c +0
-38-{ - struct gen8_interface_descriptor_data *idd; - uint32_t offset; - uint32_t binding_table_offset, kernel_offset; - - binding_table_offset = gen8_fill_binding_table(batch, dst); - kernel_offset = gen7_fill_gpgpu_kernel(batch, kernel, size); - - idd = batch_alloc(batch, sizeof(*idd), 64); - offset = batch_offset(batch, idd); - - idd->desc0.kernel_start_pointer = (kernel_offset >> 6); - - idd->desc2.single_program_flow = 1; - idd->desc2.floating_point_mode = GEN8_FLOATING_POINT_IEEE_754; - - idd->desc3.sampler_count = 0; /* 0 samplers used */ - idd->desc3.sampler_state_pointer = 0; - - idd->desc4.binding_table_entry_count = 0; - idd->desc4.binding_table_pointer = (binding_table_offset >> 5); - - idd->desc5.constant_urb_entry_read_offset = 0; - idd->desc5.constant_urb_entry_read_length = 1; /* grf 1 */ - - return offset; -} - -static void -gen7_emit_state_base_address (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN7_STATE_BASE_ADDRESS | (10 - 2)); - - /* general */ - OUT_BATCH(0); - - /* surface */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);
-
- /* dynamic */
-OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY);lib/gpgpu_fill.c +0
-6- - /* indirect */ - OUT_BATCH(0); - - /* instruction */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);lib/gpgpu_fill.c +0
-22- - /* general/dynamic/indirect/instruction access Bound */ - OUT_BATCH(0); - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(0); - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); -} - -static void -gen8_emit_state_base_address (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_STATE_BASE_ADDRESS | (16 - 2)); - - /* general */ - OUT_BATCH(0 | (0x78 << 4) | (0 << 1) | BASE_ADDRESS_MODIFY); - OUT_BATCH(0); - - /* stateless data port */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - - /* surface */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_SAMPLER, 0,
BASE_ADDRESS_MODIFY);
-
- /* dynamic */
- OUT_RELOC(batch->bo,I915_GEM_DOMAIN_RENDER|I915_GEM_DOMAIN_INSTRUCTION,
- 0,BASE_ADDRESS_MODIFY);lib/gpgpu_fill.c +0
-7- - /* indirect */ - OUT_BATCH(0); - OUT_BATCH(0 ); - - /* instruction */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);
-
- /* general state buffer size */
-OUT_BATCH(0xfffff000 | 1);
- /* dynamic state buffer size */
-OUT_BATCH(1 << 12 | 1);
- /* indirect object buffer size */
-OUT_BATCH(0xfffff000 | 1);
- /* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */
-OUT_BATCH(1 << 12 | 1);lib/gpgpu_fill.c +0
-16-} - -static void -gen9_emit_state_base_address (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_STATE_BASE_ADDRESS | (19 - 2)); - - /* general */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(0); - - /* stateless data port */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - - /* surface */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_SAMPLER, 0,
BASE_ADDRESS_MODIFY);
-
- /* dynamic */
- OUT_RELOC(batch->bo,I915_GEM_DOMAIN_RENDER|I915_GEM_DOMAIN_INSTRUCTION,
- 0,BASE_ADDRESS_MODIFY);lib/gpgpu_fill.c +0
-7- - /* indirect */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* instruction */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);
-
- /* general state buffer size */
-OUT_BATCH(0xfffff000 | 1);
- /* dynamic state buffer size */
-OUT_BATCH(1 << 12 | 1);
- /* indirect object buffer size */
-OUT_BATCH(0xfffff000 | 1);
- /* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */
-OUT_BATCH(1 << 12 | 1);lib/gpgpu_fill.c +0
-57- - /* Bindless surface state base address */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(0); - OUT_BATCH(0xfffff000); -} - -static void -gen7_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN7_MEDIA_VFE_STATE | (8 - 2)); - - /* scratch buffer */ - OUT_BATCH(0); - - /* number of threads & urb entries */ - OUT_BATCH(1 << 16 | /* max num of threads */ - 0 << 8 | /* num of URB entry */ - 1 << 2); /* GPGPU mode */ - - OUT_BATCH(0); - - /* urb entry size & curbe size */ - OUT_BATCH(0 << 16 | /* URB entry size in 256 bits unit */ - 1); /* CURBE entry size in 256 bits unit */ - - /* scoreboard */ - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(0); -} - -static void -gen8_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_MEDIA_VFE_STATE | (9 - 2)); - - /* scratch buffer */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* number of threads & urb entries */ - OUT_BATCH(1 << 16 | 1 << 8); - - OUT_BATCH(0); - - /* urb entry size & curbe size */ - OUT_BATCH(0 << 16 | 1); - - /* scoreboard */ - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(0); -} - -static void -gen7_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t
curbe_buffer)
-{
-OUT_BATCH(GEN7_MEDIA_CURBE_LOAD | (4 - 2));
-OUT_BATCH(0);
- /* curbe total data length */
-OUT_BATCH(64);
- /* curbe data start address, is relative to the dynamics base address */
-OUT_BATCH(curbe_buffer);lib/gpgpu_fill.c +0
-4-} - -static void -gen7_emit_interface_descriptor_load(struct intel_batchbuffer *batch,
uint32_tinterface_descriptor)
-{
-OUT_BATCH(GEN7_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 - 2)); -OUT_BATCH(0);
- /* interface descriptor data length */
-OUT_BATCH(sizeof(struct gen7_interface_descriptor_data)); - /* interface descriptor address, is relative to the dynamics base address */
-OUT_BATCH(interface_descriptor);lib/gpgpu_fill.c +0
-4-} - -static void -gen8_emit_interface_descriptor_load(struct intel_batchbuffer *batch,
uint32_tinterface_descriptor)
-{
-OUT_BATCH(GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 - 2)); -OUT_BATCH(0);
- /* interface descriptor data length */
-OUT_BATCH(sizeof(struct gen8_interface_descriptor_data)); - /* interface descriptor address, is relative to the dynamics base address */
-OUT_BATCH(interface_descriptor);lib/gpgpu_fill.c +0
-119-} - -static void -gen7_emit_gpgpu_walk (struct intel_batchbuffer *batch, - unsigned x, unsigned y, - unsigned width, unsigned height) -{ - uint32_t x_dim, y_dim, tmp, right_mask; - - /* - * Simply do SIMD16 based dispatch, so every thread uses - * SIMD16 channels. - * - * Define our own thread group size, e.g 16x1 for every group, then - * will have 1 thread each group in SIMD16 dispatch. So thread - * width/height/depth are all 1. - * - * Then thread group X = width / 16 (aligned to 16) - * thread group Y = height; - */ - x_dim = (width + 15) / 16; - y_dim = height; - - tmp = width & 15; - if (tmp == 0) - right_mask = (1 << 16) - 1; - else - right_mask = (1 << tmp) - 1; - - OUT_BATCH(GEN7_GPGPU_WALKER | 9); - - /* interface descriptor offset */ - OUT_BATCH(0); - - /* SIMD size, thread w/h/d */ - OUT_BATCH(1 << 30 | /* SIMD16 */ - 0 << 16 | /* depth:1 */ - 0 << 8 | /* height:1 */ - 0); /* width:1 */ - - /* thread group X */ - OUT_BATCH(0); - OUT_BATCH(x_dim); - - /* thread group Y */ - OUT_BATCH(0); - OUT_BATCH(y_dim); - - /* thread group Z */ - OUT_BATCH(0); - OUT_BATCH(1); - - /* right mask */ - OUT_BATCH(right_mask); - - /* bottom mask, height 1, always 0xffffffff */ - OUT_BATCH(0xffffffff); -} - -static void -gen8_emit_gpgpu_walk (struct intel_batchbuffer *batch, - unsigned x, unsigned y, - unsigned width, unsigned height) -{ - uint32_t x_dim, y_dim, tmp, right_mask; - - /* - * Simply do SIMD16 based dispatch, so every thread uses - * SIMD16 channels. - * - * Define our own thread group size, e.g 16x1 for every group, then - * will have 1 thread each group in SIMD16 dispatch. So thread - * width/height/depth are all 1. - * - * Then thread group X = width / 16 (aligned to 16) - * thread group Y = height; - */ - x_dim = (width + 15) / 16; - y_dim = height; - - tmp = width & 15; - if (tmp == 0) - right_mask = (1 << 16) - 1; - else - right_mask = (1 << tmp) - 1; - - OUT_BATCH(GEN7_GPGPU_WALKER | 13); - - OUT_BATCH(0); /* kernel offset */ - OUT_BATCH(0); /* indirect data length */ - OUT_BATCH(0); /* indirect data offset */ - - /* SIMD size, thread w/h/d */ - OUT_BATCH(1 << 30 | /* SIMD16 */ - 0 << 16 | /* depth:1 */ - 0 << 8 | /* height:1 */ - 0); /* width:1 */ - - /* thread group X */ - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(x_dim); - - /* thread group Y */ - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(y_dim); - - /* thread group Z */ - OUT_BATCH(0); - OUT_BATCH(1); - - /* right mask */ - OUT_BATCH(right_mask); - - /* bottom mask, height 1, always 0xffffffff */ - OUT_BATCH(0xffffffff); -} -/*
* This sets up the gpgpu pipeline,
*lib/gpu_fill.c new file +28
-0@@ -0,0 +1,729 @@ +#include <intel_bufmgr.h> +#include <i915_drm.h> + +#include "intel_reg.h" +#include "drmtest.h" +#include "gpu_fill.h" +#include <assert.h> +#include "gen7_media.h" +#include "gen8_media.h" + + +uint32_t +batch_used (struct intel_batchbuffer *batch) +{ + return batch->ptr - batch->buffer; +} + +uint32_t +batch_align (struct intel_batchbuffer *batch,uint32_t align) +{ + uint32_t offset = batch_used(batch); + offset = ALIGN(offset, align); + batch->ptr = batch->buffer + offset; + return offset; +} + +void * +batch_alloc(struct intel_batchbuffer *batch, uint32_t size, uint32_talign)
lib/gpu_fill.c new file +14
-0+{ + uint32_t offset = batch_align(batch, align); + batch->ptr += size; + return memset(batch->buffer + offset, 0, size); +} + +uint32_t +batch_offset (struct intel_batchbuffer *batch,void *ptr) +{ + return (uint8_t *)ptr - batch->buffer; +} + +uint32_t +batch_copy(struct intel_batchbuffer *batch, const void *ptr, uint32_tsize,
uint32_talign)
+{
+ returnbatch_offset(batch, memcpy(batch_alloc(batch, size, align), ptr, size));lib/gpu_fill.c new file +87
-0+} + +void +gen7_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end) +{ + int ret; + + ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer); + if (ret == 0) + ret = drm_intel_bo_mrb_exec(batch->bo, batch_end, + NULL, 0, 0, 0); + igt_assert(ret == 0); +} + +uint32_t +gen7_fill_curbe_buffer_data (struct intel_batchbuffer *batch, + uint8_t color) +{ + uint8_t *curbe_buffer; + uint32_t offset; + + curbe_buffer = batch_alloc(batch, sizeof(uint32_t) * 8, 64); + offset = batch_offset(batch, curbe_buffer); + *curbe_buffer = color; + + return offset; +} + +uint32_t +gen7_fill_surface_state (struct intel_batchbuffer *batch, + struct igt_buf *buf, + uint32_t format, + int is_dst) +{ + struct gen7_surface_state *ss; + uint32_t write_domain, read_domain, offset; + int ret; + + if (is_dst) { + write_domain = read_domain = I915_GEM_DOMAIN_RENDER; + } else { + write_domain = 0; + read_domain = I915_GEM_DOMAIN_SAMPLER; + } + + ss = batch_alloc(batch, sizeof(*ss), 64); + offset = batch_offset(batch, ss); + + ss->ss0.surface_type = GEN7_SURFACE_2D; + ss->ss0.surface_format = format; + ss->ss0.render_cache_read_write = 1; + + if (buf->tiling == I915_TILING_X) + ss->ss0.tiled_mode = 2; + else if (buf->tiling == I915_TILING_Y) + ss->ss0.tiled_mode = 3; + + ss->ss1.base_addr = buf->bo->offset; + ret = drm_intel_bo_emit_reloc(batch->bo, + batch_offset(batch, ss) + 4, + buf->bo, 0, + read_domain, write_domain); + igt_assert(ret == 0); + + ss->ss2.height = igt_buf_height(buf) - 1; + ss->ss2.width = igt_buf_width(buf) - 1; + + ss->ss3.pitch = buf->stride - 1; + + ss->ss7.shader_chanel_select_r = 4; + ss->ss7.shader_chanel_select_g = 5; + ss->ss7.shader_chanel_select_b = 6; + ss->ss7.shader_chanel_select_a = 7; + + return offset; +} + +uint32_t +gen7_fill_binding_table (struct intel_batchbuffer *batch, + struct igt_buf *dst) +{ + uint32_t *binding_table, offset; + + binding_table = batch_alloc(batch, 32, 64); + offset = batch_offset(batch, binding_table); + + binding_table[0] = gen7_fill_surface_state(batch, dst,
GEN7_SURFACEFORMAT_R8_UNORM, 1);lib/gpu_fill.c new file +18
-0+ + return offset; +} + +uint32_t +gen7_fill_kernel (struct intel_batchbuffer *batch, + const uint32_t kernel[][4], + size_t size) +{ + uint32_t offset; + + offset = batch_copy(batch, kernel, size, 64); + + return offset; +} + +uint32_t +gen7_fill_interface_descriptor(struct intel_batchbuffer *batch,struct
igt_buf*dst,
+ constuint32_tkernel[][4],size_tsize)lib/gpu_fill.c new file +38
-0+{ + struct gen7_interface_descriptor_data *idd; + uint32_t offset; + uint32_t binding_table_offset, kernel_offset; + + binding_table_offset = gen7_fill_binding_table(batch, dst); + kernel_offset = gen7_fill_kernel(batch, kernel, size); + + idd = batch_alloc(batch, sizeof(*idd), 64); + offset = batch_offset(batch, idd); + + idd->desc0.kernel_start_pointer = (kernel_offset >> 6); + + idd->desc1.single_program_flow = 1; + idd->desc1.floating_point_mode = GEN7_FLOATING_POINT_IEEE_754; + + idd->desc2.sampler_count = 0; /* 0 samplers used */ + idd->desc2.sampler_state_pointer = 0; + + idd->desc3.binding_table_entry_count = 0; + idd->desc3.binding_table_pointer = (binding_table_offset >> 5); + + idd->desc4.constant_urb_entry_read_offset = 0; + idd->desc4.constant_urb_entry_read_length = 1; /* grf 1 */ + + return offset; +} + +void +gen7_emit_state_base_address (struct intel_batchbuffer *batch) +{ + OUT_BATCH(GEN7_STATE_BASE_ADDRESS | (10 - 2)); + + /* general */ + OUT_BATCH(0); + + /* surface */ + OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);
+
+ /* dynamic */
+OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY);lib/gpu_fill.c new file +6
-0+ + /* indirect */ + OUT_BATCH(0); + + /* instruction */ + OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);lib/gpu_fill.c new file +59
-0+ + /* general/dynamic/indirect/instruction access Bound */ + OUT_BATCH(0); + OUT_BATCH(0 | BASE_ADDRESS_MODIFY); + OUT_BATCH(0); + OUT_BATCH(0 | BASE_ADDRESS_MODIFY); +} + +void +gen7_emit_vfe_state (struct intel_batchbuffer *batch) +{ + OUT_BATCH(GEN7_MEDIA_VFE_STATE | (8 - 2)); + + /* scratch buffer */ + OUT_BATCH(0); + + /* number of threads & urb entries */ + OUT_BATCH(1 << 16 | + 2 << 8); + + OUT_BATCH(0); + + /* urb entry size & curbe size */ + OUT_BATCH(2 << 16 | /* in 256 bits unit */ + 2); /* in 256 bits unit */ + + /* scoreboard */ + OUT_BATCH(0); + OUT_BATCH(0); + OUT_BATCH(0); +} + +void +gen7_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch) +{ + OUT_BATCH(GEN7_MEDIA_VFE_STATE | (8 - 2)); + + /* scratch buffer */ + OUT_BATCH(0); + + /* number of threads & urb entries */ + OUT_BATCH(1 << 16 | /* max num of threads */ + 0 << 8 | /* num of URB entry */ + 1 << 2); /* GPGPU mode */ + + OUT_BATCH(0); + + /* urb entry size & curbe size */ + OUT_BATCH(0 << 16 | /* URB entry size in 256 bits unit */ + 1); /* CURBE entry size in 256 bits unit */ + + /* scoreboard */ + OUT_BATCH(0); + OUT_BATCH(0); + OUT_BATCH(0); +} + +void +gen7_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t
curbe_buffer)
+{
+OUT_BATCH(GEN7_MEDIA_CURBE_LOAD | (4 - 2));
+OUT_BATCH(0);
+ /* curbe total data length */
+OUT_BATCH(64);
+ /* curbe data start address, is relative to the dynamics base address */
+OUT_BATCH(curbe_buffer);lib/gpu_fill.c new file +4
-0+} + +void +gen7_emit_interface_descriptor_load(struct intel_batchbuffer *batch,
uint32_tinterface_descriptor)
+{
+OUT_BATCH(GEN7_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 - 2)); +OUT_BATCH(0);
+ /* interface descriptor data length */
+OUT_BATCH(sizeof(struct gen7_interface_descriptor_data)); + /* interface descriptor address, is relative to the dynamics base address */
+OUT_BATCH(interface_descriptor);lib/gpu_fill.c new file +149
-0+} + +void +gen7_emit_media_objects (struct intel_batchbuffer *batch, + unsigned x, unsigned y, + unsigned width, unsigned height) +{ + int i, j; + + for (i = 0; i < width / 16; i++) { + for (j = 0; j < height / 16; j++) { + OUT_BATCH(GEN7_MEDIA_OBJECT | (8 - 2)); + + /* interface descriptor offset */ + OUT_BATCH(0); + + /* without indirect data */ + OUT_BATCH(0); + OUT_BATCH(0); + + /* scoreboard */ + OUT_BATCH(0); + OUT_BATCH(0); + + /* inline data (xoffset, yoffset) */ + OUT_BATCH(x + i * 16); + OUT_BATCH(y + j * 16); + } + } +} + +void +gen7_emit_gpgpu_walk (struct intel_batchbuffer *batch, + unsigned x, unsigned y, + unsigned width, unsigned height) +{ + uint32_t x_dim, y_dim, tmp, right_mask; + + /* + * Simply do SIMD16 based dispatch, so every thread uses + * SIMD16 channels. + * + * Define our own thread group size, e.g 16x1 for every group, then + * will have 1 thread each group in SIMD16 dispatch. So thread + * width/height/depth are all 1. + * + * Then thread group X = width / 16 (aligned to 16) + * thread group Y = height; + */ + x_dim = (width + 15) / 16; + y_dim = height; + + tmp = width & 15; + if (tmp == 0) + right_mask = (1 << 16) - 1; + else + right_mask = (1 << tmp) - 1; + + OUT_BATCH(GEN7_GPGPU_WALKER | 9); + + /* interface descriptor offset */ + OUT_BATCH(0); + + /* SIMD size, thread w/h/d */ + OUT_BATCH(1 << 30 | /* SIMD16 */ + 0 << 16 | /* depth:1 */ + 0 << 8 | /* height:1 */ + 0); /* width:1 */ + + /* thread group X */ + OUT_BATCH(0); + OUT_BATCH(x_dim); + + /* thread group Y */ + OUT_BATCH(0); + OUT_BATCH(y_dim); + + /* thread group Z */ + OUT_BATCH(0); + OUT_BATCH(1); + + /* right mask */ + OUT_BATCH(right_mask); + + /* bottom mask, height 1, always 0xffffffff */ + OUT_BATCH(0xffffffff); +} + +uint32_t +gen8_fill_surface_state (struct intel_batchbuffer *batch, + struct igt_buf *buf, + uint32_t format, + int is_dst) +{ + struct gen8_surface_state *ss; + uint32_t write_domain, read_domain, offset; + int ret; + + if (is_dst) { + write_domain = read_domain = I915_GEM_DOMAIN_RENDER; + } else { + write_domain = 0; + read_domain = I915_GEM_DOMAIN_SAMPLER; + } + + ss = batch_alloc(batch, sizeof(*ss), 64); + offset = batch_offset(batch, ss); + + ss->ss0.surface_type = GEN8_SURFACE_2D; + ss->ss0.surface_format = format; + ss->ss0.render_cache_read_write = 1; + ss->ss0.vertical_alignment = 1; /* align 4 */ + ss->ss0.horizontal_alignment = 1; /* align 4 */ + + if (buf->tiling == I915_TILING_X) + ss->ss0.tiled_mode = 2; + else if (buf->tiling == I915_TILING_Y) + ss->ss0.tiled_mode = 3; + + ss->ss8.base_addr = buf->bo->offset; + + ret = drm_intel_bo_emit_reloc(batch->bo, + batch_offset(batch, ss) + 8 * 4, + buf->bo, 0, + read_domain, write_domain); + igt_assert(ret == 0); + + ss->ss2.height = igt_buf_height(buf) - 1; + ss->ss2.width = igt_buf_width(buf) - 1; + ss->ss3.pitch = buf->stride - 1; + + ss->ss7.shader_chanel_select_r = 4; + ss->ss7.shader_chanel_select_g = 5; + ss->ss7.shader_chanel_select_b = 6; + ss->ss7.shader_chanel_select_a = 7; + + return offset; +} + +uint32_t +gen8_fill_binding_table (struct intel_batchbuffer *batch, + struct igt_buf *dst) +{ + uint32_t *binding_table, offset; + + binding_table = batch_alloc(batch, 32, 64); + offset = batch_offset(batch, binding_table); + + binding_table[0] = gen8_fill_surface_state(batch, dst,
GEN8_SURFACEFORMAT_R8_UNORM, 1);lib/gpu_fill.c new file +6
-0+ + return offset; +} + +uint32_t +gen8_fill_interface_descriptor(struct intel_batchbuffer *batch,struct
igt_buf*dst, constuint32_tkernel[][4],size_tsize)lib/gpu_fill.c new file +42
-0+{ + struct gen8_interface_descriptor_data *idd; + uint32_t offset; + uint32_t binding_table_offset, kernel_offset; + + binding_table_offset = gen8_fill_binding_table(batch, dst); + kernel_offset = gen7_fill_kernel(batch, kernel, sizeof(kernel)); + + idd = batch_alloc(batch, sizeof(*idd), 64); + offset = batch_offset(batch, idd); + + idd->desc0.kernel_start_pointer = (kernel_offset >> 6); + + idd->desc2.single_program_flow = 1; + idd->desc2.floating_point_mode = GEN8_FLOATING_POINT_IEEE_754; + + idd->desc3.sampler_count = 0; /* 0 samplers used */ + idd->desc3.sampler_state_pointer = 0; + + idd->desc4.binding_table_entry_count = 0; + idd->desc4.binding_table_pointer = (binding_table_offset >> 5); + + idd->desc5.constant_urb_entry_read_offset = 0; + idd->desc5.constant_urb_entry_read_length = 1; /* grf 1 */ + + return offset; +} + +void +gen8_emit_state_base_address (struct intel_batchbuffer *batch) +{ + OUT_BATCH(GEN8_STATE_BASE_ADDRESS | (16 - 2)); + + /* general */ + OUT_BATCH(0 | BASE_ADDRESS_MODIFY); + OUT_BATCH(0); + + /* stateless data port */ + OUT_BATCH(0 | BASE_ADDRESS_MODIFY); + + /* surface */ + OUT_RELOC(batch->bo, I915_GEM_DOMAIN_SAMPLER, 0,
BASE_ADDRESS_MODIFY);
+
+ /* dynamic */
+ OUT_RELOC(batch->bo,I915_GEM_DOMAIN_RENDER|I915_GEM_DOMAIN_INSTRUCTION,
+ 0,BASE_ADDRESS_MODIFY);lib/gpu_fill.c new file +7
-0+ + /* indirect */ + OUT_BATCH(0); + OUT_BATCH(0); + + /* instruction */ + OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);
+
+ /* general state buffer size */
+OUT_BATCH(0xfffff000 | 1);
+ /* dynamic state buffer size */
+OUT_BATCH(1 << 12 | 1);
+ /* indirect object buffer size */
+OUT_BATCH(0xfffff000 | 1);
+ /* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */
+OUT_BATCH(1 << 12 | 1);lib/gpu_fill.c new file +52
-0+} + +void +gen8_emit_vfe_state (struct intel_batchbuffer *batch) +{ + OUT_BATCH(GEN8_MEDIA_VFE_STATE | (9 - 2)); + + /* scratch buffer */ + OUT_BATCH(0); + OUT_BATCH(0); + + /* number of threads & urb entries */ + OUT_BATCH(1 << 16 | + 2 << 8); + + OUT_BATCH(0); + + /* urb entry size & curbe size */ + OUT_BATCH(2 << 16 | + 2); + + /* scoreboard */ + OUT_BATCH(0); + OUT_BATCH(0); + OUT_BATCH(0); +} + +void +gen8_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch) +{ + OUT_BATCH(GEN8_MEDIA_VFE_STATE | (9 - 2)); + + /* scratch buffer */ + OUT_BATCH(0); + OUT_BATCH(0); + + /* number of threads & urb entries */ + OUT_BATCH(1 << 16 | 1 << 8); + + OUT_BATCH(0); + + /* urb entry size & curbe size */ + OUT_BATCH(0 << 16 | 1); + + /* scoreboard */ + OUT_BATCH(0); + OUT_BATCH(0); + OUT_BATCH(0); +} + +void +gen8_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t
curbe_buffer)
+{
+OUT_BATCH(GEN8_MEDIA_CURBE_LOAD | (4 - 2));
+OUT_BATCH(0);
+ /* curbe total data length */
+OUT_BATCH(64);
+ /* curbe data start address, is relative to the dynamics base address */
+OUT_BATCH(curbe_buffer);lib/gpu_fill.c new file +4
-0+} + +void +gen8_emit_interface_descriptor_load(struct intel_batchbuffer *batch,
uint32_tinterface_descriptor)
+{
+OUT_BATCH(GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 - 2)); +OUT_BATCH(0);
+ /* interface descriptor data length */
+OUT_BATCH(sizeof(struct gen8_interface_descriptor_data)); + /* interface descriptor address, is relative to the dynamics base address */
+OUT_BATCH(interface_descriptor);lib/gpu_fill.c new file +142
-0+} + +void +gen8_emit_media_state_flush (struct intel_batchbuffer *batch) +{ + OUT_BATCH(GEN8_MEDIA_STATE_FLUSH | (2 - 2)); + OUT_BATCH(0); +} + +void +gen8_emit_media_objects (struct intel_batchbuffer *batch, + unsigned x, unsigned y, + unsigned width, unsigned height) +{ + int i, j; + + for (i = 0; i < width / 16; i++) { + for (j = 0; j < height / 16; j++) { + OUT_BATCH(GEN8_MEDIA_OBJECT | (8 - 2)); + + /* interface descriptor offset */ + OUT_BATCH(0); + + /* without indirect data */ + OUT_BATCH(0); + OUT_BATCH(0); + + /* scoreboard */ + OUT_BATCH(0); + OUT_BATCH(0); + + /* inline data (xoffset, yoffset) */ + OUT_BATCH(x + i * 16); + OUT_BATCH(y + j * 16); + gen8_emit_media_state_flush(batch); + } + } +} + +void +gen8lp_emit_media_objects (struct intel_batchbuffer *batch, + unsigned x, unsigned y, + unsigned width, unsigned height) +{ + int i, j; + + for (i = 0; i < width / 16; i++) { + for (j = 0; j < height / 16; j++) { + OUT_BATCH(GEN8_MEDIA_OBJECT | (8 - 2)); + + /* interface descriptor offset */ + OUT_BATCH(0); + + /* without indirect data */ + OUT_BATCH(0); + OUT_BATCH(0); + + /* scoreboard */ + OUT_BATCH(0); + OUT_BATCH(0); + + /* inline data (xoffset, yoffset) */ + OUT_BATCH(x + i * 16); + OUT_BATCH(y + j * 16); + } + } +} + +void +gen8_emit_gpgpu_walk (struct intel_batchbuffer *batch, + unsigned x, unsigned y, + unsigned width, unsigned height) +{ + uint32_t x_dim, y_dim, tmp, right_mask; + + /* + * Simply do SIMD16 based dispatch, so every thread uses + * SIMD16 channels. + * + * Define our own thread group size, e.g 16x1 for every group, then + * will have 1 thread each group in SIMD16 dispatch. So thread + * width/height/depth are all 1. + * + * Then thread group X = width / 16 (aligned to 16) + * thread group Y = height; + */ + x_dim = (width + 15) / 16; + y_dim = height; + + tmp = width & 15; + if (tmp == 0) + right_mask = (1 << 16) - 1; + else + right_mask = (1 << tmp) - 1; + + OUT_BATCH(GEN7_GPGPU_WALKER | 13); + + OUT_BATCH(0); /* kernel offset */ + OUT_BATCH(0); /* indirect data length */ + OUT_BATCH(0); /* indirect data offset */ + + /* SIMD size, thread w/h/d */ + OUT_BATCH(1 << 30 | /* SIMD16 */ + 0 << 16 | /* depth:1 */ + 0 << 8 | /* height:1 */ + 0); /* width:1 */ + + /* thread group X */ + OUT_BATCH(0); + OUT_BATCH(0); + OUT_BATCH(x_dim); + + /* thread group Y */ + OUT_BATCH(0); + OUT_BATCH(0); + OUT_BATCH(y_dim); + + /* thread group Z */ + OUT_BATCH(0); + OUT_BATCH(1); + + /* right mask */ + OUT_BATCH(right_mask); + + /* bottom mask, height 1, always 0xffffffff */ + OUT_BATCH(0xffffffff); +} + +void +gen9_emit_state_base_address (struct intel_batchbuffer *batch) +{ + OUT_BATCH(GEN8_STATE_BASE_ADDRESS | (19 - 2)); + + /* general */ + OUT_BATCH(0 | BASE_ADDRESS_MODIFY); + OUT_BATCH(0); + + /* stateless data port */ + OUT_BATCH(0 | BASE_ADDRESS_MODIFY); + + /* surface */ + OUT_RELOC(batch->bo, I915_GEM_DOMAIN_SAMPLER, 0,
BASE_ADDRESS_MODIFY);
+
+ /* dynamic */
+ OUT_RELOC(batch->bo,I915_GEM_DOMAIN_RENDER|I915_GEM_DOMAIN_INSTRUCTION,
+ 0,BASE_ADDRESS_MODIFY);lib/gpu_fill.c new file +7
-0+ + /* indirect */ + OUT_BATCH(0); + OUT_BATCH(0); + + /* instruction */ + OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);
+
+ /* general state buffer size */
+OUT_BATCH(0xfffff000 | 1);
+ /* dynamic state buffer size */
+OUT_BATCH(1 << 12 | 1);
+ /* indirect object buffer size */
+OUT_BATCH(0xfffff000 | 1);
+ /* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */
+OUT_BATCH(1 << 12 | 1);lib/gpu_fill.c new file +6
-0+ + /* Bindless surface state base address */ + OUT_BATCH(0 | BASE_ADDRESS_MODIFY); + OUT_BATCH(0); + OUT_BATCH(0xfffff000); +}lib/gpu_fill.h new file +4
-0@@ -0,0 +1,141 @@ +/* +* Copyright © 2018 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */lib/gpu_fill.h new file +12
-0+ +#ifndef GPU_FILL_H +#define GPU_FILL_H + +uint32_t +batch_used (struct intel_batchbuffer *batch); + +uint32_t +batch_align (struct intel_batchbuffer *batch,uint32_t align); + +void * +batch_alloc(struct intel_batchbuffer *batch, uint32_t size, uint32_talign);
lib/gpu_fill.h new file +6
-0+ +uint32_t +batch_offset (struct intel_batchbuffer *batch,void *ptr); + +uint32_t +batch_copy(struct intel_batchbuffer *batch, const void *ptr, uint32_tsize,
uint32_talign);lib/gpu_fill.h new file +24
-0+ +void +gen7_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end); + +uint32_t +gen7_fill_curbe_buffer_data (struct intel_batchbuffer *batch, + uint8_t color); + +uint32_t +gen7_fill_surface_state (struct intel_batchbuffer *batch, + struct igt_buf *buf, + uint32_t format, + int is_dst); + +uint32_t +gen7_fill_binding_table (struct intel_batchbuffer *batch, + struct igt_buf *dst); +uint32_t +gen7_fill_kernel (struct intel_batchbuffer *batch, + const uint32_t kernel[][4], + size_t size); + +uint32_t +gen7_fill_interface_descriptor(struct intel_batchbuffer *batch,struct
igt_buf*dst,
+ constuint32_tkernel[][4],size_tsize);lib/gpu_fill.h new file +12
-0+ +void +gen7_emit_state_base_address (struct intel_batchbuffer *batch); + +void +gen7_emit_vfe_state (struct intel_batchbuffer *batch); + +void +gen7_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch); + +void +gen7_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t
curbe_buffer);lib/gpu_fill.h new file +3
-0+ +void +gen7_emit_interface_descriptor_load(struct intel_batchbuffer *batch,
uint32_tinterface_descriptor);lib/gpu_fill.h new file +18
-0+ +void +gen7_emit_media_objects (struct intel_batchbuffer *batch, + unsigned x, unsigned y, + unsigned width, unsigned height); + +uint32_t +gen8_fill_surface_state (struct intel_batchbuffer *batch, + struct igt_buf *buf, + uint32_t format, + int is_dst); + +uint32_t +gen8_fill_binding_table (struct intel_batchbuffer *batch, + struct igt_buf *dst); + +uint32_t +gen8_fill_interface_descriptor(struct intel_batchbuffer *batch,struct
igt_buf*dst, constuint32_tkernel[][4],size_tsize);lib/gpu_fill.h new file +12
-0+ +void +gen8_emit_state_base_address (struct intel_batchbuffer *batch); + +void +gen8_emit_vfe_state (struct intel_batchbuffer *batch); + +void +gen8_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch); + +void +gen8_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t
curbe_buffer);lib/gpu_fill.h new file +3
-0+ +void +gen8_emit_interface_descriptor_load(struct intel_batchbuffer *batch,
uint32_tinterface_descriptor);lib/gpu_fill.h new file +27
-0+ +void +gen8_emit_media_state_flush (struct intel_batchbuffer *batch); + +void +gen8_emit_media_objects (struct intel_batchbuffer *batch, + unsigned x, unsigned y, + unsigned width, unsigned height); + +void +gen8lp_emit_media_objects (struct intel_batchbuffer *batch, + unsigned x, unsigned y, + unsigned width, unsigned height); + +void +gen9_emit_state_base_address (struct intel_batchbuffer *batch); + +void +gen7_emit_gpgpu_walk (struct intel_batchbuffer *batch, + unsigned x, unsigned y, + unsigned width, unsigned height); +void +gen8_emit_gpgpu_walk (struct intel_batchbuffer *batch, + unsigned x, unsigned y, + unsigned width, unsigned height); + +#endif /* GPU_FILL_H */ lib/media_fill_gen7.c +1
-139@@ -5,7 +5,7 @@ #include "gen7_media.h" #include "intel_reg.h" #include "drmtest.h" - +#include "gpu_fill.h" #include <assert.h> static const uint32_t media_kernel[][4] = {@@ -22,275 +22,6 @@ static const uint32_t media_kernel[][4] = { { 0x07800031, 0x20001ca8, 0x00000e00, 0x82000010 }, }; -static uint32_t -batch_used (struct intel_batchbuffer *batch) -{ - return batch->ptr - batch->buffer; -} - -static uint32_t -batch_align (struct intel_batchbuffer *batch,uint32_t align) -{ - uint32_t offset = batch_used(batch); - offset = ALIGN(offset, align); - batch->ptr = batch->buffer + offset; - return offset; -} - -static void * -batch_alloc (struct intel_batchbuffer *batch,uint32_t size,uint32_t align) -{ - uint32_t offset = batch_align(batch, align); - batch->ptr += size; - return memset(batch->buffer + offset, 0, size); -} - -static uint32_t -batch_offset (struct intel_batchbuffer *batch,void *ptr) -{ - return (uint8_t *)ptr - batch->buffer; -} - -static uint32_t -batch_copy (struct intel_batchbuffer *batch,const void *ptr,uint32_t size, uint32_t align) -{ - return batch_offset(batch, memcpy(batch_alloc(batch, size, align), ptr, size)); -} - -static void -gen7_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end) -{ - int ret; - - ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer); - if (ret == 0) - ret = drm_intel_bo_mrb_exec(batch->bo, batch_end, - NULL, 0, 0, 0); - igt_assert(ret == 0); -} - -static uint32_t -gen7_fill_curbe_buffer_data (struct intel_batchbuffer *batch, - uint8_t color) -{ - uint8_t *curbe_buffer; - uint32_t offset; - - curbe_buffer = batch_alloc(batch, sizeof(uint32_t) * 8, 64); - offset = batch_offset(batch, curbe_buffer); - *curbe_buffer = color; - - return offset; -} - -static uint32_t -gen7_fill_surface_state (struct intel_batchbuffer *batch, - struct igt_buf *buf, - uint32_t format, - int is_dst) -{ - struct gen7_surface_state *ss; - uint32_t write_domain, read_domain, offset; - int ret; - - if (is_dst) { - write_domain = read_domain = I915_GEM_DOMAIN_RENDER; - } else { - write_domain = 0; - read_domain = I915_GEM_DOMAIN_SAMPLER; - } - - ss = batch_alloc(batch, sizeof(*ss), 64); - offset = batch_offset(batch, ss); - - ss->ss0.surface_type = GEN7_SURFACE_2D; - ss->ss0.surface_format = format; - ss->ss0.render_cache_read_write = 1; - - if (buf->tiling == I915_TILING_X) - ss->ss0.tiled_mode = 2; - else if (buf->tiling == I915_TILING_Y) - ss->ss0.tiled_mode = 3; - - ss->ss1.base_addr = buf->bo->offset; - ret = drm_intel_bo_emit_reloc(batch->bo, - batch_offset(batch, ss) + 4, - buf->bo, 0, - read_domain, write_domain); - igt_assert(ret == 0); - - ss->ss2.height = igt_buf_height(buf) - 1; - ss->ss2.width = igt_buf_width(buf) - 1; - - ss->ss3.pitch = buf->stride - 1; - - ss->ss7.shader_chanel_select_r = 4; - ss->ss7.shader_chanel_select_g = 5; - ss->ss7.shader_chanel_select_b = 6; - ss->ss7.shader_chanel_select_a = 7; - - return offset; -} - -static uint32_t -gen7_fill_binding_table (struct intel_batchbuffer *batch, - struct igt_buf *dst) -{ - uint32_t *binding_table, offset; - - binding_table = batch_alloc(batch, 32, 64); - offset = batch_offset(batch, binding_table); - - binding_table[0] = gen7_fill_surface_state(batch, dst, GEN7_SURFACEFORMAT_R8_UNORM, 1); - - return offset; -} - -static uint32_t -gen7_fill_media_kernel (struct intel_batchbuffer *batch, - const uint32_t kernel[][4], - size_t size) -{ - uint32_t offset; - - offset = batch_copy(batch, kernel, size, 64); - - return offset; -} - -static uint32_t -gen7_fill_interface_descriptor(struct intel_batchbuffer *batch,struct
igt_buf*dst,
- constuint32_tkernel[][4],size_tsize)lib/media_fill_gen7.c +0
-38-{ - struct gen7_interface_descriptor_data *idd; - uint32_t offset; - uint32_t binding_table_offset, kernel_offset; - - binding_table_offset = gen7_fill_binding_table(batch, dst); - kernel_offset = gen7_fill_media_kernel(batch, kernel, size); - - idd = batch_alloc(batch, sizeof(*idd), 64); - offset = batch_offset(batch, idd); - - idd->desc0.kernel_start_pointer = (kernel_offset >> 6); - - idd->desc1.single_program_flow = 1; - idd->desc1.floating_point_mode = GEN7_FLOATING_POINT_IEEE_754; - - idd->desc2.sampler_count = 0; /* 0 samplers used */ - idd->desc2.sampler_state_pointer = 0; - - idd->desc3.binding_table_entry_count = 0; - idd->desc3.binding_table_pointer = (binding_table_offset >> 5); - - idd->desc4.constant_urb_entry_read_offset = 0; - idd->desc4.constant_urb_entry_read_length = 1; /* grf 1 */ - - return offset; -} - -static void -gen7_emit_state_base_address (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN7_STATE_BASE_ADDRESS | (10 - 2)); - - /* general */ - OUT_BATCH(0); - - /* surface */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);
-
- /* dynamic */
-OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY);lib/media_fill_gen7.c +0
-6- - /* indirect */ - OUT_BATCH(0); - - /* instruction */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);lib/media_fill_gen7.c +0
-34- - /* general/dynamic/indirect/instruction access Bound */ - OUT_BATCH(0); - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(0); - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); -} - -static void -gen7_emit_vfe_state (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN7_MEDIA_VFE_STATE | (8 - 2)); - - /* scratch buffer */ - OUT_BATCH(0); - - /* number of threads & urb entries */ - OUT_BATCH(1 << 16 | - 2 << 8); - - OUT_BATCH(0); - - /* urb entry size & curbe size */ - OUT_BATCH(2 << 16 | /* in 256 bits unit */ - 2); /* in 256 bits unit */ - - /* scoreboard */ - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(0); -} - -static void -gen7_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t
curbe_buffer)
-{
-OUT_BATCH(GEN7_MEDIA_CURBE_LOAD | (4 - 2));
-OUT_BATCH(0);
- /* curbe total data length */
-OUT_BATCH(64);
- /* curbe data start address, is relative to the dynamics base address */
-OUT_BATCH(curbe_buffer);lib/media_fill_gen7.c +0
-4-} - -static void -gen7_emit_interface_descriptor_load(struct intel_batchbuffer *batch,
uint32_tinterface_descriptor)
-{
-OUT_BATCH(GEN7_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 - 2)); -OUT_BATCH(0);
- /* interface descriptor data length */
-OUT_BATCH(sizeof(struct gen7_interface_descriptor_data)); - /* interface descriptor address, is relative to the dynamics base address */
-OUT_BATCH(interface_descriptor);lib/media_fill_gen7.c +0
-31-} - -static void -gen7_emit_media_objects (struct intel_batchbuffer *batch, - unsigned x, unsigned y, - unsigned width, unsigned height) -{ - int i, j; - - for (i = 0; i < width / 16; i++) { - for (j = 0; j < height / 16; j++) { - OUT_BATCH(GEN7_MEDIA_OBJECT | (8 - 2)); - - /* interface descriptor offset */ - OUT_BATCH(0); - - /* without indirect data */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* scoreboard */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* inline data (xoffset, yoffset) */ - OUT_BATCH(x + i * 16); - OUT_BATCH(y + j * 16); - } - } -} -/*
* This sets up the media pipeline,
*lib/media_fill_gen8.c +1
-141@@ -5,7 +5,7 @@ #include "gen8_media.h" #include "intel_reg.h" #include "drmtest.h" - +#include "gpu_fill.h" #include <assert.h>@@ -23,294 +23,6 @@ static const uint32_t media_kernel[][4] = { { 0x07800031, 0x20000a40, 0x0e000e00, 0x82000010 }, }; -static uint32_t -batch_used (struct intel_batchbuffer *batch) -{ - return batch->ptr - batch->buffer; -} - -static uint32_t -batch_align (struct intel_batchbuffer *batch,uint32_t align) -{ - uint32_t offset = batch_used(batch); - offset = ALIGN(offset, align); - batch->ptr = batch->buffer + offset; - return offset; -} - -static void * -batch_alloc (struct intel_batchbuffer *batch,uint32_t size,uint32_t align) -{ - uint32_t offset = batch_align(batch, align); - batch->ptr += size; - return memset(batch->buffer + offset, 0, size); -} - -static uint32_t -batch_offset (struct intel_batchbuffer *batch,void *ptr) -{ - return (uint8_t *)ptr - batch->buffer; -} - -static uint32_t -batch_copy (struct intel_batchbuffer *batch,const void *ptr,uint32_t size, uint32_t align) -{ - return batch_offset(batch, memcpy(batch_alloc(batch, size, align), ptr, size)); -} - -static void -gen8_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end) -{ - int ret; - - ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer); - if (ret == 0) - ret = drm_intel_bo_mrb_exec(batch->bo, batch_end, - NULL, 0, 0, 0); - igt_assert(ret == 0); -} - -static uint32_t -gen8_fill_curbe_buffer_data (struct intel_batchbuffer *batch, - uint8_t color) -{ - uint8_t *curbe_buffer; - uint32_t offset; - - curbe_buffer = batch_alloc(batch, sizeof(uint32_t) * 8, 64); - offset = batch_offset(batch, curbe_buffer); - *curbe_buffer = color; - - return offset; -} - -static uint32_t -gen8_fill_surface_state (struct intel_batchbuffer *batch, - struct igt_buf *buf, - uint32_t format, - int is_dst) -{ - struct gen8_surface_state *ss; - uint32_t write_domain, read_domain, offset; - int ret; - - if (is_dst) { - write_domain = read_domain = I915_GEM_DOMAIN_RENDER; - } else { - write_domain = 0; - read_domain = I915_GEM_DOMAIN_SAMPLER; - } - - ss = batch_alloc(batch, sizeof(*ss), 64); - offset = batch_offset(batch, ss); - - ss->ss0.surface_type = GEN8_SURFACE_2D; - ss->ss0.surface_format = format; - ss->ss0.render_cache_read_write = 1; - ss->ss0.vertical_alignment = 1; /* align 4 */ - ss->ss0.horizontal_alignment = 1; /* align 4 */ - - if (buf->tiling == I915_TILING_X) - ss->ss0.tiled_mode = 2; - else if (buf->tiling == I915_TILING_Y) - ss->ss0.tiled_mode = 3; - - ss->ss8.base_addr = buf->bo->offset; - - ret = drm_intel_bo_emit_reloc(batch->bo, - batch_offset(batch, ss) + 8 * 4, - buf->bo, 0, - read_domain, write_domain); - igt_assert(ret == 0); - - ss->ss2.height = igt_buf_height(buf) - 1; - ss->ss2.width = igt_buf_width(buf) - 1; - ss->ss3.pitch = buf->stride - 1; - - ss->ss7.shader_chanel_select_r = 4; - ss->ss7.shader_chanel_select_g = 5; - ss->ss7.shader_chanel_select_b = 6; - ss->ss7.shader_chanel_select_a = 7; - - return offset; -} - -static uint32_t -gen8_fill_binding_table (struct intel_batchbuffer *batch, - struct igt_buf *dst) -{ - uint32_t *binding_table, offset; - - binding_table = batch_alloc(batch, 32, 64); - offset = batch_offset(batch, binding_table); - - binding_table[0] = gen8_fill_surface_state(batch, dst, GEN8_SURFACEFORMAT_R8_UNORM, 1); - - return offset; -} - -static uint32_t -gen8_fill_media_kernel (struct intel_batchbuffer *batch, - const uint32_t kernel[][4], - size_t size) -{ - uint32_t offset; - - offset = batch_copy(batch, kernel, size, 64); - - return offset; -} - -static uint32_t -gen8_fill_interface_descriptor(struct intel_batchbuffer *batch,struct
igt_buf*dst)lib/media_fill_gen8.c +0
-7-{ - struct gen8_interface_descriptor_data *idd; - uint32_t offset; - uint32_t binding_table_offset, kernel_offset; - - binding_table_offset = gen8_fill_binding_table(batch, dst); - kernel_offset = gen8_fill_media_kernel(batch, media_kernel,
sizeof(media_kernel));lib/media_fill_gen8.c +0
-35- - idd = batch_alloc(batch, sizeof(*idd), 64); - offset = batch_offset(batch, idd); - - idd->desc0.kernel_start_pointer = (kernel_offset >> 6); - - idd->desc2.single_program_flow = 1; - idd->desc2.floating_point_mode = GEN8_FLOATING_POINT_IEEE_754; - - idd->desc3.sampler_count = 0; /* 0 samplers used */ - idd->desc3.sampler_state_pointer = 0; - - idd->desc4.binding_table_entry_count = 0; - idd->desc4.binding_table_pointer = (binding_table_offset >> 5); - - idd->desc5.constant_urb_entry_read_offset = 0; - idd->desc5.constant_urb_entry_read_length = 1; /* grf 1 */ - - return offset; -} - -static void -gen8_emit_state_base_address (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_STATE_BASE_ADDRESS | (16 - 2)); - - /* general */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(0); - - /* stateless data port */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - - /* surface */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_SAMPLER, 0,
BASE_ADDRESS_MODIFY);
-
- /* dynamic */
- OUT_RELOC(batch->bo,I915_GEM_DOMAIN_RENDER|I915_GEM_DOMAIN_INSTRUCTION,
- 0,BASE_ADDRESS_MODIFY);lib/media_fill_gen8.c +0
-7- - /* indirect */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* instruction */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);
-
- /* general state buffer size */
-OUT_BATCH(0xfffff000 | 1);
- /* dynamic state buffer size */
-OUT_BATCH(1 << 12 | 1);
- /* indirect object buffer size */
-OUT_BATCH(0xfffff000 | 1);
- /* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */
-OUT_BATCH(1 << 12 | 1);lib/media_fill_gen8.c +0
-29-} - -static void -gen8_emit_vfe_state (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_MEDIA_VFE_STATE | (9 - 2)); - - /* scratch buffer */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* number of threads & urb entries */ - OUT_BATCH(1 << 16 | - 2 << 8); - - OUT_BATCH(0); - - /* urb entry size & curbe size */ - OUT_BATCH(2 << 16 | - 2); - - /* scoreboard */ - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(0); -} - -static void -gen8_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t
curbe_buffer)
-{
-OUT_BATCH(GEN8_MEDIA_CURBE_LOAD | (4 - 2));
-OUT_BATCH(0);
- /* curbe total data length */
-OUT_BATCH(64);
- /* curbe data start address, is relative to the dynamics base address */
-OUT_BATCH(curbe_buffer);lib/media_fill_gen8.c +0
-4-} - -static void -gen8_emit_interface_descriptor_load(struct intel_batchbuffer *batch,
uint32_tinterface_descriptor)
-{
-OUT_BATCH(GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 - 2)); -OUT_BATCH(0);
- /* interface descriptor data length */
-OUT_BATCH(sizeof(struct gen8_interface_descriptor_data)); - /* interface descriptor address, is relative to the dynamics base address */
-OUT_BATCH(interface_descriptor);lib/media_fill_gen8.c +0
-39-} - -static void -gen8_emit_media_state_flush (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_MEDIA_STATE_FLUSH | (2 - 2)); - OUT_BATCH(0); -} - -static void -gen8_emit_media_objects (struct intel_batchbuffer *batch, - unsigned x, unsigned y, - unsigned width, unsigned height) -{ - int i, j; - - for (i = 0; i < width / 16; i++) { - for (j = 0; j < height / 16; j++) { - OUT_BATCH(GEN8_MEDIA_OBJECT | (8 - 2)); - - /* interface descriptor offset */ - OUT_BATCH(0); - - /* without indirect data */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* scoreboard */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* inline data (xoffset, yoffset) */ - OUT_BATCH(x + i * 16); - OUT_BATCH(y + j * 16); - gen8_emit_media_state_flush(batch); - } - } -} -/*
* This sets up the media pipeline,
*lib/media_fill_gen8.c +4
-3@@ -348,8 +60,9 @@ gen8_media_fillfunc(struct intel_batchbuffer *batch, /* setup states */ batch->ptr = &batch->buffer[BATCH_STATE_SPLIT]; - curbe_buffer = gen8_fill_curbe_buffer_data(batch, color); - interface_descriptor = gen8_fill_interface_descriptor(batch, dst); + curbe_buffer = gen7_fill_curbe_buffer_data(batch, color); + interface_descriptor = gen8_fill_interface_descriptor(batch, dst, + media_kernel, sizeof(media_kernel)); igt_assert(batch->ptr < &batch->buffer[4095]); /* media pipeline */@@ -370,6 +83,6 @@ gen8_media_fillfunc(struct intel_batchbuffer *batch, batch_end = batch_align(batch, 8); igt_assert(batch_end < BATCH_STATE_SPLIT); - gen8_render_flush(batch, batch_end); + gen7_render_flush(batch, batch_end); intel_batchbuffer_reset(batch); }lib/media_fill_gen8lp.c +1
-141@@ -5,7 +5,7 @@ #include "gen8_media.h" #include "intel_reg.h" #include "drmtest.h" - +#include "gpu_fill.h" #include <assert.h>@@ -23,286 +23,6 @@ static const uint32_t media_kernel[][4] = { { 0x07800031, 0x20000a40, 0x0e000e00, 0x82000010 }, }; -static uint32_t -batch_used (struct intel_batchbuffer *batch) -{ - return batch->ptr - batch->buffer; -} - -static uint32_t -batch_align (struct intel_batchbuffer *batch,uint32_t align) -{ - uint32_t offset = batch_used(batch); - offset = ALIGN(offset, align); - batch->ptr = batch->buffer + offset; - return offset; -} - -static void * -batch_alloc (struct intel_batchbuffer *batch,uint32_t size,uint32_t align) -{ - uint32_t offset = batch_align(batch, align); - batch->ptr += size; - return memset(batch->buffer + offset, 0, size); -} - -static uint32_t -batch_offset (struct intel_batchbuffer *batch,void *ptr) -{ - return (uint8_t *)ptr - batch->buffer; -} - -static uint32_t -batch_copy (struct intel_batchbuffer *batch,const void *ptr,uint32_t size, uint32_t align) -{ - return batch_offset(batch, memcpy(batch_alloc(batch, size, align), ptr, size)); -} - -static void -gen8_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end) -{ - int ret; - - ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer); - if (ret == 0) - ret = drm_intel_bo_mrb_exec(batch->bo, batch_end, - NULL, 0, 0, 0); - igt_assert(ret == 0); -} - -static uint32_t -gen8_fill_curbe_buffer_data (struct intel_batchbuffer *batch, - uint8_t color) -{ - uint8_t *curbe_buffer; - uint32_t offset; - - curbe_buffer = batch_alloc(batch, sizeof(uint32_t) * 8, 64); - offset = batch_offset(batch, curbe_buffer); - *curbe_buffer = color; - - return offset; -} - -static uint32_t -gen8_fill_surface_state (struct intel_batchbuffer *batch, - struct igt_buf *buf, - uint32_t format, - int is_dst) -{ - struct gen8_surface_state *ss; - uint32_t write_domain, read_domain, offset; - int ret; - - if (is_dst) { - write_domain = read_domain = I915_GEM_DOMAIN_RENDER; - } else { - write_domain = 0; - read_domain = I915_GEM_DOMAIN_SAMPLER; - } - - ss = batch_alloc(batch, sizeof(*ss), 64); - offset = batch_offset(batch, ss); - - ss->ss0.surface_type = GEN8_SURFACE_2D; - ss->ss0.surface_format = format; - ss->ss0.render_cache_read_write = 1; - ss->ss0.vertical_alignment = 1; /* align 4 */ - ss->ss0.horizontal_alignment = 1; /* align 4 */ - - if (buf->tiling == I915_TILING_X) - ss->ss0.tiled_mode = 2; - else if (buf->tiling == I915_TILING_Y) - ss->ss0.tiled_mode = 3; - - ss->ss8.base_addr = buf->bo->offset; - - ret = drm_intel_bo_emit_reloc(batch->bo, - batch_offset(batch, ss) + 8 * 4, - buf->bo, 0, - read_domain, write_domain); - igt_assert(ret == 0); - - ss->ss2.height = igt_buf_height(buf) - 1; - ss->ss2.width = igt_buf_width(buf) - 1; - ss->ss3.pitch = buf->stride - 1; - - ss->ss7.shader_chanel_select_r = 4; - ss->ss7.shader_chanel_select_g = 5; - ss->ss7.shader_chanel_select_b = 6; - ss->ss7.shader_chanel_select_a = 7; - - return offset; -} - -static uint32_t -gen8_fill_binding_table (struct intel_batchbuffer *batch, - struct igt_buf *dst) -{ - uint32_t *binding_table, offset; - - binding_table = batch_alloc(batch, 32, 64); - offset = batch_offset(batch, binding_table); - - binding_table[0] = gen8_fill_surface_state(batch, dst, GEN8_SURFACEFORMAT_R8_UNORM, 1); - - return offset; -} - -static uint32_t -gen8_fill_media_kernel (struct intel_batchbuffer *batch, - const uint32_t kernel[][4], - size_t size) -{ - uint32_t offset; - - offset = batch_copy(batch, kernel, size, 64); - - return offset; -} - -static uint32_t -gen8_fill_interface_descriptor(struct intel_batchbuffer *batch,struct
igt_buf*dst)lib/media_fill_gen8lp.c +0
-7-{ - struct gen8_interface_descriptor_data *idd; - uint32_t offset; - uint32_t binding_table_offset, kernel_offset; - - binding_table_offset = gen8_fill_binding_table(batch, dst); - kernel_offset = gen8_fill_media_kernel(batch, media_kernel,
sizeof(media_kernel));lib/media_fill_gen8lp.c +0
-35- - idd = batch_alloc(batch, sizeof(*idd), 64); - offset = batch_offset(batch, idd); - - idd->desc0.kernel_start_pointer = (kernel_offset >> 6); - - idd->desc2.single_program_flow = 1; - idd->desc2.floating_point_mode = GEN8_FLOATING_POINT_IEEE_754; - - idd->desc3.sampler_count = 0; /* 0 samplers used */ - idd->desc3.sampler_state_pointer = 0; - - idd->desc4.binding_table_entry_count = 0; - idd->desc4.binding_table_pointer = (binding_table_offset >> 5); - - idd->desc5.constant_urb_entry_read_offset = 0; - idd->desc5.constant_urb_entry_read_length = 1; /* grf 1 */ - - return offset; -} - -static void -gen8_emit_state_base_address (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_STATE_BASE_ADDRESS | (16 - 2)); - - /* general */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(0); - - /* stateless data port */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - - /* surface */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_SAMPLER, 0,
BASE_ADDRESS_MODIFY);
-
- /* dynamic */
- OUT_RELOC(batch->bo,I915_GEM_DOMAIN_RENDER|I915_GEM_DOMAIN_INSTRUCTION,
- 0,BASE_ADDRESS_MODIFY);lib/media_fill_gen8lp.c +0
-7- - /* indirect */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* instruction */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);
-
- /* general state buffer size */
-OUT_BATCH(0xfffff000 | 1);
- /* dynamic state buffer size */
-OUT_BATCH(1 << 12 | 1);
- /* indirect object buffer size */
-OUT_BATCH(0xfffff000 | 1);
- /* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */
-OUT_BATCH(1 << 12 | 1);lib/media_fill_gen8lp.c +0
-29-} - -static void -gen8_emit_vfe_state (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_MEDIA_VFE_STATE | (9 - 2)); - - /* scratch buffer */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* number of threads & urb entries */ - OUT_BATCH(1 << 16 | - 2 << 8); - - OUT_BATCH(0); - - /* urb entry size & curbe size */ - OUT_BATCH(2 << 16 | - 2); - - /* scoreboard */ - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(0); -} - -static void -gen8_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t
curbe_buffer)
-{
-OUT_BATCH(GEN8_MEDIA_CURBE_LOAD | (4 - 2));
-OUT_BATCH(0);
- /* curbe total data length */
-OUT_BATCH(64);
- /* curbe data start address, is relative to the dynamics base address */
-OUT_BATCH(curbe_buffer);lib/media_fill_gen8lp.c +0
-4-} - -static void -gen8_emit_interface_descriptor_load(struct intel_batchbuffer *batch,
uint32_tinterface_descriptor)
-{
-OUT_BATCH(GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 - 2)); -OUT_BATCH(0);
- /* interface descriptor data length */
-OUT_BATCH(sizeof(struct gen8_interface_descriptor_data)); - /* interface descriptor address, is relative to the dynamics base address */
-OUT_BATCH(interface_descriptor);lib/media_fill_gen8lp.c +0
-31-} - -static void -gen8lp_emit_media_objects (struct intel_batchbuffer *batch, - unsigned x, unsigned y, - unsigned width, unsigned height) -{ - int i, j; - - for (i = 0; i < width / 16; i++) { - for (j = 0; j < height / 16; j++) { - OUT_BATCH(GEN8_MEDIA_OBJECT | (8 - 2)); - - /* interface descriptor offset */ - OUT_BATCH(0); - - /* without indirect data */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* scoreboard */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* inline data (xoffset, yoffset) */ - OUT_BATCH(x + i * 16); - OUT_BATCH(y + j * 16); - } - } -} -/*
* This sets up the media pipeline,
*lib/media_fill_gen8lp.c +4
-3@@ -340,8 +60,9 @@ gen8lp_media_fillfunc(struct intel_batchbuffer *batch, /* setup states */ batch->ptr = &batch->buffer[BATCH_STATE_SPLIT]; - curbe_buffer = gen8_fill_curbe_buffer_data(batch, color); - interface_descriptor = gen8_fill_interface_descriptor(batch, dst); + curbe_buffer = gen7_fill_curbe_buffer_data(batch, color); + interface_descriptor = gen8_fill_interface_descriptor(batch, dst, + media_kernel, sizeof(media_kernel)); igt_assert(batch->ptr < &batch->buffer[4095]); /* media pipeline */@@ -362,6 +83,6 @@ gen8lp_media_fillfunc(struct intel_batchbuffer *batch, batch_end = batch_align(batch, 8); igt_assert(batch_end < BATCH_STATE_SPLIT); - gen8_render_flush(batch, batch_end); + gen7_render_flush(batch, batch_end); intel_batchbuffer_reset(batch); }lib/media_fill_gen9.c +1
-143@@ -4,11 +4,9 @@ #include "media_fill.h" #include "gen8_media.h" #include "intel_reg.h" - +#include "gpu_fill.h" #include <assert.h> -#define ALIGN (x, y) (((x) + (y)-1) & ~((y)-1)) - static const uint32_t media_kernel[][4] = { { 0x00400001, 0x20202288, 0x00000020, 0x00000000 }, { 0x00600001, 0x20800208, 0x008d0000, 0x00000000 },@@ -23,299 +21,6 @@ static const uint32_t media_kernel[][4] = { { 0x07800031, 0x20000a40, 0x0e000e00, 0x82000010 }, }; -static uint32_t -batch_used (struct intel_batchbuffer *batch) -{ - return batch->ptr - batch->buffer; -} - -static uint32_t -batch_align (struct intel_batchbuffer *batch,uint32_t align) -{ - uint32_t offset = batch_used(batch); - offset = ALIGN(offset, align); - batch->ptr = batch->buffer + offset; - return offset; -} - -static void * -batch_alloc (struct intel_batchbuffer *batch,uint32_t size,uint32_t align) -{ - uint32_t offset = batch_align(batch, align); - batch->ptr += size; - return memset(batch->buffer + offset, 0, size); -} - -static uint32_t -batch_offset (struct intel_batchbuffer *batch,void *ptr) -{ - return (uint8_t *)ptr - batch->buffer; -} - -static uint32_t -batch_copy (struct intel_batchbuffer *batch,const void *ptr,uint32_t size, uint32_t align) -{ - return batch_offset(batch, memcpy(batch_alloc(batch, size, align), ptr, size)); -} - -static void -gen8_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end) -{ - int ret; - - ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer); - if (ret == 0) - ret = drm_intel_bo_mrb_exec(batch->bo, batch_end, - NULL, 0, 0, 0); - assert(ret == 0); -} - -static uint32_t -gen8_fill_curbe_buffer_data (struct intel_batchbuffer *batch, - uint8_t color) -{ - uint8_t *curbe_buffer; - uint32_t offset; - - curbe_buffer = batch_alloc(batch, sizeof(uint32_t) * 8, 64); - offset = batch_offset(batch, curbe_buffer); - *curbe_buffer = color; - - return offset; -} - -static uint32_t -gen8_fill_surface_state (struct intel_batchbuffer *batch, - struct igt_buf *buf, - uint32_t format, - int is_dst) -{ - struct gen8_surface_state *ss; - uint32_t write_domain, read_domain, offset; - int ret; - - if (is_dst) { - write_domain = read_domain = I915_GEM_DOMAIN_RENDER; - } else { - write_domain = 0; - read_domain = I915_GEM_DOMAIN_SAMPLER; - } - - ss = batch_alloc(batch, sizeof(*ss), 64); - offset = batch_offset(batch, ss); - - ss->ss0.surface_type = GEN8_SURFACE_2D; - ss->ss0.surface_format = format; - ss->ss0.render_cache_read_write = 1; - ss->ss0.vertical_alignment = 1; /* align 4 */ - ss->ss0.horizontal_alignment = 1; /* align 4 */ - - if (buf->tiling == I915_TILING_X) - ss->ss0.tiled_mode = 2; - else if (buf->tiling == I915_TILING_Y) - ss->ss0.tiled_mode = 3; - - ss->ss8.base_addr = buf->bo->offset; - - ret = drm_intel_bo_emit_reloc(batch->bo, - batch_offset(batch, ss) + 8 * 4, - buf->bo, 0, - read_domain, write_domain); - assert(ret == 0); - - ss->ss2.height = igt_buf_height(buf) - 1; - ss->ss2.width = igt_buf_width(buf) - 1; - ss->ss3.pitch = buf->stride - 1; - - ss->ss7.shader_chanel_select_r = 4; - ss->ss7.shader_chanel_select_g = 5; - ss->ss7.shader_chanel_select_b = 6; - ss->ss7.shader_chanel_select_a = 7; - - return offset; -} - -static uint32_t -gen8_fill_binding_table (struct intel_batchbuffer *batch, - struct igt_buf *dst) -{ - uint32_t *binding_table, offset; - - binding_table = batch_alloc(batch, 32, 64); - offset = batch_offset(batch, binding_table); - - binding_table[0] = gen8_fill_surface_state(batch, dst, GEN8_SURFACEFORMAT_R8_UNORM, 1); - - return offset; -} - -static uint32_t -gen8_fill_media_kernel (struct intel_batchbuffer *batch, - const uint32_t kernel[][4], - size_t size) -{ - uint32_t offset; - - offset = batch_copy(batch, kernel, size, 64); - - return offset; -} - -static uint32_t -gen8_fill_interface_descriptor(struct intel_batchbuffer *batch,struct
igt_buf*dst)lib/media_fill_gen9.c +0
-7-{ - struct gen8_interface_descriptor_data *idd; - uint32_t offset; - uint32_t binding_table_offset, kernel_offset; - - binding_table_offset = gen8_fill_binding_table(batch, dst); - kernel_offset = gen8_fill_media_kernel(batch, media_kernel,
sizeof(media_kernel));lib/media_fill_gen9.c +0
-35- - idd = batch_alloc(batch, sizeof(*idd), 64); - offset = batch_offset(batch, idd); - - idd->desc0.kernel_start_pointer = (kernel_offset >> 6); - - idd->desc2.single_program_flow = 1; - idd->desc2.floating_point_mode = GEN8_FLOATING_POINT_IEEE_754; - - idd->desc3.sampler_count = 0; /* 0 samplers used */ - idd->desc3.sampler_state_pointer = 0; - - idd->desc4.binding_table_entry_count = 0; - idd->desc4.binding_table_pointer = (binding_table_offset >> 5); - - idd->desc5.constant_urb_entry_read_offset = 0; - idd->desc5.constant_urb_entry_read_length = 1; /* grf 1 */ - - return offset; -} - -static void -gen9_emit_state_base_address (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_STATE_BASE_ADDRESS | (19 - 2)); - - /* general */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(0); - - /* stateless data port */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - - /* surface */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_SAMPLER, 0,
BASE_ADDRESS_MODIFY);
-
- /* dynamic */
- OUT_RELOC(batch->bo,I915_GEM_DOMAIN_RENDER|I915_GEM_DOMAIN_INSTRUCTION,
- 0,BASE_ADDRESS_MODIFY);lib/media_fill_gen9.c +0
-7- - /* indirect */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* instruction */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);
-
- /* general state buffer size */
-OUT_BATCH(0xfffff000 | 1);
- /* dynamic state buffer size */
-OUT_BATCH(1 << 12 | 1);
- /* indirect object buffer size */
-OUT_BATCH(0xfffff000 | 1);
- /* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */
-OUT_BATCH(1 << 12 | 1);lib/media_fill_gen9.c +0
-34- - /* Bindless surface state base address */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(0); - OUT_BATCH(0xfffff000); -} - -static void -gen8_emit_vfe_state (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_MEDIA_VFE_STATE | (9 - 2)); - - /* scratch buffer */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* number of threads & urb entries */ - OUT_BATCH(1 << 16 | - 2 << 8); - - OUT_BATCH(0); - - /* urb entry size & curbe size */ - OUT_BATCH(2 << 16 | - 2); - - /* scoreboard */ - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(0); -} - -static void -gen8_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t
curbe_buffer)
-{
-OUT_BATCH(GEN8_MEDIA_CURBE_LOAD | (4 - 2));
-OUT_BATCH(0);
- /* curbe total data length */
-OUT_BATCH(64);
- /* curbe data start address, is relative to the dynamics base address */
-OUT_BATCH(curbe_buffer);lib/media_fill_gen9.c +0
-4-} - -static void -gen8_emit_interface_descriptor_load(struct intel_batchbuffer *batch,
uint32_tinterface_descriptor)
-{
-OUT_BATCH(GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 - 2)); -OUT_BATCH(0);
- /* interface descriptor data length */
-OUT_BATCH(sizeof(struct gen8_interface_descriptor_data)); - /* interface descriptor address, is relative to the dynamics base address */
-OUT_BATCH(interface_descriptor);lib/media_fill_gen9.c +0
-39-} - -static void -gen8_emit_media_state_flush (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_MEDIA_STATE_FLUSH | (2 - 2)); - OUT_BATCH(0); -} - -static void -gen8_emit_media_objects (struct intel_batchbuffer *batch, - unsigned x, unsigned y, - unsigned width, unsigned height) -{ - int i, j; - - for (i = 0; i < width / 16; i++) { - for (j = 0; j < height / 16; j++) { - OUT_BATCH(GEN8_MEDIA_OBJECT | (8 - 2)); - - /* interface descriptor offset */ - OUT_BATCH(0); - - /* without indirect data */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* scoreboard */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* inline data (xoffset, yoffset) */ - OUT_BATCH(x + i * 16); - OUT_BATCH(y + j * 16); - gen8_emit_media_state_flush(batch); - } - } -} -/*
* This sets up the media pipeline,
*lib/media_fill_gen9.c +4
-3@@ -353,8 +58,9 @@ gen9_media_fillfunc(struct intel_batchbuffer *batch, /* setup states */ batch->ptr = &batch->buffer[BATCH_STATE_SPLIT]; - curbe_buffer = gen8_fill_curbe_buffer_data(batch, color); - interface_descriptor = gen8_fill_interface_descriptor(batch, dst); + curbe_buffer = gen7_fill_curbe_buffer_data(batch, color); + interface_descriptor = gen8_fill_interface_descriptor(batch, dst, + media_kernel, sizeof(media_kernel)); assert(batch->ptr < &batch->buffer[4095]); /* media pipeline */@@ -387,6 +93,6 @@ gen9_media_fillfunc(struct intel_batchbuffer *batch, batch_end = batch_align(batch, 8); assert(batch_end < BATCH_STATE_SPLIT); - gen8_render_flush(batch, batch_end); + gen7_render_flush(batch, batch_end); intel_batchbuffer_reset(batch); }lib/meson.build +1
-0@@ -24,6 +24,7 @@ lib_sources = [ 'intel_os.c', 'intel_mmio.c', 'ioctl_wrappers.c', + 'gpu_fill.c',
Quoted 8 lines
lib/meson.build lib_sources = [ · line 30
Quoted 4 lines
lib/meson.build +0
-0'media_fill_gen7.c', 'media_fill_gen8.c', 'media_fill_gen8lp.c',_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 1/4] lib: Move common gpgpu/media functions to gpu_fill library
Quoted 85 lines · Daniele Ceraolo Spurio
Quoted 82 lines · Daniele Ceraolo Spurio
Quoted 57 lines · Katarzyna Dec
Gpgpu_fillandmedia_filllibraries are very similar and many functions can be shared. I have created librarygpu_fillwith all functions needed for implementinggpgpu_fillandmedia_filltests for all Gens. Duplicates, e.g. where only name was changed, were removed. The earliest common function remained.v2: Changed code layout.
GenX_fill_media_kernelwas identical togenX_fill_gpgpu_kernelso this function was unified togen7_fill_kernel. There were 2 very similar functionsgen8_emit_state_base_addressfor media and gpgpu, where the one for gpgpu was configured like it would be using indirect state (while we are using CURBE). I have checked if media fill version works fine in gpgpu test on Gen8 and unified them.Signed-off-by Katarzyna Dec <[email protected]>Cc Lukasz Kalamarz <[email protected]>Cc Daniele Ceraolo Spurio <[email protected]>---
lib/Makefile.sources | 2 +
lib/gpgpu_fill.c | 567 +------------------------------------ lib/gpu_fill.c | 729
++++++++++++++++++++++++++++++++++++++++++++++++
lib/gpu_fill.h | 141 ++++++++++ lib/media_fill_gen7.c | 271 +----------------- lib/media_fill_gen8.c | 297 +-------------------lib/media_fill_gen8lp.c| 289 +------------------ lib/media_fill_gen9.c | 304 +------------------- lib/meson.build | 1 +9 files changed, 890 insertions(+), 1711 deletions(-)create mode 100644
lib/gpu_fill.c
create mode 100644lib/gpu_fill.hlib/Makefile.sources +2
-0@@ -55,6 +55,8 @@ lib_source_list = \ intel_reg.h \ ioctl_wrappers.c \ ioctl_wrappers.h \ + gpu_fill.h \ + gpu_fill.c \ media_fill.h \ media_fill_gen7.c \ media_fill_gen8.c \lib/gpgpu_fill.c +1
-0@@ -34,6 +34,7 @@ #include "gen7_media.h" #include "gen8_media.h" #include "gpgpu_fill.h" +#include "gpu_fill.h" /* shaders/gpgpu/gpgpu_fill.gxa */ static const uint32_t gen7_gpgpu_kernel[][4] = {lib/gpgpu_fill.c static const uint32_t gen9_gpgpu_kernel[][4] = { · line 82
Quoted 8 lines
lib/gpgpu_fill.c +0
-6@@ -75,572 +76,6 @@ static const uint32_t gen9_gpgpu_kernel[][4] = { { 0x07800031, 0x20000a40, 0x06000e00, 0x82000010 }, }; -static uint32_t -batch_used (struct intel_batchbuffer *batch) -{ - return batch->ptr - batch->buffer; -} -Hi,
As I mentioned on the previous review I think that the batch_* functions shouldn't go to the
gpu_fill.cfile and should instead go with the otherintel_batchbuffermethods. I don't think that moving it togpu_fill.cas an interim solution works because we'll have to do another patch to move everything tointel_batchbuffer.c, including the other copies of the functions from the rendercopy files. It makes more sense IMO to move the code directly to its final destination.
If Lukasz is going to look at that then please sync with him so that his patch goes before this one (either as part of this series or standalone).
Quoted 3 lines
Quoted 3 lines
Thanks,
Daniele
I think it is good to move batch_* functions to intel_batchbuffer, but we need to do it separately from my series. That is because it would require to rework my patch and Lukasz will be making changes in places that will be removed or changed by my series. Moving batch_* affects not only libraries from my series, but also rendercopy and media_spin.
I have talked to Lukasz about that and we decided that it will be less rework and much clearer when whole batch_* movement will go as a standalone series or together with rendercopy refactoring series.
I hope you will agree on such solution.
Kasia :)
Quoted 2,851 lines
I've realized I've been a bit unclear here, considering that you've already said in the cover letter that your plan was to move the batch_* functions as a second step. What I wanted to express above is that I think moving the batch_* as first step is cleaner and results in overall less work (only moving things once). This isn't a blocking suggestion.
Daniele
Quoted 2,842 lines
Quoted 2,831 lines
lib/gpgpu_fill.c +0
-166-static uint32_t -batch_align (struct intel_batchbuffer *batch,uint32_t align) -{ - uint32_t offset = batch_used(batch); - offset = ALIGN(offset, align); - batch->ptr = batch->buffer + offset; - return offset; -} - -static void * -batch_alloc (struct intel_batchbuffer *batch,uint32_t size, uint32_t align) -{ - uint32_t offset = batch_align(batch, align); - batch->ptr += size; - return memset(batch->buffer + offset, 0, size); -} - -static uint32_t -batch_offset (struct intel_batchbuffer *batch,void *ptr) -{ - return (uint8_t *)ptr - batch->buffer; -} - -static uint32_t -batch_copy (struct intel_batchbuffer *batch,const void *ptr,uint32_t size, - uint32_t align) -{ - return batch_offset(batch, memcpy(batch_alloc(batch, size, align), ptr, size)); -} - -static void -gen7_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end) -{ - int ret; - - ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer); - if (ret == 0) - ret = drm_intel_bo_mrb_exec(batch->bo, batch_end, - NULL, 0, 0, 0); - igt_assert(ret == 0); -} - -static uint32_t -gen7_fill_curbe_buffer_data (struct intel_batchbuffer *batch, uint8_t color) -{ - uint8_t *curbe_buffer; - uint32_t offset; - - curbe_buffer = batch_alloc(batch, sizeof(uint32_t) * 8, 64); - offset = batch_offset(batch, curbe_buffer); - *curbe_buffer = color; - - return offset; -} - -static uint32_t -gen7_fill_surface_state (struct intel_batchbuffer *batch, - struct igt_buf *buf, - uint32_t format, - int is_dst) -{ - struct gen7_surface_state *ss; - uint32_t write_domain, read_domain, offset; - int ret; - - if (is_dst) { - write_domain = read_domain = I915_GEM_DOMAIN_RENDER; - } else { - write_domain = 0; - read_domain = I915_GEM_DOMAIN_SAMPLER; - } - - ss = batch_alloc(batch, sizeof(*ss), 64); - offset = batch_offset(batch, ss); - - ss->ss0.surface_type = GEN7_SURFACE_2D; - ss->ss0.surface_format = format; - ss->ss0.render_cache_read_write = 1; - - if (buf->tiling == I915_TILING_X) - ss->ss0.tiled_mode = 2; - else if (buf->tiling == I915_TILING_Y) - ss->ss0.tiled_mode = 3; - - ss->ss1.base_addr = buf->bo->offset; - ret = drm_intel_bo_emit_reloc(batch->bo, - batch_offset(batch, ss) + 4, - buf->bo, 0, - read_domain, write_domain); - igt_assert(ret == 0); - - ss->ss2.height = igt_buf_height(buf) - 1; - ss->ss2.width = igt_buf_width(buf) - 1; - - ss->ss3.pitch = buf->stride - 1; - - ss->ss7.shader_chanel_select_r = 4; - ss->ss7.shader_chanel_select_g = 5; - ss->ss7.shader_chanel_select_b = 6; - ss->ss7.shader_chanel_select_a = 7; - - return offset; -} - -static uint32_t -gen8_fill_surface_state (struct intel_batchbuffer *batch, - struct igt_buf *buf, - uint32_t format, - int is_dst) -{ - struct gen8_surface_state *ss; - uint32_t write_domain, read_domain, offset; - int ret; - - if (is_dst) { - write_domain = read_domain = I915_GEM_DOMAIN_RENDER; - } else { - write_domain = 0; - read_domain = I915_GEM_DOMAIN_SAMPLER; - } - - ss = batch_alloc(batch, sizeof(*ss), 64); - offset = batch_offset(batch, ss); - - ss->ss0.surface_type = GEN8_SURFACE_2D; - ss->ss0.surface_format = format; - ss->ss0.render_cache_read_write = 1; - ss->ss0.vertical_alignment = 1; /* align 4 */ - ss->ss0.horizontal_alignment = 1; /* align 4 */ - - if (buf->tiling == I915_TILING_X) - ss->ss0.tiled_mode = 2; - else if (buf->tiling == I915_TILING_Y) - ss->ss0.tiled_mode = 3; - - ss->ss8.base_addr = buf->bo->offset; - - ret = drm_intel_bo_emit_reloc(batch->bo, - batch_offset(batch, ss) + 8 * 4, - buf->bo, 0, - read_domain, write_domain); - igt_assert_eq(ret, 0); - - ss->ss2.height = igt_buf_height(buf) - 1; - ss->ss2.width = igt_buf_width(buf) - 1; - ss->ss3.pitch = buf->stride - 1; - - ss->ss7.shader_chanel_select_r = 4; - ss->ss7.shader_chanel_select_g = 5; - ss->ss7.shader_chanel_select_b = 6; - ss->ss7.shader_chanel_select_a = 7; - - return offset; - -} - -static uint32_t -gen7_fill_binding_table (struct intel_batchbuffer *batch, - struct igt_buf *dst) -{ - uint32_t *binding_table, offset; - - binding_table = batch_alloc(batch, 32, 64); - offset = batch_offset(batch, binding_table); - - binding_table[0] = gen7_fill_surface_state(batch, dst,
GEN7_SURFACEFORMAT_R8_UNORM, 1);lib/gpgpu_fill.c +0
-14- - return offset; -} - -static uint32_t -gen8_fill_binding_table (struct intel_batchbuffer *batch, - struct igt_buf *dst) -{ - uint32_t *binding_table, offset; - - binding_table = batch_alloc(batch, 32, 64); - offset = batch_offset(batch, binding_table); - - binding_table[0] = gen8_fill_surface_state(batch, dst,
GEN8_SURFACEFORMAT_R8_UNORM, 1);lib/gpgpu_fill.c +0
-18- - return offset; -} - -static uint32_t -gen7_fill_gpgpu_kernel (struct intel_batchbuffer *batch, - const uint32_t kernel[][4], - size_t size) -{ - uint32_t offset; - - offset = batch_copy(batch, kernel, size, 64); - - return offset; -} - -static uint32_t -gen7_fill_interface_descriptor(struct intel_batchbuffer *batch,struct
igt_buf*dst,
- constuint32_tkernel[][4],size_tsize)lib/gpgpu_fill.c +0
-30-{ - struct gen7_interface_descriptor_data *idd; - uint32_t offset; - uint32_t binding_table_offset, kernel_offset; - - binding_table_offset = gen7_fill_binding_table(batch, dst); - kernel_offset = gen7_fill_gpgpu_kernel(batch, kernel, size); - - idd = batch_alloc(batch, sizeof(*idd), 64); - offset = batch_offset(batch, idd); - - idd->desc0.kernel_start_pointer = (kernel_offset >> 6); - - idd->desc1.single_program_flow = 1; - idd->desc1.floating_point_mode = GEN7_FLOATING_POINT_IEEE_754; - - idd->desc2.sampler_count = 0; /* 0 samplers used */ - idd->desc2.sampler_state_pointer = 0; - - idd->desc3.binding_table_entry_count = 0; - idd->desc3.binding_table_pointer = (binding_table_offset >> 5); - - idd->desc4.constant_urb_entry_read_offset = 0; - idd->desc4.constant_urb_entry_read_length = 1; /* grf 1 */ - - return offset; -} - -static uint32_t -gen8_fill_interface_descriptor(struct intel_batchbuffer *batch,struct
igt_buf*dst,
- constuint32_tkernel[][4],size_tsize)lib/gpgpu_fill.c +0
-38-{ - struct gen8_interface_descriptor_data *idd; - uint32_t offset; - uint32_t binding_table_offset, kernel_offset; - - binding_table_offset = gen8_fill_binding_table(batch, dst); - kernel_offset = gen7_fill_gpgpu_kernel(batch, kernel, size); - - idd = batch_alloc(batch, sizeof(*idd), 64); - offset = batch_offset(batch, idd); - - idd->desc0.kernel_start_pointer = (kernel_offset >> 6); - - idd->desc2.single_program_flow = 1; - idd->desc2.floating_point_mode = GEN8_FLOATING_POINT_IEEE_754; - - idd->desc3.sampler_count = 0; /* 0 samplers used */ - idd->desc3.sampler_state_pointer = 0; - - idd->desc4.binding_table_entry_count = 0; - idd->desc4.binding_table_pointer = (binding_table_offset >> 5); - - idd->desc5.constant_urb_entry_read_offset = 0; - idd->desc5.constant_urb_entry_read_length = 1; /* grf 1 */ - - return offset; -} - -static void -gen7_emit_state_base_address (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN7_STATE_BASE_ADDRESS | (10 - 2)); - - /* general */ - OUT_BATCH(0); - - /* surface */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);
-
- /* dynamic */
-OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY);lib/gpgpu_fill.c +0
-6- - /* indirect */ - OUT_BATCH(0); - - /* instruction */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);lib/gpgpu_fill.c +0
-22- - /* general/dynamic/indirect/instruction access Bound */ - OUT_BATCH(0); - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(0); - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); -} - -static void -gen8_emit_state_base_address (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_STATE_BASE_ADDRESS | (16 - 2)); - - /* general */ - OUT_BATCH(0 | (0x78 << 4) | (0 << 1) | BASE_ADDRESS_MODIFY); - OUT_BATCH(0); - - /* stateless data port */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - - /* surface */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_SAMPLER, 0,
BASE_ADDRESS_MODIFY);
-
- /* dynamic */
- OUT_RELOC(batch->bo,I915_GEM_DOMAIN_RENDER|I915_GEM_DOMAIN_INSTRUCTION,
- 0,BASE_ADDRESS_MODIFY);lib/gpgpu_fill.c +0
-7- - /* indirect */ - OUT_BATCH(0); - OUT_BATCH(0 ); - - /* instruction */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);
-
- /* general state buffer size */
-OUT_BATCH(0xfffff000 | 1);
- /* dynamic state buffer size */
-OUT_BATCH(1 << 12 | 1);
- /* indirect object buffer size */
-OUT_BATCH(0xfffff000 | 1);
- /* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */
-OUT_BATCH(1 << 12 | 1);lib/gpgpu_fill.c +0
-16-} - -static void -gen9_emit_state_base_address (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_STATE_BASE_ADDRESS | (19 - 2)); - - /* general */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(0); - - /* stateless data port */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - - /* surface */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_SAMPLER, 0,
BASE_ADDRESS_MODIFY);
-
- /* dynamic */
- OUT_RELOC(batch->bo,I915_GEM_DOMAIN_RENDER|I915_GEM_DOMAIN_INSTRUCTION,
- 0,BASE_ADDRESS_MODIFY);lib/gpgpu_fill.c +0
-7- - /* indirect */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* instruction */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);
-
- /* general state buffer size */
-OUT_BATCH(0xfffff000 | 1);
- /* dynamic state buffer size */
-OUT_BATCH(1 << 12 | 1);
- /* indirect object buffer size */
-OUT_BATCH(0xfffff000 | 1);
- /* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */
-OUT_BATCH(1 << 12 | 1);lib/gpgpu_fill.c +0
-57- - /* Bindless surface state base address */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(0); - OUT_BATCH(0xfffff000); -} - -static void -gen7_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN7_MEDIA_VFE_STATE | (8 - 2)); - - /* scratch buffer */ - OUT_BATCH(0); - - /* number of threads & urb entries */ - OUT_BATCH(1 << 16 | /* max num of threads */ - 0 << 8 | /* num of URB entry */ - 1 << 2); /* GPGPU mode */ - - OUT_BATCH(0); - - /* urb entry size & curbe size */ - OUT_BATCH(0 << 16 | /* URB entry size in 256 bits unit */ - 1); /* CURBE entry size in 256 bits unit */ - - /* scoreboard */ - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(0); -} - -static void -gen8_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_MEDIA_VFE_STATE | (9 - 2)); - - /* scratch buffer */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* number of threads & urb entries */ - OUT_BATCH(1 << 16 | 1 << 8); - - OUT_BATCH(0); - - /* urb entry size & curbe size */ - OUT_BATCH(0 << 16 | 1); - - /* scoreboard */ - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(0); -} - -static void -gen7_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t
curbe_buffer)
-{
-OUT_BATCH(GEN7_MEDIA_CURBE_LOAD | (4 - 2));
-OUT_BATCH(0);
- /* curbe total data length */
-OUT_BATCH(64);
- /* curbe data start address, is relative to the dynamics base address */
-OUT_BATCH(curbe_buffer);lib/gpgpu_fill.c +0
-4-} - -static void -gen7_emit_interface_descriptor_load(struct intel_batchbuffer*batch,
uint32_tinterface_descriptor)
-{
-OUT_BATCH(GEN7_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 - 2)); -OUT_BATCH(0);
- /* interface descriptor data length */
-OUT_BATCH(sizeof(struct gen7_interface_descriptor_data)); - /* interface descriptor address, is relative to the dynamics base address */
-OUT_BATCH(interface_descriptor);lib/gpgpu_fill.c +0
-4-} - -static void -gen8_emit_interface_descriptor_load(struct intel_batchbuffer*batch,
uint32_tinterface_descriptor)
-{
-OUT_BATCH(GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 - 2)); -OUT_BATCH(0);
- /* interface descriptor data length */
-OUT_BATCH(sizeof(struct gen8_interface_descriptor_data)); - /* interface descriptor address, is relative to the dynamics base address */
-OUT_BATCH(interface_descriptor);lib/gpgpu_fill.c +0
-119-} - -static void -gen7_emit_gpgpu_walk (struct intel_batchbuffer *batch, - unsigned x, unsigned y, - unsigned width, unsigned height) -{ - uint32_t x_dim, y_dim, tmp, right_mask; - - /* - * Simply do SIMD16 based dispatch, so every thread uses - * SIMD16 channels. - * - * Define our own thread group size, e.g 16x1 for every group, then - * will have 1 thread each group in SIMD16 dispatch. So thread - * width/height/depth are all 1. - * - * Then thread group X = width / 16 (aligned to 16) - * thread group Y = height; - */ - x_dim = (width + 15) / 16; - y_dim = height; - - tmp = width & 15; - if (tmp == 0) - right_mask = (1 << 16) - 1; - else - right_mask = (1 << tmp) - 1; - - OUT_BATCH(GEN7_GPGPU_WALKER | 9); - - /* interface descriptor offset */ - OUT_BATCH(0); - - /* SIMD size, thread w/h/d */ - OUT_BATCH(1 << 30 | /* SIMD16 */ - 0 << 16 | /* depth:1 */ - 0 << 8 | /* height:1 */ - 0); /* width:1 */ - - /* thread group X */ - OUT_BATCH(0); - OUT_BATCH(x_dim); - - /* thread group Y */ - OUT_BATCH(0); - OUT_BATCH(y_dim); - - /* thread group Z */ - OUT_BATCH(0); - OUT_BATCH(1); - - /* right mask */ - OUT_BATCH(right_mask); - - /* bottom mask, height 1, always 0xffffffff */ - OUT_BATCH(0xffffffff); -} - -static void -gen8_emit_gpgpu_walk (struct intel_batchbuffer *batch, - unsigned x, unsigned y, - unsigned width, unsigned height) -{ - uint32_t x_dim, y_dim, tmp, right_mask; - - /* - * Simply do SIMD16 based dispatch, so every thread uses - * SIMD16 channels. - * - * Define our own thread group size, e.g 16x1 for every group, then - * will have 1 thread each group in SIMD16 dispatch. So thread - * width/height/depth are all 1. - * - * Then thread group X = width / 16 (aligned to 16) - * thread group Y = height; - */ - x_dim = (width + 15) / 16; - y_dim = height; - - tmp = width & 15; - if (tmp == 0) - right_mask = (1 << 16) - 1; - else - right_mask = (1 << tmp) - 1; - - OUT_BATCH(GEN7_GPGPU_WALKER | 13); - - OUT_BATCH(0); /* kernel offset */ - OUT_BATCH(0); /* indirect data length */ - OUT_BATCH(0); /* indirect data offset */ - - /* SIMD size, thread w/h/d */ - OUT_BATCH(1 << 30 | /* SIMD16 */ - 0 << 16 | /* depth:1 */ - 0 << 8 | /* height:1 */ - 0); /* width:1 */ - - /* thread group X */ - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(x_dim); - - /* thread group Y */ - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(y_dim); - - /* thread group Z */ - OUT_BATCH(0); - OUT_BATCH(1); - - /* right mask */ - OUT_BATCH(right_mask); - - /* bottom mask, height 1, always 0xffffffff */ - OUT_BATCH(0xffffffff); -} -/*
* This sets up the gpgpu pipeline,
*lib/gpu_fill.c new file +28
-0@@ -0,0 +1,729 @@ +#include <intel_bufmgr.h> +#include <i915_drm.h> + +#include "intel_reg.h" +#include "drmtest.h" +#include "gpu_fill.h" +#include <assert.h> +#include "gen7_media.h" +#include "gen8_media.h" + + +uint32_t +batch_used (struct intel_batchbuffer *batch) +{ + return batch->ptr - batch->buffer; +} + +uint32_t +batch_align (struct intel_batchbuffer *batch,uint32_t align) +{ + uint32_t offset = batch_used(batch); + offset = ALIGN(offset, align); + batch->ptr = batch->buffer + offset; + return offset; +} + +void * +batch_alloc(struct intel_batchbuffer *batch, uint32_t size,
uint32_talign)lib/gpu_fill.c new file +14
-0+{ + uint32_t offset = batch_align(batch, align); + batch->ptr += size; + return memset(batch->buffer + offset, 0, size); +} + +uint32_t +batch_offset (struct intel_batchbuffer *batch,void *ptr) +{ + return (uint8_t *)ptr - batch->buffer; +} + +uint32_t +batch_copy(struct intel_batchbuffer *batch, const void *ptr,
uint32_tsize,uint32_talign)
+{
+ returnbatch_offset(batch, memcpy(batch_alloc(batch, size, align), ptr, size));lib/gpu_fill.c new file +87
-0+} + +void +gen7_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end) +{ + int ret; + + ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer); + if (ret == 0) + ret = drm_intel_bo_mrb_exec(batch->bo, batch_end, + NULL, 0, 0, 0); + igt_assert(ret == 0); +} + +uint32_t +gen7_fill_curbe_buffer_data (struct intel_batchbuffer *batch, + uint8_t color) +{ + uint8_t *curbe_buffer; + uint32_t offset; + + curbe_buffer = batch_alloc(batch, sizeof(uint32_t) * 8, 64); + offset = batch_offset(batch, curbe_buffer); + *curbe_buffer = color; + + return offset; +} + +uint32_t +gen7_fill_surface_state (struct intel_batchbuffer *batch, + struct igt_buf *buf, + uint32_t format, + int is_dst) +{ + struct gen7_surface_state *ss; + uint32_t write_domain, read_domain, offset; + int ret; + + if (is_dst) { + write_domain = read_domain = I915_GEM_DOMAIN_RENDER; + } else { + write_domain = 0; + read_domain = I915_GEM_DOMAIN_SAMPLER; + } + + ss = batch_alloc(batch, sizeof(*ss), 64); + offset = batch_offset(batch, ss); + + ss->ss0.surface_type = GEN7_SURFACE_2D; + ss->ss0.surface_format = format; + ss->ss0.render_cache_read_write = 1; + + if (buf->tiling == I915_TILING_X) + ss->ss0.tiled_mode = 2; + else if (buf->tiling == I915_TILING_Y) + ss->ss0.tiled_mode = 3; + + ss->ss1.base_addr = buf->bo->offset; + ret = drm_intel_bo_emit_reloc(batch->bo, + batch_offset(batch, ss) + 4, + buf->bo, 0, + read_domain, write_domain); + igt_assert(ret == 0); + + ss->ss2.height = igt_buf_height(buf) - 1; + ss->ss2.width = igt_buf_width(buf) - 1; + + ss->ss3.pitch = buf->stride - 1; + + ss->ss7.shader_chanel_select_r = 4; + ss->ss7.shader_chanel_select_g = 5; + ss->ss7.shader_chanel_select_b = 6; + ss->ss7.shader_chanel_select_a = 7; + + return offset; +} + +uint32_t +gen7_fill_binding_table (struct intel_batchbuffer *batch, + struct igt_buf *dst) +{ + uint32_t *binding_table, offset; + + binding_table = batch_alloc(batch, 32, 64); + offset = batch_offset(batch, binding_table); + + binding_table[0] = gen7_fill_surface_state(batch, dst,
GEN7_SURFACEFORMAT_R8_UNORM, 1);lib/gpu_fill.c new file +18
-0+ + return offset; +} + +uint32_t +gen7_fill_kernel (struct intel_batchbuffer *batch, + const uint32_t kernel[][4], + size_t size) +{ + uint32_t offset; + + offset = batch_copy(batch, kernel, size, 64); + + return offset; +} + +uint32_t +gen7_fill_interface_descriptor(struct intel_batchbuffer *batch,struct
igt_buf*dst,
+ constuint32_tkernel[][4],size_tsize)lib/gpu_fill.c new file +38
-0+{ + struct gen7_interface_descriptor_data *idd; + uint32_t offset; + uint32_t binding_table_offset, kernel_offset; + + binding_table_offset = gen7_fill_binding_table(batch, dst); + kernel_offset = gen7_fill_kernel(batch, kernel, size); + + idd = batch_alloc(batch, sizeof(*idd), 64); + offset = batch_offset(batch, idd); + + idd->desc0.kernel_start_pointer = (kernel_offset >> 6); + + idd->desc1.single_program_flow = 1; + idd->desc1.floating_point_mode = GEN7_FLOATING_POINT_IEEE_754; + + idd->desc2.sampler_count = 0; /* 0 samplers used */ + idd->desc2.sampler_state_pointer = 0; + + idd->desc3.binding_table_entry_count = 0; + idd->desc3.binding_table_pointer = (binding_table_offset >> 5); + + idd->desc4.constant_urb_entry_read_offset = 0; + idd->desc4.constant_urb_entry_read_length = 1; /* grf 1 */ + + return offset; +} + +void +gen7_emit_state_base_address (struct intel_batchbuffer *batch) +{ + OUT_BATCH(GEN7_STATE_BASE_ADDRESS | (10 - 2)); + + /* general */ + OUT_BATCH(0); + + /* surface */ + OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);
+
+ /* dynamic */
+OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY);lib/gpu_fill.c new file +6
-0+ + /* indirect */ + OUT_BATCH(0); + + /* instruction */ + OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);lib/gpu_fill.c new file +59
-0+ + /* general/dynamic/indirect/instruction access Bound */ + OUT_BATCH(0); + OUT_BATCH(0 | BASE_ADDRESS_MODIFY); + OUT_BATCH(0); + OUT_BATCH(0 | BASE_ADDRESS_MODIFY); +} + +void +gen7_emit_vfe_state (struct intel_batchbuffer *batch) +{ + OUT_BATCH(GEN7_MEDIA_VFE_STATE | (8 - 2)); + + /* scratch buffer */ + OUT_BATCH(0); + + /* number of threads & urb entries */ + OUT_BATCH(1 << 16 | + 2 << 8); + + OUT_BATCH(0); + + /* urb entry size & curbe size */ + OUT_BATCH(2 << 16 | /* in 256 bits unit */ + 2); /* in 256 bits unit */ + + /* scoreboard */ + OUT_BATCH(0); + OUT_BATCH(0); + OUT_BATCH(0); +} + +void +gen7_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch) +{ + OUT_BATCH(GEN7_MEDIA_VFE_STATE | (8 - 2)); + + /* scratch buffer */ + OUT_BATCH(0); + + /* number of threads & urb entries */ + OUT_BATCH(1 << 16 | /* max num of threads */ + 0 << 8 | /* num of URB entry */ + 1 << 2); /* GPGPU mode */ + + OUT_BATCH(0); + + /* urb entry size & curbe size */ + OUT_BATCH(0 << 16 | /* URB entry size in 256 bits unit */ + 1); /* CURBE entry size in 256 bits unit */ + + /* scoreboard */ + OUT_BATCH(0); + OUT_BATCH(0); + OUT_BATCH(0); +} + +void +gen7_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t
curbe_buffer)
+{
+OUT_BATCH(GEN7_MEDIA_CURBE_LOAD | (4 - 2));
+OUT_BATCH(0);
+ /* curbe total data length */
+OUT_BATCH(64);
+ /* curbe data start address, is relative to the dynamics base address */
+OUT_BATCH(curbe_buffer);lib/gpu_fill.c new file +4
-0+} + +void +gen7_emit_interface_descriptor_load(struct intel_batchbuffer*batch,
uint32_tinterface_descriptor)
+{
+OUT_BATCH(GEN7_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 - 2)); +OUT_BATCH(0);
+ /* interface descriptor data length */
+OUT_BATCH(sizeof(struct gen7_interface_descriptor_data)); + /* interface descriptor address, is relative to the dynamics base address */
+OUT_BATCH(interface_descriptor);lib/gpu_fill.c new file +149
-0+} + +void +gen7_emit_media_objects (struct intel_batchbuffer *batch, + unsigned x, unsigned y, + unsigned width, unsigned height) +{ + int i, j; + + for (i = 0; i < width / 16; i++) { + for (j = 0; j < height / 16; j++) { + OUT_BATCH(GEN7_MEDIA_OBJECT | (8 - 2)); + + /* interface descriptor offset */ + OUT_BATCH(0); + + /* without indirect data */ + OUT_BATCH(0); + OUT_BATCH(0); + + /* scoreboard */ + OUT_BATCH(0); + OUT_BATCH(0); + + /* inline data (xoffset, yoffset) */ + OUT_BATCH(x + i * 16); + OUT_BATCH(y + j * 16); + } + } +} + +void +gen7_emit_gpgpu_walk (struct intel_batchbuffer *batch, + unsigned x, unsigned y, + unsigned width, unsigned height) +{ + uint32_t x_dim, y_dim, tmp, right_mask; + + /* + * Simply do SIMD16 based dispatch, so every thread uses + * SIMD16 channels. + * + * Define our own thread group size, e.g 16x1 for every group, then + * will have 1 thread each group in SIMD16 dispatch. So thread + * width/height/depth are all 1. + * + * Then thread group X = width / 16 (aligned to 16) + * thread group Y = height; + */ + x_dim = (width + 15) / 16; + y_dim = height; + + tmp = width & 15; + if (tmp == 0) + right_mask = (1 << 16) - 1; + else + right_mask = (1 << tmp) - 1; + + OUT_BATCH(GEN7_GPGPU_WALKER | 9); + + /* interface descriptor offset */ + OUT_BATCH(0); + + /* SIMD size, thread w/h/d */ + OUT_BATCH(1 << 30 | /* SIMD16 */ + 0 << 16 | /* depth:1 */ + 0 << 8 | /* height:1 */ + 0); /* width:1 */ + + /* thread group X */ + OUT_BATCH(0); + OUT_BATCH(x_dim); + + /* thread group Y */ + OUT_BATCH(0); + OUT_BATCH(y_dim); + + /* thread group Z */ + OUT_BATCH(0); + OUT_BATCH(1); + + /* right mask */ + OUT_BATCH(right_mask); + + /* bottom mask, height 1, always 0xffffffff */ + OUT_BATCH(0xffffffff); +} + +uint32_t +gen8_fill_surface_state (struct intel_batchbuffer *batch, + struct igt_buf *buf, + uint32_t format, + int is_dst) +{ + struct gen8_surface_state *ss; + uint32_t write_domain, read_domain, offset; + int ret; + + if (is_dst) { + write_domain = read_domain = I915_GEM_DOMAIN_RENDER; + } else { + write_domain = 0; + read_domain = I915_GEM_DOMAIN_SAMPLER; + } + + ss = batch_alloc(batch, sizeof(*ss), 64); + offset = batch_offset(batch, ss); + + ss->ss0.surface_type = GEN8_SURFACE_2D; + ss->ss0.surface_format = format; + ss->ss0.render_cache_read_write = 1; + ss->ss0.vertical_alignment = 1; /* align 4 */ + ss->ss0.horizontal_alignment = 1; /* align 4 */ + + if (buf->tiling == I915_TILING_X) + ss->ss0.tiled_mode = 2; + else if (buf->tiling == I915_TILING_Y) + ss->ss0.tiled_mode = 3; + + ss->ss8.base_addr = buf->bo->offset; + + ret = drm_intel_bo_emit_reloc(batch->bo, + batch_offset(batch, ss) + 8 * 4, + buf->bo, 0, + read_domain, write_domain); + igt_assert(ret == 0); + + ss->ss2.height = igt_buf_height(buf) - 1; + ss->ss2.width = igt_buf_width(buf) - 1; + ss->ss3.pitch = buf->stride - 1; + + ss->ss7.shader_chanel_select_r = 4; + ss->ss7.shader_chanel_select_g = 5; + ss->ss7.shader_chanel_select_b = 6; + ss->ss7.shader_chanel_select_a = 7; + + return offset; +} + +uint32_t +gen8_fill_binding_table (struct intel_batchbuffer *batch, + struct igt_buf *dst) +{ + uint32_t *binding_table, offset; + + binding_table = batch_alloc(batch, 32, 64); + offset = batch_offset(batch, binding_table); + + binding_table[0] = gen8_fill_surface_state(batch, dst,
GEN8_SURFACEFORMAT_R8_UNORM, 1);lib/gpu_fill.c new file +6
-0+ + return offset; +} + +uint32_t +gen8_fill_interface_descriptor(struct intel_batchbuffer *batch,struct
igt_buf*dst, constuint32_tkernel[][4],size_tsize)lib/gpu_fill.c new file +42
-0+{ + struct gen8_interface_descriptor_data *idd; + uint32_t offset; + uint32_t binding_table_offset, kernel_offset; + + binding_table_offset = gen8_fill_binding_table(batch, dst); + kernel_offset = gen7_fill_kernel(batch, kernel, sizeof(kernel)); + + idd = batch_alloc(batch, sizeof(*idd), 64); + offset = batch_offset(batch, idd); + + idd->desc0.kernel_start_pointer = (kernel_offset >> 6); + + idd->desc2.single_program_flow = 1; + idd->desc2.floating_point_mode = GEN8_FLOATING_POINT_IEEE_754; + + idd->desc3.sampler_count = 0; /* 0 samplers used */ + idd->desc3.sampler_state_pointer = 0; + + idd->desc4.binding_table_entry_count = 0; + idd->desc4.binding_table_pointer = (binding_table_offset >> 5); + + idd->desc5.constant_urb_entry_read_offset = 0; + idd->desc5.constant_urb_entry_read_length = 1; /* grf 1 */ + + return offset; +} + +void +gen8_emit_state_base_address (struct intel_batchbuffer *batch) +{ + OUT_BATCH(GEN8_STATE_BASE_ADDRESS | (16 - 2)); + + /* general */ + OUT_BATCH(0 | BASE_ADDRESS_MODIFY); + OUT_BATCH(0); + + /* stateless data port */ + OUT_BATCH(0 | BASE_ADDRESS_MODIFY); + + /* surface */ + OUT_RELOC(batch->bo, I915_GEM_DOMAIN_SAMPLER, 0,
BASE_ADDRESS_MODIFY);
+
+ /* dynamic */
+ OUT_RELOC(batch->bo,I915_GEM_DOMAIN_RENDER|I915_GEM_DOMAIN_INSTRUCTION,
+ 0,BASE_ADDRESS_MODIFY);lib/gpu_fill.c new file +7
-0+ + /* indirect */ + OUT_BATCH(0); + OUT_BATCH(0); + + /* instruction */ + OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);
+
+ /* general state buffer size */
+OUT_BATCH(0xfffff000 | 1);
+ /* dynamic state buffer size */
+OUT_BATCH(1 << 12 | 1);
+ /* indirect object buffer size */
+OUT_BATCH(0xfffff000 | 1);
+ /* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */
+OUT_BATCH(1 << 12 | 1);lib/gpu_fill.c new file +52
-0+} + +void +gen8_emit_vfe_state (struct intel_batchbuffer *batch) +{ + OUT_BATCH(GEN8_MEDIA_VFE_STATE | (9 - 2)); + + /* scratch buffer */ + OUT_BATCH(0); + OUT_BATCH(0); + + /* number of threads & urb entries */ + OUT_BATCH(1 << 16 | + 2 << 8); + + OUT_BATCH(0); + + /* urb entry size & curbe size */ + OUT_BATCH(2 << 16 | + 2); + + /* scoreboard */ + OUT_BATCH(0); + OUT_BATCH(0); + OUT_BATCH(0); +} + +void +gen8_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch) +{ + OUT_BATCH(GEN8_MEDIA_VFE_STATE | (9 - 2)); + + /* scratch buffer */ + OUT_BATCH(0); + OUT_BATCH(0); + + /* number of threads & urb entries */ + OUT_BATCH(1 << 16 | 1 << 8); + + OUT_BATCH(0); + + /* urb entry size & curbe size */ + OUT_BATCH(0 << 16 | 1); + + /* scoreboard */ + OUT_BATCH(0); + OUT_BATCH(0); + OUT_BATCH(0); +} + +void +gen8_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t
curbe_buffer)
+{
+OUT_BATCH(GEN8_MEDIA_CURBE_LOAD | (4 - 2));
+OUT_BATCH(0);
+ /* curbe total data length */
+OUT_BATCH(64);
+ /* curbe data start address, is relative to the dynamics base address */
+OUT_BATCH(curbe_buffer);lib/gpu_fill.c new file +4
-0+} + +void +gen8_emit_interface_descriptor_load(struct intel_batchbuffer*batch,
uint32_tinterface_descriptor)
+{
+OUT_BATCH(GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 - 2)); +OUT_BATCH(0);
+ /* interface descriptor data length */
+OUT_BATCH(sizeof(struct gen8_interface_descriptor_data)); + /* interface descriptor address, is relative to the dynamics base address */
+OUT_BATCH(interface_descriptor);lib/gpu_fill.c new file +142
-0+} + +void +gen8_emit_media_state_flush (struct intel_batchbuffer *batch) +{ + OUT_BATCH(GEN8_MEDIA_STATE_FLUSH | (2 - 2)); + OUT_BATCH(0); +} + +void +gen8_emit_media_objects (struct intel_batchbuffer *batch, + unsigned x, unsigned y, + unsigned width, unsigned height) +{ + int i, j; + + for (i = 0; i < width / 16; i++) { + for (j = 0; j < height / 16; j++) { + OUT_BATCH(GEN8_MEDIA_OBJECT | (8 - 2)); + + /* interface descriptor offset */ + OUT_BATCH(0); + + /* without indirect data */ + OUT_BATCH(0); + OUT_BATCH(0); + + /* scoreboard */ + OUT_BATCH(0); + OUT_BATCH(0); + + /* inline data (xoffset, yoffset) */ + OUT_BATCH(x + i * 16); + OUT_BATCH(y + j * 16); + gen8_emit_media_state_flush(batch); + } + } +} + +void +gen8lp_emit_media_objects (struct intel_batchbuffer *batch, + unsigned x, unsigned y, + unsigned width, unsigned height) +{ + int i, j; + + for (i = 0; i < width / 16; i++) { + for (j = 0; j < height / 16; j++) { + OUT_BATCH(GEN8_MEDIA_OBJECT | (8 - 2)); + + /* interface descriptor offset */ + OUT_BATCH(0); + + /* without indirect data */ + OUT_BATCH(0); + OUT_BATCH(0); + + /* scoreboard */ + OUT_BATCH(0); + OUT_BATCH(0); + + /* inline data (xoffset, yoffset) */ + OUT_BATCH(x + i * 16); + OUT_BATCH(y + j * 16); + } + } +} + +void +gen8_emit_gpgpu_walk (struct intel_batchbuffer *batch, + unsigned x, unsigned y, + unsigned width, unsigned height) +{ + uint32_t x_dim, y_dim, tmp, right_mask; + + /* + * Simply do SIMD16 based dispatch, so every thread uses + * SIMD16 channels. + * + * Define our own thread group size, e.g 16x1 for every group, then + * will have 1 thread each group in SIMD16 dispatch. So thread + * width/height/depth are all 1. + * + * Then thread group X = width / 16 (aligned to 16) + * thread group Y = height; + */ + x_dim = (width + 15) / 16; + y_dim = height; + + tmp = width & 15; + if (tmp == 0) + right_mask = (1 << 16) - 1; + else + right_mask = (1 << tmp) - 1; + + OUT_BATCH(GEN7_GPGPU_WALKER | 13); + + OUT_BATCH(0); /* kernel offset */ + OUT_BATCH(0); /* indirect data length */ + OUT_BATCH(0); /* indirect data offset */ + + /* SIMD size, thread w/h/d */ + OUT_BATCH(1 << 30 | /* SIMD16 */ + 0 << 16 | /* depth:1 */ + 0 << 8 | /* height:1 */ + 0); /* width:1 */ + + /* thread group X */ + OUT_BATCH(0); + OUT_BATCH(0); + OUT_BATCH(x_dim); + + /* thread group Y */ + OUT_BATCH(0); + OUT_BATCH(0); + OUT_BATCH(y_dim); + + /* thread group Z */ + OUT_BATCH(0); + OUT_BATCH(1); + + /* right mask */ + OUT_BATCH(right_mask); + + /* bottom mask, height 1, always 0xffffffff */ + OUT_BATCH(0xffffffff); +} + +void +gen9_emit_state_base_address (struct intel_batchbuffer *batch) +{ + OUT_BATCH(GEN8_STATE_BASE_ADDRESS | (19 - 2)); + + /* general */ + OUT_BATCH(0 | BASE_ADDRESS_MODIFY); + OUT_BATCH(0); + + /* stateless data port */ + OUT_BATCH(0 | BASE_ADDRESS_MODIFY); + + /* surface */ + OUT_RELOC(batch->bo, I915_GEM_DOMAIN_SAMPLER, 0,
BASE_ADDRESS_MODIFY);
+
+ /* dynamic */
+ OUT_RELOC(batch->bo,I915_GEM_DOMAIN_RENDER|I915_GEM_DOMAIN_INSTRUCTION,
+ 0,BASE_ADDRESS_MODIFY);lib/gpu_fill.c new file +7
-0+ + /* indirect */ + OUT_BATCH(0); + OUT_BATCH(0); + + /* instruction */ + OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);
+
+ /* general state buffer size */
+OUT_BATCH(0xfffff000 | 1);
+ /* dynamic state buffer size */
+OUT_BATCH(1 << 12 | 1);
+ /* indirect object buffer size */
+OUT_BATCH(0xfffff000 | 1);
+ /* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */
+OUT_BATCH(1 << 12 | 1);lib/gpu_fill.c new file +6
-0+ + /* Bindless surface state base address */ + OUT_BATCH(0 | BASE_ADDRESS_MODIFY); + OUT_BATCH(0); + OUT_BATCH(0xfffff000); +}lib/gpu_fill.h new file +4
-0@@ -0,0 +1,141 @@ +/* +* Copyright © 2018 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */lib/gpu_fill.h new file +12
-0+ +#ifndef GPU_FILL_H +#define GPU_FILL_H + +uint32_t +batch_used (struct intel_batchbuffer *batch); + +uint32_t +batch_align (struct intel_batchbuffer *batch,uint32_t align); + +void * +batch_alloc(struct intel_batchbuffer *batch, uint32_t size,
uint32_talign);lib/gpu_fill.h new file +6
-0+ +uint32_t +batch_offset (struct intel_batchbuffer *batch,void *ptr); + +uint32_t +batch_copy(struct intel_batchbuffer *batch, const void *ptr,
uint32_tsize,uint32_talign);lib/gpu_fill.h new file +24
-0+ +void +gen7_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end); + +uint32_t +gen7_fill_curbe_buffer_data (struct intel_batchbuffer *batch, + uint8_t color); + +uint32_t +gen7_fill_surface_state (struct intel_batchbuffer *batch, + struct igt_buf *buf, + uint32_t format, + int is_dst); + +uint32_t +gen7_fill_binding_table (struct intel_batchbuffer *batch, + struct igt_buf *dst); +uint32_t +gen7_fill_kernel (struct intel_batchbuffer *batch, + const uint32_t kernel[][4], + size_t size); + +uint32_t +gen7_fill_interface_descriptor(struct intel_batchbuffer *batch,struct
igt_buf*dst,
+ constuint32_tkernel[][4],size_tsize);lib/gpu_fill.h new file +12
-0+ +void +gen7_emit_state_base_address (struct intel_batchbuffer *batch); + +void +gen7_emit_vfe_state (struct intel_batchbuffer *batch); + +void +gen7_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch); + +void +gen7_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t
curbe_buffer);lib/gpu_fill.h new file +3
-0+ +void +gen7_emit_interface_descriptor_load(struct intel_batchbuffer*batch,
uint32_tinterface_descriptor);lib/gpu_fill.h new file +18
-0+ +void +gen7_emit_media_objects (struct intel_batchbuffer *batch, + unsigned x, unsigned y, + unsigned width, unsigned height); + +uint32_t +gen8_fill_surface_state (struct intel_batchbuffer *batch, + struct igt_buf *buf, + uint32_t format, + int is_dst); + +uint32_t +gen8_fill_binding_table (struct intel_batchbuffer *batch, + struct igt_buf *dst); + +uint32_t +gen8_fill_interface_descriptor(struct intel_batchbuffer *batch,struct
igt_buf*dst, constuint32_tkernel[][4],size_tsize);lib/gpu_fill.h new file +12
-0+ +void +gen8_emit_state_base_address (struct intel_batchbuffer *batch); + +void +gen8_emit_vfe_state (struct intel_batchbuffer *batch); + +void +gen8_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch); + +void +gen8_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t
curbe_buffer);lib/gpu_fill.h new file +3
-0+ +void +gen8_emit_interface_descriptor_load(struct intel_batchbuffer*batch,
uint32_tinterface_descriptor);lib/gpu_fill.h new file +27
-0+ +void +gen8_emit_media_state_flush (struct intel_batchbuffer *batch); + +void +gen8_emit_media_objects (struct intel_batchbuffer *batch, + unsigned x, unsigned y, + unsigned width, unsigned height); + +void +gen8lp_emit_media_objects (struct intel_batchbuffer *batch, + unsigned x, unsigned y, + unsigned width, unsigned height); + +void +gen9_emit_state_base_address (struct intel_batchbuffer *batch); + +void +gen7_emit_gpgpu_walk (struct intel_batchbuffer *batch, + unsigned x, unsigned y, + unsigned width, unsigned height); +void +gen8_emit_gpgpu_walk (struct intel_batchbuffer *batch, + unsigned x, unsigned y, + unsigned width, unsigned height); + +#endif /* GPU_FILL_H */ lib/media_fill_gen7.c +1
-139@@ -5,7 +5,7 @@ #include "gen7_media.h" #include "intel_reg.h" #include "drmtest.h" - +#include "gpu_fill.h" #include <assert.h> static const uint32_t media_kernel[][4] = {@@ -22,275 +22,6 @@ static const uint32_t media_kernel[][4] = { { 0x07800031, 0x20001ca8, 0x00000e00, 0x82000010 }, }; -static uint32_t -batch_used (struct intel_batchbuffer *batch) -{ - return batch->ptr - batch->buffer; -} - -static uint32_t -batch_align (struct intel_batchbuffer *batch,uint32_t align) -{ - uint32_t offset = batch_used(batch); - offset = ALIGN(offset, align); - batch->ptr = batch->buffer + offset; - return offset; -} - -static void * -batch_alloc (struct intel_batchbuffer *batch,uint32_t size, uint32_t align) -{ - uint32_t offset = batch_align(batch, align); - batch->ptr += size; - return memset(batch->buffer + offset, 0, size); -} - -static uint32_t -batch_offset (struct intel_batchbuffer *batch,void *ptr) -{ - return (uint8_t *)ptr - batch->buffer; -} - -static uint32_t -batch_copy (struct intel_batchbuffer *batch,const void *ptr, uint32_t size, uint32_t align) -{ - return batch_offset(batch, memcpy(batch_alloc(batch, size, align), ptr, size)); -} - -static void -gen7_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end) -{ - int ret; - - ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer); - if (ret == 0) - ret = drm_intel_bo_mrb_exec(batch->bo, batch_end, - NULL, 0, 0, 0); - igt_assert(ret == 0); -} - -static uint32_t -gen7_fill_curbe_buffer_data (struct intel_batchbuffer *batch, - uint8_t color) -{ - uint8_t *curbe_buffer; - uint32_t offset; - - curbe_buffer = batch_alloc(batch, sizeof(uint32_t) * 8, 64); - offset = batch_offset(batch, curbe_buffer); - *curbe_buffer = color; - - return offset; -} - -static uint32_t -gen7_fill_surface_state (struct intel_batchbuffer *batch, - struct igt_buf *buf, - uint32_t format, - int is_dst) -{ - struct gen7_surface_state *ss; - uint32_t write_domain, read_domain, offset; - int ret; - - if (is_dst) { - write_domain = read_domain = I915_GEM_DOMAIN_RENDER; - } else { - write_domain = 0; - read_domain = I915_GEM_DOMAIN_SAMPLER; - } - - ss = batch_alloc(batch, sizeof(*ss), 64); - offset = batch_offset(batch, ss); - - ss->ss0.surface_type = GEN7_SURFACE_2D; - ss->ss0.surface_format = format; - ss->ss0.render_cache_read_write = 1; - - if (buf->tiling == I915_TILING_X) - ss->ss0.tiled_mode = 2; - else if (buf->tiling == I915_TILING_Y) - ss->ss0.tiled_mode = 3; - - ss->ss1.base_addr = buf->bo->offset; - ret = drm_intel_bo_emit_reloc(batch->bo, - batch_offset(batch, ss) + 4, - buf->bo, 0, - read_domain, write_domain); - igt_assert(ret == 0); - - ss->ss2.height = igt_buf_height(buf) - 1; - ss->ss2.width = igt_buf_width(buf) - 1; - - ss->ss3.pitch = buf->stride - 1; - - ss->ss7.shader_chanel_select_r = 4; - ss->ss7.shader_chanel_select_g = 5; - ss->ss7.shader_chanel_select_b = 6; - ss->ss7.shader_chanel_select_a = 7; - - return offset; -} - -static uint32_t -gen7_fill_binding_table (struct intel_batchbuffer *batch, - struct igt_buf *dst) -{ - uint32_t *binding_table, offset; - - binding_table = batch_alloc(batch, 32, 64); - offset = batch_offset(batch, binding_table); - - binding_table[0] = gen7_fill_surface_state(batch, dst, GEN7_SURFACEFORMAT_R8_UNORM, 1); - - return offset; -} - -static uint32_t -gen7_fill_media_kernel (struct intel_batchbuffer *batch, - const uint32_t kernel[][4], - size_t size) -{ - uint32_t offset; - - offset = batch_copy(batch, kernel, size, 64); - - return offset; -} - -static uint32_t -gen7_fill_interface_descriptor(struct intel_batchbuffer *batch,struct
igt_buf*dst,
- constuint32_tkernel[][4],size_tsize)lib/media_fill_gen7.c +0
-38-{ - struct gen7_interface_descriptor_data *idd; - uint32_t offset; - uint32_t binding_table_offset, kernel_offset; - - binding_table_offset = gen7_fill_binding_table(batch, dst); - kernel_offset = gen7_fill_media_kernel(batch, kernel, size); - - idd = batch_alloc(batch, sizeof(*idd), 64); - offset = batch_offset(batch, idd); - - idd->desc0.kernel_start_pointer = (kernel_offset >> 6); - - idd->desc1.single_program_flow = 1; - idd->desc1.floating_point_mode = GEN7_FLOATING_POINT_IEEE_754; - - idd->desc2.sampler_count = 0; /* 0 samplers used */ - idd->desc2.sampler_state_pointer = 0; - - idd->desc3.binding_table_entry_count = 0; - idd->desc3.binding_table_pointer = (binding_table_offset >> 5); - - idd->desc4.constant_urb_entry_read_offset = 0; - idd->desc4.constant_urb_entry_read_length = 1; /* grf 1 */ - - return offset; -} - -static void -gen7_emit_state_base_address (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN7_STATE_BASE_ADDRESS | (10 - 2)); - - /* general */ - OUT_BATCH(0); - - /* surface */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);
-
- /* dynamic */
-OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY);lib/media_fill_gen7.c +0
-6- - /* indirect */ - OUT_BATCH(0); - - /* instruction */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);lib/media_fill_gen7.c +0
-34- - /* general/dynamic/indirect/instruction access Bound */ - OUT_BATCH(0); - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(0); - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); -} - -static void -gen7_emit_vfe_state (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN7_MEDIA_VFE_STATE | (8 - 2)); - - /* scratch buffer */ - OUT_BATCH(0); - - /* number of threads & urb entries */ - OUT_BATCH(1 << 16 | - 2 << 8); - - OUT_BATCH(0); - - /* urb entry size & curbe size */ - OUT_BATCH(2 << 16 | /* in 256 bits unit */ - 2); /* in 256 bits unit */ - - /* scoreboard */ - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(0); -} - -static void -gen7_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t
curbe_buffer)
-{
-OUT_BATCH(GEN7_MEDIA_CURBE_LOAD | (4 - 2));
-OUT_BATCH(0);
- /* curbe total data length */
-OUT_BATCH(64);
- /* curbe data start address, is relative to the dynamics base address */
-OUT_BATCH(curbe_buffer);lib/media_fill_gen7.c +0
-4-} - -static void -gen7_emit_interface_descriptor_load(struct intel_batchbuffer*batch,
uint32_tinterface_descriptor)
-{
-OUT_BATCH(GEN7_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 - 2)); -OUT_BATCH(0);
- /* interface descriptor data length */
-OUT_BATCH(sizeof(struct gen7_interface_descriptor_data)); - /* interface descriptor address, is relative to the dynamics base address */
-OUT_BATCH(interface_descriptor);lib/media_fill_gen7.c +0
-31-} - -static void -gen7_emit_media_objects (struct intel_batchbuffer *batch, - unsigned x, unsigned y, - unsigned width, unsigned height) -{ - int i, j; - - for (i = 0; i < width / 16; i++) { - for (j = 0; j < height / 16; j++) { - OUT_BATCH(GEN7_MEDIA_OBJECT | (8 - 2)); - - /* interface descriptor offset */ - OUT_BATCH(0); - - /* without indirect data */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* scoreboard */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* inline data (xoffset, yoffset) */ - OUT_BATCH(x + i * 16); - OUT_BATCH(y + j * 16); - } - } -} -/*
* This sets up the media pipeline,
*lib/media_fill_gen8.c +1
-141@@ -5,7 +5,7 @@ #include "gen8_media.h" #include "intel_reg.h" #include "drmtest.h" - +#include "gpu_fill.h" #include <assert.h>@@ -23,294 +23,6 @@ static const uint32_t media_kernel[][4] = { { 0x07800031, 0x20000a40, 0x0e000e00, 0x82000010 }, }; -static uint32_t -batch_used (struct intel_batchbuffer *batch) -{ - return batch->ptr - batch->buffer; -} - -static uint32_t -batch_align (struct intel_batchbuffer *batch,uint32_t align) -{ - uint32_t offset = batch_used(batch); - offset = ALIGN(offset, align); - batch->ptr = batch->buffer + offset; - return offset; -} - -static void * -batch_alloc (struct intel_batchbuffer *batch,uint32_t size, uint32_t align) -{ - uint32_t offset = batch_align(batch, align); - batch->ptr += size; - return memset(batch->buffer + offset, 0, size); -} - -static uint32_t -batch_offset (struct intel_batchbuffer *batch,void *ptr) -{ - return (uint8_t *)ptr - batch->buffer; -} - -static uint32_t -batch_copy (struct intel_batchbuffer *batch,const void *ptr, uint32_t size, uint32_t align) -{ - return batch_offset(batch, memcpy(batch_alloc(batch, size, align), ptr, size)); -} - -static void -gen8_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end) -{ - int ret; - - ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer); - if (ret == 0) - ret = drm_intel_bo_mrb_exec(batch->bo, batch_end, - NULL, 0, 0, 0); - igt_assert(ret == 0); -} - -static uint32_t -gen8_fill_curbe_buffer_data (struct intel_batchbuffer *batch, - uint8_t color) -{ - uint8_t *curbe_buffer; - uint32_t offset; - - curbe_buffer = batch_alloc(batch, sizeof(uint32_t) * 8, 64); - offset = batch_offset(batch, curbe_buffer); - *curbe_buffer = color; - - return offset; -} - -static uint32_t -gen8_fill_surface_state (struct intel_batchbuffer *batch, - struct igt_buf *buf, - uint32_t format, - int is_dst) -{ - struct gen8_surface_state *ss; - uint32_t write_domain, read_domain, offset; - int ret; - - if (is_dst) { - write_domain = read_domain = I915_GEM_DOMAIN_RENDER; - } else { - write_domain = 0; - read_domain = I915_GEM_DOMAIN_SAMPLER; - } - - ss = batch_alloc(batch, sizeof(*ss), 64); - offset = batch_offset(batch, ss); - - ss->ss0.surface_type = GEN8_SURFACE_2D; - ss->ss0.surface_format = format; - ss->ss0.render_cache_read_write = 1; - ss->ss0.vertical_alignment = 1; /* align 4 */ - ss->ss0.horizontal_alignment = 1; /* align 4 */ - - if (buf->tiling == I915_TILING_X) - ss->ss0.tiled_mode = 2; - else if (buf->tiling == I915_TILING_Y) - ss->ss0.tiled_mode = 3; - - ss->ss8.base_addr = buf->bo->offset; - - ret = drm_intel_bo_emit_reloc(batch->bo, - batch_offset(batch, ss) + 8 * 4, - buf->bo, 0, - read_domain, write_domain); - igt_assert(ret == 0); - - ss->ss2.height = igt_buf_height(buf) - 1; - ss->ss2.width = igt_buf_width(buf) - 1; - ss->ss3.pitch = buf->stride - 1; - - ss->ss7.shader_chanel_select_r = 4; - ss->ss7.shader_chanel_select_g = 5; - ss->ss7.shader_chanel_select_b = 6; - ss->ss7.shader_chanel_select_a = 7; - - return offset; -} - -static uint32_t -gen8_fill_binding_table (struct intel_batchbuffer *batch, - struct igt_buf *dst) -{ - uint32_t *binding_table, offset; - - binding_table = batch_alloc(batch, 32, 64); - offset = batch_offset(batch, binding_table); - - binding_table[0] = gen8_fill_surface_state(batch, dst, GEN8_SURFACEFORMAT_R8_UNORM, 1); - - return offset; -} - -static uint32_t -gen8_fill_media_kernel (struct intel_batchbuffer *batch, - const uint32_t kernel[][4], - size_t size) -{ - uint32_t offset; - - offset = batch_copy(batch, kernel, size, 64); - - return offset; -} - -static uint32_t -gen8_fill_interface_descriptor(struct intel_batchbuffer *batch,struct
igt_buf*dst)lib/media_fill_gen8.c +0
-7-{ - struct gen8_interface_descriptor_data *idd; - uint32_t offset; - uint32_t binding_table_offset, kernel_offset; - - binding_table_offset = gen8_fill_binding_table(batch, dst); - kernel_offset = gen8_fill_media_kernel(batch, media_kernel,
sizeof(media_kernel));lib/media_fill_gen8.c +0
-35- - idd = batch_alloc(batch, sizeof(*idd), 64); - offset = batch_offset(batch, idd); - - idd->desc0.kernel_start_pointer = (kernel_offset >> 6); - - idd->desc2.single_program_flow = 1; - idd->desc2.floating_point_mode = GEN8_FLOATING_POINT_IEEE_754; - - idd->desc3.sampler_count = 0; /* 0 samplers used */ - idd->desc3.sampler_state_pointer = 0; - - idd->desc4.binding_table_entry_count = 0; - idd->desc4.binding_table_pointer = (binding_table_offset >> 5); - - idd->desc5.constant_urb_entry_read_offset = 0; - idd->desc5.constant_urb_entry_read_length = 1; /* grf 1 */ - - return offset; -} - -static void -gen8_emit_state_base_address (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_STATE_BASE_ADDRESS | (16 - 2)); - - /* general */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(0); - - /* stateless data port */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - - /* surface */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_SAMPLER, 0,
BASE_ADDRESS_MODIFY);
-
- /* dynamic */
- OUT_RELOC(batch->bo,I915_GEM_DOMAIN_RENDER|I915_GEM_DOMAIN_INSTRUCTION,
- 0,BASE_ADDRESS_MODIFY);lib/media_fill_gen8.c +0
-7- - /* indirect */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* instruction */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);
-
- /* general state buffer size */
-OUT_BATCH(0xfffff000 | 1);
- /* dynamic state buffer size */
-OUT_BATCH(1 << 12 | 1);
- /* indirect object buffer size */
-OUT_BATCH(0xfffff000 | 1);
- /* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */
-OUT_BATCH(1 << 12 | 1);lib/media_fill_gen8.c +0
-29-} - -static void -gen8_emit_vfe_state (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_MEDIA_VFE_STATE | (9 - 2)); - - /* scratch buffer */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* number of threads & urb entries */ - OUT_BATCH(1 << 16 | - 2 << 8); - - OUT_BATCH(0); - - /* urb entry size & curbe size */ - OUT_BATCH(2 << 16 | - 2); - - /* scoreboard */ - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(0); -} - -static void -gen8_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t
curbe_buffer)
-{
-OUT_BATCH(GEN8_MEDIA_CURBE_LOAD | (4 - 2));
-OUT_BATCH(0);
- /* curbe total data length */
-OUT_BATCH(64);
- /* curbe data start address, is relative to the dynamics base address */
-OUT_BATCH(curbe_buffer);lib/media_fill_gen8.c +0
-4-} - -static void -gen8_emit_interface_descriptor_load(struct intel_batchbuffer*batch,
uint32_tinterface_descriptor)
-{
-OUT_BATCH(GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 - 2)); -OUT_BATCH(0);
- /* interface descriptor data length */
-OUT_BATCH(sizeof(struct gen8_interface_descriptor_data)); - /* interface descriptor address, is relative to the dynamics base address */
-OUT_BATCH(interface_descriptor);lib/media_fill_gen8.c +0
-39-} - -static void -gen8_emit_media_state_flush (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_MEDIA_STATE_FLUSH | (2 - 2)); - OUT_BATCH(0); -} - -static void -gen8_emit_media_objects (struct intel_batchbuffer *batch, - unsigned x, unsigned y, - unsigned width, unsigned height) -{ - int i, j; - - for (i = 0; i < width / 16; i++) { - for (j = 0; j < height / 16; j++) { - OUT_BATCH(GEN8_MEDIA_OBJECT | (8 - 2)); - - /* interface descriptor offset */ - OUT_BATCH(0); - - /* without indirect data */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* scoreboard */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* inline data (xoffset, yoffset) */ - OUT_BATCH(x + i * 16); - OUT_BATCH(y + j * 16); - gen8_emit_media_state_flush(batch); - } - } -} -/*
* This sets up the media pipeline,
*lib/media_fill_gen8.c +4
-3@@ -348,8 +60,9 @@ gen8_media_fillfunc(struct intel_batchbuffer *batch, /* setup states */ batch->ptr = &batch->buffer[BATCH_STATE_SPLIT]; - curbe_buffer = gen8_fill_curbe_buffer_data(batch, color); - interface_descriptor = gen8_fill_interface_descriptor(batch, dst); + curbe_buffer = gen7_fill_curbe_buffer_data(batch, color); + interface_descriptor = gen8_fill_interface_descriptor(batch, dst, + media_kernel, sizeof(media_kernel)); igt_assert(batch->ptr < &batch->buffer[4095]); /* media pipeline */@@ -370,6 +83,6 @@ gen8_media_fillfunc(struct intel_batchbuffer *batch, batch_end = batch_align(batch, 8); igt_assert(batch_end < BATCH_STATE_SPLIT); - gen8_render_flush(batch, batch_end); + gen7_render_flush(batch, batch_end); intel_batchbuffer_reset(batch); }lib/media_fill_gen8lp.c +1
-141@@ -5,7 +5,7 @@ #include "gen8_media.h" #include "intel_reg.h" #include "drmtest.h" - +#include "gpu_fill.h" #include <assert.h>@@ -23,286 +23,6 @@ static const uint32_t media_kernel[][4] = { { 0x07800031, 0x20000a40, 0x0e000e00, 0x82000010 }, }; -static uint32_t -batch_used (struct intel_batchbuffer *batch) -{ - return batch->ptr - batch->buffer; -} - -static uint32_t -batch_align (struct intel_batchbuffer *batch,uint32_t align) -{ - uint32_t offset = batch_used(batch); - offset = ALIGN(offset, align); - batch->ptr = batch->buffer + offset; - return offset; -} - -static void * -batch_alloc (struct intel_batchbuffer *batch,uint32_t size, uint32_t align) -{ - uint32_t offset = batch_align(batch, align); - batch->ptr += size; - return memset(batch->buffer + offset, 0, size); -} - -static uint32_t -batch_offset (struct intel_batchbuffer *batch,void *ptr) -{ - return (uint8_t *)ptr - batch->buffer; -} - -static uint32_t -batch_copy (struct intel_batchbuffer *batch,const void *ptr, uint32_t size, uint32_t align) -{ - return batch_offset(batch, memcpy(batch_alloc(batch, size, align), ptr, size)); -} - -static void -gen8_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end) -{ - int ret; - - ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer); - if (ret == 0) - ret = drm_intel_bo_mrb_exec(batch->bo, batch_end, - NULL, 0, 0, 0); - igt_assert(ret == 0); -} - -static uint32_t -gen8_fill_curbe_buffer_data (struct intel_batchbuffer *batch, - uint8_t color) -{ - uint8_t *curbe_buffer; - uint32_t offset; - - curbe_buffer = batch_alloc(batch, sizeof(uint32_t) * 8, 64); - offset = batch_offset(batch, curbe_buffer); - *curbe_buffer = color; - - return offset; -} - -static uint32_t -gen8_fill_surface_state (struct intel_batchbuffer *batch, - struct igt_buf *buf, - uint32_t format, - int is_dst) -{ - struct gen8_surface_state *ss; - uint32_t write_domain, read_domain, offset; - int ret; - - if (is_dst) { - write_domain = read_domain = I915_GEM_DOMAIN_RENDER; - } else { - write_domain = 0; - read_domain = I915_GEM_DOMAIN_SAMPLER; - } - - ss = batch_alloc(batch, sizeof(*ss), 64); - offset = batch_offset(batch, ss); - - ss->ss0.surface_type = GEN8_SURFACE_2D; - ss->ss0.surface_format = format; - ss->ss0.render_cache_read_write = 1; - ss->ss0.vertical_alignment = 1; /* align 4 */ - ss->ss0.horizontal_alignment = 1; /* align 4 */ - - if (buf->tiling == I915_TILING_X) - ss->ss0.tiled_mode = 2; - else if (buf->tiling == I915_TILING_Y) - ss->ss0.tiled_mode = 3; - - ss->ss8.base_addr = buf->bo->offset; - - ret = drm_intel_bo_emit_reloc(batch->bo, - batch_offset(batch, ss) + 8 * 4, - buf->bo, 0, - read_domain, write_domain); - igt_assert(ret == 0); - - ss->ss2.height = igt_buf_height(buf) - 1; - ss->ss2.width = igt_buf_width(buf) - 1; - ss->ss3.pitch = buf->stride - 1; - - ss->ss7.shader_chanel_select_r = 4; - ss->ss7.shader_chanel_select_g = 5; - ss->ss7.shader_chanel_select_b = 6; - ss->ss7.shader_chanel_select_a = 7; - - return offset; -} - -static uint32_t -gen8_fill_binding_table (struct intel_batchbuffer *batch, - struct igt_buf *dst) -{ - uint32_t *binding_table, offset; - - binding_table = batch_alloc(batch, 32, 64); - offset = batch_offset(batch, binding_table); - - binding_table[0] = gen8_fill_surface_state(batch, dst, GEN8_SURFACEFORMAT_R8_UNORM, 1); - - return offset; -} - -static uint32_t -gen8_fill_media_kernel (struct intel_batchbuffer *batch, - const uint32_t kernel[][4], - size_t size) -{ - uint32_t offset; - - offset = batch_copy(batch, kernel, size, 64); - - return offset; -} - -static uint32_t -gen8_fill_interface_descriptor(struct intel_batchbuffer *batch,struct
igt_buf*dst)lib/media_fill_gen8lp.c +0
-7-{ - struct gen8_interface_descriptor_data *idd; - uint32_t offset; - uint32_t binding_table_offset, kernel_offset; - - binding_table_offset = gen8_fill_binding_table(batch, dst); - kernel_offset = gen8_fill_media_kernel(batch, media_kernel,
sizeof(media_kernel));lib/media_fill_gen8lp.c +0
-35- - idd = batch_alloc(batch, sizeof(*idd), 64); - offset = batch_offset(batch, idd); - - idd->desc0.kernel_start_pointer = (kernel_offset >> 6); - - idd->desc2.single_program_flow = 1; - idd->desc2.floating_point_mode = GEN8_FLOATING_POINT_IEEE_754; - - idd->desc3.sampler_count = 0; /* 0 samplers used */ - idd->desc3.sampler_state_pointer = 0; - - idd->desc4.binding_table_entry_count = 0; - idd->desc4.binding_table_pointer = (binding_table_offset >> 5); - - idd->desc5.constant_urb_entry_read_offset = 0; - idd->desc5.constant_urb_entry_read_length = 1; /* grf 1 */ - - return offset; -} - -static void -gen8_emit_state_base_address (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_STATE_BASE_ADDRESS | (16 - 2)); - - /* general */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(0); - - /* stateless data port */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - - /* surface */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_SAMPLER, 0,
BASE_ADDRESS_MODIFY);
-
- /* dynamic */
- OUT_RELOC(batch->bo,I915_GEM_DOMAIN_RENDER|I915_GEM_DOMAIN_INSTRUCTION,
- 0,BASE_ADDRESS_MODIFY);lib/media_fill_gen8lp.c +0
-7- - /* indirect */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* instruction */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);
-
- /* general state buffer size */
-OUT_BATCH(0xfffff000 | 1);
- /* dynamic state buffer size */
-OUT_BATCH(1 << 12 | 1);
- /* indirect object buffer size */
-OUT_BATCH(0xfffff000 | 1);
- /* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */
-OUT_BATCH(1 << 12 | 1);lib/media_fill_gen8lp.c +0
-29-} - -static void -gen8_emit_vfe_state (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_MEDIA_VFE_STATE | (9 - 2)); - - /* scratch buffer */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* number of threads & urb entries */ - OUT_BATCH(1 << 16 | - 2 << 8); - - OUT_BATCH(0); - - /* urb entry size & curbe size */ - OUT_BATCH(2 << 16 | - 2); - - /* scoreboard */ - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(0); -} - -static void -gen8_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t
curbe_buffer)
-{
-OUT_BATCH(GEN8_MEDIA_CURBE_LOAD | (4 - 2));
-OUT_BATCH(0);
- /* curbe total data length */
-OUT_BATCH(64);
- /* curbe data start address, is relative to the dynamics base address */
-OUT_BATCH(curbe_buffer);lib/media_fill_gen8lp.c +0
-4-} - -static void -gen8_emit_interface_descriptor_load(struct intel_batchbuffer*batch,
uint32_tinterface_descriptor)
-{
-OUT_BATCH(GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 - 2)); -OUT_BATCH(0);
- /* interface descriptor data length */
-OUT_BATCH(sizeof(struct gen8_interface_descriptor_data)); - /* interface descriptor address, is relative to the dynamics base address */
-OUT_BATCH(interface_descriptor);lib/media_fill_gen8lp.c +0
-31-} - -static void -gen8lp_emit_media_objects (struct intel_batchbuffer *batch, - unsigned x, unsigned y, - unsigned width, unsigned height) -{ - int i, j; - - for (i = 0; i < width / 16; i++) { - for (j = 0; j < height / 16; j++) { - OUT_BATCH(GEN8_MEDIA_OBJECT | (8 - 2)); - - /* interface descriptor offset */ - OUT_BATCH(0); - - /* without indirect data */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* scoreboard */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* inline data (xoffset, yoffset) */ - OUT_BATCH(x + i * 16); - OUT_BATCH(y + j * 16); - } - } -} -/*
* This sets up the media pipeline,
*lib/media_fill_gen8lp.c +4
-3@@ -340,8 +60,9 @@ gen8lp_media_fillfunc(struct intel_batchbuffer *batch, /* setup states */ batch->ptr = &batch->buffer[BATCH_STATE_SPLIT]; - curbe_buffer = gen8_fill_curbe_buffer_data(batch, color); - interface_descriptor = gen8_fill_interface_descriptor(batch, dst); + curbe_buffer = gen7_fill_curbe_buffer_data(batch, color); + interface_descriptor = gen8_fill_interface_descriptor(batch, dst, + media_kernel, sizeof(media_kernel)); igt_assert(batch->ptr < &batch->buffer[4095]); /* media pipeline */@@ -362,6 +83,6 @@ gen8lp_media_fillfunc(struct intel_batchbuffer *batch, batch_end = batch_align(batch, 8); igt_assert(batch_end < BATCH_STATE_SPLIT); - gen8_render_flush(batch, batch_end); + gen7_render_flush(batch, batch_end); intel_batchbuffer_reset(batch); }lib/media_fill_gen9.c +1
-143@@ -4,11 +4,9 @@ #include "media_fill.h" #include "gen8_media.h" #include "intel_reg.h" - +#include "gpu_fill.h" #include <assert.h> -#define ALIGN (x, y) (((x) + (y)-1) & ~((y)-1)) - static const uint32_t media_kernel[][4] = { { 0x00400001, 0x20202288, 0x00000020, 0x00000000 }, { 0x00600001, 0x20800208, 0x008d0000, 0x00000000 },@@ -23,299 +21,6 @@ static const uint32_t media_kernel[][4] = { { 0x07800031, 0x20000a40, 0x0e000e00, 0x82000010 }, }; -static uint32_t -batch_used (struct intel_batchbuffer *batch) -{ - return batch->ptr - batch->buffer; -} - -static uint32_t -batch_align (struct intel_batchbuffer *batch,uint32_t align) -{ - uint32_t offset = batch_used(batch); - offset = ALIGN(offset, align); - batch->ptr = batch->buffer + offset; - return offset; -} - -static void * -batch_alloc (struct intel_batchbuffer *batch,uint32_t size, uint32_t align) -{ - uint32_t offset = batch_align(batch, align); - batch->ptr += size; - return memset(batch->buffer + offset, 0, size); -} - -static uint32_t -batch_offset (struct intel_batchbuffer *batch,void *ptr) -{ - return (uint8_t *)ptr - batch->buffer; -} - -static uint32_t -batch_copy (struct intel_batchbuffer *batch,const void *ptr, uint32_t size, uint32_t align) -{ - return batch_offset(batch, memcpy(batch_alloc(batch, size, align), ptr, size)); -} - -static void -gen8_render_flush (struct intel_batchbuffer *batch,uint32_t batch_end) -{ - int ret; - - ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer); - if (ret == 0) - ret = drm_intel_bo_mrb_exec(batch->bo, batch_end, - NULL, 0, 0, 0); - assert(ret == 0); -} - -static uint32_t -gen8_fill_curbe_buffer_data (struct intel_batchbuffer *batch, - uint8_t color) -{ - uint8_t *curbe_buffer; - uint32_t offset; - - curbe_buffer = batch_alloc(batch, sizeof(uint32_t) * 8, 64); - offset = batch_offset(batch, curbe_buffer); - *curbe_buffer = color; - - return offset; -} - -static uint32_t -gen8_fill_surface_state (struct intel_batchbuffer *batch, - struct igt_buf *buf, - uint32_t format, - int is_dst) -{ - struct gen8_surface_state *ss; - uint32_t write_domain, read_domain, offset; - int ret; - - if (is_dst) { - write_domain = read_domain = I915_GEM_DOMAIN_RENDER; - } else { - write_domain = 0; - read_domain = I915_GEM_DOMAIN_SAMPLER; - } - - ss = batch_alloc(batch, sizeof(*ss), 64); - offset = batch_offset(batch, ss); - - ss->ss0.surface_type = GEN8_SURFACE_2D; - ss->ss0.surface_format = format; - ss->ss0.render_cache_read_write = 1; - ss->ss0.vertical_alignment = 1; /* align 4 */ - ss->ss0.horizontal_alignment = 1; /* align 4 */ - - if (buf->tiling == I915_TILING_X) - ss->ss0.tiled_mode = 2; - else if (buf->tiling == I915_TILING_Y) - ss->ss0.tiled_mode = 3; - - ss->ss8.base_addr = buf->bo->offset; - - ret = drm_intel_bo_emit_reloc(batch->bo, - batch_offset(batch, ss) + 8 * 4, - buf->bo, 0, - read_domain, write_domain); - assert(ret == 0); - - ss->ss2.height = igt_buf_height(buf) - 1; - ss->ss2.width = igt_buf_width(buf) - 1; - ss->ss3.pitch = buf->stride - 1; - - ss->ss7.shader_chanel_select_r = 4; - ss->ss7.shader_chanel_select_g = 5; - ss->ss7.shader_chanel_select_b = 6; - ss->ss7.shader_chanel_select_a = 7; - - return offset; -} - -static uint32_t -gen8_fill_binding_table (struct intel_batchbuffer *batch, - struct igt_buf *dst) -{ - uint32_t *binding_table, offset; - - binding_table = batch_alloc(batch, 32, 64); - offset = batch_offset(batch, binding_table); - - binding_table[0] = gen8_fill_surface_state(batch, dst, GEN8_SURFACEFORMAT_R8_UNORM, 1); - - return offset; -} - -static uint32_t -gen8_fill_media_kernel (struct intel_batchbuffer *batch, - const uint32_t kernel[][4], - size_t size) -{ - uint32_t offset; - - offset = batch_copy(batch, kernel, size, 64); - - return offset; -} - -static uint32_t -gen8_fill_interface_descriptor(struct intel_batchbuffer *batch,struct
igt_buf*dst)lib/media_fill_gen9.c +0
-7-{ - struct gen8_interface_descriptor_data *idd; - uint32_t offset; - uint32_t binding_table_offset, kernel_offset; - - binding_table_offset = gen8_fill_binding_table(batch, dst); - kernel_offset = gen8_fill_media_kernel(batch, media_kernel,
sizeof(media_kernel));lib/media_fill_gen9.c +0
-35- - idd = batch_alloc(batch, sizeof(*idd), 64); - offset = batch_offset(batch, idd); - - idd->desc0.kernel_start_pointer = (kernel_offset >> 6); - - idd->desc2.single_program_flow = 1; - idd->desc2.floating_point_mode = GEN8_FLOATING_POINT_IEEE_754; - - idd->desc3.sampler_count = 0; /* 0 samplers used */ - idd->desc3.sampler_state_pointer = 0; - - idd->desc4.binding_table_entry_count = 0; - idd->desc4.binding_table_pointer = (binding_table_offset >> 5); - - idd->desc5.constant_urb_entry_read_offset = 0; - idd->desc5.constant_urb_entry_read_length = 1; /* grf 1 */ - - return offset; -} - -static void -gen9_emit_state_base_address (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_STATE_BASE_ADDRESS | (19 - 2)); - - /* general */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(0); - - /* stateless data port */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - - /* surface */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_SAMPLER, 0,
BASE_ADDRESS_MODIFY);
-
- /* dynamic */
- OUT_RELOC(batch->bo,I915_GEM_DOMAIN_RENDER|I915_GEM_DOMAIN_INSTRUCTION,
- 0,BASE_ADDRESS_MODIFY);lib/media_fill_gen9.c +0
-7- - /* indirect */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* instruction */ - OUT_RELOC(batch->bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
BASE_ADDRESS_MODIFY);
-
- /* general state buffer size */
-OUT_BATCH(0xfffff000 | 1);
- /* dynamic state buffer size */
-OUT_BATCH(1 << 12 | 1);
- /* indirect object buffer size */
-OUT_BATCH(0xfffff000 | 1);
- /* intruction buffer size, must set modify enable bit, otherwise it may result in GPU hang */
-OUT_BATCH(1 << 12 | 1);lib/media_fill_gen9.c +0
-34- - /* Bindless surface state base address */ - OUT_BATCH(0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(0); - OUT_BATCH(0xfffff000); -} - -static void -gen8_emit_vfe_state (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_MEDIA_VFE_STATE | (9 - 2)); - - /* scratch buffer */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* number of threads & urb entries */ - OUT_BATCH(1 << 16 | - 2 << 8); - - OUT_BATCH(0); - - /* urb entry size & curbe size */ - OUT_BATCH(2 << 16 | - 2); - - /* scoreboard */ - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(0); -} - -static void -gen8_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t
curbe_buffer)
-{
-OUT_BATCH(GEN8_MEDIA_CURBE_LOAD | (4 - 2));
-OUT_BATCH(0);
- /* curbe total data length */
-OUT_BATCH(64);
- /* curbe data start address, is relative to the dynamics base address */
-OUT_BATCH(curbe_buffer);lib/media_fill_gen9.c +0
-4-} - -static void -gen8_emit_interface_descriptor_load(struct intel_batchbuffer*batch,
uint32_tinterface_descriptor)
-{
-OUT_BATCH(GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 - 2)); -OUT_BATCH(0);
- /* interface descriptor data length */
-OUT_BATCH(sizeof(struct gen8_interface_descriptor_data)); - /* interface descriptor address, is relative to the dynamics base address */
-OUT_BATCH(interface_descriptor);lib/media_fill_gen9.c +0
-39-} - -static void -gen8_emit_media_state_flush (struct intel_batchbuffer *batch) -{ - OUT_BATCH(GEN8_MEDIA_STATE_FLUSH | (2 - 2)); - OUT_BATCH(0); -} - -static void -gen8_emit_media_objects (struct intel_batchbuffer *batch, - unsigned x, unsigned y, - unsigned width, unsigned height) -{ - int i, j; - - for (i = 0; i < width / 16; i++) { - for (j = 0; j < height / 16; j++) { - OUT_BATCH(GEN8_MEDIA_OBJECT | (8 - 2)); - - /* interface descriptor offset */ - OUT_BATCH(0); - - /* without indirect data */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* scoreboard */ - OUT_BATCH(0); - OUT_BATCH(0); - - /* inline data (xoffset, yoffset) */ - OUT_BATCH(x + i * 16); - OUT_BATCH(y + j * 16); - gen8_emit_media_state_flush(batch); - } - } -} -/*
* This sets up the media pipeline,
*lib/media_fill_gen9.c +4
-3@@ -353,8 +58,9 @@ gen9_media_fillfunc(struct intel_batchbuffer *batch, /* setup states */ batch->ptr = &batch->buffer[BATCH_STATE_SPLIT]; - curbe_buffer = gen8_fill_curbe_buffer_data(batch, color); - interface_descriptor = gen8_fill_interface_descriptor(batch, dst); + curbe_buffer = gen7_fill_curbe_buffer_data(batch, color); + interface_descriptor = gen8_fill_interface_descriptor(batch, dst, + media_kernel, sizeof(media_kernel)); assert(batch->ptr < &batch->buffer[4095]); /* media pipeline */@@ -387,6 +93,6 @@ gen9_media_fillfunc(struct intel_batchbuffer *batch, batch_end = batch_align(batch, 8); assert(batch_end < BATCH_STATE_SPLIT); - gen8_render_flush(batch, batch_end); + gen7_render_flush(batch, batch_end); intel_batchbuffer_reset(batch); }lib/meson.build +0
-0lib/meson.build lib_sources = [ · line 30
Quoted 7 lines
lib/meson.build +1
-0@@ -24,6 +24,7 @@ lib_sources = [ 'intel_os.c', 'intel_mmio.c', 'ioctl_wrappers.c', + 'gpu_fill.c', 'media_fill_gen7.c', 'media_fill_gen8.c', 'media_fill_gen8lp.c',_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 2/4 lib: Adjust refactored gpu_fill library to our coding style
In reply to Katarzyna DecWhile I am making changes in gpgpu and media fill area let's adjust code to our coding style.
--- lib/gpgpu_fill.c | 12 +++--- lib/gpgpu_fill.h | 12 +++--- lib/gpu_fill.c | 109 +++++++++++++++++++++++++++--------------------- lib/gpu_fill.h | 61 +++++++++++++-------------- lib/media_fill.h | 36 ++++++++-------- lib/media_fill_gen7.c | 8 ++-- lib/media_fill_gen8.c | 9 ++-- lib/media_fill_gen8lp.c | 8 ++-- lib/media_fill_gen9.c | 28 +++++++------ 9 files changed, 152 insertions(+), 131 deletions(-)
lib/gpgpu_fill.c +6 -6
@@ -101,8 +101,8 @@ static const uint32_t gen9_gpgpu_kernel[][4] = {void gen7_gpgpu_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst, -unsigned x,unsigned y, -unsigned width,unsigned height, +unsigned int x,unsigned int y, +unsigned int width,unsigned int height,uint8_t color) {uint32_t curbe_buffer, interface_descriptor;
@@ -149,8 +149,8 @@ gen7_gpgpu_fillfunc(struct intel_batchbuffer *batch,void gen8_gpgpu_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst, -unsigned x,unsigned y, -unsigned width,unsigned height, +unsigned int x,unsigned int y, +unsigned int width,unsigned int height,uint8_t color) {uint32_t curbe_buffer, interface_descriptor;
@@ -197,8 +197,8 @@ gen8_gpgpu_fillfunc(struct intel_batchbuffer *batch,void gen9_gpgpu_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst, -unsigned x,unsigned y, -unsigned width,unsigned height, +unsigned int x,unsigned int y, +unsigned int width,unsigned int height,uint8_t color) {uint32_t curbe_buffer, interface_descriptor;
lib/gpgpu_fill.h +6 -6
@@ -30,22 +30,22 @@void gen7_gpgpu_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst, -unsigned x,unsigned y, -unsigned width,unsigned height, +unsigned int x,unsigned int y, +unsigned int width,unsigned int height,uint8_t color);void gen8_gpgpu_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst, -unsigned x,unsigned y, -unsigned width,unsigned height, +unsigned int x,unsigned int y, +unsigned int width,unsigned int height,uint8_t color);void gen9_gpgpu_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst, -unsigned x,unsigned y, -unsigned width,unsigned height, +unsigned int x,unsigned int y, +unsigned int width,unsigned int height,uint8_t color);#endif /* GPGPU_FILL_H */
lib/gpu_fill.c +61 -48
291 lines not on this page · raw message
lib/gpu_fill.h +30 -31
111 lines not on this page · raw message
lib/media_fill.h +18 -18
@@ -5,31 +5,31 @@#include "intel_batchbuffer.h" void -gen8_media_fillfunc (struct intel_batchbuffer *batch, -struct igt_buf *dst, -unsigned x,unsigned y, -unsigned width,unsigned height, -uint8_t color); +gen7_media_fillfunc (struct intel_batchbuffer *batch, +struct igt_buf *dst, +unsigned int x,unsigned int y, +unsigned int width,unsigned int height, +uint8_t color);void -gen7_media_fillfunc (struct intel_batchbuffer *batch, -struct igt_buf *dst, -unsigned x,unsigned y, -unsigned width,unsigned height, -uint8_t color); +gen8_media_fillfunc (struct intel_batchbuffer *batch, +struct igt_buf *dst, +unsigned int x,unsigned int y, +unsigned int width,unsigned int height, +uint8_t color);void gen8lp_media_fillfunc (struct intel_batchbuffer *batch, -struct igt_buf *dst, -unsigned x,unsigned y, -unsigned width,unsigned height, -uint8_t color); +struct igt_buf *dst, +unsigned int x,unsigned int y, +unsigned int width,unsigned int height, +uint8_t color);void gen9_media_fillfunc (struct intel_batchbuffer *batch, -struct igt_buf *dst, -unsigned x,unsigned y, -unsigned width,unsigned height, -uint8_t color); +struct igt_buf *dst, +unsigned int x,unsigned int y, +unsigned int width,unsigned int height, +uint8_t color);#endif /* RENDE_MEDIA_FILL_H */
lib/media_fill_gen7.c +5 -3
@@ -47,8 +47,8 @@ static const uint32_t media_kernel[][4] = {void gen7_media_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst, -unsigned x,unsigned y, -unsigned width,unsigned height, +unsigned int x,unsigned int y, +unsigned int width,unsigned int height,uint8_t color) {uint32_t curbe_buffer, interface_descriptor;
@@ -62,12 +62,14 @@ gen7_media_fillfunc(struct intel_batchbuffer *batch, curbe_buffer =gen7_fill_curbe_buffer_data (batch, color); interface_descriptor =gen7_fill_interface_descriptor (batch, dst, media_kernel, -sizeof (media_kernel)); +sizeof + (media_kernel));igt_assert (batch->ptr < &batch->buffer[4095 ]);/* media pipeline */ batch->ptr = batch->buffer;OUT_BATCH (GEN7_PIPELINE_SELECT |PIPELINE_SELECT_MEDIA ); +gen7_emit_state_base_address (batch);gen7_emit_vfe_state (batch);
lib/media_fill_gen8.c +6 -3
@@ -48,8 +48,8 @@ static const uint32_t media_kernel[][4] = {void gen8_media_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst, -unsigned x,unsigned y, -unsigned width,unsigned height, +unsigned int x,unsigned int y, +unsigned int width,unsigned int height,uint8_t color) {uint32_t curbe_buffer, interface_descriptor;
@@ -62,7 +62,10 @@ gen8_media_fillfunc(struct intel_batchbuffer *batch, curbe_buffer =gen7_fill_curbe_buffer_data (batch, color); interface_descriptor =gen8_fill_interface_descriptor (batch, dst, - media_kernel,sizeof (media_kernel)); + media_kernel, +sizeof + (media_kernel)); +igt_assert (batch->ptr < &batch->buffer[4095 ]);/* media pipeline */
lib/media_fill_gen8lp.c +5 -3
@@ -48,8 +48,8 @@ static const uint32_t media_kernel[][4] = {void gen8lp_media_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst, -unsigned x,unsigned y, -unsigned width,unsigned height, +unsigned int x,unsigned int y, +unsigned int width,unsigned int height,uint8_t color) {uint32_t curbe_buffer, interface_descriptor;
@@ -62,7 +62,9 @@ gen8lp_media_fillfunc(struct intel_batchbuffer *batch, curbe_buffer =gen7_fill_curbe_buffer_data (batch, color); interface_descriptor =gen8_fill_interface_descriptor (batch, dst, - media_kernel,sizeof (media_kernel)); + media_kernel, +sizeof + (media_kernel));igt_assert (batch->ptr < &batch->buffer[4095 ]);/* media pipeline */
lib/media_fill_gen9.c +15 -13
@@ -46,8 +46,8 @@ static const uint32_t media_kernel[][4] = {void gen9_media_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst, -unsigned x,unsigned y, -unsigned width,unsigned height, +unsigned int x,unsigned int y, +unsigned int width,unsigned int height,uint8_t color) {uint32_t curbe_buffer, interface_descriptor;
@@ -60,17 +60,19 @@ gen9_media_fillfunc(struct intel_batchbuffer *batch, curbe_buffer =gen7_fill_curbe_buffer_data (batch, color); interface_descriptor =gen8_fill_interface_descriptor (batch, dst, - media_kernel,sizeof (media_kernel)); + media_kernel, +sizeof + (media_kernel));assert (batch->ptr < &batch->buffer[4095 ]);/* media pipeline */ batch->ptr = batch->buffer;OUT_BATCH (GEN8_PIPELINE_SELECT |PIPELINE_SELECT_MEDIA | -GEN9_FORCE_MEDIA_AWAKE_ENABLE | -GEN9_SAMPLER_DOP_GATE_DISABLE | -GEN9_PIPELINE_SELECTION_MASK | -GEN9_SAMPLER_DOP_GATE_MASK | -GEN9_FORCE_MEDIA_AWAKE_MASK ); +GEN9_FORCE_MEDIA_AWAKE_ENABLE | +GEN9_SAMPLER_DOP_GATE_DISABLE | +GEN9_PIPELINE_SELECTION_MASK | +GEN9_SAMPLER_DOP_GATE_MASK | +GEN9_FORCE_MEDIA_AWAKE_MASK );gen9_emit_state_base_address (batch);gen8_emit_vfe_state (batch);
@@ -82,11 +84,11 @@ gen9_media_fillfunc(struct intel_batchbuffer *batch,gen8_emit_media_objects (batch, x, y, width, height);OUT_BATCH (GEN8_PIPELINE_SELECT |PIPELINE_SELECT_MEDIA | -GEN9_FORCE_MEDIA_AWAKE_DISABLE | -GEN9_SAMPLER_DOP_GATE_ENABLE | -GEN9_PIPELINE_SELECTION_MASK | -GEN9_SAMPLER_DOP_GATE_MASK | -GEN9_FORCE_MEDIA_AWAKE_MASK ); +GEN9_FORCE_MEDIA_AWAKE_DISABLE | +GEN9_SAMPLER_DOP_GATE_ENABLE | +GEN9_PIPELINE_SELECTION_MASK | +GEN9_SAMPLER_DOP_GATE_MASK | +GEN9_FORCE_MEDIA_AWAKE_MASK );OUT_BATCH (MI_BATCH_BUFFER_END );
Signature · 6 lines
2.14.3 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 3/4 lib: Removing duplications in gpu_fill library
In reply to Katarzyna DecAfter moving all functions needed for gpgpu and media fill testing there is a lot of duplications which can be removed:
Library media_fill_gen8lp for CHT was removed, media state flush
for !CHT was added to gen7_emit_media_objects.
Many gen8 functions were replaced with gen7 version with devid
parameter (gen7_fill_curbe_load, gen7_emit_interface_descriptor, gen7_fill_binding_table, gen7_emit_media_objects).
Duplicated constants like GEN8_MEDIA_VFE_STATE, GEN8_MEDIA_CURBE_LOAD,GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD, GEN8_MEDIA_OBJECT were replaced by GEN7 version. However this constants were not removed from gen8_media.h library, because they are used by other tests for Gen8+. More refactoring in this gen*_media.h libraries is needed.
It seems that further unification of *_fillfunc functions will introduce more confusion in understanding what the tests are doing and what were changes between Gens.
--- lib/Makefile.sources | 1 - lib/gpgpu_fill.c | 27 +++++----- lib/gpgpu_fill.h | 6 +-- lib/gpu_fill.c | 135 +++++++++--------------------------------------- lib/gpu_fill.h | 33 +++--------- lib/intel_batchbuffer.c | 4 +- lib/intel_batchbuffer.h | 3 +- lib/media_fill.h | 13 ++--- lib/media_fill_gen7.c | 11 ++-- lib/media_fill_gen8.c | 11 ++-- lib/media_fill_gen8lp.c | 90 -------------------------------- lib/media_fill_gen9.c | 11 ++-- lib/meson.build | 1 - tests/gem_gpgpu_fill.c | 2 +- tests/gem_media_fill.c | 2 +- 15 files changed, 77 insertions(+), 273 deletions(-) delete mode 100644 lib/media_fill_gen8lp.c
lib/Makefile.sources +0 -1
@@ -60,7 +60,6 @@ lib_source_list = \ media_fill.h \ media_fill_gen7.c \ media_fill_gen8.c \ - media_fill_gen8lp.c \ media_fill_gen9.c \ media_spin.h \ media_spin.c \
lib/gpgpu_fill.c +15 -12
@@ -103,7 +103,7 @@ gen7_gpgpu_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color) + uint8_t color, int devid) { uint32_t curbe_buffer, interface_descriptor;uint32_t batch_end;
@@ -123,7 +123,8 @@ gen7_gpgpu_fillfunc(struct intel_batchbuffer *batch, interface_descriptor =gen7_fill_interface_descriptor (batch, dst, gen7_gpgpu_kernel, -sizeof (gen7_gpgpu_kernel)); +sizeof (gen7_gpgpu_kernel), + devid);igt_assert (batch->ptr < &batch->buffer[4095 ]); batch->ptr = batch->buffer;
@@ -133,8 +134,8 @@ gen7_gpgpu_fillfunc(struct intel_batchbuffer *batch,gen7_emit_state_base_address (batch);gen7_emit_vfe_state_gpgpu (batch); -gen7_emit_curbe_load (batch, curbe_buffer); -gen7_emit_interface_descriptor_load (batch, interface_descriptor); +gen7_emit_curbe_load (batch, curbe_buffer, devid); +gen7_emit_interface_descriptor_load (batch, interface_descriptor, devid);gen7_emit_gpgpu_walk (batch, x, y, width, height);OUT_BATCH (MI_BATCH_BUFFER_END );
@@ -151,7 +152,7 @@ gen8_gpgpu_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color) + uint8_t color, int devid) { uint32_t curbe_buffer, interface_descriptor;uint32_t batch_end;
@@ -171,7 +172,8 @@ gen8_gpgpu_fillfunc(struct intel_batchbuffer *batch, interface_descriptor =gen8_fill_interface_descriptor (batch, dst, gen8_gpgpu_kernel, -sizeof (gen8_gpgpu_kernel)); +sizeof (gen8_gpgpu_kernel), + devid);igt_assert (batch->ptr < &batch->buffer[4095 ]); batch->ptr = batch->buffer;
@@ -181,8 +183,8 @@ gen8_gpgpu_fillfunc(struct intel_batchbuffer *batch,gen8_emit_state_base_address (batch);gen8_emit_vfe_state_gpgpu (batch); -gen7_emit_curbe_load (batch, curbe_buffer); -gen8_emit_interface_descriptor_load (batch, interface_descriptor); +gen7_emit_curbe_load (batch, curbe_buffer, devid); +gen7_emit_interface_descriptor_load (batch, interface_descriptor, devid);gen8_emit_gpgpu_walk (batch, x, y, width, height);OUT_BATCH (MI_BATCH_BUFFER_END );
@@ -199,7 +201,7 @@ gen9_gpgpu_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color) + uint8_t color, int devid) { uint32_t curbe_buffer, interface_descriptor;uint32_t batch_end;
@@ -219,7 +221,8 @@ gen9_gpgpu_fillfunc(struct intel_batchbuffer *batch, interface_descriptor =gen8_fill_interface_descriptor (batch, dst, gen9_gpgpu_kernel, -sizeof (gen9_gpgpu_kernel)); +sizeof (gen9_gpgpu_kernel), + devid);igt_assert (batch->ptr < &batch->buffer[4095 ]); batch->ptr = batch->buffer;
@@ -229,8 +232,8 @@ gen9_gpgpu_fillfunc(struct intel_batchbuffer *batch,gen9_emit_state_base_address (batch);gen8_emit_vfe_state_gpgpu (batch); -gen7_emit_curbe_load (batch, curbe_buffer); -gen7_emit_interface_descriptor_load (batch, interface_descriptor); +gen7_emit_curbe_load (batch, curbe_buffer, devid); +gen7_emit_interface_descriptor_load (batch, interface_descriptor, devid);gen8_emit_gpgpu_walk (batch, x, y, width, height);OUT_BATCH (MI_BATCH_BUFFER_END );
lib/gpgpu_fill.h +3 -3
@@ -32,20 +32,20 @@ gen7_gpgpu_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color); + uint8_t color, int devid);void gen8_gpgpu_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst,unsigned int x,unsigned int y,unsigned int width,unsigned int height, -uint8_t color); +uint8_t color,int devid);void gen9_gpgpu_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst,unsigned int x,unsigned int y,unsigned int width,unsigned int height, -uint8_t color); +uint8_t color,int devid);#endif /* GPGPU_FILL_H */
lib/gpu_fill.c +25 -110
231 lines not on this page · raw message
lib/gpu_fill.h +8 -25
@@ -53,7 +53,8 @@ gen7_fill_surface_state(struct intel_batchbuffer *batch, struct igt_buf *buf, uint32_t format, int is_dst);uint32_t -gen7_fill_binding_table (struct intel_batchbuffer *batch,struct igt_buf *dst); +gen7_fill_binding_table (struct intel_batchbuffer *batch,struct igt_buf *dst, +int devid); uint32_t gen7_fill_kernel(struct intel_batchbuffer *batch, const uint32_t kernel[][4],
@@ -62,7 +63,7 @@ gen7_fill_kernel(struct intel_batchbuffer *batch, const uint32_t kernel[][4],uint32_t gen7_fill_interface_descriptor (struct intel_batchbuffer *batch,struct igt_buf *dst,const uint32_t kernel[][4 ], -size_t size); +size_t size,int devid);void gen7_emit_state_base_address (struct intel_batchbuffer *batch);
@@ -74,28 +75,26 @@ void gen7_emit_vfe_state_gpgpu(struct intel_batchbuffer *batch);void -gen7_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer); +gen7_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer, +int devid);void gen7_emit_interface_descriptor_load (struct intel_batchbuffer *batch, -uint32_t interface_descriptor); +uint32_t interface_descriptor,int devid);void gen7_emit_media_objects (struct intel_batchbuffer *batch,unsigned int x,unsigned int y, -unsigned int width,unsigned int height); +unsigned int width,unsigned int height,int devid);uint32_t gen8_fill_surface_state (struct intel_batchbuffer *batch,struct igt_buf *buf,uint32_t format,int is_dst); -uint32_t -gen8_fill_binding_table (struct intel_batchbuffer *batch,struct igt_buf *dst); -uint32_t gen8_fill_interface_descriptor (struct intel_batchbuffer *batch,struct igt_buf *dst,const uint32_t kernel[][4 ], -size_t size); +size_t size,int devid);void gen8_emit_state_base_address (struct intel_batchbuffer *batch);
@@ -106,25 +105,9 @@ gen8_emit_vfe_state(struct intel_batchbuffer *batch);void gen8_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch); -void -gen8_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer); - -void -gen8_emit_interface_descriptor_load (struct intel_batchbuffer *batch,uint32_t interface_descriptor); -void gen8_emit_media_state_flush (struct intel_batchbuffer *batch); -void -gen8_emit_media_objects (struct intel_batchbuffer *batch, -unsigned int x,unsigned int y, -unsigned int width,unsigned int height); - -void -gen8lp_emit_media_objects (struct intel_batchbuffer *batch, -unsigned int x,unsigned int y, -unsigned int width,unsigned int height); -void gen9_emit_state_base_address (struct intel_batchbuffer *batch);
lib/intel_batchbuffer.c +1 -3
@@ -796,12 +796,10 @@ igt_fillfunc_t igt_get_media_fillfunc(int devid)if (IS_GEN9 (devid)) fill = gen9_media_fillfunc; -else if (IS_BROADWELL (devid)) +else if (IS_GEN8 (devid)) fill = gen8_media_fillfunc;else if (IS_GEN7 (devid)) fill = gen7_media_fillfunc; -else if (IS_CHERRYVIEW (devid)) - fill = gen8lp_media_fillfunc;return fill; }
lib/intel_batchbuffer.h +2 -1
@@ -304,7 +304,8 @@ typedef void (*igt_fillfunc_t)(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned x, unsigned y, unsigned width, unsigned height, - uint8_t color); + uint8_t color, + int devid);igt_fillfunc_t igt_get_media_fillfunc (int devid);igt_fillfunc_t igt_get_gpgpu_fillfunc (int devid);
lib/media_fill.h +3 -10
@@ -9,27 +9,20 @@ gen7_media_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color); + uint8_t color, int devid);void gen8_media_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst,unsigned int x,unsigned int y,unsigned int width,unsigned int height, -uint8_t color); - -void -gen8lp_media_fillfunc (struct intel_batchbuffer *batch, -struct igt_buf *dst, -unsigned int x,unsigned int y, -unsigned int width,unsigned int height, -uint8_t color); +uint8_t color,int devid);void gen9_media_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst,unsigned int x,unsigned int y,unsigned int width,unsigned int height, -uint8_t color); +uint8_t color,int devid);#endif /* RENDE_MEDIA_FILL_H */
lib/media_fill_gen7.c +6 -5
@@ -49,7 +49,7 @@ gen7_media_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color) + uint8_t color, int devid) { uint32_t curbe_buffer, interface_descriptor;uint32_t batch_end;
@@ -63,7 +63,8 @@ gen7_media_fillfunc(struct intel_batchbuffer *batch, interface_descriptor =gen7_fill_interface_descriptor (batch, dst, media_kernel,sizeof - (media_kernel)); + (media_kernel), + devid);igt_assert (batch->ptr < &batch->buffer[4095 ]);/* media pipeline */
@@ -74,11 +75,11 @@ gen7_media_fillfunc(struct intel_batchbuffer *batch,gen7_emit_vfe_state (batch); -gen7_emit_curbe_load (batch, curbe_buffer); +gen7_emit_curbe_load (batch, curbe_buffer, devid); -gen7_emit_interface_descriptor_load (batch, interface_descriptor); +gen7_emit_interface_descriptor_load (batch, interface_descriptor, devid); -gen7_emit_media_objects (batch, x, y, width, height); +gen7_emit_media_objects (batch, x, y, width, height, devid);OUT_BATCH (MI_BATCH_BUFFER_END );
lib/media_fill_gen8.c +6 -5
@@ -50,7 +50,7 @@ gen8_media_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color) + uint8_t color, int devid) { uint32_t curbe_buffer, interface_descriptor;uint32_t batch_end;
@@ -64,7 +64,8 @@ gen8_media_fillfunc(struct intel_batchbuffer *batch, interface_descriptor =gen8_fill_interface_descriptor (batch, dst, media_kernel,sizeof - (media_kernel)); + (media_kernel), + devid);igt_assert (batch->ptr < &batch->buffer[4095 ]);
@@ -75,11 +76,11 @@ gen8_media_fillfunc(struct intel_batchbuffer *batch,gen8_emit_vfe_state (batch); -gen8_emit_curbe_load (batch, curbe_buffer); +gen7_emit_curbe_load (batch, curbe_buffer, devid); -gen8_emit_interface_descriptor_load (batch, interface_descriptor); +gen7_emit_interface_descriptor_load (batch, interface_descriptor, devid); -gen8_emit_media_objects (batch, x, y, width, height); +gen7_emit_media_objects (batch, x, y, width, height, devid);OUT_BATCH (MI_BATCH_BUFFER_END );
lib/media_fill_gen8lp.c deleted +0 -90
90 lines not on this page · raw message
lib/media_fill_gen9.c +6 -5
@@ -48,7 +48,7 @@ gen9_media_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color) + uint8_t color, int devid) { uint32_t curbe_buffer, interface_descriptor;uint32_t batch_end;
@@ -62,7 +62,8 @@ gen9_media_fillfunc(struct intel_batchbuffer *batch, interface_descriptor =gen8_fill_interface_descriptor (batch, dst, media_kernel,sizeof - (media_kernel)); + (media_kernel), + devid);assert (batch->ptr < &batch->buffer[4095 ]);/* media pipeline */
@@ -77,11 +78,11 @@ gen9_media_fillfunc(struct intel_batchbuffer *batch,gen8_emit_vfe_state (batch); -gen8_emit_curbe_load (batch, curbe_buffer); +gen7_emit_curbe_load (batch, curbe_buffer, devid); -gen8_emit_interface_descriptor_load (batch, interface_descriptor); +gen7_emit_interface_descriptor_load (batch, interface_descriptor, devid); -gen8_emit_media_objects (batch, x, y, width, height); +gen7_emit_media_objects (batch, x, y, width, height, devid); OUT_BATCH(GEN8_PIPELINE_SELECT | PIPELINE_SELECT_MEDIA | GEN9_FORCE_MEDIA_AWAKE_DISABLE |
lib/meson.build +0 -1
@@ -27,7 +27,6 @@ lib_sources = [ 'gpu_fill.c', 'media_fill_gen7.c', 'media_fill_gen8.c', - 'media_fill_gen8lp.c', 'media_fill_gen9.c', 'media_spin.c', 'gpgpu_fill.c',
tests/gem_gpgpu_fill.c +1 -1
@@ -124,7 +124,7 @@ igt_simple_maingpgpu_fill (batch, &dst,0 ,0 ,WIDTH /2 ,HEIGHT /2 , -COLOR_4C ); +COLOR_4C , data.devid);for (i =0 ; i <WIDTH ; i++) {for (j =0 ; j <HEIGHT ; j++) {
tests/gem_media_fill.c +1 -1
@@ -129,7 +129,7 @@ igt_simple_mainmedia_fill (batch, &dst,0 ,0 ,WIDTH /2 ,HEIGHT /2 , -COLOR_4C ); +COLOR_4C , data.devid);for (i =0 ; i <WIDTH ; i++) {for (j =0 ; j <HEIGHT ; j++) {
Signature · 6 lines
2.14.3 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 3/4] lib: Removing duplications in gpu_fill library
Quoted 56 lines · Katarzyna Dec
After moving all functions needed for gpgpu and media fill testing there is a lot of duplications which can be removed:
Librarymedia_fill_gen8lpfor CHT was removed, media state flush
for !CHT was added togen7_emit_media_objects.
Many gen8 functions were replaced with gen7 version with devid
parameter (gen7_fill_curbe_load,gen7_emit_interface_descriptor,gen7_fill_binding_table,gen7_emit_media_objects).
Duplicated constants likeGEN8_MEDIA_VFE_STATE,GEN8_MEDIA_CURBE_LOAD,GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD,GEN8_MEDIA_OBJECTwere replaced by GEN7 version. However this constants were not removed fromgen8_media.hlibrary, because they are used by other tests for Gen8+. More refactoring in this gen*_media.h libraries is needed.It seems that further unification of
*_fillfuncfunctions will introduce more confusion in understanding what the tests are doing and what were changes between Gens.Signed-off-by Katarzyna Dec <[email protected]>Cc Lukasz Kalamarz <[email protected]>Cc Daniele Ceraolo Spurio <[email protected]>--- lib/Makefile.sources | 1 - lib/gpgpu_fill.c | 27 +++++----- lib/gpgpu_fill.h | 6 +-- lib/gpu_fill.c | 135 +++++++++--------------------------------------- lib/gpu_fill.h | 33 +++--------- lib/intel_batchbuffer.c | 4 +- lib/intel_batchbuffer.h | 3 +- lib/media_fill.h | 13 ++--- lib/media_fill_gen7.c | 11 ++-- lib/media_fill_gen8.c | 11 ++-- lib/media_fill_gen8lp.c | 90 -------------------------------- lib/media_fill_gen9.c | 11 ++-- lib/meson.build | 1 - tests/gem_gpgpu_fill.c | 2 +- tests/gem_media_fill.c | 2 +- 15 files changed, 77 insertions(+), 273 deletions(-)delete mode 100644
lib/media_fill_gen8lp.clib/Makefile.sources +0
-1@@ -60,7 +60,6 @@ lib_source_list = \ media_fill.h \ media_fill_gen7.c \ media_fill_gen8.c \ - media_fill_gen8lp.c \ media_fill_gen9.c \ media_spin.h \ media_spin.c \lib/gpgpu_fill.c +0
-0
lib/gpgpu_fill.c gen7_gpgpu_fillfunc(struct intel_batchbuffer *batch, · line 106
Quoted 5 lines
lib/gpgpu_fill.c +1
-1@@ -103,7 +103,7 @@ gen7_gpgpu_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color) + uint8_t color, int devid)
devid is stored in intel_batchbuffer so you don't need to pass it in and can just use batch->devid instead. The same applies for all other functions that have intel_batchbuffer as one of the parameters.
Quoted 125 lines
lib/gpgpu_fill.c +14
-11{uint32_t curbe_buffer, interface_descriptor;uint32_t batch_end;@@ -123,7 +123,8 @@ gen7_gpgpu_fillfunc(struct intel_batchbuffer *batch, interface_descriptor =gen7_fill_interface_descriptor (batch, dst, gen7_gpgpu_kernel, -sizeof (gen7_gpgpu_kernel)); +sizeof (gen7_gpgpu_kernel), + devid);igt_assert (batch->ptr < &batch->buffer[4095 ]); batch->ptr = batch->buffer;@@ -133,8 +134,8 @@ gen7_gpgpu_fillfunc(struct intel_batchbuffer *batch,gen7_emit_state_base_address (batch);gen7_emit_vfe_state_gpgpu (batch); -gen7_emit_curbe_load (batch, curbe_buffer); -gen7_emit_interface_descriptor_load (batch, interface_descriptor); +gen7_emit_curbe_load (batch, curbe_buffer, devid); +gen7_emit_interface_descriptor_load (batch, interface_descriptor, devid);gen7_emit_gpgpu_walk (batch, x, y, width, height);OUT_BATCH (MI_BATCH_BUFFER_END );@@ -151,7 +152,7 @@ gen8_gpgpu_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color) + uint8_t color, int devid) { uint32_t curbe_buffer, interface_descriptor;uint32_t batch_end;@@ -171,7 +172,8 @@ gen8_gpgpu_fillfunc(struct intel_batchbuffer *batch, interface_descriptor =gen8_fill_interface_descriptor (batch, dst, gen8_gpgpu_kernel, -sizeof (gen8_gpgpu_kernel)); +sizeof (gen8_gpgpu_kernel), + devid);igt_assert (batch->ptr < &batch->buffer[4095 ]); batch->ptr = batch->buffer;@@ -181,8 +183,8 @@ gen8_gpgpu_fillfunc(struct intel_batchbuffer *batch,gen8_emit_state_base_address (batch);gen8_emit_vfe_state_gpgpu (batch); -gen7_emit_curbe_load (batch, curbe_buffer); -gen8_emit_interface_descriptor_load (batch, interface_descriptor); +gen7_emit_curbe_load (batch, curbe_buffer, devid); +gen7_emit_interface_descriptor_load (batch, interface_descriptor, devid);gen8_emit_gpgpu_walk (batch, x, y, width, height);OUT_BATCH (MI_BATCH_BUFFER_END );@@ -199,7 +201,7 @@ gen9_gpgpu_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color) + uint8_t color, int devid) { uint32_t curbe_buffer, interface_descriptor;uint32_t batch_end;@@ -219,7 +221,8 @@ gen9_gpgpu_fillfunc(struct intel_batchbuffer *batch, interface_descriptor =gen8_fill_interface_descriptor (batch, dst, gen9_gpgpu_kernel, -sizeof (gen9_gpgpu_kernel)); +sizeof (gen9_gpgpu_kernel), + devid);igt_assert (batch->ptr < &batch->buffer[4095 ]); batch->ptr = batch->buffer;@@ -229,8 +232,8 @@ gen9_gpgpu_fillfunc(struct intel_batchbuffer *batch,gen9_emit_state_base_address (batch);gen8_emit_vfe_state_gpgpu (batch); -gen7_emit_curbe_load (batch, curbe_buffer); -gen7_emit_interface_descriptor_load (batch, interface_descriptor); +gen7_emit_curbe_load (batch, curbe_buffer, devid); +gen7_emit_interface_descriptor_load (batch, interface_descriptor, devid);gen8_emit_gpgpu_walk (batch, x, y, width, height);OUT_BATCH (MI_BATCH_BUFFER_END );lib/gpgpu_fill.h +3
-3@@ -32,20 +32,20 @@ gen7_gpgpu_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color); + uint8_t color, int devid);void gen8_gpgpu_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst,unsigned int x,unsigned int y,unsigned int width,unsigned int height, -uint8_t color); +uint8_t color,int devid);void gen9_gpgpu_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst,unsigned int x,unsigned int y,unsigned int width,unsigned int height, -uint8_t color); +uint8_t color,int devid);#endif /* GPGPU_FILL_H */ lib/gpu_fill.c +1
-0@@ -2,6 +2,7 @@#include <i915_drm.h> #include "intel_reg.h" +#include "intel_chipset.h" #include "drmtest.h" #include "gpu_fill.h" #include <assert.h>
lib/gpu_fill.c gen7_fill_surface_state(struct intel_batchbuffer *batch, struct igt_buf *buf, · line 126
Quoted 7 lines
lib/gpu_fill.c +2
-1@@ -120,15 +121,20 @@ gen7_fill_surface_state(struct intel_batchbuffer *batch, struct igt_buf *buf, }uint32_t -gen7_fill_binding_table (struct intel_batchbuffer *batch,struct igt_buf *dst) +gen7_fill_binding_table (struct intel_batchbuffer *batch,struct igt_buf *dst, +int devid) {
Since this now applies to all gens we can probably drop the gen7_ prefix. The same applies to other functions that are now applicable to all gens. Some of those renamings can probably go in patch 1.
Quoted 71 lines
lib/gpu_fill.c +16
-8uint32_t *binding_table, offset; binding_table =batch_alloc (batch,32 ,64 ); offset =batch_offset (batch, binding_table); - binding_table[0 ] =gen7_fill_surface_state (batch, dst, +if (IS_GEN7 (devid)) + binding_table[0 ] =gen7_fill_surface_state (batch, dst,GEN7_SURFACEFORMAT_R8_UNORM ,1 ); +else + binding_table[0 ] =gen8_fill_surface_state (batch, dst, +GEN8_SURFACEFORMAT_R8_UNORM ,1 );return offset; }@@ -146,14 +152,14 @@ gen7_fill_kernel(struct intel_batchbuffer *batch, const uint32_t kernel[][4],uint32_t gen7_fill_interface_descriptor (struct intel_batchbuffer *batch, -struct igt_buf *dst, -const uint32_t kernel[][4 ],size_t size) +struct igt_buf *dst,const uint32_t kernel[][4 ], +size_t size,int devid) {struct gen7_interface_descriptor_data *idd;uint32_t offset;uint32_t binding_table_offset, kernel_offset; - binding_table_offset =gen7_fill_binding_table (batch, dst); + binding_table_offset =gen7_fill_binding_table (batch, dst, devid); kernel_offset =gen7_fill_kernel (batch, kernel, size); idd =batch_alloc (batch,sizeof (*idd),64 );@@ -256,7 +262,8 @@ gen7_emit_vfe_state_gpgpu(struct intel_batchbuffer *batch) }void -gen7_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer) +gen7_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer, +int devid) {OUT_BATCH (GEN7_MEDIA_CURBE_LOAD | (4 -2 ));OUT_BATCH (0 );@@ -267,12 +274,15 @@ gen7_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t curbe_buffer) }void -gen7_emit_interface_descriptor_load (struct intel_batchbuffer *batch,uint32_t interface_descriptor) +gen7_emit_interface_descriptor_load (struct intel_batchbuffer *batch,uint32_t interface_descriptor,int devid) {OUT_BATCH (GEN7_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 -2 ));OUT_BATCH (0 );/* interface descriptor data length */ -OUT_BATCH (sizeof (struct gen7_interface_descriptor_data )); +if (IS_GEN7 (devid)) +OUT_BATCH (sizeof (struct gen7_interface_descriptor_data )); +else +OUT_BATCH (sizeof (struct gen8_interface_descriptor_data ));/* interface descriptor address, is relative to the dynamics base * address */ @@ -282,7 +292,7 @@ gen7_emit_interface_descriptor_load(struct intel_batchbuffer *batch, uint32_t invoid gen7_emit_media_objects (struct intel_batchbuffer *batch,unsigned int x,unsigned int y, -unsigned int width,unsigned int height) +unsigned int width,unsigned int height,int devid) {int i, j;
lib/gpu_fill.c gen7_emit_media_objects(struct intel_batchbuffer *batch, · line 317
Quoted 4 lines
lib/gpu_fill.c +1
-0@@ -304,6 +314,8 @@ gen7_emit_media_objects(struct intel_batchbuffer *batch,/* inline data (xoffset, yoffset) */ OUT_BATCH (x + i *16 );OUT_BATCH (y + j *16 ); +if (!IS_CHERRYVIEW (devid))
This won't work for gen7, as the below only applies for gen8+ (excluding CHV). you can use something like:
if (AT_LEAST_GEN(devid, 8) && !IS_CHERRYVIEW(devid)).
Daniele
Quoted 543 lines
lib/gpu_fill.c +5
-101+gen8_emit_media_state_flush (batch); } } }@@ -414,30 +426,16 @@ gen8_fill_surface_state(struct intel_batchbuffer *batch, struct igt_buf *buf,return offset; } -uint32_t -gen8_fill_binding_table (struct intel_batchbuffer *batch,struct igt_buf *dst) -{ -uint32_t *binding_table, offset; - - binding_table =batch_alloc (batch,32 ,64 ); - offset =batch_offset (batch, binding_table); - - binding_table[0 ] =gen8_fill_surface_state (batch, dst, -GEN8_SURFACEFORMAT_R8_UNORM ,1 ); - -return offset; -} -uint32_t gen8_fill_interface_descriptor (struct intel_batchbuffer *batch,struct igt_buf *dst,const uint32_t kernel[][4 ], -size_t size) +size_t size,int devid) {struct gen8_interface_descriptor_data *idd;uint32_t offset;uint32_t binding_table_offset, kernel_offset; - binding_table_offset =gen8_fill_binding_table (batch, dst); + binding_table_offset =gen7_fill_binding_table (batch, dst, devid); kernel_offset =gen7_fill_kernel (batch, kernel,sizeof (kernel)); idd =batch_alloc (batch,sizeof (*idd),64 );@@ -501,7 +499,7 @@ gen8_emit_state_base_address(struct intel_batchbuffer *batch)void gen8_emit_vfe_state (struct intel_batchbuffer *batch) { -OUT_BATCH (GEN8_MEDIA_VFE_STATE | (9 -2 )); +OUT_BATCH (GEN7_MEDIA_VFE_STATE | (9 -2 ));/* scratch buffer */ OUT_BATCH (0 );@@ -526,7 +524,7 @@ gen8_emit_vfe_state(struct intel_batchbuffer *batch)void gen8_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch) { -OUT_BATCH (GEN8_MEDIA_VFE_STATE | (9 -2 )); +OUT_BATCH (GEN7_MEDIA_VFE_STATE | (9 -2 ));/* scratch buffer */ OUT_BATCH (0 );@@ -546,31 +544,6 @@ gen8_emit_vfe_state_gpgpu(struct intel_batchbuffer *batch)OUT_BATCH (0 ); } -void -gen8_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer) -{ -OUT_BATCH (GEN8_MEDIA_CURBE_LOAD | (4 -2 )); -OUT_BATCH (0 ); -/* curbe total data length */ -OUT_BATCH (64 ); -/* curbe data start address, is relative to the dynamics base address */ -OUT_BATCH (curbe_buffer); -} - -void -gen8_emit_interface_descriptor_load (struct intel_batchbuffer *batch, -uint32_t interface_descriptor) -{ -OUT_BATCH (GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 -2 )); -OUT_BATCH (0 ); -/* interface descriptor data length */ -OUT_BATCH (sizeof (struct gen8_interface_descriptor_data )); -/* interface descriptor address, is relative to the dynamics base -* address -*/ -OUT_BATCH (interface_descriptor); -} -void gen8_emit_media_state_flush (struct intel_batchbuffer *batch) {@@ -578,64 +551,6 @@ gen8_emit_media_state_flush(struct intel_batchbuffer *batch)OUT_BATCH (0 ); } -void -gen8_emit_media_objects (struct intel_batchbuffer *batch, -unsigned int x,unsigned int y, -unsigned int width,unsigned int height) -{ -int i, j; - -for (i =0 ; i < width /16 ; i++) { -for (j =0 ; j < height /16 ; j++) { -OUT_BATCH (GEN8_MEDIA_OBJECT | (8 -2 )); - -/* interface descriptor offset */ -OUT_BATCH (0 ); - -/* without indirect data */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* scoreboard */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* inline data (xoffset, yoffset) */ -OUT_BATCH (x + i *16 ); -OUT_BATCH (y + j *16 ); -gen8_emit_media_state_flush (batch); - } - } -} - -void -gen8lp_emit_media_objects (struct intel_batchbuffer *batch, -unsigned int x,unsigned int y, -unsigned int width,unsigned int height) -{ -int i, j; - -for (i =0 ; i < width /16 ; i++) { -for (j =0 ; j < height /16 ; j++) { -OUT_BATCH (GEN8_MEDIA_OBJECT | (8 -2 )); - -/* interface descriptor offset */ -OUT_BATCH (0 ); - -/* without indirect data */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* scoreboard */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* inline data (xoffset, yoffset) */ -OUT_BATCH (x + i *16 ); -OUT_BATCH (y + j *16 ); - } - } -} void gen8_emit_gpgpu_walk(struct intel_batchbuffer *batch,lib/gpu_fill.h +8
-25@@ -53,7 +53,8 @@ gen7_fill_surface_state(struct intel_batchbuffer *batch, struct igt_buf *buf, uint32_t format, int is_dst);uint32_t -gen7_fill_binding_table (struct intel_batchbuffer *batch,struct igt_buf *dst); +gen7_fill_binding_table (struct intel_batchbuffer *batch,struct igt_buf *dst, +int devid); uint32_t gen7_fill_kernel(struct intel_batchbuffer *batch, const uint32_t kernel[][4],@@ -62,7 +63,7 @@ gen7_fill_kernel(struct intel_batchbuffer *batch, const uint32_t kernel[][4],uint32_t gen7_fill_interface_descriptor (struct intel_batchbuffer *batch,struct igt_buf *dst,const uint32_t kernel[][4 ], -size_t size); +size_t size,int devid);void gen7_emit_state_base_address (struct intel_batchbuffer *batch);@@ -74,28 +75,26 @@ void gen7_emit_vfe_state_gpgpu(struct intel_batchbuffer *batch);void -gen7_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer); +gen7_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer, +int devid);void gen7_emit_interface_descriptor_load (struct intel_batchbuffer *batch, -uint32_t interface_descriptor); +uint32_t interface_descriptor,int devid);void gen7_emit_media_objects (struct intel_batchbuffer *batch,unsigned int x,unsigned int y, -unsigned int width,unsigned int height); +unsigned int width,unsigned int height,int devid);uint32_t gen8_fill_surface_state (struct intel_batchbuffer *batch,struct igt_buf *buf,uint32_t format,int is_dst); -uint32_t -gen8_fill_binding_table (struct intel_batchbuffer *batch,struct igt_buf *dst); -uint32_t gen8_fill_interface_descriptor (struct intel_batchbuffer *batch,struct igt_buf *dst,const uint32_t kernel[][4 ], -size_t size); +size_t size,int devid);void gen8_emit_state_base_address (struct intel_batchbuffer *batch);@@ -106,25 +105,9 @@ gen8_emit_vfe_state(struct intel_batchbuffer *batch);void gen8_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch); -void -gen8_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer); - -void -gen8_emit_interface_descriptor_load (struct intel_batchbuffer *batch,uint32_t interface_descriptor); -void gen8_emit_media_state_flush (struct intel_batchbuffer *batch); -void -gen8_emit_media_objects (struct intel_batchbuffer *batch, -unsigned int x,unsigned int y, -unsigned int width,unsigned int height); - -void -gen8lp_emit_media_objects (struct intel_batchbuffer *batch, -unsigned int x,unsigned int y, -unsigned int width,unsigned int height); -void gen9_emit_state_base_address (struct intel_batchbuffer *batch);lib/intel_batchbuffer.c +1
-3@@ -796,12 +796,10 @@ igt_fillfunc_t igt_get_media_fillfunc(int devid)if (IS_GEN9 (devid)) fill = gen9_media_fillfunc; -else if (IS_BROADWELL (devid)) +else if (IS_GEN8 (devid)) fill = gen8_media_fillfunc;else if (IS_GEN7 (devid)) fill = gen7_media_fillfunc; -else if (IS_CHERRYVIEW (devid)) - fill = gen8lp_media_fillfunc;return fill; }lib/intel_batchbuffer.h +2
-1@@ -304,7 +304,8 @@ typedef void (*igt_fillfunc_t)(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned x, unsigned y, unsigned width, unsigned height, - uint8_t color); + uint8_t color, + int devid);igt_fillfunc_t igt_get_media_fillfunc (int devid);igt_fillfunc_t igt_get_gpgpu_fillfunc (int devid);lib/media_fill.h +3
-10@@ -9,27 +9,20 @@ gen7_media_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color); + uint8_t color, int devid);void gen8_media_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst,unsigned int x,unsigned int y,unsigned int width,unsigned int height, -uint8_t color); - -void -gen8lp_media_fillfunc (struct intel_batchbuffer *batch, -struct igt_buf *dst, -unsigned int x,unsigned int y, -unsigned int width,unsigned int height, -uint8_t color); +uint8_t color,int devid);void gen9_media_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst,unsigned int x,unsigned int y,unsigned int width,unsigned int height, -uint8_t color); +uint8_t color,int devid);#endif /* RENDE_MEDIA_FILL_H */ lib/media_fill_gen7.c +6
-5@@ -49,7 +49,7 @@ gen7_media_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color) + uint8_t color, int devid) { uint32_t curbe_buffer, interface_descriptor;uint32_t batch_end;@@ -63,7 +63,8 @@ gen7_media_fillfunc(struct intel_batchbuffer *batch, interface_descriptor =gen7_fill_interface_descriptor (batch, dst, media_kernel,sizeof - (media_kernel)); + (media_kernel), + devid);igt_assert (batch->ptr < &batch->buffer[4095 ]);/* media pipeline */ @@ -74,11 +75,11 @@ gen7_media_fillfunc(struct intel_batchbuffer *batch,gen7_emit_vfe_state (batch); -gen7_emit_curbe_load (batch, curbe_buffer); +gen7_emit_curbe_load (batch, curbe_buffer, devid); -gen7_emit_interface_descriptor_load (batch, interface_descriptor); +gen7_emit_interface_descriptor_load (batch, interface_descriptor, devid); -gen7_emit_media_objects (batch, x, y, width, height); +gen7_emit_media_objects (batch, x, y, width, height, devid);OUT_BATCH (MI_BATCH_BUFFER_END );lib/media_fill_gen8.c +6
-5@@ -50,7 +50,7 @@ gen8_media_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color) + uint8_t color, int devid) { uint32_t curbe_buffer, interface_descriptor;uint32_t batch_end;@@ -64,7 +64,8 @@ gen8_media_fillfunc(struct intel_batchbuffer *batch, interface_descriptor =gen8_fill_interface_descriptor (batch, dst, media_kernel,sizeof - (media_kernel)); + (media_kernel), + devid);igt_assert (batch->ptr < &batch->buffer[4095 ]);@@ -75,11 +76,11 @@ gen8_media_fillfunc(struct intel_batchbuffer *batch,gen8_emit_vfe_state (batch); -gen8_emit_curbe_load (batch, curbe_buffer); +gen7_emit_curbe_load (batch, curbe_buffer, devid); -gen8_emit_interface_descriptor_load (batch, interface_descriptor); +gen7_emit_interface_descriptor_load (batch, interface_descriptor, devid); -gen8_emit_media_objects (batch, x, y, width, height); +gen7_emit_media_objects (batch, x, y, width, height, devid);OUT_BATCH (MI_BATCH_BUFFER_END );lib/media_fill_gen8lp.c deleted +0
-90@@ -1,90 +0,0 @@ -#include <intel_bufmgr.h> -#include <i915_drm.h> - -#include "media_fill.h" -#include "gen8_media.h" -#include "intel_reg.h" -#include "drmtest.h" -#include "gpu_fill.h" -#include <assert.h> - - -static const uint32_t media_kernel[][4 ] = { - {0x00400001 ,0x20202288 ,0x00000020 ,0x00000000 }, - {0x00600001 ,0x20800208 ,0x008d0000 ,0x00000000 }, - {0x00200001 ,0x20800208 ,0x00450040 ,0x00000000 }, - {0x00000001 ,0x20880608 ,0x00000000 ,0x000f000f }, - {0x00800001 ,0x20a00208 ,0x00000020 ,0x00000000 }, - {0x00800001 ,0x20e00208 ,0x00000020 ,0x00000000 }, - {0x00800001 ,0x21200208 ,0x00000020 ,0x00000000 }, - {0x00800001 ,0x21600208 ,0x00000020 ,0x00000000 }, - {0x0c800031 ,0x24000a40 ,0x0e000080 ,0x120a8000 }, - {0x00600001 ,0x2e000208 ,0x008d0000 ,0x00000000 }, - {0x07800031 ,0x20000a40 ,0x0e000e00 ,0x82000010 }, -}; - -/* -* This sets up the media pipeline, -* -* +---------------+ <---- 4096 -* | ^ | -* | | | -* | various | -* | state | -* | | | -* |_______|_______| <---- 2048 + ? -* | ^ | -* | | | -* | batch | -* | commands | -* | | | -* | | | -* +---------------+ <---- 0 + ? -* -*/ - -#define BATCH_STATE_SPLIT 2048 - -void -gen8lp_media_fillfunc (struct intel_batchbuffer *batch, -struct igt_buf *dst, -unsigned int x,unsigned int y, -unsigned int width,unsigned int height, -uint8_t color) -{ -uint32_t curbe_buffer, interface_descriptor; -uint32_t batch_end; - -intel_batchbuffer_flush (batch); - -/* setup states */ - batch->ptr = &batch->buffer[BATCH_STATE_SPLIT ]; - - curbe_buffer =gen7_fill_curbe_buffer_data (batch, color); - interface_descriptor =gen8_fill_interface_descriptor (batch, dst, - media_kernel, -sizeof - (media_kernel)); -igt_assert (batch->ptr < &batch->buffer[4095 ]); - -/* media pipeline */ - batch->ptr = batch->buffer; -OUT_BATCH (GEN8_PIPELINE_SELECT |PIPELINE_SELECT_MEDIA ); -gen8_emit_state_base_address (batch); - -gen8_emit_vfe_state (batch); - -gen8_emit_curbe_load (batch, curbe_buffer); - -gen8_emit_interface_descriptor_load (batch, interface_descriptor); - -gen8lp_emit_media_objects (batch, x, y, width, height); - -OUT_BATCH (MI_BATCH_BUFFER_END ); - - batch_end =batch_align (batch,8 ); -igt_assert (batch_end <BATCH_STATE_SPLIT ); - -gen7_render_flush (batch, batch_end); -intel_batchbuffer_reset (batch); -}lib/media_fill_gen9.c +6
-5@@ -48,7 +48,7 @@ gen9_media_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color) + uint8_t color, int devid) { uint32_t curbe_buffer, interface_descriptor;uint32_t batch_end;@@ -62,7 +62,8 @@ gen9_media_fillfunc(struct intel_batchbuffer *batch, interface_descriptor =gen8_fill_interface_descriptor (batch, dst, media_kernel,sizeof - (media_kernel)); + (media_kernel), + devid);assert (batch->ptr < &batch->buffer[4095 ]);/* media pipeline */ @@ -77,11 +78,11 @@ gen9_media_fillfunc(struct intel_batchbuffer *batch,gen8_emit_vfe_state (batch); -gen8_emit_curbe_load (batch, curbe_buffer); +gen7_emit_curbe_load (batch, curbe_buffer, devid); -gen8_emit_interface_descriptor_load (batch, interface_descriptor); +gen7_emit_interface_descriptor_load (batch, interface_descriptor, devid); -gen8_emit_media_objects (batch, x, y, width, height); +gen7_emit_media_objects (batch, x, y, width, height, devid); OUT_BATCH(GEN8_PIPELINE_SELECT | PIPELINE_SELECT_MEDIA | GEN9_FORCE_MEDIA_AWAKE_DISABLE |lib/meson.build +0
-1@@ -27,7 +27,6 @@ lib_sources = [ 'gpu_fill.c', 'media_fill_gen7.c', 'media_fill_gen8.c', - 'media_fill_gen8lp.c', 'media_fill_gen9.c', 'media_spin.c', 'gpgpu_fill.c',tests/gem_gpgpu_fill.c +1
-1@@ -124,7 +124,7 @@ igt_simple_maingpgpu_fill (batch, &dst,0 ,0 ,WIDTH /2 ,HEIGHT /2 , -COLOR_4C ); +COLOR_4C , data.devid);for (i =0 ; i <WIDTH ; i++) {for (j =0 ; j <HEIGHT ; j++) {tests/gem_media_fill.c +0
-0
tests/gem_media_fill.c igt_simple_main · line 135
Quoted 8 lines
tests/gem_media_fill.c +1
-1@@ -129,7 +129,7 @@ igt_simple_mainmedia_fill (batch, &dst,0 ,0 ,WIDTH /2 ,HEIGHT /2 , -COLOR_4C ); +COLOR_4C , data.devid);for (i =0 ; i <WIDTH ; i++) {for (j =0 ; j <HEIGHT ; j++) {
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 3/4] lib: Removing duplications in gpu_fill library
Quoted 60 lines · Daniele Ceraolo Spurio
Quoted 57 lines · Katarzyna Dec
After moving all functions needed for gpgpu and media fill testing there is a lot of duplications which can be removed:
Librarymedia_fill_gen8lpfor CHT was removed, media state flush
for !CHT was added togen7_emit_media_objects.
Many gen8 functions were replaced with gen7 version with devid
parameter (gen7_fill_curbe_load,gen7_emit_interface_descriptor,gen7_fill_binding_table,gen7_emit_media_objects).
Duplicated constants likeGEN8_MEDIA_VFE_STATE,GEN8_MEDIA_CURBE_LOAD,GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD,GEN8_MEDIA_OBJECTwere replaced by GEN7 version. However this constants were not removed fromgen8_media.hlibrary, because they are used by other tests for Gen8+. More refactoring in this gen*_media.h libraries is needed.It seems that further unification of
*_fillfuncfunctions will introduce more confusion in understanding what the tests are doing and what were changes between Gens.Signed-off-by Katarzyna Dec <[email protected]>Cc Lukasz Kalamarz <[email protected]>Cc Daniele Ceraolo Spurio <[email protected]>--- lib/Makefile.sources | 1 - lib/gpgpu_fill.c | 27 +++++----- lib/gpgpu_fill.h | 6 +-- lib/gpu_fill.c | 135 +++++++++--------------------------------------- lib/gpu_fill.h | 33 +++--------- lib/intel_batchbuffer.c | 4 +- lib/intel_batchbuffer.h | 3 +- lib/media_fill.h | 13 ++--- lib/media_fill_gen7.c | 11 ++-- lib/media_fill_gen8.c | 11 ++-- lib/media_fill_gen8lp.c | 90 -------------------------------- lib/media_fill_gen9.c | 11 ++-- lib/meson.build | 1 - tests/gem_gpgpu_fill.c | 2 +- tests/gem_media_fill.c | 2 +- 15 files changed, 77 insertions(+), 273 deletions(-)delete mode 100644
lib/media_fill_gen8lp.clib/Makefile.sources +0
-1@@ -60,7 +60,6 @@ lib_source_list = \ media_fill.h \ media_fill_gen7.c \ media_fill_gen8.c \ - media_fill_gen8lp.c \ media_fill_gen9.c \ media_spin.h \ media_spin.c \lib/gpgpu_fill.c +0
-0@@ -103,7 +103,7 @@ gen7_gpgpu_fillfunc(struct intel_batchbuffer *batch, struct igt_buf *dst,
Quoted 9 lines
lib/gpgpu_fill.c gen7_gpgpu_fillfunc(struct intel_batchbuffer *batch, · line 106
Quoted 4 lines
lib/gpgpu_fill.c +1
-1unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color) + uint8_t color, int devid)devid is stored in
intel_batchbufferso you don't need to pass it in and can just usebatch->devidinstead. The same applies for all other functions that haveintel_batchbufferas one of the parameters.
Sorry, I've missed that, I will for sure fix it.
Quoted 111 lines
Quoted 111 lines
lib/gpgpu_fill.c +14
-11{uint32_t curbe_buffer, interface_descriptor;uint32_t batch_end;@@ -123,7 +123,8 @@ gen7_gpgpu_fillfunc(struct intel_batchbuffer *batch, interface_descriptor =gen7_fill_interface_descriptor (batch, dst, gen7_gpgpu_kernel, -sizeof (gen7_gpgpu_kernel)); +sizeof (gen7_gpgpu_kernel), + devid);igt_assert (batch->ptr < &batch->buffer[4095 ]); batch->ptr = batch->buffer;@@ -133,8 +134,8 @@ gen7_gpgpu_fillfunc(struct intel_batchbuffer *batch,gen7_emit_state_base_address (batch);gen7_emit_vfe_state_gpgpu (batch); -gen7_emit_curbe_load (batch, curbe_buffer); -gen7_emit_interface_descriptor_load (batch, interface_descriptor); +gen7_emit_curbe_load (batch, curbe_buffer, devid); +gen7_emit_interface_descriptor_load (batch, interface_descriptor, devid);gen7_emit_gpgpu_walk (batch, x, y, width, height);OUT_BATCH (MI_BATCH_BUFFER_END );@@ -151,7 +152,7 @@ gen8_gpgpu_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color) + uint8_t color, int devid) { uint32_t curbe_buffer, interface_descriptor;uint32_t batch_end;@@ -171,7 +172,8 @@ gen8_gpgpu_fillfunc(struct intel_batchbuffer *batch, interface_descriptor =gen8_fill_interface_descriptor (batch, dst, gen8_gpgpu_kernel, -sizeof (gen8_gpgpu_kernel)); +sizeof (gen8_gpgpu_kernel), + devid);igt_assert (batch->ptr < &batch->buffer[4095 ]); batch->ptr = batch->buffer;@@ -181,8 +183,8 @@ gen8_gpgpu_fillfunc(struct intel_batchbuffer *batch,gen8_emit_state_base_address (batch);gen8_emit_vfe_state_gpgpu (batch); -gen7_emit_curbe_load (batch, curbe_buffer); -gen8_emit_interface_descriptor_load (batch, interface_descriptor); +gen7_emit_curbe_load (batch, curbe_buffer, devid); +gen7_emit_interface_descriptor_load (batch, interface_descriptor, devid);gen8_emit_gpgpu_walk (batch, x, y, width, height);OUT_BATCH (MI_BATCH_BUFFER_END );@@ -199,7 +201,7 @@ gen9_gpgpu_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color) + uint8_t color, int devid) { uint32_t curbe_buffer, interface_descriptor;uint32_t batch_end;@@ -219,7 +221,8 @@ gen9_gpgpu_fillfunc(struct intel_batchbuffer *batch, interface_descriptor =gen8_fill_interface_descriptor (batch, dst, gen9_gpgpu_kernel, -sizeof (gen9_gpgpu_kernel)); +sizeof (gen9_gpgpu_kernel), + devid);igt_assert (batch->ptr < &batch->buffer[4095 ]); batch->ptr = batch->buffer;@@ -229,8 +232,8 @@ gen9_gpgpu_fillfunc(struct intel_batchbuffer *batch,gen9_emit_state_base_address (batch);gen8_emit_vfe_state_gpgpu (batch); -gen7_emit_curbe_load (batch, curbe_buffer); -gen7_emit_interface_descriptor_load (batch, interface_descriptor); +gen7_emit_curbe_load (batch, curbe_buffer, devid); +gen7_emit_interface_descriptor_load (batch, interface_descriptor, devid);gen8_emit_gpgpu_walk (batch, x, y, width, height);OUT_BATCH (MI_BATCH_BUFFER_END );lib/gpgpu_fill.h +3
-3@@ -32,20 +32,20 @@ gen7_gpgpu_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color); + uint8_t color, int devid);void gen8_gpgpu_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst,unsigned int x,unsigned int y,unsigned int width,unsigned int height, -uint8_t color); +uint8_t color,int devid);void gen9_gpgpu_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst,unsigned int x,unsigned int y,unsigned int width,unsigned int height, -uint8_t color); +uint8_t color,int devid);#endif /* GPGPU_FILL_H */ lib/gpu_fill.c +1
-0@@ -2,6 +2,7 @@#include <i915_drm.h> #include "intel_reg.h" +#include "intel_chipset.h" #include "drmtest.h" #include "gpu_fill.h" #include <assert.h> @@ -120,15 +121,20 @@ gen7_fill_surface_state(struct intel_batchbuffer *batch, struct igt_buf *buf, }uint32_t
Quoted 9 lines
lib/gpu_fill.c gen7_fill_surface_state(struct intel_batchbuffer *batch, struct igt_buf *buf, · line 126
Quoted 4 lines
lib/gpu_fill.c +2
-1-gen7_fill_binding_table(struct intel_batchbuffer *batch, struct igt_buf *dst) +gen7_fill_binding_table(struct intel_batchbuffer *batch, struct igt_buf *dst, + int devid) {Since this now applies to all gens we can probably drop the
gen7_prefix. The same applies to other functions that are now applicable to all gens. Some of those renamings can probably go in patch 1.
I was wondering if we should change that and I think that removing gen7 prefix would affect test understanding. Now, if you look at main fill function, you can easily see what is 'a base' for media/gpgpu pipeline and what was changes in other gens. This is my point of view. If there will be a demand for change, I will do it.
Quoted 70 lines
Quoted 62 lines
lib/gpu_fill.c +16
-8uint32_t *binding_table, offset; binding_table =batch_alloc (batch,32 ,64 ); offset =batch_offset (batch, binding_table); - binding_table[0 ] =gen7_fill_surface_state (batch, dst, +if (IS_GEN7 (devid)) + binding_table[0 ] =gen7_fill_surface_state (batch, dst,GEN7_SURFACEFORMAT_R8_UNORM ,1 ); +else + binding_table[0 ] =gen8_fill_surface_state (batch, dst, +GEN8_SURFACEFORMAT_R8_UNORM ,1 );return offset; }@@ -146,14 +152,14 @@ gen7_fill_kernel(struct intel_batchbuffer *batch, const uint32_t kernel[][4],uint32_t gen7_fill_interface_descriptor (struct intel_batchbuffer *batch, -struct igt_buf *dst, -const uint32_t kernel[][4 ],size_t size) +struct igt_buf *dst,const uint32_t kernel[][4 ], +size_t size,int devid) {struct gen7_interface_descriptor_data *idd;uint32_t offset;uint32_t binding_table_offset, kernel_offset; - binding_table_offset =gen7_fill_binding_table (batch, dst); + binding_table_offset =gen7_fill_binding_table (batch, dst, devid); kernel_offset =gen7_fill_kernel (batch, kernel, size); idd =batch_alloc (batch,sizeof (*idd),64 );@@ -256,7 +262,8 @@ gen7_emit_vfe_state_gpgpu(struct intel_batchbuffer *batch) }void -gen7_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer) +gen7_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer, +int devid) {OUT_BATCH (GEN7_MEDIA_CURBE_LOAD | (4 -2 ));OUT_BATCH (0 );@@ -267,12 +274,15 @@ gen7_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t curbe_buffer) }void -gen7_emit_interface_descriptor_load (struct intel_batchbuffer *batch,uint32_t interface_descriptor) +gen7_emit_interface_descriptor_load (struct intel_batchbuffer *batch,uint32_t interface_descriptor,int devid) {OUT_BATCH (GEN7_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 -2 ));OUT_BATCH (0 );/* interface descriptor data length */ -OUT_BATCH (sizeof (struct gen7_interface_descriptor_data )); +if (IS_GEN7 (devid)) +OUT_BATCH (sizeof (struct gen7_interface_descriptor_data )); +else +OUT_BATCH (sizeof (struct gen8_interface_descriptor_data ));/* interface descriptor address, is relative to the dynamics base * address */ @@ -282,7 +292,7 @@ gen7_emit_interface_descriptor_load(struct intel_batchbuffer *batch, uint32_t invoid gen7_emit_media_objects (struct intel_batchbuffer *batch,unsigned int x,unsigned int y, -unsigned int width,unsigned int height) +unsigned int width,unsigned int height,int devid) {int i, j;lib/gpu_fill.c gen7_emit_media_objects(struct intel_batchbuffer *batch, · line 317
Quoted 4 lines
lib/gpu_fill.c +1
-0@@ -304,6 +314,8 @@ gen7_emit_media_objects(struct intel_batchbuffer *batch,/* inline data (xoffset, yoffset) */ OUT_BATCH (x + i *16 );OUT_BATCH (y + j *16 ); +if (!IS_CHERRYVIEW (devid))This won't work for gen7, as the below only applies for gen8+ (excluding CHV). you can use something like:
Quoted 3 lines
if (AT_LEAST_GEN(devid, 8) && !IS_CHERRYVIEW(devid)).Daniele
I will definitely change that this way.
I also need to look at APL becasue this tests are failing there.
Thanks for the review Daniele!
Kasia :)
Quoted 493 lines
Quoted 493 lines
lib/gpu_fill.c +5
-101+gen8_emit_media_state_flush (batch); } } }@@ -414,30 +426,16 @@ gen8_fill_surface_state(struct intel_batchbuffer *batch, struct igt_buf *buf,return offset; } -uint32_t -gen8_fill_binding_table (struct intel_batchbuffer *batch,struct igt_buf *dst) -{ -uint32_t *binding_table, offset; - - binding_table =batch_alloc (batch,32 ,64 ); - offset =batch_offset (batch, binding_table); - - binding_table[0 ] =gen8_fill_surface_state (batch, dst, -GEN8_SURFACEFORMAT_R8_UNORM ,1 ); - -return offset; -} -uint32_t gen8_fill_interface_descriptor (struct intel_batchbuffer *batch,struct igt_buf *dst,const uint32_t kernel[][4 ], -size_t size) +size_t size,int devid) {struct gen8_interface_descriptor_data *idd;uint32_t offset;uint32_t binding_table_offset, kernel_offset; - binding_table_offset =gen8_fill_binding_table (batch, dst); + binding_table_offset =gen7_fill_binding_table (batch, dst, devid); kernel_offset =gen7_fill_kernel (batch, kernel,sizeof (kernel)); idd =batch_alloc (batch,sizeof (*idd),64 );@@ -501,7 +499,7 @@ gen8_emit_state_base_address(struct intel_batchbuffer *batch)void gen8_emit_vfe_state (struct intel_batchbuffer *batch) { -OUT_BATCH (GEN8_MEDIA_VFE_STATE | (9 -2 )); +OUT_BATCH (GEN7_MEDIA_VFE_STATE | (9 -2 ));/* scratch buffer */ OUT_BATCH (0 );@@ -526,7 +524,7 @@ gen8_emit_vfe_state(struct intel_batchbuffer *batch)void gen8_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch) { -OUT_BATCH (GEN8_MEDIA_VFE_STATE | (9 -2 )); +OUT_BATCH (GEN7_MEDIA_VFE_STATE | (9 -2 ));/* scratch buffer */ OUT_BATCH (0 );@@ -546,31 +544,6 @@ gen8_emit_vfe_state_gpgpu(struct intel_batchbuffer *batch)OUT_BATCH (0 ); } -void -gen8_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer) -{ -OUT_BATCH (GEN8_MEDIA_CURBE_LOAD | (4 -2 )); -OUT_BATCH (0 ); -/* curbe total data length */ -OUT_BATCH (64 ); -/* curbe data start address, is relative to the dynamics base address */ -OUT_BATCH (curbe_buffer); -} - -void -gen8_emit_interface_descriptor_load (struct intel_batchbuffer *batch, -uint32_t interface_descriptor) -{ -OUT_BATCH (GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 -2 )); -OUT_BATCH (0 ); -/* interface descriptor data length */ -OUT_BATCH (sizeof (struct gen8_interface_descriptor_data )); -/* interface descriptor address, is relative to the dynamics base -* address -*/ -OUT_BATCH (interface_descriptor); -} -void gen8_emit_media_state_flush (struct intel_batchbuffer *batch) {@@ -578,64 +551,6 @@ gen8_emit_media_state_flush(struct intel_batchbuffer *batch)OUT_BATCH (0 ); } -void -gen8_emit_media_objects (struct intel_batchbuffer *batch, -unsigned int x,unsigned int y, -unsigned int width,unsigned int height) -{ -int i, j; - -for (i =0 ; i < width /16 ; i++) { -for (j =0 ; j < height /16 ; j++) { -OUT_BATCH (GEN8_MEDIA_OBJECT | (8 -2 )); - -/* interface descriptor offset */ -OUT_BATCH (0 ); - -/* without indirect data */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* scoreboard */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* inline data (xoffset, yoffset) */ -OUT_BATCH (x + i *16 ); -OUT_BATCH (y + j *16 ); -gen8_emit_media_state_flush (batch); - } - } -} - -void -gen8lp_emit_media_objects (struct intel_batchbuffer *batch, -unsigned int x,unsigned int y, -unsigned int width,unsigned int height) -{ -int i, j; - -for (i =0 ; i < width /16 ; i++) { -for (j =0 ; j < height /16 ; j++) { -OUT_BATCH (GEN8_MEDIA_OBJECT | (8 -2 )); - -/* interface descriptor offset */ -OUT_BATCH (0 ); - -/* without indirect data */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* scoreboard */ -OUT_BATCH (0 ); -OUT_BATCH (0 ); - -/* inline data (xoffset, yoffset) */ -OUT_BATCH (x + i *16 ); -OUT_BATCH (y + j *16 ); - } - } -} void gen8_emit_gpgpu_walk(struct intel_batchbuffer *batch,lib/gpu_fill.h +8
-25@@ -53,7 +53,8 @@ gen7_fill_surface_state(struct intel_batchbuffer *batch, struct igt_buf *buf, uint32_t format, int is_dst);uint32_t -gen7_fill_binding_table (struct intel_batchbuffer *batch,struct igt_buf *dst); +gen7_fill_binding_table (struct intel_batchbuffer *batch,struct igt_buf *dst, +int devid); uint32_t gen7_fill_kernel(struct intel_batchbuffer *batch, const uint32_t kernel[][4],@@ -62,7 +63,7 @@ gen7_fill_kernel(struct intel_batchbuffer *batch, const uint32_t kernel[][4],uint32_t gen7_fill_interface_descriptor (struct intel_batchbuffer *batch,struct igt_buf *dst,const uint32_t kernel[][4 ], -size_t size); +size_t size,int devid);void gen7_emit_state_base_address (struct intel_batchbuffer *batch);@@ -74,28 +75,26 @@ void gen7_emit_vfe_state_gpgpu(struct intel_batchbuffer *batch);void -gen7_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer); +gen7_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer, +int devid);void gen7_emit_interface_descriptor_load (struct intel_batchbuffer *batch, -uint32_t interface_descriptor); +uint32_t interface_descriptor,int devid);void gen7_emit_media_objects (struct intel_batchbuffer *batch,unsigned int x,unsigned int y, -unsigned int width,unsigned int height); +unsigned int width,unsigned int height,int devid);uint32_t gen8_fill_surface_state (struct intel_batchbuffer *batch,struct igt_buf *buf,uint32_t format,int is_dst); -uint32_t -gen8_fill_binding_table (struct intel_batchbuffer *batch,struct igt_buf *dst); -uint32_t gen8_fill_interface_descriptor (struct intel_batchbuffer *batch,struct igt_buf *dst,const uint32_t kernel[][4 ], -size_t size); +size_t size,int devid);void gen8_emit_state_base_address (struct intel_batchbuffer *batch);@@ -106,25 +105,9 @@ gen8_emit_vfe_state(struct intel_batchbuffer *batch);void gen8_emit_vfe_state_gpgpu (struct intel_batchbuffer *batch); -void -gen8_emit_curbe_load (struct intel_batchbuffer *batch,uint32_t curbe_buffer); - -void -gen8_emit_interface_descriptor_load (struct intel_batchbuffer *batch,uint32_t interface_descriptor); -void gen8_emit_media_state_flush (struct intel_batchbuffer *batch); -void -gen8_emit_media_objects (struct intel_batchbuffer *batch, -unsigned int x,unsigned int y, -unsigned int width,unsigned int height); - -void -gen8lp_emit_media_objects (struct intel_batchbuffer *batch, -unsigned int x,unsigned int y, -unsigned int width,unsigned int height); -void gen9_emit_state_base_address (struct intel_batchbuffer *batch);lib/intel_batchbuffer.c +1
-3@@ -796,12 +796,10 @@ igt_fillfunc_t igt_get_media_fillfunc(int devid)if (IS_GEN9 (devid)) fill = gen9_media_fillfunc; -else if (IS_BROADWELL (devid)) +else if (IS_GEN8 (devid)) fill = gen8_media_fillfunc;else if (IS_GEN7 (devid)) fill = gen7_media_fillfunc; -else if (IS_CHERRYVIEW (devid)) - fill = gen8lp_media_fillfunc;return fill; }lib/intel_batchbuffer.h +2
-1@@ -304,7 +304,8 @@ typedef void (*igt_fillfunc_t)(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned x, unsigned y, unsigned width, unsigned height, - uint8_t color); + uint8_t color, + int devid);igt_fillfunc_t igt_get_media_fillfunc (int devid);igt_fillfunc_t igt_get_gpgpu_fillfunc (int devid);lib/media_fill.h +3
-10@@ -9,27 +9,20 @@ gen7_media_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color); + uint8_t color, int devid);void gen8_media_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst,unsigned int x,unsigned int y,unsigned int width,unsigned int height, -uint8_t color); - -void -gen8lp_media_fillfunc (struct intel_batchbuffer *batch, -struct igt_buf *dst, -unsigned int x,unsigned int y, -unsigned int width,unsigned int height, -uint8_t color); +uint8_t color,int devid);void gen9_media_fillfunc (struct intel_batchbuffer *batch,struct igt_buf *dst,unsigned int x,unsigned int y,unsigned int width,unsigned int height, -uint8_t color); +uint8_t color,int devid);#endif /* RENDE_MEDIA_FILL_H */ lib/media_fill_gen7.c +6
-5@@ -49,7 +49,7 @@ gen7_media_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color) + uint8_t color, int devid) { uint32_t curbe_buffer, interface_descriptor;uint32_t batch_end;@@ -63,7 +63,8 @@ gen7_media_fillfunc(struct intel_batchbuffer *batch, interface_descriptor =gen7_fill_interface_descriptor (batch, dst, media_kernel,sizeof - (media_kernel)); + (media_kernel), + devid);igt_assert (batch->ptr < &batch->buffer[4095 ]);/* media pipeline */ @@ -74,11 +75,11 @@ gen7_media_fillfunc(struct intel_batchbuffer *batch,gen7_emit_vfe_state (batch); -gen7_emit_curbe_load (batch, curbe_buffer); +gen7_emit_curbe_load (batch, curbe_buffer, devid); -gen7_emit_interface_descriptor_load (batch, interface_descriptor); +gen7_emit_interface_descriptor_load (batch, interface_descriptor, devid); -gen7_emit_media_objects (batch, x, y, width, height); +gen7_emit_media_objects (batch, x, y, width, height, devid);OUT_BATCH (MI_BATCH_BUFFER_END );lib/media_fill_gen8.c +6
-5@@ -50,7 +50,7 @@ gen8_media_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color) + uint8_t color, int devid) { uint32_t curbe_buffer, interface_descriptor;uint32_t batch_end;@@ -64,7 +64,8 @@ gen8_media_fillfunc(struct intel_batchbuffer *batch, interface_descriptor =gen8_fill_interface_descriptor (batch, dst, media_kernel,sizeof - (media_kernel)); + (media_kernel), + devid);igt_assert (batch->ptr < &batch->buffer[4095 ]);@@ -75,11 +76,11 @@ gen8_media_fillfunc(struct intel_batchbuffer *batch,gen8_emit_vfe_state (batch); -gen8_emit_curbe_load (batch, curbe_buffer); +gen7_emit_curbe_load (batch, curbe_buffer, devid); -gen8_emit_interface_descriptor_load (batch, interface_descriptor); +gen7_emit_interface_descriptor_load (batch, interface_descriptor, devid); -gen8_emit_media_objects (batch, x, y, width, height); +gen7_emit_media_objects (batch, x, y, width, height, devid);OUT_BATCH (MI_BATCH_BUFFER_END );lib/media_fill_gen8lp.c deleted +0
-90@@ -1,90 +0,0 @@ -#include <intel_bufmgr.h> -#include <i915_drm.h> - -#include "media_fill.h" -#include "gen8_media.h" -#include "intel_reg.h" -#include "drmtest.h" -#include "gpu_fill.h" -#include <assert.h> - - -static const uint32_t media_kernel[][4 ] = { - {0x00400001 ,0x20202288 ,0x00000020 ,0x00000000 }, - {0x00600001 ,0x20800208 ,0x008d0000 ,0x00000000 }, - {0x00200001 ,0x20800208 ,0x00450040 ,0x00000000 }, - {0x00000001 ,0x20880608 ,0x00000000 ,0x000f000f }, - {0x00800001 ,0x20a00208 ,0x00000020 ,0x00000000 }, - {0x00800001 ,0x20e00208 ,0x00000020 ,0x00000000 }, - {0x00800001 ,0x21200208 ,0x00000020 ,0x00000000 }, - {0x00800001 ,0x21600208 ,0x00000020 ,0x00000000 }, - {0x0c800031 ,0x24000a40 ,0x0e000080 ,0x120a8000 }, - {0x00600001 ,0x2e000208 ,0x008d0000 ,0x00000000 }, - {0x07800031 ,0x20000a40 ,0x0e000e00 ,0x82000010 }, -}; - -/* -* This sets up the media pipeline, -* -* +---------------+ <---- 4096 -* | ^ | -* | | | -* | various | -* | state | -* | | | -* |_______|_______| <---- 2048 + ? -* | ^ | -* | | | -* | batch | -* | commands | -* | | | -* | | | -* +---------------+ <---- 0 + ? -* -*/ - -#define BATCH_STATE_SPLIT 2048 - -void -gen8lp_media_fillfunc (struct intel_batchbuffer *batch, -struct igt_buf *dst, -unsigned int x,unsigned int y, -unsigned int width,unsigned int height, -uint8_t color) -{ -uint32_t curbe_buffer, interface_descriptor; -uint32_t batch_end; - -intel_batchbuffer_flush (batch); - -/* setup states */ - batch->ptr = &batch->buffer[BATCH_STATE_SPLIT ]; - - curbe_buffer =gen7_fill_curbe_buffer_data (batch, color); - interface_descriptor =gen8_fill_interface_descriptor (batch, dst, - media_kernel, -sizeof - (media_kernel)); -igt_assert (batch->ptr < &batch->buffer[4095 ]); - -/* media pipeline */ - batch->ptr = batch->buffer; -OUT_BATCH (GEN8_PIPELINE_SELECT |PIPELINE_SELECT_MEDIA ); -gen8_emit_state_base_address (batch); - -gen8_emit_vfe_state (batch); - -gen8_emit_curbe_load (batch, curbe_buffer); - -gen8_emit_interface_descriptor_load (batch, interface_descriptor); - -gen8lp_emit_media_objects (batch, x, y, width, height); - -OUT_BATCH (MI_BATCH_BUFFER_END ); - - batch_end =batch_align (batch,8 ); -igt_assert (batch_end <BATCH_STATE_SPLIT ); - -gen7_render_flush (batch, batch_end); -intel_batchbuffer_reset (batch); -}lib/media_fill_gen9.c +6
-5@@ -48,7 +48,7 @@ gen9_media_fillfunc(struct intel_batchbuffer *batch,struct igt_buf *dst, unsigned int x, unsigned int y, unsigned int width, unsigned int height, - uint8_t color) + uint8_t color, int devid) { uint32_t curbe_buffer, interface_descriptor;uint32_t batch_end;@@ -62,7 +62,8 @@ gen9_media_fillfunc(struct intel_batchbuffer *batch, interface_descriptor =gen8_fill_interface_descriptor (batch, dst, media_kernel,sizeof - (media_kernel)); + (media_kernel), + devid);assert (batch->ptr < &batch->buffer[4095 ]);/* media pipeline */ @@ -77,11 +78,11 @@ gen9_media_fillfunc(struct intel_batchbuffer *batch,gen8_emit_vfe_state (batch); -gen8_emit_curbe_load (batch, curbe_buffer); +gen7_emit_curbe_load (batch, curbe_buffer, devid); -gen8_emit_interface_descriptor_load (batch, interface_descriptor); +gen7_emit_interface_descriptor_load (batch, interface_descriptor, devid); -gen8_emit_media_objects (batch, x, y, width, height); +gen7_emit_media_objects (batch, x, y, width, height, devid); OUT_BATCH(GEN8_PIPELINE_SELECT | PIPELINE_SELECT_MEDIA | GEN9_FORCE_MEDIA_AWAKE_DISABLE |lib/meson.build +0
-1@@ -27,7 +27,6 @@ lib_sources = [ 'gpu_fill.c', 'media_fill_gen7.c', 'media_fill_gen8.c', - 'media_fill_gen8lp.c', 'media_fill_gen9.c', 'media_spin.c', 'gpgpu_fill.c',tests/gem_gpgpu_fill.c +1
-1@@ -124,7 +124,7 @@ igt_simple_maingpgpu_fill (batch, &dst,0 ,0 ,WIDTH /2 ,HEIGHT /2 , -COLOR_4C ); +COLOR_4C , data.devid);for (i =0 ; i <WIDTH ; i++) {for (j =0 ; j <HEIGHT ; j++) {tests/gem_media_fill.c +0
-0
Quoted 8 lines
tests/gem_media_fill.c igt_simple_main · line 134
Quoted 8 lines
tests/gem_media_fill.c +1
-1@@ -129,7 +129,7 @@ igt_simple_mainmedia_fill (batch, &dst,0 ,0 ,WIDTH /2 ,HEIGHT /2 , -COLOR_4C ); +COLOR_4C , data.devid);for (i =0 ; i <WIDTH ; i++) {for (j =0 ; j <HEIGHT ; j++) {
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 4/4 lib/gpgpu_fill: Add missing configuration parameters for gpgpu_fill
In reply to Katarzyna DecThere are missing parameters for Gen8 configuration of gpgpu_fill that are causing GPU hangs on newer hardware. We need to set the number of threads in TG in gen8_fill_interface_descriptor. This field was omitted (apparently without any side effects), but according to bspec from BDW this field cannot be set to 0. We also need to use pipeline selection mask to gen9_gpgpu_fillfunc, which is necessary from SKL.
v2: rebased on refactored library
v3: Removed replacing gen7_emit_interface_descriptor_load with gen8 version in gen9_gpgpgu_fillfunc, because during refactoring gen8 function was removed.
--- lib/gpgpu_fill.c | 3 ++- lib/gpu_fill.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-)
lib/gpgpu_fill.c +2 -1
@@ -228,7 +228,8 @@ gen9_gpgpu_fillfunc(struct intel_batchbuffer *batch, batch->ptr = batch->buffer;/* GPGPU pipeline */ -OUT_BATCH (GEN7_PIPELINE_SELECT |PIPELINE_SELECT_GPGPU ); +OUT_BATCH (GEN7_PIPELINE_SELECT |GEN9_PIPELINE_SELECTION_MASK | +PIPELINE_SELECT_GPGPU );gen9_emit_state_base_address (batch);gen8_emit_vfe_state_gpgpu (batch);
lib/gpu_fill.c +2 -0
@@ -455,6 +455,8 @@ gen8_fill_interface_descriptor(struct intel_batchbuffer *batch, idd->desc5.constant_urb_entry_read_offset =0 ; idd->desc5.constant_urb_entry_read_length =1 ;/* grf 1 */ + idd->desc6.num_threads_in_tg =1 ; +return offset; }
Signature · 6 lines
2.14.3 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✓ Fi.CI.BAT: success for Refactoring of *_fill libraries
In reply to Katarzyna Dec== Series Details ==
== Series Details ==
Series: Refactoring of *_fill libraries
URL : https://patchwork.freedesktop.org/series/41212/
State : success
== Summary ==
IGT patchset tested on top of latest successful build 164b4a3ab34bd7d18d34181c62bfaedb906a76e3 blacklist: Don't run tests on pipe-d, pipe-e or pipe-f
with latest DRM-Tip kernel build CI_DRM_40250eddede73765 drm-tip: 2018y-04m-05d-09h-51m-03s UTC integration manifest
No testlist changes.
---- Known issues:
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-c:
pass -> INCOMPLETE (fi-bxt-dsi) fdo#103927
dmesg-warn -> PASS (fi-glk-j4005) fdo#105644
pass -> FAIL (fi-skl-guc) fdo#104108
Test prime_vgem:
Subgroup basic-fence-flip:
fail -> PASS (fi-ilk-650) fdo#104008fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
fdo#105644 https://bugs.freedesktop.org/show_bug.cgi?id=105644
fdo#104108 https://bugs.freedesktop.org/show_bug.cgi?id=104108
fdo#104008 https://bugs.freedesktop.org/show_bug.cgi?id=104008
fi-bdw-5557u total:285 pass:264 dwarn:0 dfail:0 fail:0 skip:21 time:435s fi-bdw-gvtdvm total:285 pass:261 dwarn:0 dfail:0 fail:0 skip:24 time:446s fi-blb-e6850 total:285 pass:220 dwarn:1 dfail:0 fail:0 skip:64 time:382s fi-bsw-n3050 total:285 pass:239 dwarn:0 dfail:0 fail:0 skip:46 time:543s fi-bwr-2160 total:285 pass:180 dwarn:0 dfail:0 fail:0 skip:105 time:299s fi-bxt-dsi total:243 pass:216 dwarn:0 dfail:0 fail:0 skip:26 fi-bxt-j4205 total:285 pass:256 dwarn:0 dfail:0 fail:0 skip:29 time:514s fi-byt-j1900 total:285 pass:250 dwarn:0 dfail:0 fail:0 skip:35 time:525s fi-byt-n2820 total:285 pass:246 dwarn:0 dfail:0 fail:0 skip:39 time:514s fi-cfl-8700k total:285 pass:257 dwarn:0 dfail:0 fail:0 skip:28 time:416s fi-cfl-s3 total:285 pass:259 dwarn:0 dfail:0 fail:0 skip:26 time:568s fi-cfl-u total:285 pass:259 dwarn:0 dfail:0 fail:0 skip:26 time:516s fi-cnl-y3 total:285 pass:259 dwarn:0 dfail:0 fail:0 skip:26 time:583s fi-elk-e7500 total:285 pass:226 dwarn:0 dfail:0 fail:0 skip:59 time:436s fi-gdg-551 total:285 pass:176 dwarn:0 dfail:0 fail:1 skip:108 time:316s fi-glk-1 total:285 pass:257 dwarn:0 dfail:0 fail:0 skip:28 time:539s fi-glk-j4005 total:285 pass:256 dwarn:0 dfail:0 fail:0 skip:29 time:483s fi-hsw-4770 total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:405s fi-ilk-650 total:285 pass:225 dwarn:0 dfail:0 fail:0 skip:60 time:421s fi-ivb-3520m total:285 pass:256 dwarn:0 dfail:0 fail:0 skip:29 time:472s fi-ivb-3770 total:285 pass:252 dwarn:0 dfail:0 fail:0 skip:33 time:432s fi-kbl-7500u total:285 pass:260 dwarn:1 dfail:0 fail:0 skip:24 time:471s fi-kbl-7567u total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:463s fi-kbl-r total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:512s fi-pnv-d510 total:285 pass:220 dwarn:1 dfail:0 fail:0 skip:64 time:671s fi-skl-6260u total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:444s fi-skl-6600u total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:540s fi-skl-6700k2 total:285 pass:261 dwarn:0 dfail:0 fail:0 skip:24 time:499s fi-skl-6770hq total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:515s fi-skl-guc total:285 pass:256 dwarn:0 dfail:0 fail:1 skip:28 time:408s fi-skl-gvtdvm total:285 pass:262 dwarn:0 dfail:0 fail:0 skip:23 time:446s fi-snb-2520m total:285 pass:245 dwarn:0 dfail:0 fail:0 skip:40 time:589s fi-snb-2600 total:285 pass:245 dwarn:0 dfail:0 fail:0 skip:40 time:402s
Blacklisted hosts:
fi-cnl-psr total:285 pass:256 dwarn:3 dfail:0 fail:0 skip:26 time:524s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1229/issues.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✗ Fi.CI.IGT: failure for Refactoring of *_fill libraries
In reply to Katarzyna Dec== Series Details ==
== Series Details ==
Series: Refactoring of *_fill libraries
URL : https://patchwork.freedesktop.org/series/41212/
State : failure
== Summary ==
---- Possible new issues:
Test gem_gpgpu_fill:
pass -> FAIL (shard-apl)
Test gem_media_fill:
pass -> FAIL (shard-apl)---- Known issues:
Test kms_flip:
Subgroup 2x-flip-vs-expired-vblank:
pass -> FAIL (shard-hsw) fdo#102887
Subgroup 2x-plain-flip-fb-recreate-interruptible:
pass -> FAIL (shard-hsw) fdo#100368
Subgroup flip-vs-modeset-vs-hang-interruptible:
pass -> DMESG-WARN (shard-snb) fdo#104311
Test kms_frontbuffer_tracking:
Subgroup fbc-1p-primscrn-pri-indfb-draw-render:
fail -> PASS (shard-snb) fdo#103167
Test perf:
Subgroup blocking:
pass -> FAIL (shard-hsw) fdo#102252fdo#102887 https://bugs.freedesktop.org/show_bug.cgi?id=102887
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#104311 https://bugs.freedesktop.org/show_bug.cgi?id=104311
fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
shard-apl total:2680 pass:1833 dwarn:1 dfail:0 fail:9 skip:836 time:12744s shard-hsw total:2680 pass:1782 dwarn:1 dfail:0 fail:5 skip:891 time:11549s shard-snb total:2680 pass:1375 dwarn:2 dfail:0 fail:4 skip:1299 time:6946s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1229/shards.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev