Pass through marker colours to UI

This commit is contained in:
baldurk
2016-05-27 19:28:58 +02:00
parent 7b3cb14186
commit 54106a2108
5 changed files with 66 additions and 1 deletions
+3
View File
@@ -325,6 +325,7 @@ struct FetchDrawcall
eventID = 0;
drawcallID = 0;
flags = 0;
markerColour[0] = markerColour[1] = markerColour[2] = markerColour[3] = 0.0f;
numIndices = 0;
numInstances = 0;
indexOffset = 0;
@@ -357,6 +358,8 @@ struct FetchDrawcall
uint32_t flags;
float markerColour[4];
uint32_t numIndices;
uint32_t numInstances;
int32_t baseVertex;
+3 -1
View File
@@ -1050,6 +1050,8 @@ void Serialiser::Serialise(const char *name, FetchDrawcall &el)
Serialise("", el.flags);
SerialisePODArray<4>("", el.markerColour);
Serialise("", el.numIndices);
Serialise("", el.numInstances);
Serialise("", el.baseVertex);
@@ -1078,7 +1080,7 @@ void Serialiser::Serialise(const char *name, FetchDrawcall &el)
Serialise("", el.events);
Serialise("", el.children);
SIZE_CHECK(FetchDrawcall, 240);
SIZE_CHECK(FetchDrawcall, 256);
}
template <>
@@ -58,6 +58,16 @@ bool WrappedID3D11DeviceContext::Serialise_SetMarker(uint32_t col, const wchar_t
draw.name = name;
draw.flags |= eDraw_SetMarker;
byte alpha = (colour >> 24) & 0xff;
byte red = (colour >> 16) & 0xff;
byte green = (colour >> 8) & 0xff;
byte blue = (colour >> 0) & 0xff;
draw.markerColour[0] = float(red) / 255.0f;
draw.markerColour[1] = float(green) / 255.0f;
draw.markerColour[2] = float(blue) / 255.0f;
draw.markerColour[3] = float(alpha) / 255.0f;
AddDrawcall(draw, false);
}
@@ -84,6 +94,16 @@ bool WrappedID3D11DeviceContext::Serialise_PushEvent(uint32_t col, const wchar_t
draw.name = name;
draw.flags |= eDraw_PushMarker;
byte alpha = (colour >> 24) & 0xff;
byte red = (colour >> 16) & 0xff;
byte green = (colour >> 8) & 0xff;
byte blue = (colour >> 0) & 0xff;
draw.markerColour[0] = float(red) / 255.0f;
draw.markerColour[1] = float(green) / 255.0f;
draw.markerColour[2] = float(blue) / 255.0f;
draw.markerColour[3] = float(alpha) / 255.0f;
AddDrawcall(draw, false);
}
@@ -2145,6 +2145,11 @@ bool WrappedVulkan::Serialise_vkCmdDebugMarkerBeginEXT(Serialiser *localSerialis
draw.name = name;
draw.flags |= eDraw_PushMarker;
draw.markerColour[0] = RDCCLAMP(color[0], 0.0f, 1.0f);
draw.markerColour[1] = RDCCLAMP(color[1], 0.0f, 1.0f);
draw.markerColour[2] = RDCCLAMP(color[2], 0.0f, 1.0f);
draw.markerColour[3] = RDCCLAMP(color[3], 0.0f, 1.0f);
AddDrawcall(draw, false);
}
@@ -2242,6 +2247,11 @@ bool WrappedVulkan::Serialise_vkCmdDebugMarkerInsertEXT(Serialiser *localSeriali
draw.name = name;
draw.flags |= eDraw_SetMarker;
draw.markerColour[0] = RDCCLAMP(color[0], 0.0f, 1.0f);
draw.markerColour[1] = RDCCLAMP(color[1], 0.0f, 1.0f);
draw.markerColour[2] = RDCCLAMP(color[2], 0.0f, 1.0f);
draw.markerColour[3] = RDCCLAMP(color[3], 0.0f, 1.0f);
AddDrawcall(draw, false);
}
+30
View File
@@ -511,6 +511,36 @@ namespace renderdoc
public string name;
public DrawcallFlags flags;
[CustomMarshalAs(CustomUnmanagedType.FixedArray, FixedLength = 4)]
public float[] markerColour;
public System.Drawing.Color GetColor()
{
float red = markerColour[0];
float green = markerColour[1];
float blue = markerColour[2];
float alpha = markerColour[3];
return System.Drawing.Color.FromArgb(
(int)(alpha * 255.0f),
(int)(red * 255.0f),
(int)(green * 255.0f),
(int)(blue * 255.0f)
);
}
public bool ShouldUseWhiteText()
{
float red = markerColour[0];
float green = markerColour[1];
float blue = markerColour[2];
float alpha = markerColour[3];
double luminance = 0.2126 * Math.Pow(red, 2.2) + 0.7152 * Math.Pow(green, 2.2) + 0.0722 * Math.Pow(blue, 2.2);
return luminance < 0.2;
}
public UInt32 numIndices;
public UInt32 numInstances;