Re: [Mesa-dev] [PATCH] radv: add an option that allows to dump pre-optimization ir

2018-01-19 Thread Timothy Arceri

Reviewed-by: Timothy Arceri 

On 19/01/18 22:12, Samuel Pitoiset wrote:

With RADV_DEBUG=preoptir.

Signed-off-by: Samuel Pitoiset 
---
  src/amd/common/ac_nir_to_llvm.c | 3 +++
  src/amd/common/ac_nir_to_llvm.h | 1 +
  src/amd/vulkan/radv_debug.h | 1 +
  src/amd/vulkan/radv_device.c| 1 +
  src/amd/vulkan/radv_shader.c| 2 ++
  5 files changed, 8 insertions(+)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index eb32e76c4e..d7b0f01353 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -6846,6 +6846,9 @@ LLVMModuleRef 
ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
  
  	LLVMBuildRetVoid(ctx.builder);
  
+	if (options->dump_preoptir)

+   ac_dump_module(ctx.module);
+
ac_llvm_finalize_module();
  
  	if (shader_count == 1)

diff --git a/src/amd/common/ac_nir_to_llvm.h b/src/amd/common/ac_nir_to_llvm.h
index 1737866166..62ea38be37 100644
--- a/src/amd/common/ac_nir_to_llvm.h
+++ b/src/amd/common/ac_nir_to_llvm.h
@@ -81,6 +81,7 @@ struct ac_nir_compiler_options {
bool unsafe_math;
bool supports_spill;
bool clamp_shadow_reference;
+   bool dump_preoptir;
enum radeon_family family;
enum chip_class chip_class;
  };
diff --git a/src/amd/vulkan/radv_debug.h b/src/amd/vulkan/radv_debug.h
index 5b37bfe084..804f620690 100644
--- a/src/amd/vulkan/radv_debug.h
+++ b/src/amd/vulkan/radv_debug.h
@@ -42,6 +42,7 @@ enum {
RADV_DEBUG_ZERO_VRAM = 0x1000,
RADV_DEBUG_SYNC_SHADERS  = 0x2000,
RADV_DEBUG_NO_SISCHED= 0x4000,
+   RADV_DEBUG_PREOPTIR  = 0x8000,
  };
  
  enum {

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 152ae7e7ae..b8da1f7b05 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -336,6 +336,7 @@ static const struct debug_control radv_debug_options[] = {
{"zerovram", RADV_DEBUG_ZERO_VRAM},
{"syncshaders", RADV_DEBUG_SYNC_SHADERS},
{"nosisched", RADV_DEBUG_NO_SISCHED},
+   {"preoptir", RADV_DEBUG_PREOPTIR},
{NULL, 0}
  };
  
diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c

index 3bcaac168a..620effe50e 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -476,6 +476,8 @@ shader_variant_create(struct radv_device *device,
  
  	options->family = chip_family;

options->chip_class = device->physical_device->rad_info.chip_class;
+   options->dump_preoptir = radv_can_dump_shader(device, module) &&
+device->instance->debug_flags & 
RADV_DEBUG_PREOPTIR;
  
  	if (options->supports_spill)

tm_options |= AC_TM_SUPPORTS_SPILL;


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] radv: add an option that allows to dump pre-optimization ir

2018-01-19 Thread Samuel Pitoiset
With RADV_DEBUG=preoptir.

Signed-off-by: Samuel Pitoiset 
---
 src/amd/common/ac_nir_to_llvm.c | 3 +++
 src/amd/common/ac_nir_to_llvm.h | 1 +
 src/amd/vulkan/radv_debug.h | 1 +
 src/amd/vulkan/radv_device.c| 1 +
 src/amd/vulkan/radv_shader.c| 2 ++
 5 files changed, 8 insertions(+)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index eb32e76c4e..d7b0f01353 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -6846,6 +6846,9 @@ LLVMModuleRef 
ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
 
LLVMBuildRetVoid(ctx.builder);
 
+   if (options->dump_preoptir)
+   ac_dump_module(ctx.module);
+
ac_llvm_finalize_module();
 
if (shader_count == 1)
diff --git a/src/amd/common/ac_nir_to_llvm.h b/src/amd/common/ac_nir_to_llvm.h
index 1737866166..62ea38be37 100644
--- a/src/amd/common/ac_nir_to_llvm.h
+++ b/src/amd/common/ac_nir_to_llvm.h
@@ -81,6 +81,7 @@ struct ac_nir_compiler_options {
bool unsafe_math;
bool supports_spill;
bool clamp_shadow_reference;
+   bool dump_preoptir;
enum radeon_family family;
enum chip_class chip_class;
 };
diff --git a/src/amd/vulkan/radv_debug.h b/src/amd/vulkan/radv_debug.h
index 5b37bfe084..804f620690 100644
--- a/src/amd/vulkan/radv_debug.h
+++ b/src/amd/vulkan/radv_debug.h
@@ -42,6 +42,7 @@ enum {
RADV_DEBUG_ZERO_VRAM = 0x1000,
RADV_DEBUG_SYNC_SHADERS  = 0x2000,
RADV_DEBUG_NO_SISCHED= 0x4000,
+   RADV_DEBUG_PREOPTIR  = 0x8000,
 };
 
 enum {
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 152ae7e7ae..b8da1f7b05 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -336,6 +336,7 @@ static const struct debug_control radv_debug_options[] = {
{"zerovram", RADV_DEBUG_ZERO_VRAM},
{"syncshaders", RADV_DEBUG_SYNC_SHADERS},
{"nosisched", RADV_DEBUG_NO_SISCHED},
+   {"preoptir", RADV_DEBUG_PREOPTIR},
{NULL, 0}
 };
 
diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index 3bcaac168a..620effe50e 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -476,6 +476,8 @@ shader_variant_create(struct radv_device *device,
 
options->family = chip_family;
options->chip_class = device->physical_device->rad_info.chip_class;
+   options->dump_preoptir = radv_can_dump_shader(device, module) &&
+device->instance->debug_flags & 
RADV_DEBUG_PREOPTIR;
 
if (options->supports_spill)
tm_options |= AC_TM_SUPPORTS_SPILL;
-- 
2.15.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev