diff options
author | Chia-I Wu <[email protected]> | 2013-06-25 12:12:09 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2013-06-25 12:28:54 +0800 |
commit | 5c8db569abf3f1e508d57cccb95856936bce29e4 (patch) | |
tree | 13a48632710fee6bc0778830b8b2b345967339f7 /src | |
parent | 96e2133e72ec0fb6173b79838f1a7d153b8f25b6 (diff) |
ilo: add functions to query shaders
Add ilo_shader_get_type() to query the type (PIPE_SHADER_x) of the shader.
Add ilo_shader_get_kernel_offset() and ilo_shader_get_kernel_param() to query
the cache offset and various kernel parameters of the selected kernel.
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/ilo/ilo_shader.c | 114 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_shader.h | 38 |
2 files changed, 152 insertions, 0 deletions
diff --git a/src/gallium/drivers/ilo/ilo_shader.c b/src/gallium/drivers/ilo/ilo_shader.c index 4d63ec69098..21faf773e59 100644 --- a/src/gallium/drivers/ilo/ilo_shader.c +++ b/src/gallium/drivers/ilo/ilo_shader.c @@ -759,6 +759,15 @@ ilo_shader_destroy(struct ilo_shader_state *shader) } /** + * Return the type (PIPE_SHADER_x) of the shader. + */ +int +ilo_shader_get_type(const struct ilo_shader_state *shader) +{ + return shader->info.type; +} + +/** * Select a kernel for the given context. This will compile a new kernel if * none of the existing kernels work with the context. * @@ -782,3 +791,108 @@ ilo_shader_select_kernel(struct ilo_shader_state *shader, return (shader->shader != cur); } + +/** + * Return the cache offset of the selected kernel. This must be called after + * ilo_shader_select_kernel() and ilo_shader_cache_upload(). + */ +uint32_t +ilo_shader_get_kernel_offset(const struct ilo_shader_state *shader) +{ + const struct ilo_shader *kernel = shader->shader; + + assert(kernel && kernel->uploaded); + + return kernel->cache_offset; +} + +/** + * Query a kernel parameter for the selected kernel. + */ +int +ilo_shader_get_kernel_param(const struct ilo_shader_state *shader, + enum ilo_kernel_param param) +{ + const struct ilo_shader *kernel = shader->shader; + int val; + + assert(kernel); + + switch (param) { + case ILO_KERNEL_INPUT_COUNT: + val = kernel->in.count; + break; + case ILO_KERNEL_OUTPUT_COUNT: + val = kernel->out.count; + break; + case ILO_KERNEL_URB_DATA_START_REG: + val = kernel->in.start_grf; + break; + + case ILO_KERNEL_VS_INPUT_INSTANCEID: + val = shader->info.has_instanceid; + break; + case ILO_KERNEL_VS_INPUT_VERTEXID: + val = shader->info.has_vertexid; + break; + case ILO_KERNEL_VS_INPUT_EDGEFLAG: + if (shader->info.edgeflag_in >= 0) { + /* we rely on the state tracker here */ + assert(shader->info.edgeflag_in == kernel->in.count - 1); + val = true; + } + else { + val = false; + } + break; + case ILO_KERNEL_VS_PCB_UCP_SIZE: + val = kernel->pcb.clip_state_size; + break; + case ILO_KERNEL_VS_GEN6_SO: + val = kernel->stream_output; + break; + case ILO_KERNEL_VS_GEN6_SO_START_REG: + val = kernel->gs_start_grf; + break; + case ILO_KERNEL_VS_GEN6_SO_POINT_OFFSET: + val = kernel->gs_offsets[0]; + break; + case ILO_KERNEL_VS_GEN6_SO_LINE_OFFSET: + val = kernel->gs_offsets[1]; + break; + case ILO_KERNEL_VS_GEN6_SO_TRI_OFFSET: + val = kernel->gs_offsets[2]; + break; + + case ILO_KERNEL_GS_DISCARD_ADJACENCY: + val = kernel->in.discard_adj; + break; + case ILO_KERNEL_GS_GEN6_SVBI_POST_INC: + val = kernel->svbi_post_inc; + break; + + case ILO_KERNEL_FS_INPUT_Z: + case ILO_KERNEL_FS_INPUT_W: + val = kernel->in.has_pos; + break; + case ILO_KERNEL_FS_OUTPUT_Z: + val = kernel->out.has_pos; + break; + case ILO_KERNEL_FS_USE_KILL: + val = kernel->has_kill; + break; + case ILO_KERNEL_FS_BARYCENTRIC_INTERPOLATIONS: + val = kernel->in.barycentric_interpolation_mode; + break; + case ILO_KERNEL_FS_DISPATCH_16_OFFSET: + val = 0; + break; + + default: + assert(!"unknown kernel parameter"); + val = 0; + break; + } + + return val; +} diff --git a/src/gallium/drivers/ilo/ilo_shader.h b/src/gallium/drivers/ilo/ilo_shader.h index 4413c59e119..fa5a556539b 100644 --- a/src/gallium/drivers/ilo/ilo_shader.h +++ b/src/gallium/drivers/ilo/ilo_shader.h @@ -30,6 +30,34 @@ #include "ilo_common.h" +enum ilo_kernel_param { + ILO_KERNEL_INPUT_COUNT, + ILO_KERNEL_OUTPUT_COUNT, + ILO_KERNEL_URB_DATA_START_REG, + + ILO_KERNEL_VS_INPUT_INSTANCEID, + ILO_KERNEL_VS_INPUT_VERTEXID, + ILO_KERNEL_VS_INPUT_EDGEFLAG, + ILO_KERNEL_VS_PCB_UCP_SIZE, + ILO_KERNEL_VS_GEN6_SO, + ILO_KERNEL_VS_GEN6_SO_START_REG, + ILO_KERNEL_VS_GEN6_SO_POINT_OFFSET, + ILO_KERNEL_VS_GEN6_SO_LINE_OFFSET, + ILO_KERNEL_VS_GEN6_SO_TRI_OFFSET, + + ILO_KERNEL_GS_DISCARD_ADJACENCY, + ILO_KERNEL_GS_GEN6_SVBI_POST_INC, + + ILO_KERNEL_FS_INPUT_Z, + ILO_KERNEL_FS_INPUT_W, + ILO_KERNEL_FS_OUTPUT_Z, + ILO_KERNEL_FS_USE_KILL, + ILO_KERNEL_FS_BARYCENTRIC_INTERPOLATIONS, + ILO_KERNEL_FS_DISPATCH_16_OFFSET, + + ILO_KERNEL_PARAM_COUNT, +}; + struct intel_bo; struct ilo_context; struct ilo_shader_cache; @@ -77,9 +105,19 @@ ilo_shader_create_cs(const struct ilo_dev_info *dev, void ilo_shader_destroy(struct ilo_shader_state *shader); +int +ilo_shader_get_type(const struct ilo_shader_state *shader); + bool ilo_shader_select_kernel(struct ilo_shader_state *shader, const struct ilo_context *ilo, uint32_t dirty); +uint32_t +ilo_shader_get_kernel_offset(const struct ilo_shader_state *shader); + +int +ilo_shader_get_kernel_param(const struct ilo_shader_state *shader, + enum ilo_kernel_param param); + #endif /* ILO_SHADER_H */ |