Skip to content

Commit 989a3a0

Browse files
authored
[NFC] Fix most egregious clang-format missteps (microsoft#5642)
This change fixes a few of the most awful clang-format missteps in the codebase. I'm not intending to fix all the things clang-format will do something bad with, just a few of the worst ones. Further formatting fixups can be done after the clang-format change goes in.
1 parent 50c4c88 commit 989a3a0

File tree

3 files changed

+66
-37
lines changed

3 files changed

+66
-37
lines changed

include/dxc/DxilContainer/DxilContainerReader.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// This file is distributed under the University of Illinois Open Source //
66
// License. See LICENSE.TXT for details. //
77
// //
8-
// Helper class for reading from dxil container. //
8+
// Helper class for reading from dxil container. //
99
// //
1010
///////////////////////////////////////////////////////////////////////////////
1111

@@ -22,20 +22,23 @@ namespace hlsl {
2222

2323
struct DxilContainerHeader;
2424

25-
//=================================================================================================================================
25+
//============================================================================
2626
// DxilContainerReader
2727
//
2828
// Parse a DXIL or DXBC Container that you provide as input.
2929
//
3030
// Basic usage:
3131
// (1) Call Load()
32-
// (2) Call various Get*() commands to retrieve information about the container such as
33-
// how many blobs are in it, the hash of the container, the version #, and most importantly
34-
// retrieve all of the Blobs. You can retrieve blobs by searching for the FourCC, or
35-
// enumerate through all of them. Multiple blobs can even have the same FourCC, if you choose to
36-
// create the DXBC that way, and this parser will let you discover all of them.
37-
// (3) You can parse a new container by calling Load() again, or just get rid of the class.
38-
//
32+
// (2) Call various Get*() commands to retrieve information about the
33+
// container such as how many blobs are in it, the hash of the container,
34+
// the version #, and most importantly retrieve all of the Blobs. You can
35+
// retrieve blobs by searching for the FourCC, or enumerate through all of
36+
// them. Multiple blobs can even have the same FourCC, if you choose to
37+
// create the DXBC that way, and this parser will let you discover all of
38+
// them.
39+
// (3) You can parse a new container by calling Load() again, or just get rid
40+
// of the class.
41+
//
3942
class DxilContainerReader
4043
{
4144
public:
@@ -64,4 +67,4 @@ namespace hlsl {
6467
bool IsLoaded() const { return m_pHeader != nullptr; }
6568
};
6669

67-
} // namespace hlsl
70+
} // namespace hlsl

include/dxc/DxilContainer/RDAT_Macros.inl

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,40 @@
1818
// and code.
1919
// While some of associated macros sets are not defined in this file, these
2020
// definitions allow custom paths in the type definition files in certain cases.
21-
#define DEF_RDAT_DEFAULTS 1 // DEF_RDAT_TYPES and DEF_RDAT_ENUMS - define empty macros for anything not already defined
22-
#define DEF_RDAT_TYPES_BASIC_STRUCT 2 // DEF_RDAT_TYPES - define structs with basic types, matching RDAT format
23-
#define DEF_RDAT_TYPES_USE_HELPERS 3 // DEF_RDAT_TYPES - define structs using helpers, matching RDAT format
24-
#define DEF_RDAT_DUMP_DECL 4 // DEF_RDAT_TYPES and DEF_RDAT_ENUMS - write dump declarations
25-
#define DEF_RDAT_DUMP_IMPL 5 // DEF_RDAT_TYPES and DEF_RDAT_ENUMS - write dump implementation
26-
#define DEF_RDAT_TYPES_USE_POINTERS 6 // DEF_RDAT_TYPES - define deserialized version using pointers instead of offsets
27-
#define DEF_RDAT_ENUM_CLASS 7 // DEF_RDAT_ENUMS - declare enums with enum class
28-
#define DEF_RDAT_TRAITS 8 // DEF_RDAT_TYPES - define type traits
29-
#define DEF_RDAT_TYPES_FORWARD_DECL 9 // DEF_RDAT_TYPES - forward declare type struct/class
30-
#define DEF_RDAT_READER_DECL 10 // DEF_RDAT_TYPES and DEF_RDAT_ENUMS - write reader classes
31-
#define DEF_RDAT_READER_IMPL 11 // DEF_RDAT_TYPES and DEF_RDAT_ENUMS - write reader classes
32-
#define DEF_RDAT_STRUCT_VALIDATION 13 // DEF_RDAT_TYPES and DEF_RDAT_ENUMS - define structural validation
21+
22+
// DEF_RDAT_TYPES and DEF_RDAT_ENUMS - define empty macros for anything not
23+
// already defined
24+
#define DEF_RDAT_DEFAULTS 1
25+
// DEF_RDAT_TYPES - define structs with basic types, matching RDAT format
26+
#define DEF_RDAT_TYPES_BASIC_STRUCT 2
27+
// DEF_RDAT_TYPES - define structs using helpers, matching RDAT format
28+
#define DEF_RDAT_TYPES_USE_HELPERS 3
29+
// DEF_RDAT_TYPES and DEF_RDAT_ENUMS - write dump declarations
30+
#define DEF_RDAT_DUMP_DECL 4
31+
// DEF_RDAT_TYPES and DEF_RDAT_ENUMS - write dump implementation
32+
#define DEF_RDAT_DUMP_IMPL 5
33+
// DEF_RDAT_TYPES - define deserialized version using pointers instead of
34+
// offsets
35+
#define DEF_RDAT_TYPES_USE_POINTERS 6
36+
// DEF_RDAT_ENUMS - declare enums with enum class
37+
#define DEF_RDAT_ENUM_CLASS 7
38+
// DEF_RDAT_TYPES - define type traits
39+
#define DEF_RDAT_TRAITS 8
40+
// DEF_RDAT_TYPES - forward declare type struct/class
41+
#define DEF_RDAT_TYPES_FORWARD_DECL 9
42+
// DEF_RDAT_TYPES and DEF_RDAT_ENUMS - write reader classes
43+
#define DEF_RDAT_READER_DECL 10
44+
// DEF_RDAT_TYPES and DEF_RDAT_ENUMS - write reader classes
45+
#define DEF_RDAT_READER_IMPL 11
46+
// DEF_RDAT_TYPES and DEF_RDAT_ENUMS - define structural validation
47+
#define DEF_RDAT_STRUCT_VALIDATION 13
48+
3349
// PRERELEASE-TODO: deeper validation for DxilValidation (limiting enum values and other such things)
3450

51+
// clang-format off
52+
#define CLOSE_COMPOUND_DECL };
53+
// clang-format on
54+
3555
#define GLUE2(a, b) a##b
3656
#define GLUE(a, b) GLUE2(a, b)
3757

@@ -48,9 +68,9 @@
4868
#define RDAT_STRUCT(type) struct type {
4969
#define RDAT_STRUCT_DERIVED(type, base) \
5070
struct type : public base {
51-
#define RDAT_STRUCT_END() };
71+
#define RDAT_STRUCT_END() CLOSE_COMPOUND_DECL
5272
#define RDAT_UNION() union {
53-
#define RDAT_UNION_END() };
73+
#define RDAT_UNION_END() CLOSE_COMPOUND_DECL
5474
#define RDAT_RECORD_REF(type, name) uint32_t name;
5575
#define RDAT_RECORD_ARRAY_REF(type, name) uint32_t name;
5676
#define RDAT_RECORD_VALUE(type, name) type name;
@@ -67,9 +87,9 @@
6787

6888
#define RDAT_STRUCT(type) struct type {
6989
#define RDAT_STRUCT_DERIVED(type, base) struct type : public base {
70-
#define RDAT_STRUCT_END() };
90+
#define RDAT_STRUCT_END() CLOSE_COMPOUND_DECL
7191
#define RDAT_UNION() union {
72-
#define RDAT_UNION_END() };
92+
#define RDAT_UNION_END() CLOSE_COMPOUND_DECL
7393
#define RDAT_RECORD_REF(type, name) RecordRef<type> name;
7494
#define RDAT_RECORD_ARRAY_REF(type, name) RecordArrayRef<type> name;
7595
#define RDAT_RECORD_VALUE(type, name) type name;
@@ -100,7 +120,7 @@
100120
type##_Reader(); \
101121
const RecordType *asRecord() const; \
102122
const RecordType *operator->() const { return asRecord(); }
103-
#define RDAT_STRUCT_END() };
123+
#define RDAT_STRUCT_END() CLOSE_COMPOUND_DECL
104124
#define RDAT_UNION_IF(name, expr) bool has##name() const;
105125
#define RDAT_UNION_ELIF(name, expr) RDAT_UNION_IF(name, expr)
106126
#define RDAT_RECORD_REF(type, name) type##_Reader get##name() const;
@@ -304,7 +324,7 @@
304324
#define RDAT_ENUM_VALUE(name, value) name = value,
305325
#define RDAT_ENUM_VALUE_ALIAS(name, value) name = value,
306326
#define RDAT_ENUM_VALUE_NODEF(name) name,
307-
#define RDAT_ENUM_END() };
327+
#define RDAT_ENUM_END() CLOSE_COMPOUND_DECL
308328

309329
#elif DEF_RDAT_ENUMS == DEF_RDAT_DUMP_DECL
310330

include/dxc/HLSL/DxilSignatureAllocator.inl

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -280,25 +280,31 @@ unsigned DxilSignatureAllocator::PackOptimized(std::vector<PackElement*> element
280280
unsigned rowsUsed = 0;
281281

282282
// Clip/Cull needs special handling due to limitations unique to these.
283-
// Otherwise, packer could easily pack across too many registers in available gaps.
283+
// Otherwise, packer could easily pack across too many registers in available
284+
// gaps.
284285
// The rules are special/weird:
285-
// - for interpolation mode, clip must be linear or linearCentroid, while cull may be anything
286+
// - for interpolation mode, clip must be linear or linearCentroid, while
287+
// cull may be anything
286288
// - both have a maximum of 8 components shared between them
287-
// - you can have a combined maximum of two registers declared with clip or cull SV's
289+
// - you can have a combined maximum of two registers declared with clip or
290+
// cull SV's
288291
// other SV rules still apply:
289292
// - X no indexing allowed X - This rule has been changed to allow indexing
290293
// - cannot come before arbitrary values in same register
291294
// Strategy for dealing with these with rows == 1 for all elements:
292295
// - attempt to pack these into a two register allocator
293-
// - if this fails, some constraint is blocking, or declaration order is preventing good packing
294-
// for example: 2, 1, 2, 3 - total 8 components and packable, but if greedily packed, it will fail
295-
// Packing largest to smallest would solve this.
296-
// - track components used for each register and create temp elements for allocation tests
296+
// - if this fails, some constraint is blocking, or declaration order is
297+
// preventing good packing for example: 2, 1, 2, 3 - total 8 components
298+
// and packable, but if greedily packed, it will fail Packing largest to
299+
// smallest would solve this.
300+
// - track components used for each register and create temp elements for
301+
// allocation tests
297302
// - iterate rows and look for a viable location for each temp element
298303
// When found, allocate original sub-elements associated with temp element.
299304
// If one or more clip/cull elements have rows > 1:
300-
// - walk through each pair of adjacent rows, initializing a temp two-row allocator
301-
// with existing contents and trying to pack all elements into the remaining space.
305+
// - walk through each pair of adjacent rows, initializing a temp two-row
306+
// allocator with existing contents and trying to pack all elements into
307+
// the remaining space.
302308
// - when successful, do real allocation into these rows.
303309

304310
// Packing overview

0 commit comments

Comments
 (0)