Use rdcfixedarray in parameters for functions instead of C arrays

* This maps better to tuples in python
This commit is contained in:
baldurk
2020-12-15 22:52:38 +00:00
parent 2b0f9c2eba
commit 3aaccc4fda
25 changed files with 101 additions and 65 deletions
@@ -414,8 +414,28 @@ void ARRAY_INSTANTIATION_CHECK_NAME(arrayType)(arrayType<nspace::innerType> *)
%define TEMPLATE_FIXEDARRAY_DECLARE(typeName)
%typemap(in) const typeName & {
static_assert(false, "Error! Should not use this typemap");
%typemap(in) const typeName & (unsigned char tempmem[16*8]) {
using array_type = std::remove_pointer<decltype($1)>::type;
{
tempalloc($1, tempmem);
int failIdx = 0;
int res = TypeConversion<array_type>::ConvertFromPy($input, indirect($1), &failIdx);
if(!SWIG_IsOK(res))
{
if(res == SWIG_TypeError)
{
SWIG_exception_fail(SWIG_ArgError(res), "in method '$symname' argument $argnum of type '$1_basetype'");
}
else
{
snprintf(convert_error, sizeof(convert_error)-1, "in method '$symname' argument $argnum of type '$1_basetype', decoding element %d", failIdx);
SWIG_exception_fail(SWIG_ArgError(res), convert_error);
}
}
}
}
%typemap(in) typeName {
+1
View File
@@ -319,6 +319,7 @@ TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, uint64_t, 4)
TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, int32_t, 4)
TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, ResourceId, 4)
TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, ResourceId, 8)
TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, bool, 4)
TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, bool, 8)
TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, float, 16)
TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, int32_t, 16)
@@ -3151,8 +3151,8 @@ void D3D11PipelineStateViewer::on_debugThread_clicked()
struct threadSelect
{
uint32_t g[3];
uint32_t t[3];
rdcfixedarray<uint32_t, 3> g;
rdcfixedarray<uint32_t, 3> t;
} thread = {
// g[]
{(uint32_t)ui->groupX->value(), (uint32_t)ui->groupY->value(), (uint32_t)ui->groupZ->value()},
@@ -3228,8 +3228,8 @@ void D3D12PipelineStateViewer::on_debugThread_clicked()
struct threadSelect
{
uint32_t g[3];
uint32_t t[3];
rdcfixedarray<uint32_t, 3> g;
rdcfixedarray<uint32_t, 3> t;
} thread = {
// g[]
{(uint32_t)ui->groupX->value(), (uint32_t)ui->groupY->value(), (uint32_t)ui->groupZ->value()},
@@ -3996,8 +3996,8 @@ void VulkanPipelineStateViewer::on_debugThread_clicked()
struct threadSelect
{
uint32_t g[3];
uint32_t t[3];
rdcfixedarray<uint32_t, 3> g;
rdcfixedarray<uint32_t, 3> t;
} thread = {
// g[]
{(uint32_t)ui->groupX->value(), (uint32_t)ui->groupY->value(), (uint32_t)ui->groupZ->value()},
+1 -1
View File
@@ -834,7 +834,7 @@ void TextureViewer::RT_UpdateVisualRange(IReplayController *r)
if(m_TexDisplay.customShaderId != ResourceId())
fmt.compCount = 4;
bool channels[] = {
rdcfixedarray<bool, 4> channels = {
m_TexDisplay.red ? true : false, m_TexDisplay.green && fmt.compCount > 1,
m_TexDisplay.blue && fmt.compCount > 2, m_TexDisplay.alpha && fmt.compCount > 3,
};
+3 -2
View File
@@ -819,7 +819,7 @@ bucket when the pixel values are divided between ``minval`` and ``maxval``.
)");
virtual rdcarray<uint32_t> GetHistogram(ResourceId textureId, const Subresource &sub,
CompType typeCast, float minval, float maxval,
bool channels[4]) = 0;
const rdcfixedarray<bool, 4> &channels) = 0;
DOCUMENT(R"(Retrieve the history of modifications to the selected pixel on the selected texture.
@@ -885,7 +885,8 @@ bucket when the pixel values are divided between ``minval`` and ``maxval``.
:meth:`FreeTrace`.
:rtype: ShaderDebugTrace
)");
virtual ShaderDebugTrace *DebugThread(const uint32_t groupid[3], const uint32_t threadid[3]) = 0;
virtual ShaderDebugTrace *DebugThread(const rdcfixedarray<uint32_t, 3> &groupid,
const rdcfixedarray<uint32_t, 3> &threadid) = 0;
DOCUMENT(R"(Continue a shader's debugging with a given shader debugger instance. This will run an
implementation defined number of steps and then return those steps in a list. This may be a fixed
+4 -3
View File
@@ -133,7 +133,8 @@ public:
return m_Proxy->GetMinMax(m_TextureID, sub, typeCast, minval, maxval);
}
bool GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast, float minval,
float maxval, bool channels[4], rdcarray<uint32_t> &histogram)
float maxval, const rdcfixedarray<bool, 4> &channels,
rdcarray<uint32_t> &histogram)
{
return m_Proxy->GetHistogram(m_TextureID, sub, typeCast, minval, maxval, channels, histogram);
}
@@ -283,8 +284,8 @@ public:
{
return new ShaderDebugTrace();
}
ShaderDebugTrace *DebugThread(uint32_t eventId, const uint32_t groupid[3],
const uint32_t threadid[3])
ShaderDebugTrace *DebugThread(uint32_t eventId, const rdcfixedarray<uint32_t, 3> &groupid,
const rdcfixedarray<uint32_t, 3> &threadid)
{
return new ShaderDebugTrace();
}
+9 -13
View File
@@ -1532,28 +1532,25 @@ ShaderDebugTrace *ReplayProxy::DebugPixel(uint32_t eventId, uint32_t x, uint32_t
template <typename ParamSerialiser, typename ReturnSerialiser>
ShaderDebugTrace *ReplayProxy::Proxied_DebugThread(ParamSerialiser &paramser,
ReturnSerialiser &retser, uint32_t eventId,
const uint32_t groupid[3],
const uint32_t threadid[3])
const rdcfixedarray<uint32_t, 3> &groupid,
const rdcfixedarray<uint32_t, 3> &threadid)
{
const ReplayProxyPacket expectedPacket = eReplayProxy_DebugThread;
ReplayProxyPacket packet = eReplayProxy_DebugThread;
ShaderDebugTrace *ret;
uint32_t GroupID[3] = {groupid[0], groupid[1], groupid[2]};
uint32_t ThreadID[3] = {threadid[0], threadid[1], threadid[2]};
{
BEGIN_PARAMS();
SERIALISE_ELEMENT(eventId);
SERIALISE_ELEMENT(GroupID);
SERIALISE_ELEMENT(ThreadID);
SERIALISE_ELEMENT(groupid);
SERIALISE_ELEMENT(threadid);
END_PARAMS();
}
{
REMOTE_EXECUTION();
if(paramser.IsReading() && !paramser.IsErrored() && !m_IsErrored)
ret = m_Remote->DebugThread(eventId, GroupID, ThreadID);
ret = m_Remote->DebugThread(eventId, groupid, threadid);
else
ret = new ShaderDebugTrace;
}
@@ -1563,8 +1560,9 @@ ShaderDebugTrace *ReplayProxy::Proxied_DebugThread(ParamSerialiser &paramser,
return ret;
}
ShaderDebugTrace *ReplayProxy::DebugThread(uint32_t eventId, const uint32_t groupid[3],
const uint32_t threadid[3])
ShaderDebugTrace *ReplayProxy::DebugThread(uint32_t eventId,
const rdcfixedarray<uint32_t, 3> &groupid,
const rdcfixedarray<uint32_t, 3> &threadid)
{
PROXY_FUNCTION(DebugThread, eventId, groupid, threadid);
}
@@ -2825,9 +2823,7 @@ bool ReplayProxy::Tick(int type)
case eReplayProxy_DebugPixel: DebugPixel(0, 0, 0, 0, 0); break;
case eReplayProxy_DebugThread:
{
uint32_t dummy1[3] = {0};
uint32_t dummy2[3] = {0};
DebugThread(0, dummy1, dummy2);
DebugThread(0, {}, {});
break;
}
case eReplayProxy_ContinueDebug: ContinueDebug(NULL); break;
+4 -2
View File
@@ -314,7 +314,8 @@ public:
}
bool GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast, float minval,
float maxval, bool channels[4], rdcarray<uint32_t> &histogram)
float maxval, const rdcfixedarray<bool, 4> &channels,
rdcarray<uint32_t> &histogram)
{
if(m_Proxy)
{
@@ -528,7 +529,8 @@ public:
IMPLEMENT_FUNCTION_PROXIED(ShaderDebugTrace *, DebugPixel, uint32_t eventId, uint32_t x,
uint32_t y, uint32_t sample, uint32_t primitive);
IMPLEMENT_FUNCTION_PROXIED(ShaderDebugTrace *, DebugThread, uint32_t eventId,
const uint32_t groupid[3], const uint32_t threadid[3]);
const rdcfixedarray<uint32_t, 3> &groupid,
const rdcfixedarray<uint32_t, 3> &threadid);
IMPLEMENT_FUNCTION_PROXIED(rdcarray<ShaderDebugState>, ContinueDebug, ShaderDebugger *debugger);
IMPLEMENT_FUNCTION_PROXIED(void, FreeDebugger, ShaderDebugger *debugger);
+1 -1
View File
@@ -1806,7 +1806,7 @@ bool D3D11Replay::GetMinMax(ResourceId texid, const Subresource &sub, CompType t
}
bool D3D11Replay::GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast,
float minval, float maxval, bool channels[4],
float minval, float maxval, const rdcfixedarray<bool, 4> &channels,
rdcarray<uint32_t> &histogram)
{
if(minval >= maxval)
+4 -3
View File
@@ -181,7 +181,8 @@ public:
bool GetMinMax(ResourceId texid, const Subresource &sub, CompType typeCast, float *minval,
float *maxval);
bool GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast, float minval,
float maxval, bool channels[4], rdcarray<uint32_t> &histogram);
float maxval, const rdcfixedarray<bool, 4> &channels,
rdcarray<uint32_t> &histogram);
MeshFormat GetPostVSBuffers(uint32_t eventId, uint32_t instID, uint32_t viewID,
MeshDataStage stage);
@@ -235,8 +236,8 @@ public:
uint32_t view);
ShaderDebugTrace *DebugPixel(uint32_t eventId, uint32_t x, uint32_t y, uint32_t sample,
uint32_t primitive);
ShaderDebugTrace *DebugThread(uint32_t eventId, const uint32_t groupid[3],
const uint32_t threadid[3]);
ShaderDebugTrace *DebugThread(uint32_t eventId, const rdcfixedarray<uint32_t, 3> &groupid,
const rdcfixedarray<uint32_t, 3> &threadid);
rdcarray<ShaderDebugState> ContinueDebug(ShaderDebugger *debugger);
void FreeDebugger(ShaderDebugger *debugger);
+3 -2
View File
@@ -2868,8 +2868,9 @@ void ExtractInputsPS(PSInput IN, float4 debug_pixelPos : SV_Position,
return ret;
}
ShaderDebugTrace *D3D11Replay::DebugThread(uint32_t eventId, const uint32_t groupid[3],
const uint32_t threadid[3])
ShaderDebugTrace *D3D11Replay::DebugThread(uint32_t eventId,
const rdcfixedarray<uint32_t, 3> &groupid,
const rdcfixedarray<uint32_t, 3> &threadid)
{
using namespace DXBCBytecode;
using namespace DXBCDebug;
+1 -1
View File
@@ -2460,7 +2460,7 @@ bool D3D12Replay::GetMinMax(ResourceId texid, const Subresource &sub, CompType t
}
bool D3D12Replay::GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast,
float minval, float maxval, bool channels[4],
float minval, float maxval, const rdcfixedarray<bool, 4> &channels,
rdcarray<uint32_t> &histogram)
{
if(minval >= maxval)
+4 -3
View File
@@ -136,7 +136,8 @@ public:
bool GetMinMax(ResourceId texid, const Subresource &sub, CompType typeCast, float *minval,
float *maxval);
bool GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast, float minval,
float maxval, bool channels[4], rdcarray<uint32_t> &histogram);
float maxval, const rdcfixedarray<bool, 4> &channels,
rdcarray<uint32_t> &histogram);
MeshFormat GetPostVSBuffers(uint32_t eventId, uint32_t instID, uint32_t viewID,
MeshDataStage stage);
@@ -190,8 +191,8 @@ public:
uint32_t view);
ShaderDebugTrace *DebugPixel(uint32_t eventId, uint32_t x, uint32_t y, uint32_t sample,
uint32_t primitive);
ShaderDebugTrace *DebugThread(uint32_t eventId, const uint32_t groupid[3],
const uint32_t threadid[3]);
ShaderDebugTrace *DebugThread(uint32_t eventId, const rdcfixedarray<uint32_t, 3> &groupid,
const rdcfixedarray<uint32_t, 3> &threadid);
rdcarray<ShaderDebugState> ContinueDebug(ShaderDebugger *debugger);
void FreeDebugger(ShaderDebugger *debugger);
+3 -2
View File
@@ -2951,8 +2951,9 @@ void ExtractInputsPS(PSInput IN, float4 debug_pixelPos : SV_Position,
return ret;
}
ShaderDebugTrace *D3D12Replay::DebugThread(uint32_t eventId, const uint32_t groupid[3],
const uint32_t threadid[3])
ShaderDebugTrace *D3D12Replay::DebugThread(uint32_t eventId,
const rdcfixedarray<uint32_t, 3> &groupid,
const rdcfixedarray<uint32_t, 3> &threadid)
{
using namespace DXBCBytecode;
using namespace DXBCDebug;
+6 -2
View File
@@ -1912,8 +1912,9 @@ bool GLReplay::GetMinMax(ResourceId texid, const Subresource &sub, CompType type
return true;
}
bool GLReplay::GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast, float minval,
float maxval, bool channels[4], rdcarray<uint32_t> &histogram)
bool GLReplay::GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast,
float minval, float maxval, const rdcfixedarray<bool, 4> &channels_,
rdcarray<uint32_t> &histogram)
{
if(minval >= maxval || texid == ResourceId())
return false;
@@ -1924,6 +1925,9 @@ bool GLReplay::GetHistogram(ResourceId texid, const Subresource &sub, CompType t
if(!HasExt[ARB_compute_shader] || !HasExt[ARB_shading_language_420pack])
return false;
// take a local copy so we can modify it
rdcfixedarray<bool, 4> channels = channels_;
auto &texDetails = m_pDriver->m_Textures[texid];
TextureDescription details = GetTexture(texid);
+2 -2
View File
@@ -3670,8 +3670,8 @@ ShaderDebugTrace *GLReplay::DebugPixel(uint32_t eventId, uint32_t x, uint32_t y,
return new ShaderDebugTrace();
}
ShaderDebugTrace *GLReplay::DebugThread(uint32_t eventId, const uint32_t groupid[3],
const uint32_t threadid[3])
ShaderDebugTrace *GLReplay::DebugThread(uint32_t eventId, const rdcfixedarray<uint32_t, 3> &groupid,
const rdcfixedarray<uint32_t, 3> &threadid)
{
GLNOTIMP("DebugThread");
return new ShaderDebugTrace();
+4 -3
View File
@@ -176,7 +176,8 @@ public:
bool GetMinMax(ResourceId texid, const Subresource &sub, CompType typeCast, float *minval,
float *maxval);
bool GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast, float minval,
float maxval, bool channels[4], rdcarray<uint32_t> &histogram);
float maxval, const rdcfixedarray<bool, 4> &channels,
rdcarray<uint32_t> &histogram);
MeshFormat GetPostVSBuffers(uint32_t eventId, uint32_t instID, uint32_t viewID,
MeshDataStage stage);
@@ -222,8 +223,8 @@ public:
uint32_t view);
ShaderDebugTrace *DebugPixel(uint32_t eventId, uint32_t x, uint32_t y, uint32_t sample,
uint32_t primitive);
ShaderDebugTrace *DebugThread(uint32_t eventId, const uint32_t groupid[3],
const uint32_t threadid[3]);
ShaderDebugTrace *DebugThread(uint32_t eventId, const rdcfixedarray<uint32_t, 3> &groupid,
const rdcfixedarray<uint32_t, 3> &threadid);
rdcarray<ShaderDebugState> ContinueDebug(ShaderDebugger *debugger);
void FreeDebugger(ShaderDebugger *debugger);
uint32_t PickVertex(uint32_t eventId, int32_t width, int32_t height, const MeshDisplay &cfg,
+5 -4
View File
@@ -2588,7 +2588,7 @@ bool VulkanReplay::GetMinMax(ResourceId texid, const Subresource &sub, CompType
}
bool VulkanReplay::GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast,
float minval, float maxval, bool channels[4],
float minval, float maxval, const rdcfixedarray<bool, 4> &channels,
rdcarray<uint32_t> &histogram)
{
if(minval >= maxval)
@@ -2654,9 +2654,6 @@ bool VulkanReplay::GetHistogram(ResourceId texid, const Subresource &sub, CompTy
// rescale the range so that stencil seems to fit to 0-1
minval *= 255.0f;
maxval *= 255.0f;
// shuffle the channel selection, since stencil comes back in red
std::swap(channels[0], channels[1]);
}
descSetBinding += textype;
@@ -2782,6 +2779,10 @@ bool VulkanReplay::GetHistogram(ResourceId texid, const Subresource &sub, CompTy
if(channels[3])
chans |= 0x8;
// shuffle the channel selection, since stencil comes back in red
if(stencil)
chans = 0x1;
data->HistogramChannels = chans;
data->HistogramFlags = 0;
+4 -3
View File
@@ -323,7 +323,8 @@ public:
bool GetMinMax(ResourceId texid, const Subresource &sub, CompType typeCast, float *minval,
float *maxval);
bool GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast, float minval,
float maxval, bool channels[4], rdcarray<uint32_t> &histogram);
float maxval, const rdcfixedarray<bool, 4> &channels,
rdcarray<uint32_t> &histogram);
VkDescriptorSet GetPixelHistoryDescriptor();
void ResetPixelHistoryDescriptorPool();
@@ -381,8 +382,8 @@ public:
uint32_t view);
ShaderDebugTrace *DebugPixel(uint32_t eventId, uint32_t x, uint32_t y, uint32_t sample,
uint32_t primitive);
ShaderDebugTrace *DebugThread(uint32_t eventId, const uint32_t groupid[3],
const uint32_t threadid[3]);
ShaderDebugTrace *DebugThread(uint32_t eventId, const rdcfixedarray<uint32_t, 3> &groupid,
const rdcfixedarray<uint32_t, 3> &threadid);
rdcarray<ShaderDebugState> ContinueDebug(ShaderDebugger *debugger);
void FreeDebugger(ShaderDebugger *debugger);
+3 -2
View File
@@ -4576,8 +4576,9 @@ ShaderDebugTrace *VulkanReplay::DebugPixel(uint32_t eventId, uint32_t x, uint32_
return ret;
}
ShaderDebugTrace *VulkanReplay::DebugThread(uint32_t eventId, const uint32_t groupid[3],
const uint32_t threadid[3])
ShaderDebugTrace *VulkanReplay::DebugThread(uint32_t eventId,
const rdcfixedarray<uint32_t, 3> &groupid,
const rdcfixedarray<uint32_t, 3> &threadid)
{
if(!GetAPIProperties().shaderDebugging)
{
+3 -2
View File
@@ -1580,7 +1580,7 @@ rdcpair<PixelValue, PixelValue> ReplayController::GetMinMax(ResourceId textureId
rdcarray<uint32_t> ReplayController::GetHistogram(ResourceId textureId, const Subresource &sub,
CompType typeCast, float minval, float maxval,
bool channels[4])
const rdcfixedarray<bool, 4> &channels)
{
CHECK_REPLAY_THREAD();
@@ -1620,7 +1620,8 @@ ShaderDebugTrace *ReplayController::DebugPixel(uint32_t x, uint32_t y, uint32_t
return ret;
}
ShaderDebugTrace *ReplayController::DebugThread(const uint32_t groupid[3], const uint32_t threadid[3])
ShaderDebugTrace *ReplayController::DebugThread(const rdcfixedarray<uint32_t, 3> &groupid,
const rdcfixedarray<uint32_t, 3> &threadid)
{
CHECK_REPLAY_THREAD();
+3 -2
View File
@@ -182,12 +182,13 @@ public:
rdcpair<PixelValue, PixelValue> GetMinMax(ResourceId textureId, const Subresource &sub,
CompType typeCast);
rdcarray<uint32_t> GetHistogram(ResourceId textureId, const Subresource &sub, CompType typeCast,
float minval, float maxval, bool channels[4]);
float minval, float maxval, const rdcfixedarray<bool, 4> &channels);
rdcarray<PixelModification> PixelHistory(ResourceId target, uint32_t x, uint32_t y,
const Subresource &sub, CompType typeCast);
ShaderDebugTrace *DebugVertex(uint32_t vertid, uint32_t instid, uint32_t idx, uint32_t view);
ShaderDebugTrace *DebugPixel(uint32_t x, uint32_t y, uint32_t sample, uint32_t primitive);
ShaderDebugTrace *DebugThread(const uint32_t groupid[3], const uint32_t threadid[3]);
ShaderDebugTrace *DebugThread(const rdcfixedarray<uint32_t, 3> &groupid,
const rdcfixedarray<uint32_t, 3> &threadid);
rdcarray<ShaderDebugState> ContinueDebug(ShaderDebugger *debugger);
void FreeTrace(ShaderDebugTrace *trace);
+5 -4
View File
@@ -203,8 +203,8 @@ public:
uint32_t idx, uint32_t view) = 0;
virtual ShaderDebugTrace *DebugPixel(uint32_t eventId, uint32_t x, uint32_t y, uint32_t sample,
uint32_t primitive) = 0;
virtual ShaderDebugTrace *DebugThread(uint32_t eventId, const uint32_t groupid[3],
const uint32_t threadid[3]) = 0;
virtual ShaderDebugTrace *DebugThread(uint32_t eventId, const rdcfixedarray<uint32_t, 3> &groupid,
const rdcfixedarray<uint32_t, 3> &threadid) = 0;
virtual rdcarray<ShaderDebugState> ContinueDebug(ShaderDebugger *debugger) = 0;
virtual void FreeDebugger(ShaderDebugger *debugger) = 0;
@@ -245,8 +245,9 @@ public:
virtual bool GetMinMax(ResourceId texid, const Subresource &sub, CompType typeCast, float *minval,
float *maxval) = 0;
virtual bool GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast, float minval,
float maxval, bool channels[4], rdcarray<uint32_t> &histogram) = 0;
virtual bool GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast,
float minval, float maxval, const rdcfixedarray<bool, 4> &channels,
rdcarray<uint32_t> &histogram) = 0;
virtual void PickPixel(ResourceId texture, uint32_t x, uint32_t y, const Subresource &sub,
CompType typeCast, float pixel[4]) = 0;