Remove 'magic constant' use of ~0U as invalid/skip/no result.

* In python it's not as quick to get ~0U since ints aren't unsigned or
  fixed size. Adding named constants makes it easier for people to use
  the right values, and C++ users can still pass ~0U.
This commit is contained in:
baldurk
2017-04-07 11:53:20 +01:00
parent f6c045f473
commit 43eb5072b4
8 changed files with 77 additions and 17 deletions
+1 -1
View File
@@ -232,7 +232,7 @@ void RemoteManager::refreshHost(QTreeWidgetItem *node)
nextIdent = RENDERDOC_EnumerateRemoteTargets(hostnameBytes.data(), nextIdent);
if(nextIdent == ~0U || prevIdent >= nextIdent)
if(nextIdent == 0 || prevIdent >= nextIdent)
break;
ITargetControl *conn =
+24 -4
View File
@@ -109,6 +109,10 @@ class Camera;
DOCUMENT(R"(
Describes how to render a mesh preview of one or more meshes. Describes the camera configuration as
well as what options to use when rendering both the current mesh, and any other auxilliary meshes.
.. data:: NoHighlight
Value for :data:`highlightVert` if no vertex should be highlighted.
)");
struct MeshDisplay
{
@@ -139,7 +143,7 @@ struct MeshDisplay
DOCUMENT("The index of the currently selected instance in the drawcall.");
uint32_t curInstance;
DOCUMENT("The index of the vertex to highlight, or ``0xffffffff`` to select no vertex.");
DOCUMENT("The index of the vertex to highlight, or :data:`NoHighlight` to select no vertex.");
uint32_t highlightVert;
DOCUMENT("The :class:`MeshFormat` of the position data for the mesh.");
MeshFormat position;
@@ -158,6 +162,8 @@ struct MeshDisplay
SolidShade solidShadeMode;
DOCUMENT("``True`` if the wireframe of the mesh should be rendered as well as solid shading.");
bool32 wireframeDraw;
static const uint32_t NoHighlight = ~0U;
};
DECLARE_REFLECTION_STRUCT(MeshDisplay);
@@ -166,6 +172,10 @@ DOCUMENT(R"(
Describes how to render a texture preview of an image. Describes the zoom and pan settings for the
texture when rendering on a particular output, as well as the modification and selection of a
particular subresource (such as array slice, mip or multi-sampled sample).
.. data:: ResolveSamples
Value for :data:`sampleIdx` if the samples should be averaged.
)");
struct TextureDisplay
{
@@ -239,7 +249,8 @@ See :meth:`ReplayRenderer.BuildCustomShader` for creating an appropriate custom
DOCUMENT(R"(Select the sample of the texture to display if it's a multi-sampled texture.
If this is set to ``0xffffffff`` then a default resolve will be performed averaging all samples.
If this is set to :data:`ResolveSamples` then a default resolve will be performed that averages all
samples.
)");
uint32_t sampleIdx;
@@ -263,6 +274,8 @@ the input texture in cases where it isn't easy to directly fetch the input textu
DOCUMENT("Selects a :class:`DebugOverlay` to draw over the top of the texture.");
DebugOverlay overlay;
static const uint32_t ResolveSamples = ~0U;
};
DECLARE_REFLECTION_STRUCT(TextureDisplay);
@@ -279,7 +292,12 @@ struct TextureComponentMapping
DECLARE_REFLECTION_STRUCT(TextureComponentMapping);
DOCUMENT("How to map multisampled textures for saving to non-multisampled file formats.");
DOCUMENT(R"(How to map multisampled textures for saving to non-multisampled file formats.
.. data:: ResolveSamples
Value for :data:`sampleIndex` if the samples should be averaged.
)");
struct TextureSampleMapping
{
DOCUMENT(R"(
@@ -293,9 +311,11 @@ is ignored.
DOCUMENT(R"(
If :data:`mapToArray` is ``False`` this selects which sample should be extracted to treat as a
normal 2D image. If set to ``0xffffffff`` then instead there's a default average resolve.
normal 2D image. If set to :data:`ResolveSamples` then instead there's a default average resolve.
)");
uint32_t sampleIndex;
static const uint32_t ResolveSamples = ~0U;
};
DECLARE_REFLECTION_STRUCT(TextureSampleMapping);
+10 -2
View File
@@ -29,7 +29,12 @@
namespace D3D11Pipe
{
DOCUMENT("Describes a single D3D11 input layout element for one vertex input.");
DOCUMENT(R"(Describes a single D3D11 input layout element for one vertex input.
.. data:: TightlyPacked
Value for :data:`ByteOffset` that indicates this element is tightly packed.
)");
struct Layout
{
DOCUMENT("The semantic name for this input.");
@@ -47,7 +52,7 @@ struct Layout
DOCUMENT(R"(The byte offset from the start of the vertex data in the vertex buffer from
:data:`InputSlot`.
If the value is ``0xffffffff`` then the element is packed tightly after the previous element, or 0
If the value is :data:`TightlyPacked` then the element is packed tightly after the previous element, or 0
if this is the first element.
)");
uint32_t ByteOffset = 0;
@@ -62,6 +67,9 @@ E.g. if this value is two, then two instances will be drawn with the first insta
with the next instance data.
)");
uint32_t InstanceDataStepRate = 0;
// D3D11_APPEND_ALIGNED_ELEMENT
static const uint32_t TightlyPacked = ~0U;
};
DOCUMENT("Describes a single D3D11 vertex buffer binding.")
+10 -2
View File
@@ -28,7 +28,12 @@
namespace D3D12Pipe
{
DOCUMENT("Describes a single D3D12 input layout element for one vertex input.");
DOCUMENT(R"(Describes a single D3D12 input layout element for one vertex input.
.. data:: TightlyPacked
Value for :data:`ByteOffset` that indicates this element is tightly packed.
)");
struct Layout
{
DOCUMENT("The semantic name for this input.");
@@ -46,7 +51,7 @@ struct Layout
DOCUMENT(R"(The byte offset from the start of the vertex data in the vertex buffer from
:data:`InputSlot`.
If the value is ``0xffffffff`` then the element is packed tightly after the previous element, or 0
If the value is :data:`TightlyPacked` then the element is packed tightly after the previous element, or 0
if this is the first element.
)");
uint32_t ByteOffset = 0;
@@ -61,6 +66,9 @@ E.g. if this value is two, then two instances will be drawn with the first insta
with the next instance data.
)");
uint32_t InstanceDataStepRate = 0;
// D3D12_APPEND_ALIGNED_ELEMENT
static const uint32_t TightlyPacked = ~0U;
};
DOCUMENT("Describes a single D3D12 vertex buffer binding.")
+22 -4
View File
@@ -236,6 +236,10 @@ of the capture. This allows multiple outputs to run independently without interf
other.
The different types are enumerated in :class:`ReplayOutputType`.
.. data:: NoResult
No result was found in e.g. :meth:`PickVertex`.
)");
struct IReplayOutput
{
@@ -363,11 +367,13 @@ Should only be called for mesh outputs.
:param int x: The x co-ordinate to pick from.
:param int y: The y co-ordinate to pick from.
:return: A tuple with the first value being the vertex index in the mesh, and the second value being
the instance index. The values are set to ``0xffffffff`` if no vertex was found,
the instance index. The values are set to :data:`NoResult` if no vertex was found,
:rtype: ``tuple`` of ``int`` and ``int``
)");
virtual rdctype::pair<uint32_t, uint32_t> PickVertex(uint32_t eventID, uint32_t x, uint32_t y) = 0;
static const uint32_t NoResult = ~0U;
protected:
IReplayOutput() = default;
~IReplayOutput() = default;
@@ -375,6 +381,10 @@ protected:
DOCUMENT(R"(The primary interface to access a capture's information and control the replay and
analysis functionality available.
.. data:: NoPreference
No preference for a particular value, see :meth:`DebugPixel`.
)");
struct IReplayRenderer
{
@@ -664,7 +674,7 @@ newly generated messages will be returned after that.
:param int y: The y co-ordinate.
:param int sample: The multi-sampled sample. Ignored if non-multisampled texture.
:param int primitive: Debug the pixel from this primitive if there's ambiguity. If set to
``0xffffffff`` then a random fragment writing to the given co-ordinate is debugged.
:data:`NoPreference` then a random fragment writing to the given co-ordinate is debugged.
:return: The resulting trace resulting from debugging.
:rtype: ShaderDebugTrace
)");
@@ -749,6 +759,8 @@ sample 0, etc.
)");
virtual rdctype::array<byte> GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip) = 0;
static const uint32_t NoPreference = ~0U;
protected:
IReplayRenderer() = default;
~IReplayRenderer() = default;
@@ -854,6 +866,10 @@ DOCUMENT(R"(A connection to a running remote RenderDoc server on another machine
transfer of captures to and from the local machine, as well as remotely replaying a capture with a
local proxy renderer, so that captures that are not supported locally can still be debugged with as
much work as possible happening on the local machine.
.. data:: NoPreference
No preference for a particular value, see :meth:`DebugPixel`.
)");
struct IRemoteServer
{
@@ -976,7 +992,7 @@ or an error has occurred.
:meth:`ReplayRenderer.Shutdown`.
:param int proxyid: The index in the array returned by :meth:`LocalProxies` to use as a local proxy,
or ``0xffffffff`` to indicate no preference for any proxy.
or :data:`NoPreference` to indicate no preference for any proxy.
:param str logfile: The path on the remote system where the file is. If the file is only available
locally you can use :meth:`CopyCaptureToRemote` to transfer it over the remote connection.
:param float progress: A reference to a ``float`` value that will be updated as the copy happens
@@ -995,6 +1011,8 @@ or an error has occurred.
)");
virtual void CloseCapture(IReplayRenderer *rend) = 0;
static const uint32_t NoPreference = ~0U;
protected:
IRemoteServer() = default;
~IRemoteServer() = default;
@@ -1137,7 +1155,7 @@ This function will block for a variable timeout depending on how many targets ar
:param str host: The hostname to connect to. If blank, the local machine is used.
:param int nextIdent: The next ident to scan.
:return: The ident of the next active target, or ``0xffffffff`` if no other targets exist.
:return: The ident of the next active target, or ``0`` if no other targets exist.
:rtype: ``int``
)");
extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_EnumerateRemoteTargets(const char *host,
+8 -2
View File
@@ -243,6 +243,10 @@ DECLARE_REFLECTION_STRUCT(ShaderDebugTrace);
DOCUMENT(R"(The information describing an input or output signature element describing the interface
between shader stages.
.. data:: NoIndex
Value for an index that means it is invalid or not applicable for this parameter.
)");
struct SigParameter
{
@@ -274,7 +278,7 @@ struct SigParameter
DOCUMENT(R"(The index of the shader register/binding used to store this signature element.
This may be ``0xffffffff`` if the element is system-generated and not consumed by another shader
This may be :data:`NoIndex` if the element is system-generated and not consumed by another shader
stage. See :data:`systemValue`.
)");
uint32_t regIndex;
@@ -299,8 +303,10 @@ shader itself, for APIs that pack signatures together.
"Selects a stream for APIs that provide multiple output streams for the same named output.");
uint32_t stream;
DOCUMENT("If this element is part of an array, indicates the index, or ``0xffffffff`` if not.");
DOCUMENT("If this element is part of an array, indicates the index, or :data:`NoIndex` if not.");
uint32_t arrayIndex;
static const uint32_t NoIndex = ~0U;
};
DECLARE_REFLECTION_STRUCT(SigParameter);
+1 -1
View File
@@ -615,7 +615,7 @@ extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_EnumerateRemoteTargets(
}
// tried all idents remaining and found nothing
return ~0U;
return 0;
}
extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_GetDefaultRemoteServerPort()
+1 -1
View File
@@ -280,7 +280,7 @@ namespace renderdoc
nextIdent = RENDERDOC_EnumerateRemoteTargets(host_mem, nextIdent);
if (nextIdent == UInt32.MaxValue || prevIdent >= nextIdent)
if (nextIdent == 0 || prevIdent >= nextIdent)
break;
callback(nextIdent);