diff --git a/Content/Content.vcxitems b/Content/Content.vcxitems index 874a615d51d..a39875f28d0 100644 --- a/Content/Content.vcxitems +++ b/Content/Content.vcxitems @@ -597,10 +597,14 @@ + + + + @@ -609,6 +613,7 @@ + diff --git a/Content/Content.vcxitems.filters b/Content/Content.vcxitems.filters index 951aba8480c..6c2a8f3d220 100644 --- a/Content/Content.vcxitems.filters +++ b/Content/Content.vcxitems.filters @@ -569,6 +569,21 @@ scripts\character_controller\assets + + scripts\character_controller\assets + + + models\Sponza + + + scripts\character_controller + + + scripts\dungeon_generator + + + scripts\fighting_game + diff --git a/Content/Documentation/ScriptingAPI-Documentation.md b/Content/Documentation/ScriptingAPI-Documentation.md index cbe14ba38c3..518c4ea687f 100644 --- a/Content/Documentation/ScriptingAPI-Documentation.md +++ b/Content/Documentation/ScriptingAPI-Documentation.md @@ -48,7 +48,7 @@ This is a reference and explanation of Lua scripting features in Wicked Engine. 19. [DecalComponent](#decalcomponent) 10. [Canvas](#canvas) 11. [High Level Interface](#high-level-interface) - 1. [MainComponent](#maincomponent) + 1. [Application](#application) 2. [RenderPath](#renderpath) 1. [RenderPath2D](#renderpath2d) 2. [RenderPath3D](#renderpath3d) @@ -60,6 +60,10 @@ This is a reference and explanation of Lua scripting features in Wicked Engine. 4. [Capsule](#capsule) 12. [Input](#input) 13. [Physics](#physics) + 14. [Path finding](#path-finding) + 1. [VoxelGrid](#voxelgrid) + 2. [PathQuery](#pathquery) + 15. [TrailRenderer](#trailrenderer) ## Introduction and usage Scripting in Wicked Engine is powered by Lua, meaning that the user can make use of the @@ -153,11 +157,29 @@ You can use the Renderer with the following functions, all of which are in the g [outer]DEBUG_TEXT_DEPTH_TEST -- text can be occluded by geometry [outer]DEBUG_TEXT_CAMERA_FACING -- text will be rotated to face the camera [outer]DEBUG_TEXT_CAMERA_SCALING -- text will be always the same size, independent of distance to camera +- DrawVoxelGrid(VoxelGrid voxelgrid) -- draws the voxel grid in the debug rendering phase. VoxelGrid object must not be destroyed until then! +- DrawPathQuery(PathQuery pathquery) -- draws the path query in the debug rendering phase. PathQuery object must not be destroyed until then! +- DrawTrail(TrailRenderer trail) -- draws the trail in the debug rendering phase. TrailRenderer object must not be destroyed until then! +- PaintIntoTexture(PaintTextureParams params) +- CreatePaintableTexture(int width,height, opt int mips = 0, opt Vector initialColor = Vector()) -- creates a texture that can be used for destination of PaintIntoTexture() - PutWaterRipple(Vector position) -- put down a water ripple with default embedded asset - PutWaterRipple(string imagename, Vector position) -- put down water ripple texture from image asset file - ClearWorld(opt Scene scene) -- Clears the scene and the associated renderer resources. If parmaeter is not specified, it will clear the global scene - ReloadShaders() +#### PaintTextureParams +- [constructor]PaintTextureParams +- SetEditTexture(Texture tex) +- SetBrushTexture(Texture tex) +- SetRevealTexture(Texture tex) +- SetBrushColor(Vector value) +- SetCenterPixel(Vector value) +- SetBrushRadius(int value) +- SetBrushAmount(float value) +- SetBrushSmoothness(float value) +- SetBrushRotation(float value) +- SetBrushShape(int value) -- 0 = circle, 1 = rectangle + ### Sprite Render images on the screen. - Params : ImageParams @@ -174,6 +196,8 @@ Render images on the screen. - GetTexture() : Texture - SetMaskTexture(Texture texture) - GetMaskTexture() : Texture +- SetHidden(bool value) +- IsHidden() : bool #### ImageParams Specify Sprite properties, like position, size, etc. @@ -231,6 +255,8 @@ Specify Sprite properties, like position, size, etc. - DisableMirror() - EnableBackgroundBlur(opt float mip = 0) - DisableBackgroundBlur() +- SetMaskAlphaRange(float start, end) +- GetMaskAlphaRange() : float start, end - [outer]STENCILMODE_DISABLED : int - [outer]STENCILMODE_EQUAL : int @@ -463,11 +489,13 @@ Loads and plays an audio files. #### Sound An audio file. Can be instanced several times via SoundInstance. - [constructor]Sound() -- creates an empty sound. Use the audio device to load sounds from files +- [constructor]Sound(string name) -- loads a sound from a file - IsValid() : bool -- returns whether the sound was created successfully #### SoundInstance An audio file instance that can be played. Note: after modifying parameters of the SoundInstance, the SoundInstance will need to be recreated from a specified sound - [constructor]SoundInstance() -- creates an empty soundinstance. Use the audio device to clone sounds +- [constructor]SoundInstance(Sound sound, opt float begin,length) -- creates a soundinstance from a sound - SetSubmixType(int submixtype) -- set a submix type group (default is SUBMIX_TYPE_SOUNDEFFECT) - SetBegin(float seconds) -- beginning of the playback in seconds, relative to the Sound it will be created from (0 = from beginning) - SetLength(float seconds) -- length in seconds (0 = until end) @@ -578,6 +606,7 @@ A four component floating point vector. Provides efficient calculations with SIM - Cross(Vector v1,v2) : Vector result - Lerp(Vector v1,v2, float t) : Vector result - Rotate(Vector v1,quaternion) : Vector result -- rotates the first argument 3D vector with the second argument quaternion +- QuaternionIdentity() : Vector resultQuaternion -- return a quaternion representing identity orientation - QuaternionInverse(Vector quaternion) : Vector resultQuaternion - QuaternionMultiply(Vector quaternion1,quaternion2) : Vector resultQuaternion - QuaternionFromRollPitchYaw(Vector rotXYZ) : Vector resultQuaternion @@ -604,6 +633,13 @@ A four by four matrix, efficient calculations with SIMD support. - Add(Matrix m1,m2) : Matrix result - Transpose(Matrix m) : Matrix result - Inverse(Matrix m) : Matrix result, float determinant +- GetForward() : Vector -- returns forward direction of self +- GetUp() : Vector -- returns upwards direction of self +- GetRight() : Vector -- returns right direction of self +- GetForward(Matrix mat) : Vector -- returns forward direction of parameter matrix +- GetUp(Matrix mat) : Vector -- returns upwards direction of parameter matrix +- GetRight(Matrix mat) : Vector -- returns right direction of parameter matrix + ### Scene System (using entity-component system) Manipulate the 3D scene with these components. @@ -634,7 +670,8 @@ The scene holds components. Entity handles can be used to retrieve associated co - [outer]FILTER_OBJECT_ALL : uint -- include all objects, meshes - [outer]FILTER_COLLIDER : uint -- include colliders - [outer]FILTER_ALL : uint -- include everything -- Intersects(Ray|Sphere|Capsule primitive, opt uint filterMask = ~0u, opt uint layerMask = ~0u, opt uint lod = 0) : int entity, Vector position,normal, float distance, Vector velocity, int subsetIndex, Matrix orientation -- intersects a primitive with the scene and returns collision parameters +- Intersects(Ray|Sphere|Capsule primitive, opt uint filterMask = ~0u, opt uint layerMask = ~0u, opt uint lod = 0) : int entity, Vector position,normal, float distance, Vector velocity, int subsetIndex, Matrix orientation, Vector uv -- intersects a primitive with the scene and returns collision parameters +- IntersectsFirst(Ray primitive, opt uint filterMask = ~0u, opt uint layerMask = ~0u, opt uint lod = 0) : bool -- intersects a primitive with the scene and returns true immediately on intersection, false if there was no intersection. This can be faster for occlusion check than regular `Intersects` that searches for closest intersection. - Update() -- updates the scene and every entity and component inside the scene - Clear() -- deletes every entity and component inside the scene - Merge(Scene other) -- moves contents from an other scene into this one. The other scene will be empty after this operation (contents are moved, not copied) @@ -650,6 +687,7 @@ The scene holds components. Entity handles can be used to retrieve associated co - Component_CreateName(Entity entity) : NameComponent result -- attach a name component to an entity. The returned component is associated with the entity and can be manipulated - Component_CreateLayer(Entity entity) : LayerComponent result -- attach a layer component to an entity. The returned component is associated with the entity and can be manipulated - Component_CreateTransform(Entity entity) : TransformComponent result -- attach a transform component to an entity. The returned component is associated with the entity and can be manipulated +- Component_CreateCamera(Entity entity) : CameraComponent result -- attach a camera component to an entity. The returned component is associated with the entity and can be manipulated - Component_CreateLight(Entity entity) : LightComponent result -- attach a light component to an entity. The returned component is associated with the entity and can be manipulated - Component_CreateObject(Entity entity) : ObjectComponent result -- attach an object component to an entity. The returned component is associated with the entity and can be manipulated - Component_CreateInverseKinematics(Entity entity) : InverseKinematicsComponent result -- attach an IK component to an entity. The returned component is associated with the entity and can be manipulated @@ -666,6 +704,7 @@ The scene holds components. Entity handles can be used to retrieve associated co - Component_CreateDecal(Entity entity) : DecalComponent result -- attach a DecalComponent to an entity. The returned component is associated with the entity and can be manipulated - Component_CreateSprite(Entity entity) : Sprite result -- attach a Sprite to an entity. The returned component is associated with the entity and can be manipulated - Component_CreateFont(Entity entity) : SpriteFont result -- attach a SpriteFont to an entity. The returned component is associated with the entity and can be manipulated +- Component_CreateVoxelGrid(Entity entity) : VoxelGrid result -- attach a VoxelGrid to an entity. The returned component is associated with the entity and can be manipulated - Component_GetName(Entity entity) : NameComponent? result -- query the name component of the entity (if exists) - Component_GetLayer(Entity entity) : LayerComponent? result -- query the layer component of the entity (if exists) @@ -689,7 +728,7 @@ The scene holds components. Entity handles can be used to retrieve associated co - Component_GetHumanoid(Entity entity) : HumanoidComponent? result -- query the HumanoidComponent of the entity (if exists) - Component_GetDecal(Entity entity) : DecalComponent? result -- query the DecalComponent of the entity (if exists) - Component_GetSprite(Entity entity) : Sprite? result -- query the Sprite of the entity (if exists) -- Component_GetFont(Entity entity) : SpriteFont? result -- query the SpriteFont of the entity (if exists) +- Component_GetVoxexlGrid(Entity entity) : VoxelGrid? result -- query the VoxelGrid of the entity (if exists) - Component_GetNameArray() : NameComponent[] result -- returns the array of all components of this type - Component_GetLayerArray() : LayerComponent[] result -- returns the array of all components of this type @@ -700,6 +739,7 @@ The scene holds components. Entity handles can be used to retrieve associated co - Component_GetEmitterArray() : EmitterComponent[] result -- returns the array of all components of this type - Component_GetLightArray() : LightComponent[] result -- returns the array of all components of this type - Component_GetObjectArray() : ObjectComponent[] result -- returns the array of all components of this type +- Component_GetMeshArray() : MeshComponent[] result -- returns the array of all components of this type - Component_GetInverseKinematicsArray() : InverseKinematicsComponent[] result -- returns the array of all components of this type - Component_GetSpringArray() : SpringComponent[] result -- returns the array of all components of this type - Component_GetScriptArray() : ScriptComponent[] result -- returns the array of all components of this type @@ -714,6 +754,7 @@ The scene holds components. Entity handles can be used to retrieve associated co - Component_GetDecalArray() : DecalComponent[] result -- returns the array of all components of this type - Component_GetSpriteArray() : Sprite[] result -- returns the array of all components of this type - Component_GetFontArray() : SpriteFont[] result -- returns the array of all components of this type +- Component_GetVoxelGridArray() : VoxelGrid[] result -- returns the array of all components of this type - Entity_GetNameArray() : Entity[] result -- returns the array of all entities that have this component type - Entity_GetLayerArray() : Entity[] result -- returns the array of all entities that have this component type @@ -725,6 +766,7 @@ The scene holds components. Entity handles can be used to retrieve associated co - Entity_GetEmitterArray() : Entity[] result -- returns the array of all entities that have this component type - Entity_GetLightArray() : Entity[] result -- returns the array of all entities that have this component type - Entity_GetObjectArray() : Entity[] result -- returns the array of all entities that have this component type +- Entity_GetMeshArray() : Entity[] result -- returns the array of all entities that have this component type - Entity_GetInverseKinematicsArray() : Entity[] result -- returns the array of all entities that have this component type - Entity_GetSpringArray() : Entity[] result -- returns the array of all entities that have this component type - Entity_GetScriptArray() : Entity[] result -- returns the array of all entities that have this component type @@ -739,6 +781,7 @@ The scene holds components. Entity handles can be used to retrieve associated co - Entity_GetDecalArray() : Entity[] result -- returns the array of all entities that have this component type - Entity_GetSpriteArray() : Entity[] result -- returns the array of all entities that have this component type - Entity_GetFontArray() : Entity[] result -- returns the array of all entities that have this component type +- Entity_GetVoxelGridArray() : Entity[] result -- returns the array of all entities that have this component type - Component_RemoveName(Entity entity) -- remove the name component of the entity (if exists) - Component_RemoveLayer(Entity entity) -- remove the layer component of the entity (if exists) @@ -764,6 +807,7 @@ The scene holds components. Entity handles can be used to retrieve associated co - Component_RemoveDecal(Entity entity) -- remove the DecalComponent of the entity (if exists) - Component_RemoveSprite(Entity entity) -- remove the Sprite of the entity (if exists) - Component_RemoveFont(Entity entity) -- remove the SpriteFont of the entity (if exists) +- Component_RemoveVoxelGrid(Entity entity) -- remove the VoxelGrid of the entity (if exists) - Component_Attach(Entity entity,parent, opt bool child_already_in_local_space = false) -- attaches entity to parent (adds a hierarchy component to entity). From now on, entity will inherit certain properties from parent, such as transform (entity will move with parent) or layer (entity's layer will be a sublayer of parent's layer). If child_already_in_local_space is false, then child will be transformed into parent's local space, if true, it will be used as-is. - Component_Detach(Entity entity) -- detaches entity from parent (if hierarchycomponent exists for it). Restores entity's original layer, and applies current transformation to entity @@ -773,9 +817,11 @@ The scene holds components. Entity handles can be used to retrieve associated co - GetWeather() : WeatherComponent - SetWeather(WeatherComponent weather) - - RetargetAnimation(Entity dst, src, bool bake_data) : Entity entity -- Retargets an animation from a Humanoid to an other Humanoid such that the new animation will play back on the destination humanoid. dst : destination humanoid that the animation will be fit onto src : the animation to copy, it should already target humanoid bones. bake_data : if true, the retargeted data will be baked into a new animation data. If false, it will reuse the source animation data without creating a new one and retargeting will be applied at runtime on every Update. Returns entity ID of the new animation or INVALID_ENTITY if retargeting was not successful +- VoxelizeObject(int objectIndex, VoxelGrid voxelgrid, opt bool subtract = false, opt int lod = 0) -- voxelizes a single object into the voxel grid. Subtract parameter controls whether the voxels are added (true) or removed (false). Lod argument selects object's level of detail +- VoxelizeScene(VoxelGrid voxelgrid, opt bool subtract = false, opt uint filterMask = ~0u, opt uint layerMask = ~0u, opt uint lod = 0) -- voxelizes all entities in the scene which intersect the voxel grid volume and match the filterMask and layerMask. Subtract parameter controls whether the voxels are added (true) or removed (false). Lod argument selects object's level of detail + #### NameComponent Holds a string that can more easily identify an entity to humans than an entity ID. - Name : string @@ -813,6 +859,11 @@ Describes an orientation in 3D space. - SetScale(Vector value) -- set scale in local space - SetRotation(Vector quaternnion) -- set rotation quaternion in local space - SetPosition(Vector value) -- set position in local space +- SetDirty(bool value) -- invalidate, this will cause transfomr to be updated in next scene update +- IsDirty() : bool -- check if transform was invalidated since last update +- GetForward() : Vector -- returns forward direction +- GetUp() : Vector -- returns upwards direction +- GetRight() : Vector -- returns right direction #### CameraComponent - FOV : float @@ -919,6 +970,8 @@ Describes an orientation in 3D space. - GetTexture(TextureSlot slot) : Texture - GetTextureName(TextureSlot slot) : string - GetTextureUVSet(TextureSlot slot) : int uvset +- SetCastShadow(bool value) +- IsCastingShadow() : bool ```lua TextureSlot = { @@ -948,6 +1001,7 @@ TextureSlot = { - SetMeshSubsetMaterialID(int subsetindex, Entity materialID) - GetMeshSubsetMaterialID(int subsetindex) : Entity entity +- CreateSubset() : int -- creates subset containing all faces, returns subset index #### EmitterComponent - _flags : int @@ -990,6 +1044,8 @@ TextureSlot = { - SetScaleY(float value) -- set scaling along lifetime in Y axis - SetRotation(float value) -- set rotation speed - SetMotionBlurAmount(float value) -- set the motion elongation factor +- SetCollidersDisabled(bool value) -- disable GPU colliders +- IsCollidersDisabled() #### HairParticleSystem - _flags : int @@ -1206,6 +1262,10 @@ Describes a Sound object. - IsPlaying() : bool result -- Check if sound is playing - IsLooped() : bool result -- Check if sound is looping - IsDisabled() : bool result -- Check if sound is disabled +- SetSound(Sound sound) +- SetSoundInstance(SoundInstance inst) +- GetSound() : Sound +- GetSoundInstance() : SoundInstance #### ColliderComponent Describes a Collider object. @@ -1275,6 +1335,10 @@ Describes a Collider object. - SetLookAt(Vector value) -- Set a target lookAt position (for head an eyes movement) - SetRagdollPhysicsEnabled(bool value) -- Activate dynamic ragdoll physics. Note that kinematic ragdoll physics is always active (ragdoll is animation-driven/kinematic by default). - IsRagdollPhysicsEnabled() : bool +- SetRagdollFatness(float value) -- Control the overall fatness of the ragdoll body parts except head (default: 1) +- SetRagdollHeadSize(float value) -- Control the overall size of the ragdoll head (default: 1) +- GetRagdollFatness() : float +- GetRagdollHeadSize() : float [outer] HumanoidBone = { Hips = 0, @@ -1367,7 +1431,7 @@ This is the main entry point and manages the lifetime of the application. - [void-constructor]Application() - GetContent() : Resource? result - GetActivePath() : RenderPath? result -- SetActivePath(RenderPath path, opt float fadeSeconds,fadeColorR,fadeColorG,fadeColorB) +- SetActivePath(RenderPath path, opt float fadeSeconds, opt int fadeColorR = 0, fadeColorG = 0, fadeColorB = 0) - SetFrameSkip(bool enabled) -- enable/disable frame skipping in fixed update - SetTargetFrameRate(float fps) -- set target frame rate for fixed update and variable rate update when frame rate is locked - SetFrameRateLock(bool enabled) -- if enabled, variable rate update will use a fixed delta time @@ -1382,6 +1446,8 @@ This is the main entry point and manages the lifetime of the application. - SetVRAMUsageDisplay(bool active) -- toggle display of video memory usage if info display is enabled - GetCanvas() : Canvas canvas -- returns a copy of the application's current canvas - SetCanvas(Canvas canvas) -- applies the specified canvas to the application +- Exit() -- Closes the program +- IsFaded() -- returns true when fadeout is full (fadeout can be set when switching paths with SetActivePath()) - [outer]SetProfilerEnabled(bool enabled) ### RenderPath @@ -1419,6 +1485,7 @@ It inherits functions from RenderPath2D, so it can render a 2D overlay. - AO_MSAO : int -- enable multi scale screen space ambient occlusion (use in SetAO() function) - SetAOPower(float value) -- applies AO power value if any AO is enabled - SetSSREnabled(bool value) +- SetSSGIEnabled(bool value) - SetRaytracedDiffuseEnabled(bool value) - SetRaytracedReflectionsEnabled(bool value) - SetShadowsEnabled(bool value) @@ -1473,8 +1540,13 @@ Tonemap = { It is a RenderPath2D but one that internally manages resource loading and can display information about the process. It inherits functions from RenderPath2D. - [constructor]LoadingScreen() -- AddLoadingTask(string taskScript) -- OnFinished(string taskScript) +- AddLoadModelTask(string fileName, Matrix matrix) : Entity -- Adds a scene loading task into the global scene and returns the root entity handle immediately. The loading task will be started asynchronously when the LoadingScreen is activated by the Application. +- AddLoadModelTask(Scene scene, string fileName, Matrix matrix) : Entity -- Adds a scene loading task into the specified scene and returns the root entity handle immediately. The loading task will be started asynchronously when the LoadingScreen is activated by the Application. +- AddRenderPathActivationTask(RenderPath path, opt float fadeSeconds = 0, opt int fadeR = 0,fadeG = 0,fadeB = 0) -- loads resources of a RenderPath and activates it after all loading tasks have finished +- IsFinished() : bool -- returns true when all loading tasks have finished +- GetProgress() : int -- returns percentage of loading complete (0% - 100%) +- SetBackgroundTexture(Texture tex) -- set a full screen background texture that wil be displayed when loading screen is active +- GetBackgroundTexture() : Texture ### Primitives @@ -1722,3 +1794,78 @@ Playstation button codes: Tracks a physics pick drag operation. Use it with `phyiscs.PickDrag()` function. When using this object first time to PickDrag, the operation will be started and the operation will end when you call Finish() or when the object is destroyed - [constructor]PickDragOperation() -- creates the object - Finish() -- finish the operation, puts down the physics object + + +### Path finding +Path finding operations can be made by using a voxel grid and path queries. The voxel grid can store spatial information about a scene, or a part of the scene, while the path query manages the path finding result from a point to a different point within the voxel grid. + +#### VoxelGrid +- [constructor] VoxelGrid(opt int dimX,dimY,dimZ) -- if you give parameters, it will work like the Init() function +- Init(int dimX,dimY,dimZ) -- Allocates memory for dimX * dimY * dimZ number of voxels and initializes them to empty +- ClearData() -- initializes all voxels to empty +- FromAABB(AABB aabb) -- places the voxel grid volume to fit to the given AABB. The number of voxels doesn't change, only the center and voxel size +- InjectTriangle(Vector a,b,c, opt bool subtract = false) -- voxelizes triangle, and either adds it to the voxels (default), or removes voxels +- InjectAABB(AABB aabb, opt bool subtract = false) -- voxelizes axis aligned bounding box, and either adds it to the voxels (default), or removes voxels +- InjectSphere(Sphere sphere, opt bool subtract = false) -- voxelizes sphere, and either adds it to the voxels (default), or removes voxels +- InjectCapsule(Capsule capsule, opt bool subtract = false) -- voxelizes capsule, and either adds it to the voxels (default), or removes voxels +- WorldToCoord(Vector pos) : int x,y,z -- converts a position in world space to voxel coordinate +- CoordToWorld(int x,y,z) : Vector -- converts voxel coordinate to world space position +- CheckVoxel(Vector pos) : bool -- returns false if voxel is empty, true if it's valid +- CheckVoxel(int x,y,z) : bool -- returns false if voxel is empty, true if it's valid +- SetVoxel(Vector pos, bool value) -- sets a single voxel to the specified state +- SetVoxel(int x,y,z, bool value) -- sets a single voxel to the specified state +- GetCenter() : Vector -- returns the center of the voxel grid volume +- SetCenter(Vector pos) -- sets the center of the voxel grid volume +- GetVoxelSize() : Vector -- get the half extent of one voxel in world space +- SetVoxelSize(Vector voxelsize) -- sets the half extent of one voxel in world space +- SetVoxelSize(float voxelsize) -- sets the half extent of one voxel in world space uniformly in all dimension +- GetDebugColor() : Vector -- returns color of debug visualization of voxels +- SetDebugColor(Vector color) -- set the color for debug visualization of voxels +- GetDebugColorExtent() : Vector -- returns color of debug visualization of voxel grid extents +- SetDebugColorExtent(Vector color) -- set the color for debug visualization of voxel grid extents +- GetMemorySize() : int -- returns the memory consumption of the voxel grid in bytes +- IsVisible(int observer_x,observer_y,observer_z, subject_x,subject_y,subject_z) : bool -- performs line of sight occlusion test from observer to subject voxel coordinates. Returns false if occlusion was found, true otherwise. +- IsVisible(AABB observer, subject) : bool -- performs line of sight occlusion test from observer to subject world space points. Returns false if occlusion was found, true otherwise. +- IsVisible(AABB observer, AABB subject) : bool -- performs line of sight occlusion test from observer world space point to subject AABB. Returns true if any of the AABB's touched voxels is visible, false otherwise. + +#### PathQuery +- [constructor] PathQuery() +- Process(Vector start,goal, VoxelGrid voxelgrid) -- computes the path from start to goal on a voxel grid and stores the result +- SearchCover(Vector observer,subject,direction, float max_distance, VoxelGrid voxelgrid) -- searches for a cover for subject position to hide from observer. The search will be in a specific direction, within the specified distance (approximately, within voxel precision) +- IsSuccesful() : bool -- returns whether the last call to Process() was succesfully able to find a path +- GetNextWaypoint() : Vector -- Get the next waypoint on the path from the starting location. This requires that Process() has been called beforehand. +- SetDebugDrawWaypointsEnabled(bool value) -- Enable/disable waypoint debug rendering when using DrawPathQuery(). If enabled, voxel waypoints will be drawn in blue, simplified voxel waypoints will be drawn in pink +- SetFlying(bool value) -- Enable/disable fying behaviour. When flying is enabled, then the path will be on empty voxels (air), otherwise and by default the path will be on filled voxels (ground) +- IsFlying() : bool +- SetAgentWidth(int value) --Set the navigation width requirement in voxels. This means how many voxels the query will keep away from obstacles horizontally. +- GetAgentWidth(int value) : int +- SetAgentHeight(int value) -- Set the navigation height requirement in voxels. This means how many voxels the query will keep away from obstacles vertically. +- GetAgentHeight(int value) : int +- GetWaypointCount() : int -- returns the number of waypoints that were computed in Process() +- GetWaypoint(int index) : Vector -- returns the waypoint at specified index (direction: start -> goal) +- GetGoal() : Vector -- returns goal position + +### TrailRenderer +- [constructor] TrailRenderer() +- AddPoint(Vector pos, opt float width = 1, opt Vector color = Vector(1,1,1,1)) -- adds a new point to the trail +- Cut() -- cuts the trail at last point and starts a new trail +- Clear() -- removes all points and cuts from the trail +- GetPointCount() : int -- returns the number of points in the trail +- GetPoint() : Vector pos, float width -- returns the point of the trail on the specified index +- SetPoint(Vector pos, opt float width = 1, opt Vector color = Vector(1,1,1,1)) -- sets the point parameters on the specified index +- SetBlendMode(int blendmode) -- set blend mode of the whole trail +- GetBlendMode() : int +- SetSubdivision(int subdiv) -- set the subdivision amount of the whole trail +- GetSubdivision() : int +- SetWidth(float width) -- set the width of the whole trail +- GetWidth() : float +- SetColor(Vector color) -- set the color of the whole trail +- GetColor() : Vector +- SetTexture(Texture tex) -- set the texture of the whole trail +- GetTexture() : Texture +- SetTexture2(Texture tex) -- set the texture2 of the whole trail +- GetTexture2() : Texture +- SetTexMulAdd(Texture tex) -- set the texture UV tiling multiply-add value of the whole trail +- GetTexMulAdd() : Texture +- SetTexMulAdd2(Texture tex) -- set the texture2 UV tiling multiply-add value of the whole trail +- GetTexMulAdd2() : Texture diff --git a/Content/Documentation/WickedEngine-Documentation.md b/Content/Documentation/WickedEngine-Documentation.md index 0abe2f3e9d5..eff59303caa 100644 --- a/Content/Documentation/WickedEngine-Documentation.md +++ b/Content/Documentation/WickedEngine-Documentation.md @@ -133,6 +133,8 @@ This is a reference for the C++ features of Wicked Engine 12. [wiSpinLock](#wispinlock) 13. [wiArguments](#wiarguments) 14. [wiTimer](#witimer) + 14. [wiVoxelGrid](#wivoxelgrid) + 14. [wiPathQuery](#wipathquery) 6. [Input](#input) 7. [Audio](#audio) 1. [Sound](#sound) @@ -1047,6 +1049,32 @@ This is to store the startup parameters that were passed to the application from [[Header]](../../WickedEngine/wiTimer.h) [[Cpp]](../../WickedEngine/wiTimer.cpp) High resolution stopwatch timer +### wiVoxelGrid +[[Header]](../../WickedEngine/wiVoxelGrid.h) [[Cpp]](../../WickedEngine/wiVoxelGrid.cpp) +An axis aligned bounding box volume that contains a 3D grid of voxels. It can be used to voxelize the scene, and used by [PathQuery](#wipathquery) for path finding. + +The voxel grid is created with the `init()` function, providing the dimensions of the 3D grid. This function will allocate the necessary memory to store the grid, and fill every voxel to empty. To simply clear the grid, use `cleardata()` function, which will not allocate memory, only clear all voxels to empty. + +The volume of the grid is specified by the `center` and `voxelSize` members. To set the `voxelSize`, use the `set_voxelsize()` function instead of directly modifying the `voxelSize`. You can also align it easily to an existing AABB with the `from_aabb()` function. Setting these doesn't modify voxel data, so it probably needs to be revoxelized after modifications. + +The main feature is that you can inject primitives into the voxel grid, this is the voxelization process. You can inject triangles, AABB, Sphere and Capsule primitives with the `inject_triangle()`, `inject_aabb()`, `inject_sphere()` and the `inject_capsule()` functions, respectively. All the primitives are input to these functions in world space, and they will be mapped into the voxel grid internally by these functions based on the grid center, voxelSize and resolution. These functions can also accept a bool option called `subtract` which - if set to `true` - will modify the voxelization process to remove voxels intead of add them. The voxelization process is performance sensitive, but it can be done from different threads as it is thread safe, using atomic operations to modify voxel data. + +To access individual voxels, you can use the `check_voxel()` function to check if a voxel is empty or validm and the `set_voxel()` function to set a voxel to empty or valid. These operations are not thread safe! Also these functions will both accept world position, or voxel coordinates. You can additionally convert world positions to voxel coordinates by using the `world_to_coord()` function, or do the reverse with the `coord_to_world()` function. + +Note: There are helper functions to voxelize a whole object or the whole scene, accessible from the [Scene](#scene) object. These are called `VoxelizeObject()` and `VoxelizeScene()`. + +### wiPathQuery +[[Header]](../../WickedEngine/wiPathQuery.h) [[Cpp]](../../WickedEngine/wiPathQuery.cpp) +Path query can find paths from start to goal position within a voxel grid. To run a path finding query, first prepare a [voxel grid](#wivoxelgrid) with scene data, then process it with the path query. + +The usage of the path query at minimum is to call the `process()` function, with start and goal positions and a [voxel grid](#wivoxelgrid). When the function returns, you can check path finding success with the `is_successful()` function, and `get_next_waypoint()` function to find the next waypoint in the path from the start that goes towards the goal. + +The path query can be additionally configured with the `flying` bool param. If you set `flying` to `true`, then the path finding will search a path in empty voxels (in the air), otherwise by default it will try to find a path that goes on the ground. + +The traversing entity can have a logical size, configured by the `agent_height` and `agent_width` parameters, that specify the approcimate size of traversing entity in voxels. `agent_height` will specify how many empty voxels must be above the traversed path at any waypoint. `agent_width` specifies how many empty voxels must be in the horizontal directions. With these you can specify how far the path should keep away from walls and obstacles, and also to not allow going in between tight openings that the logical size would not allow. + +Note: processing a path query can take a long time, depending on how far the goal is from the start. Consider doing multiple path queries on multiple threads, or doing them asynchronously across the frame, the [Job System](#job-system) can be used to track completion of asynchronous tasks like this. + ## Input [[Header]](../../WickedEngine/wiInput.h) [[Cpp]](../../WickedEngine/wiInput.cpp) diff --git a/Content/models/Sponza/thumbnail.png b/Content/models/Sponza/thumbnail.png new file mode 100644 index 00000000000..68cc1b267f4 Binary files /dev/null and b/Content/models/Sponza/thumbnail.png differ diff --git a/Content/scripts/character_controller/assets/level.wiscene b/Content/scripts/character_controller/assets/level.wiscene index 67843e78a81..5d2696b4ff4 100644 Binary files a/Content/scripts/character_controller/assets/level.wiscene and b/Content/scripts/character_controller/assets/level.wiscene differ diff --git a/Content/scripts/character_controller/assets/loadingscreen.png b/Content/scripts/character_controller/assets/loadingscreen.png new file mode 100644 index 00000000000..76439315660 Binary files /dev/null and b/Content/scripts/character_controller/assets/loadingscreen.png differ diff --git a/Content/scripts/character_controller/character_controller.lua b/Content/scripts/character_controller/character_controller.lua index 85826dfa858..e4a2f71a1ff 100644 --- a/Content/scripts/character_controller/character_controller.lua +++ b/Content/scripts/character_controller/character_controller.lua @@ -27,6 +27,7 @@ local framerate_lock = false local framerate_lock_target = 20 local slope_threshold = 0.2 -- How much slopeiness will cause character to slide down instead of standing on it local gravity = -30 +local dynamic_voxelization = false -- Set to true to revoxelize navigation every frame local ConversationState = { Disabled = 0, @@ -57,9 +58,9 @@ local function Conversation() -- Update conversation percentage (fade in/out of conversation) if self.state == ConversationState.Disabled then - self.percent = math.lerp(self.percent, 0, 0.05) + self.percent = math.lerp(self.percent, 0, getDeltaTime() * 4) else - self.percent = math.lerp(self.percent, 1, 0.05) + self.percent = math.lerp(self.percent, 1, getDeltaTime() * 4) end path.SetCropTop(self.percent * crop_height) path.SetCropBottom(self.percent * crop_height) @@ -277,9 +278,7 @@ local footprint_texture = Texture(script_dir() .. "assets/footprint.dds") local footprints = {} local animations = {} -local function LoadAnimations(model_name) - local anim_scene = Scene() - LoadModel(anim_scene, model_name) +local function LoadAnimations(anim_scene) animations = { IDLE = anim_scene.Entity_FindByName("idle"), WALK = anim_scene.Entity_FindByName("walk"), @@ -291,12 +290,14 @@ local function LoadAnimations(model_name) DANCE = anim_scene.Entity_FindByName("dance"), WAVE = anim_scene.Entity_FindByName("wave"), } - return anim_scene end local character_capsules = {} +local voxelgrid = VoxelGrid(128,32,128) +voxelgrid.SetVoxelSize(0.25) +voxelgrid.SetCenter(Vector(0,0.1,0)) -local function Character(model_name, start_position, face, controllable, anim_scene) +local function Character(model_entity, start_position, face, controllable, anim_scene) local self = { model = INVALID_ENTITY, target_rot_horizontal = 0, @@ -337,6 +338,7 @@ local function Character(model_name, start_position, face, controllable, anim_sc mood_amount = 1, expression = INVALID_ENTITY, + pathquery = PathQuery(), patrol_waypoints = {}, patrol_next = 0, patrol_wait = 0, @@ -345,7 +347,7 @@ local function Character(model_name, start_position, face, controllable, anim_sc dialogs = {}, next_dialog = 1, - Create = function(self, model_name, start_position, face, controllable) + Create = function(self, model_entity, start_position, face, controllable) self.start_position = start_position self.face = face self.face_next = face @@ -355,7 +357,7 @@ local function Character(model_name, start_position, face, controllable, anim_sc else self.layerMask = Layers.NPC end - self.model = LoadModel(model_name) + self.model = model_entity local layer = scene.Component_GetLayer(self.model) layer.SetLayerMask(self.layerMask) @@ -614,14 +616,13 @@ local function Character(model_name, start_position, face, controllable, anim_sc local patrol_count = len(self.patrol_waypoints) if patrol_count > 0 then local pos = savedPos - pos.SetY(0) local patrol = self.patrol_waypoints[self.patrol_next % patrol_count + 1] local patrol_transform = scene.Component_GetTransform(patrol.entity) if patrol_transform ~= nil then local patrol_pos = patrol_transform.GetPosition() - patrol_pos.SetY(0) local patrol_wait = patrol.wait or 0 -- default: 0 local patrol_vec = vector.Subtract(patrol_pos, pos) + patrol_vec.SetY(0) local distance = patrol_vec.Length() local patrol_dist = patrol.distance or 0.5 -- default : 0.5 local patrol_dist_threshold = patrol.distance_threshold or 0 -- default : 0 @@ -645,6 +646,16 @@ local function Character(model_name, start_position, face, controllable, anim_sc end else -- move towards patrol waypoint: + self.pathquery.SetAgentHeight(3) + self.pathquery.Process(pos, patrol_pos, voxelgrid) + if self.pathquery.IsSuccessful() then + -- If there is a valid pathfinding result for waypoint, replace heading direction by that: + patrol_vec = vector.Subtract(self.pathquery.GetNextWaypoint(), pos) + patrol_vec.SetY(0) + end + if debug then + DrawPathQuery(self.pathquery) + end self.patrol_wait = 0 -- check if it's blocked by player collision: local capsule = scene.Component_GetCollider(self.collider).GetCapsule() @@ -977,7 +988,7 @@ local function Character(model_name, start_position, face, controllable, anim_sc } - self:Create(model_name, start_position, face, controllable) + self:Create(model_entity, start_position, face, controllable) return self end @@ -1153,36 +1164,14 @@ local function ThirdPersonCamera(character) return self end -ClearWorld() -LoadModel(script_dir() .. "assets/level.wiscene") ---LoadModel(script_dir() .. "assets/terrain.wiscene") ---LoadModel(script_dir() .. "assets/waypoints.wiscene", matrix.Translation(Vector(1,0,2))) ---dofile(script_dir() .. "../dungeon_generator/dungeon_generator.lua") - -local anim_scene = LoadAnimations(script_dir() .. "assets/animations.wiscene") - -local player = Character(script_dir() .. "assets/character.wiscene", Vector(0,0.5,0), Vector(0,0,1), true, anim_scene) -local npcs = { - -- Patrolling NPC IDs: 1,2,3 - Character(script_dir() .. "assets/character.wiscene", Vector(4,0.1,4), Vector(0,0,-1), false, anim_scene), - Character(script_dir() .. "assets/character.wiscene", Vector(-8,1,4), Vector(-1,0,0), false, anim_scene), - Character(script_dir() .. "assets/character.wiscene", Vector(-2,0.1,8), Vector(-1,0,0), false, anim_scene), - - -- stationary NPC IDs: 3,4.... - Character(script_dir() .. "assets/character.wiscene", Vector(-1,0.1,-6), Vector(0,0,1), false, anim_scene), - --Character(script_dir() .. "assets/character.wiscene", Vector(10.8,0.1,4.1), Vector(0,0,-1), false, anim_scene), - --Character(script_dir() .. "assets/character.wiscene", Vector(11.1,4,7.2), Vector(-1,0,0), false, anim_scene), -} - -local camera = ThirdPersonCamera(player) - --- Main loop: runProcess(function() -- We will override the render path so we can invoke the script from Editor and controls won't collide with editor scripts -- Also save the active component that we can restore when ESCAPE is pressed local prevPath = application.GetActivePath() local path = RenderPath3D() + local loadingscreen = LoadingScreen() + --path.SetLightShaftsEnabled(true) path.SetLightShaftsStrength(0.01) path.SetAO(AO_MSAO) @@ -1192,18 +1181,343 @@ runProcess(function() path.SetOutlineThickness(1.7) path.SetOutlineColor(0,0,0,0.6) path.SetBloomThreshold(5) - application.SetActivePath(path) --application.SetInfoDisplay(false) - application.SetFPSDisplay(true) + --application.SetFPSDisplay(true) --path.SetResolutionScale(0.75) --path.SetFSR2Enabled(true) --path.SetFSR2Preset(FSR2_Preset.Performance) --SetProfilerEnabled(true) + -- Configure a simple loading progress bar: + local loadingbar = Sprite() + loadingbar.SetMaskTexture(texturehelper.CreateGradientTexture( + GradientType.Linear, + 2048, 1, + Vector(0, 0), Vector(1, 0), + GradientFlags.Inverse, + "111r" + )) + local loadingbarparams = loadingbar.GetParams() + loadingbarparams.SetColor(Vector(1,0.2,0.2,1)) + loadingbarparams.SetBlendMode(BLENDMODE_ALPHA) + loadingscreen.AddSprite(loadingbar) + loadingscreen.SetBackgroundTexture(Texture(script_dir() .. "assets/loadingscreen.png")) + + -- All LoadModel tasks are started by the LoadingScreen asynchronously, but we get back root Entity handles immediately: + local anim_scene = Scene() + loadingscreen.AddLoadModelTask(anim_scene, script_dir() .. "assets/animations.wiscene") + local loading_scene = Scene() + local character_entities = { + loadingscreen.AddLoadModelTask(loading_scene, script_dir() .. "assets/character.wiscene"), + loadingscreen.AddLoadModelTask(loading_scene, script_dir() .. "assets/character.wiscene"), + loadingscreen.AddLoadModelTask(loading_scene, script_dir() .. "assets/character.wiscene"), + loadingscreen.AddLoadModelTask(loading_scene, script_dir() .. "assets/character.wiscene"), + loadingscreen.AddLoadModelTask(loading_scene, script_dir() .. "assets/character.wiscene"), + } + loadingscreen.AddLoadModelTask(loading_scene, script_dir() .. "assets/level.wiscene") + loadingscreen.AddRenderPathActivationTask(path, application, 0.5) + application.SetActivePath(loadingscreen, 0.5) -- activate and switch to loading screen + + -- Because we are in a runProcess, we can block loading screen like this while application is still running normally: + -- Meanwhile, we can update the progress bar sprite + while not loadingscreen.IsFinished() do + update() -- gives back control for application for one frame, script waits until next update() phase + local canvas = application.GetCanvas() + loadingbarparams.SetPos(Vector(50, canvas.GetLogicalHeight() * 0.8)) + loadingbarparams.SetSize(Vector(canvas.GetLogicalWidth() - 100, 20)) + local progress = 1 - loadingscreen.GetProgress() / 100.0 + loadingbarparams.SetMaskAlphaRange(math.saturate(progress - 0.05), math.saturate(progress)) + loadingbar.SetParams(loadingbarparams) + end + + -- After loading finished, we clear the main scene, and merge loaded scene into it: + scene.Clear() + scene.Merge(loading_scene) + scene.Update(0) + + scene.VoxelizeScene(voxelgrid, false, FILTER_NAVIGATION_MESH | FILTER_COLLIDER, ~(Layers.Player | Layers.NPC)) -- player and npc layers not included in voxelization + + -- Parse animations from anim_scene, which was loaded by the loading screen: + LoadAnimations(anim_scene) + + -- Create characters from root Entity handles that were loaded by loading screen + local player = Character(character_entities[1], Vector(0,0.5,0), Vector(0,0,1), true, anim_scene) + local npcs = { + -- Patrolling NPC IDs: 1,2,3 + Character(character_entities[2], Vector(4,0.1,4), Vector(0,0,-1), false, anim_scene), + Character(character_entities[3], Vector(-8,1,4), Vector(-1,0,0), false, anim_scene), + Character(character_entities[4], Vector(-2,0.1,8), Vector(-1,0,0), false, anim_scene), + + -- stationary NPC IDs: 3,4.... + Character(character_entities[5], Vector(-1,0.1,-6), Vector(0,0,1), false, anim_scene), + --Character(character_entities[6], Vector(10.8,0.1,4.1), Vector(0,0,-1), false, anim_scene), + --Character(character_entities[7], Vector(11.1,4,7.2), Vector(-1,0,0), false, anim_scene), + } + + local camera = ThirdPersonCamera(player) + path.AddFont(conversation.font) path.AddFont(conversation.advance_font) + + local help_text = "Wicked Engine Character demo (LUA)\n\n" + help_text = help_text .. "Controls:\n" + help_text = help_text .. "#############\n" + help_text = help_text .. "WASD/arrows/left analog stick: walk\n" + help_text = help_text .. "SHIFT/right shoulder button: walk -> jog\n" + help_text = help_text .. "E/left shoulder button: jog -> run\n" + help_text = help_text .. "SPACE/gamepad X/gamepad button 3: Jump\n" + help_text = help_text .. "Right Mouse Button/Right thumbstick: rotate camera\n" + help_text = help_text .. "Scoll middle mouse/Left-Right triggers: adjust camera distance\n" + help_text = help_text .. "ESCAPE key: quit\n" + help_text = help_text .. "ENTER key: interact\n" + help_text = help_text .. "R: reload script\n" + help_text = help_text .. "H: toggle debug draw\n" + help_text = help_text .. "L: toggle framerate lock\n" + + + -- Conversation dialogs: + local dialogtree = { + -- Dialog starts here: + {"Hello! Today is a nice day for a walk, isn't it? The sun is shining, the wind blows lightly, and the temperature is just perfect! To be honest, I don't need anything else to be happy."}, + {"I just finished my morning routine and I'm ready for the day. What should I do now...?"}, + { + "Anything I can do for you?", + choices = { + { + "Follow me!", + action = function() + conversation.character:Follow(player) + conversation.character.next_dialog = 4 + end + }, + { + "Never mind.", + action = function() + conversation.character.next_dialog = 5 + end + } + } + }, + + -- Dialog 4: When chosen [Follow me] or [Just keep following me] + {"Lead the way!", action_after = function() conversation:Exit() conversation.character.next_dialog = 6 end}, + + -- Dialog 5: When chosen [Never mind] - this also modifies mood (expression) and state (anim) while dialog is playing + { + "Have a nice day!", + action = function() + conversation.character.mood = Mood.Happy + conversation.character.state = States.WAVE + conversation.character.anim_amount = 0.1 + end, + action_after = function() + conversation.character.mood = Mood.Neutral + conversation.character.state = States.IDLE + conversation.character.anim_amount = 1 + conversation:Exit() + conversation.character.next_dialog = 1 + end + }, + + -- Dialog 6: After Dialog 4 finished, so character is following player + { + "Where are we going?", + choices = { + {"Just keep following me.", action = function() conversation.character.next_dialog = 4 end}, + {"Stay here!", action = function() conversation.character:Unfollow() end} + } + }, + {"Gotcha!"}, -- After chosen [Stay here] + } + for i,npc in pairs(npcs) do + npc.dialogs = dialogtree + end + + -- Patrol waypoints: + + local waypoints = { + scene.Entity_FindByName("waypoint1"), + scene.Entity_FindByName("waypoint2"), + + scene.Entity_FindByName("waypoint3"), + scene.Entity_FindByName("waypoint4"), + scene.Entity_FindByName("waypoint5"), + scene.Entity_FindByName("waypoint6"), + + scene.Entity_FindByName("waypoint7"), + scene.Entity_FindByName("waypoint8"), + scene.Entity_FindByName("waypoint9"), + scene.Entity_FindByName("waypoint10"), + scene.Entity_FindByName("waypoint11"), + scene.Entity_FindByName("waypoint12"), + scene.Entity_FindByName("waypoint13"), + scene.Entity_FindByName("waypoint14"), + scene.Entity_FindByName("waypoint15"), + scene.Entity_FindByName("waypoint16"), + scene.Entity_FindByName("waypoint17"), + scene.Entity_FindByName("waypoint18"), + scene.Entity_FindByName("waypoint19"), + scene.Entity_FindByName("waypoint20"), + scene.Entity_FindByName("waypoint21"), + scene.Entity_FindByName("waypoint22"), + scene.Entity_FindByName("waypoint23"), + scene.Entity_FindByName("waypoint24"), + scene.Entity_FindByName("waypoint25"), + } + + -- Simplest 1-2 patrol: + if( + waypoints[1] ~= INVALID_ENTITY and + waypoints[2] ~= INVALID_ENTITY + ) then + npcs[1].patrol_waypoints = { + { + entity = waypoints[1], + wait = 0, + }, + { + entity = waypoints[2], + wait = 2, + }, + } + end + + -- Some more advanced, toggle between walk and jog, also swimming (because waypoints are across water mesh in test level): + if( + waypoints[3] ~= INVALID_ENTITY and + waypoints[4] ~= INVALID_ENTITY and + waypoints[5] ~= INVALID_ENTITY and + waypoints[6] ~= INVALID_ENTITY + ) then + npcs[2].patrol_waypoints = { + { + entity = waypoints[3], + wait = 0, + state = States.JOG, + }, + { + entity = waypoints[4], + wait = 0, + }, + { + entity = waypoints[5], + wait = 2, + }, + { + entity = waypoints[6], + wait = 0, + state = States.JOG, + }, + } + end + + + -- Run long circle: + if( + waypoints[7] ~= INVALID_ENTITY and + waypoints[8] ~= INVALID_ENTITY and + waypoints[9] ~= INVALID_ENTITY and + waypoints[10] ~= INVALID_ENTITY and + waypoints[11] ~= INVALID_ENTITY and + waypoints[12] ~= INVALID_ENTITY and + waypoints[13] ~= INVALID_ENTITY and + waypoints[14] ~= INVALID_ENTITY and + waypoints[15] ~= INVALID_ENTITY and + waypoints[16] ~= INVALID_ENTITY and + waypoints[17] ~= INVALID_ENTITY and + waypoints[18] ~= INVALID_ENTITY and + waypoints[19] ~= INVALID_ENTITY and + waypoints[20] ~= INVALID_ENTITY and + waypoints[21] ~= INVALID_ENTITY and + waypoints[22] ~= INVALID_ENTITY and + waypoints[23] ~= INVALID_ENTITY and + waypoints[24] ~= INVALID_ENTITY and + waypoints[25] ~= INVALID_ENTITY + ) then + npcs[3].patrol_waypoints = { + { + entity = waypoints[7], + state = States.JOG, + }, + { + entity = waypoints[8], + state = States.JOG, + }, + { + entity = waypoints[9], + state = States.JOG, + }, + { + entity = waypoints[10], + state = States.JOG, + }, + { + entity = waypoints[11], + state = States.JOG, + }, + { + entity = waypoints[12], + state = States.JOG, + }, + { + entity = waypoints[13], + state = States.JOG, + }, + { + entity = waypoints[14], + state = States.JOG, + }, + { + entity = waypoints[15], + state = States.JOG, + }, + { + entity = waypoints[16], + state = States.JOG, + }, + { + entity = waypoints[17], + state = States.JOG, + }, + { + entity = waypoints[18], + state = States.JOG, + wait = 2, -- little wait at top of slope + }, + { + entity = waypoints[19], + state = States.JOG, + }, + { + entity = waypoints[20], + state = States.JOG, + }, + { + entity = waypoints[21], + state = States.JOG, + }, + { + entity = waypoints[22], + state = States.JOG, + }, + { + entity = waypoints[23], + state = States.JOG, + }, + { + entity = waypoints[24], + state = States.JOG, + }, + { + entity = waypoints[25], + state = States.JOG, + }, + } + end + + -- Main loop: while true do player:Update() @@ -1241,58 +1555,12 @@ runProcess(function() camera:Update() end - update() - - if not backlog_isactive() then - if(input.Press(KEYBOARD_BUTTON_ESCAPE)) then - -- restore previous component - -- so if you loaded this script from the editor, you can go back to the editor with ESC - backlog_post("EXIT") - killProcesses() - application.SetActivePath(prevPath) - return - end - if(input.Press(string.byte('R'))) then - -- reload script - backlog_post("RELOAD") - killProcesses() - application.SetActivePath(prevPath) - dofile(script_file()) - return - end - if input.Press(string.byte('L')) then - framerate_lock = not framerate_lock - application.SetFrameRateLock(framerate_lock) - if framerate_lock then - application.SetTargetFrameRate(framerate_lock_target) - end - end + if dynamic_voxelization then + voxelgrid.ClearData() + scene.VoxelizeScene(voxelgrid, false, FILTER_NAVIGATION_MESH | FILTER_COLLIDER, ~(Layers.Player | Layers.NPC)) -- player and npc layers not included in voxelization end - end - -end) - --- Draw -runProcess(function() - - local help_text = "Wicked Engine Character demo (LUA)\n\n" - help_text = help_text .. "Controls:\n" - help_text = help_text .. "#############\n" - help_text = help_text .. "WASD/arrows/left analog stick: walk\n" - help_text = help_text .. "SHIFT/right shoulder button: walk -> jog\n" - help_text = help_text .. "E/left shoulder button: jog -> run\n" - help_text = help_text .. "SPACE/gamepad X/gamepad button 3: Jump\n" - help_text = help_text .. "Right Mouse Button/Right thumbstick: rotate camera\n" - help_text = help_text .. "Scoll middle mouse/Left-Right triggers: adjust camera distance\n" - help_text = help_text .. "ESCAPE key: quit\n" - help_text = help_text .. "ENTER key: interact\n" - help_text = help_text .. "R: reload script\n" - help_text = help_text .. "H: toggle debug draw\n" - help_text = help_text .. "L: toggle framerate lock\n" - - while true do - + -- Do some debug draw geometry: DrawDebugText(help_text, Vector(0,2,2), Vector(1,1,1,1), 0.1, DEBUG_TEXT_DEPTH_TEST) @@ -1337,251 +1605,44 @@ runProcess(function() --str = str .. "Velocity = " .. player.velocity.GetX() .. ", " .. player.velocity.GetY() .. "," .. player.velocity.GetZ() .. "\n" DrawDebugText(str, vector.Add(capsule.GetBase(), Vector(0,0.4)), Vector(1,1,1,1), 1, DEBUG_TEXT_CAMERA_FACING | DEBUG_TEXT_CAMERA_SCALING) - end + DrawVoxelGrid(voxelgrid) - -- Wait for the engine to render the scene - render() - end -end) + end --- Conversation dialogs: -local dialogtree = { - -- Dialog starts here: - {"Hello! Today is a nice day for a walk, isn't it? The sun is shining, the wind blows lightly, and the temperature is just perfect! To be honest, I don't need anything else to be happy."}, - {"I just finished my morning routine and I'm ready for the day. What should I do now...?"}, - { - "Anything I can do for you?", - choices = { - { - "Follow me!", - action = function() - conversation.character:Follow(player) - conversation.character.next_dialog = 4 + update() + + if not backlog_isactive() then + if(input.Press(KEYBOARD_BUTTON_ESCAPE)) then + -- restore previous component + -- so if you loaded this script from the editor, you can go back to the editor with ESC + backlog_post("EXIT") + for i,anim in ipairs(scene.Component_GetAnimationArray()) do + anim.Stop() -- stop animations because some of them are retargeted and animation source scene will be lost after we exit this script! end - }, - { - "Never mind.", - action = function() - conversation.character.next_dialog = 5 + application.SetActivePath(prevPath) + killProcesses() + return + end + if(input.Press(string.byte('R'))) then + -- reload script + backlog_post("RELOAD") + application.SetActivePath(prevPath, 0.5) + while not application.IsFaded() do + update() end - } - } - }, - - -- Dialog 4: When chosen [Follow me] or [Just keep following me] - {"Lead the way!", action_after = function() conversation:Exit() conversation.character.next_dialog = 6 end}, - - -- Dialog 5: When chosen [Never mind] - this also modifies mood (expression) and state (anim) while dialog is playing - { - "Have a nice day!", - action = function() - conversation.character.mood = Mood.Happy - conversation.character.state = States.WAVE - conversation.character.anim_amount = 0.1 - end, - action_after = function() - conversation.character.mood = Mood.Neutral - conversation.character.state = States.IDLE - conversation.character.anim_amount = 1 - conversation:Exit() - conversation.character.next_dialog = 1 + killProcesses() + dofile(script_file()) + return + end + if input.Press(string.byte('L')) then + framerate_lock = not framerate_lock + application.SetFrameRateLock(framerate_lock) + if framerate_lock then + application.SetTargetFrameRate(framerate_lock_target) + end + end end - }, - - -- Dialog 6: After Dialog 4 finished, so character is following player - { - "Where are we going?", - choices = { - {"Just keep following me.", action = function() conversation.character.next_dialog = 4 end}, - {"Stay here!", action = function() conversation.character:Unfollow() end} - } - }, - {"Gotcha!"}, -- After chosen [Stay here] -} - -for i,npc in pairs(npcs) do - npc.dialogs = dialogtree -end - --- Patrol waypoints: - -local waypoints = { - scene.Entity_FindByName("waypoint1"), - scene.Entity_FindByName("waypoint2"), - - scene.Entity_FindByName("waypoint3"), - scene.Entity_FindByName("waypoint4"), - scene.Entity_FindByName("waypoint5"), - scene.Entity_FindByName("waypoint6"), - - scene.Entity_FindByName("waypoint7"), - scene.Entity_FindByName("waypoint8"), - scene.Entity_FindByName("waypoint9"), - scene.Entity_FindByName("waypoint10"), - scene.Entity_FindByName("waypoint11"), - scene.Entity_FindByName("waypoint12"), - scene.Entity_FindByName("waypoint13"), - scene.Entity_FindByName("waypoint14"), - scene.Entity_FindByName("waypoint15"), - scene.Entity_FindByName("waypoint16"), - scene.Entity_FindByName("waypoint17"), - scene.Entity_FindByName("waypoint18"), - scene.Entity_FindByName("waypoint19"), - scene.Entity_FindByName("waypoint20"), - scene.Entity_FindByName("waypoint21"), - scene.Entity_FindByName("waypoint22"), - scene.Entity_FindByName("waypoint23"), - scene.Entity_FindByName("waypoint24"), - scene.Entity_FindByName("waypoint25"), -} - --- Simplest 1-2 patrol: -if( - waypoints[1] ~= INVALID_ENTITY and - waypoints[2] ~= INVALID_ENTITY -) then - npcs[1].patrol_waypoints = { - { - entity = waypoints[1], - wait = 0, - }, - { - entity = waypoints[2], - wait = 2, - }, - } -end - --- Some more advanced, toggle between walk and jog, also swimming (because waypoints are across water mesh in test level): -if( - waypoints[3] ~= INVALID_ENTITY and - waypoints[4] ~= INVALID_ENTITY and - waypoints[5] ~= INVALID_ENTITY and - waypoints[6] ~= INVALID_ENTITY -) then - npcs[2].patrol_waypoints = { - { - entity = waypoints[3], - wait = 0, - state = States.JOG, - }, - { - entity = waypoints[4], - wait = 0, - }, - { - entity = waypoints[5], - wait = 2, - }, - { - entity = waypoints[6], - wait = 0, - state = States.JOG, - }, - } -end - - --- Run long circle: -if( - waypoints[7] ~= INVALID_ENTITY and - waypoints[8] ~= INVALID_ENTITY and - waypoints[9] ~= INVALID_ENTITY and - waypoints[10] ~= INVALID_ENTITY and - waypoints[11] ~= INVALID_ENTITY and - waypoints[12] ~= INVALID_ENTITY and - waypoints[13] ~= INVALID_ENTITY and - waypoints[14] ~= INVALID_ENTITY and - waypoints[15] ~= INVALID_ENTITY and - waypoints[16] ~= INVALID_ENTITY and - waypoints[17] ~= INVALID_ENTITY and - waypoints[18] ~= INVALID_ENTITY and - waypoints[19] ~= INVALID_ENTITY and - waypoints[20] ~= INVALID_ENTITY and - waypoints[21] ~= INVALID_ENTITY and - waypoints[22] ~= INVALID_ENTITY and - waypoints[23] ~= INVALID_ENTITY and - waypoints[24] ~= INVALID_ENTITY and - waypoints[25] ~= INVALID_ENTITY -) then - npcs[3].patrol_waypoints = { - { - entity = waypoints[7], - state = States.JOG, - }, - { - entity = waypoints[8], - state = States.JOG, - }, - { - entity = waypoints[9], - state = States.JOG, - }, - { - entity = waypoints[10], - state = States.JOG, - }, - { - entity = waypoints[11], - state = States.JOG, - }, - { - entity = waypoints[12], - state = States.JOG, - }, - { - entity = waypoints[13], - state = States.JOG, - }, - { - entity = waypoints[14], - state = States.JOG, - }, - { - entity = waypoints[15], - state = States.JOG, - }, - { - entity = waypoints[16], - state = States.JOG, - }, - { - entity = waypoints[17], - state = States.JOG, - }, - { - entity = waypoints[18], - state = States.JOG, - wait = 2, -- little wait at top of slope - }, - { - entity = waypoints[19], - state = States.JOG, - }, - { - entity = waypoints[20], - state = States.JOG, - }, - { - entity = waypoints[21], - state = States.JOG, - }, - { - entity = waypoints[22], - state = States.JOG, - }, - { - entity = waypoints[23], - state = States.JOG, - }, - { - entity = waypoints[24], - state = States.JOG, - }, - { - entity = waypoints[25], - state = States.JOG, - }, - } -end + end + +end) diff --git a/Content/scripts/character_controller/thumbnail.png b/Content/scripts/character_controller/thumbnail.png new file mode 100644 index 00000000000..d9e99136082 Binary files /dev/null and b/Content/scripts/character_controller/thumbnail.png differ diff --git a/Content/scripts/dungeon_generator/thumbnail.png b/Content/scripts/dungeon_generator/thumbnail.png new file mode 100644 index 00000000000..7d535cd88d9 Binary files /dev/null and b/Content/scripts/dungeon_generator/thumbnail.png differ diff --git a/Content/scripts/fighting_game/thumbnail.png b/Content/scripts/fighting_game/thumbnail.png new file mode 100644 index 00000000000..b4aeb54cc0f Binary files /dev/null and b/Content/scripts/fighting_game/thumbnail.png differ diff --git a/Content/scripts/pathfinding.lua b/Content/scripts/pathfinding.lua new file mode 100644 index 00000000000..40fb21e7e46 --- /dev/null +++ b/Content/scripts/pathfinding.lua @@ -0,0 +1,43 @@ +killProcesses() -- stops all running lua coroutine processes + +backlog_post("---> START SCRIPT: pathfinding.lua") + +-- Create a simple voxel grid by inserting some shapes manually: +local voxelgrid = VoxelGrid(64, 64, 64) +local voxelsize = voxelgrid.GetVoxelSize() +voxelsize = vector.Multiply(voxelsize, 0.5) -- reduce the voxelsize by half +voxelgrid.SetVoxelSize(voxelsize) +voxelgrid.InjectTriangle(Vector(-10, 0, -10), Vector(-10, 0, 10), Vector(10, 0, -10)) +voxelgrid.InjectTriangle(Vector(-10, 0, 10), Vector(10, 0, 10), Vector(10, 0, -10)) +voxelgrid.InjectAABB(AABB(Vector(4, 0, -2), Vector(4.5, 4, 5))) +voxelgrid.InjectAABB(AABB(Vector(4, 0, 0.8), Vector(8, voxelsize.GetY() * 2, 5))) +voxelgrid.InjectAABB(AABB(Vector(4, 0, 3), Vector(8, voxelsize.GetY() * 3.5, 7))) +voxelgrid.InjectAABB(AABB(Vector(4, 0, 6), Vector(8, voxelsize.GetY() * 4.5, 7))) +voxelgrid.InjectSphere(Sphere(Vector(-4.8,1.6,-2.5), 1.6)) +voxelgrid.InjectCapsule(Capsule(Vector(4.8,-0.6,-2.5), Vector(2, 1, 1), 0.4)) + +-- If teapot model can be loaded, then load it and voxelize it too: +local scene = Scene() +local entity = LoadModel(scene, script_dir() .. "../models/teapot.wiscene", matrix.RotationY(math.pi * 0.6)) +if entity ~= INVALID_ENTITY then + for i,entity in ipairs(scene.Entity_GetObjectArray()) do + scene.VoxelizeObject(i - 1, voxelgrid) + end +end + +-- Create a path query to find paths from start to goal position on voxel grid: +local pathquery = PathQuery() +pathquery.SetDebugDrawWaypointsEnabled(true) -- enable waypoint voxel highlighting in DrawPathQuery() +local start = Vector(-7.63,0,-2.6) -- world space coordinates can be given +local goal = Vector(6.3,voxelsize.GetY() * 4.5, 6.5) -- world space coordinates can be given +pathquery.Process(start, goal, voxelgrid) -- this computes the path + +runProcess(function() + while true do + DrawVoxelGrid(voxelgrid) + DrawPathQuery(pathquery) + render() -- this loop will be blocked until render tick + end +end) + +backlog_post("---> END SCRIPT: pathfinding.lua") diff --git a/Content/scripts/trail_renderer.lua b/Content/scripts/trail_renderer.lua new file mode 100644 index 00000000000..6dd70208250 --- /dev/null +++ b/Content/scripts/trail_renderer.lua @@ -0,0 +1,58 @@ +killProcesses() -- stops all running lua coroutine processes + +backlog_post("---> START SCRIPT: trail_renderer.lua") + +local trail = TrailRenderer() +trail.SetWidth(0.2) +trail.SetColor(Vector(10,0.1,0.1,1)) +trail.SetBlendMode(BLENDMODE_ADDITIVE) +trail.SetSubdivision(100) + +-- Trail begins as red: +trail.AddPoint(Vector(-5,2,-3), 4, Vector(10,0.1,0.1,1)) +trail.AddPoint(Vector(5,1,1), 0.5, Vector(10,0.1,0.1,1)) +trail.AddPoint(Vector(10,5,4), 1.2, Vector(10,0.1,0.1,1)) +trail.AddPoint(Vector(6,8,2), 1, Vector(10,0.1,0.1,1)) +trail.AddPoint(Vector(-6,5,0), 1, Vector(10,0.1,0.1,1)) +-- Trail turn into green: +trail.AddPoint(Vector(0,2,-5), 1, Vector(0.1,100,0.1,1)) +trail.AddPoint(Vector(1,3,5), 1, Vector(0.1,100,0.1,1)) +trail.AddPoint(Vector(-3,2,8), 1, Vector(0.1,100,0.1,1)) + +trail.Cut() -- start a new trail without connecting to previous points + +-- Last trail segment is blue: +trail.AddPoint(Vector(-5,0,-2), 1, Vector(0.1,0.1,100,1)) +trail.AddPoint(Vector(5,8,5), 1, Vector(0.1,0.1,100,1)) + +-- First texture is a circle gradient, this makes the overall trail smooth at the edges: +local texture = texturehelper.CreateGradientTexture( + GradientType.Circular, + 256, 256, + Vector(0.5, 0.5), Vector(0.5, 0), + GradientFlags.Inverse, + "rrrr" +) +trail.SetTexture(texture) + +-- Second texture is a linear gradient that will be tiled and animated to achieve stippled look: +local texture2 = texturehelper.CreateGradientTexture( + GradientType.Linear, + 256, 256, + Vector(0.5, 0), Vector(0, 0), + GradientFlags.Inverse | GradientFlags.Smoothstep, + "rrrr" +) +trail.SetTexture2(texture2) + +runProcess(function() + local scrolling = 0 + while true do + scrolling = scrolling - getDeltaTime() + trail.SetTexMulAdd2(Vector(10,1,scrolling,0)) + DrawTrail(trail) + render() -- this loop will be blocked until render tick + end +end) + +backlog_post("---> END SCRIPT: trail_renderer.lua") diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index 5666410a1e0..51f5df49434 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -45,6 +45,8 @@ set (SOURCE_FILES ProfilerWindow.cpp SpriteWindow.cpp FontWindow.cpp + VoxelGridWindow.cpp + ContentBrowserWindow.cpp xatlas.cpp EmbeddedResources.cpp ) diff --git a/Editor/ComponentsWindow.cpp b/Editor/ComponentsWindow.cpp index 7eada278514..791aeb079e5 100644 --- a/Editor/ComponentsWindow.cpp +++ b/Editor/ComponentsWindow.cpp @@ -44,6 +44,7 @@ void ComponentsWindow::Create(EditorComponent* _editor) terrainWnd.Create(editor); spriteWnd.Create(editor); fontWnd.Create(editor); + voxelGridWnd.Create(editor); enum ADD_THING { @@ -72,6 +73,7 @@ void ComponentsWindow::Create(EditorComponent* _editor) ADD_VIDEO, ADD_SPRITE, ADD_FONT, + ADD_VOXELGRID, }; newComponentCombo.Create("Add: "); @@ -105,6 +107,7 @@ void ComponentsWindow::Create(EditorComponent* _editor) newComponentCombo.AddItem("Video " ICON_VIDEO, ADD_VIDEO); newComponentCombo.AddItem("Sprite " ICON_SPRITE, ADD_SPRITE); newComponentCombo.AddItem("Font " ICON_FONT, ADD_FONT); + newComponentCombo.AddItem("Voxel Grid " ICON_VOXELGRID, ADD_VOXELGRID); newComponentCombo.OnSelect([=](wi::gui::EventArgs args) { newComponentCombo.SetSelectedWithoutCallback(-1); if (editor->translator.selected.empty()) @@ -229,6 +232,10 @@ void ComponentsWindow::Create(EditorComponent* _editor) if (scene.fonts.Contains(entity)) return; break; + case ADD_VOXELGRID: + if (scene.voxel_grids.Contains(entity)) + return; + break; default: return; } @@ -338,6 +345,9 @@ void ComponentsWindow::Create(EditorComponent* _editor) case ADD_FONT: scene.fonts.Create(entity); break; + case ADD_VOXELGRID: + scene.voxel_grids.Create(entity); + break; default: break; } @@ -380,6 +390,7 @@ void ComponentsWindow::Create(EditorComponent* _editor) AddWidget(&terrainWnd); AddWidget(&spriteWnd); AddWidget(&fontWnd); + AddWidget(&voxelGridWnd); materialWnd.SetVisible(false); weatherWnd.SetVisible(false); @@ -411,6 +422,7 @@ void ComponentsWindow::Create(EditorComponent* _editor) terrainWnd.SetVisible(false); spriteWnd.SetVisible(false); fontWnd.SetVisible(false); + voxelGridWnd.SetVisible(false); XMFLOAT2 size = XMFLOAT2(338, 500); if (editor->main->config.GetSection("layout").Has("components.width")) @@ -854,4 +866,17 @@ void ComponentsWindow::ResizeLayout() { fontWnd.SetVisible(false); } + + if (scene.voxel_grids.Contains(voxelGridWnd.entity)) + { + voxelGridWnd.SetVisible(true); + voxelGridWnd.SetPos(pos); + voxelGridWnd.SetSize(XMFLOAT2(width, voxelGridWnd.GetScale().y)); + pos.y += voxelGridWnd.GetSize().y; + pos.y += padding; + } + else + { + voxelGridWnd.SetVisible(false); + } } diff --git a/Editor/ComponentsWindow.h b/Editor/ComponentsWindow.h index 5b48b5f1c02..d544499c19a 100644 --- a/Editor/ComponentsWindow.h +++ b/Editor/ComponentsWindow.h @@ -29,6 +29,7 @@ #include "TerrainWindow.h" #include "SpriteWindow.h" #include "FontWindow.h" +#include "VoxelGridWindow.h" class EditorComponent; @@ -72,4 +73,5 @@ class ComponentsWindow : public wi::gui::Window TerrainWindow terrainWnd; SpriteWindow spriteWnd; FontWindow fontWnd; + VoxelGridWindow voxelGridWnd; }; diff --git a/Editor/ContentBrowserWindow.cpp b/Editor/ContentBrowserWindow.cpp new file mode 100644 index 00000000000..9022b838bc3 --- /dev/null +++ b/Editor/ContentBrowserWindow.cpp @@ -0,0 +1,356 @@ +#include "stdafx.h" +#include "ContentBrowserWindow.h" + +using namespace wi::ecs; +using namespace wi::scene; + +void ContentBrowserWindow::Create(EditorComponent* _editor) +{ + editor = _editor; + control_size = 30; + + wi::gui::Window::WindowControls controls = wi::gui::Window::WindowControls::ALL; + controls &= ~wi::gui::Window::WindowControls::RESIZE_BOTTOMLEFT; + wi::gui::Window::Create("Content Browser", controls); + + RemoveWidget(&scrollbar_horizontal); + + SetVisible(false); +} + +static const float separator = 140; +void ContentBrowserWindow::Render(const wi::Canvas& canvas, wi::graphics::CommandList cmd) const +{ + wi::gui::Window::Render(canvas, cmd); + + if (IsVisible() && !IsCollapsed()) + { + ApplyScissor(canvas, scissorRect, cmd); + wi::image::Params params; + params.pos = XMFLOAT3(translation.x + separator, translation.y + control_size, 0); + params.siz = XMFLOAT2(2, scale.y - control_size); + params.color = shadow_color; + wi::image::Draw(nullptr, params, cmd); + } +} + +void ContentBrowserWindow::Update(const wi::Canvas& canvas, float dt) +{ + wi::gui::Window::Update(canvas, dt); + + SetShadowRadius(6); + + static const float radius = 15; + + for (int i = 0; i < arraysize(wi::gui::Widget::sprites); ++i) + { + sprites[i].params.enableCornerRounding(); + sprites[i].params.corners_rounding[0].radius = radius; + sprites[i].params.corners_rounding[1].radius = radius; + sprites[i].params.corners_rounding[2].radius = radius; + sprites[i].params.corners_rounding[3].radius = radius; + resizeDragger_UpperLeft.sprites[i].params.enableCornerRounding(); + resizeDragger_UpperLeft.sprites[i].params.corners_rounding[0].radius = radius; + resizeDragger_UpperRight.sprites[i].params.enableCornerRounding(); + resizeDragger_UpperRight.sprites[i].params.corners_rounding[1].radius = radius; + resizeDragger_BottomLeft.sprites[i].params.enableCornerRounding(); + resizeDragger_BottomLeft.sprites[i].params.corners_rounding[2].radius = radius; + resizeDragger_BottomRight.sprites[i].params.enableCornerRounding(); + resizeDragger_BottomRight.sprites[i].params.corners_rounding[3].radius = radius; + + if (IsCollapsed()) + { + resizeDragger_UpperLeft.sprites[i].params.corners_rounding[2].radius = radius; + resizeDragger_UpperRight.sprites[i].params.corners_rounding[3].radius = radius; + } + else + { + resizeDragger_UpperLeft.sprites[i].params.corners_rounding[2].radius = 0; + resizeDragger_UpperRight.sprites[i].params.corners_rounding[3].radius = 0; + } + + openFolderButton.sprites[i].params.enableCornerRounding(); + openFolderButton.sprites[i].params.corners_rounding[0].radius = radius; + openFolderButton.sprites[i].params.corners_rounding[1].radius = radius; + openFolderButton.sprites[i].params.corners_rounding[2].radius = radius; + openFolderButton.sprites[i].params.corners_rounding[3].radius = radius; + } + + for (auto& x : folderButtons) + { + x.font.params.h_align = wi::font::WIFALIGN_LEFT; + for (auto& y : x.sprites) + { + y.params.enableCornerRounding(); + y.params.corners_rounding[3].radius = radius; + } + x.SetShadowRadius(0); + } + for (auto& x : itemButtons) + { + if (x.sprites[wi::gui::IDLE].textureResource.IsValid()) + { + x.sprites[wi::gui::IDLE].params.color = wi::Color::White(); + } + for (auto& y : x.sprites) + { + y.params.enableCornerRounding(); + y.params.corners_rounding[0].radius = radius; + y.params.corners_rounding[1].radius = radius; + y.params.corners_rounding[2].radius = radius; + y.params.corners_rounding[3].radius = radius; + } + x.SetShadowRadius(4); + } + + openFolderButton.SetShadowRadius(0); + + XMFLOAT4 color_on = sprites[wi::gui::FOCUS].params.color; + XMFLOAT4 color_off = sprites[wi::gui::IDLE].params.color; + + for (auto& x : folderButtons) + { + x.sprites[wi::gui::IDLE].params.color = color_off; + } + if (current_selection < SELECTION_COUNT) + { + folderButtons[current_selection].sprites[wi::gui::IDLE].params.color = color_on; + } +} + +void ContentBrowserWindow::ResizeLayout() +{ + wi::gui::Window::ResizeLayout(); + const float padding = 4; + const float width = GetWidgetAreaSize().x; + float y = padding; + + openFolderButton.Detach(); + openFolderButton.SetPos(XMFLOAT2(translation.x + padding, translation.y + scale.y - openFolderButton.GetSize().y - padding)); + openFolderButton.SetSize(XMFLOAT2(separator - padding * 2, openFolderButton.GetSize().y)); + openFolderButton.AttachTo(this); + + for (auto& x : folderButtons) + { + x.Detach(); + x.SetPos(XMFLOAT2(translation.x + padding, translation.y + control_size + y)); + x.SetSize(XMFLOAT2(separator - padding * 2, x.GetSize().y)); + y += x.GetSize().y + padding; + x.AttachTo(this); + } + + y = padding + 10; + + float sep = separator + 10; + float hoffset = sep; + for (auto& x : itemButtons) + { + x.SetPos(XMFLOAT2(hoffset, y)); + hoffset += x.GetSize().x + 15; + if (hoffset + x.GetSize().x >= width) + { + hoffset = sep; + y += x.GetSize().y + 40; + } + } +} + +void ContentBrowserWindow::RefreshContent() +{ +#ifdef PLATFORM_UWP + content_folder = wi::helper::GetCurrentPath() + "/"; +#else + content_folder = wi::helper::GetCurrentPath() + "/Content/"; + wi::helper::MakePathAbsolute(content_folder); + if (!wi::helper::FileExists(content_folder)) + { + content_folder = wi::helper::GetCurrentPath() + "/../Content/"; + wi::helper::MakePathAbsolute(content_folder); + } +#endif // PLATFORM_UWP + + float hei = 25; + float wid = 120; + + for (auto& x : folderButtons) + { + RemoveWidget(&x); + } + + if (!editor->recentFilenames.empty()) + { + wi::gui::Button& button = folderButtons[SELECTION_RECENT]; + button.Create("Recently Used"); + button.SetLocalizationEnabled(false); + button.SetSize(XMFLOAT2(wid, hei)); + button.OnClick([this](wi::gui::EventArgs args) { + SetSelection(SELECTION_RECENT); + }); + AddWidget(&button, wi::gui::Window::AttachmentOptions::NONE); + if (current_selection == SELECTION_COUNT) + { + current_selection = SELECTION_RECENT; + } + } + if (wi::helper::DirectoryExists(content_folder + "scripts")) + { + wi::gui::Button& button = folderButtons[SELECTION_SCRIPTS]; + button.Create("Scripts"); + button.SetLocalizationEnabled(false); + button.SetSize(XMFLOAT2(wid, hei)); + button.OnClick([this](wi::gui::EventArgs args) { + SetSelection(SELECTION_SCRIPTS); + }); + AddWidget(&button, wi::gui::Window::AttachmentOptions::NONE); + if (current_selection == SELECTION_COUNT) + { + current_selection = SELECTION_SCRIPTS; + } + } + if (wi::helper::DirectoryExists(content_folder + "models")) + { + wi::gui::Button& button = folderButtons[SELECTION_MODELS]; + button.Create("Models"); + button.SetLocalizationEnabled(false); + button.SetSize(XMFLOAT2(wid, hei)); + button.OnClick([this](wi::gui::EventArgs args) { + SetSelection(SELECTION_MODELS); + }); + AddWidget(&button, wi::gui::Window::AttachmentOptions::NONE); + if (current_selection == SELECTION_COUNT) + { + current_selection = SELECTION_MODELS; + } + } + + if (current_selection != SELECTION_COUNT) + { + SetSelection(current_selection); + } +} +void ContentBrowserWindow::SetSelection(SELECTION selection) +{ + wi::eventhandler::Subscribe_Once(wi::eventhandler::EVENT_THREAD_SAFE_POINT, [=](uint64_t userdata) { + current_selection = selection; + for (auto& x : itemButtons) + { + RemoveWidget(&x); + } + itemButtons.clear(); + + RemoveWidget(&openFolderButton); + openFolderButton.Create(ICON_OPEN " Go to location"); + openFolderButton.SetSize(XMFLOAT2(60, 60)); + + switch (selection) + { + default: + case SELECTION_SCRIPTS: + AddItems(content_folder + "scripts/", "lua", ICON_SCRIPT); + openFolderButton.OnClick([this](wi::gui::EventArgs args) { + wi::helper::OpenUrl(content_folder + "scripts/"); + }); + AddWidget(&openFolderButton, wi::gui::Window::AttachmentOptions::NONE); + break; + case SELECTION_MODELS: + AddItems(content_folder + "models/", "wiscene", ICON_OBJECT); + AddItems(content_folder + "models/", "gltf", ICON_OBJECT); + AddItems(content_folder + "models/", "glb", ICON_OBJECT); + AddItems(content_folder + "models/", "obj", ICON_OBJECT); + openFolderButton.OnClick([this](wi::gui::EventArgs args) { + wi::helper::OpenUrl(content_folder + "models/"); + }); + AddWidget(&openFolderButton, wi::gui::Window::AttachmentOptions::NONE); + break; + case SELECTION_RECENT: + for (size_t i = 0; i < editor->recentFilenames.size(); ++i) + { + const std::string& filename = editor->recentFilenames[editor->recentFilenames.size() - 1 - i]; + std::string ext = wi::helper::toUpper(wi::helper::GetExtensionFromFileName(filename)); + if (!ext.compare("LUA")) + { + AddItem(filename, ICON_SCRIPT); + } + if (!ext.compare("WISCENE")) + { + AddItem(filename, ICON_OBJECT); + } + if (!ext.compare("GLTF")) + { + AddItem(filename, ICON_OBJECT); + } + if (!ext.compare("GLB")) + { + AddItem(filename, ICON_OBJECT); + } + if (!ext.compare("OBJ")) + { + AddItem(filename, ICON_OBJECT); + } + } + break; + } + + for (auto& x : itemButtons) + { + AddWidget(&x); + } + + // Refresh theme: + editor->optionsWnd.generalWnd.themeCombo.SetSelected(editor->optionsWnd.generalWnd.themeCombo.GetSelected()); + + }); +} +void ContentBrowserWindow::AddItems(const std::string& folder, const std::string& extension, const std::string& icon) +{ + // Folders parse: + wi::helper::GetFolderNamesInDirectory(folder, [&](std::string foldername) { + std::string itemname = foldername.substr(folder.size()) + "." + extension; + std::string filename = foldername + "/" + itemname; + if (wi::helper::FileExists(filename)) + { + AddItem(filename, icon); + } + }); + + // Individual items: + wi::helper::GetFileNamesInDirectory(folder, [&](std::string filename) { + AddItem(filename, icon); + }, extension); +} +void ContentBrowserWindow::AddItem(const std::string& filename, const std::string& icon) +{ + static const XMFLOAT2 siz = XMFLOAT2(240, 120); + + std::string itemname = wi::helper::GetFileNameFromPath(filename); + std::string foldername = wi::helper::GetDirectoryFromPath(filename); + + wi::gui::Button& button = itemButtons.emplace_back(); + button.Create(icon); + button.SetSize(siz); + button.SetLocalizationEnabled(false); + button.SetDescription(itemname); + button.SetTooltip(filename); + button.OnClick([this, filename](wi::gui::EventArgs args) { + wi::eventhandler::Subscribe_Once(wi::eventhandler::EVENT_THREAD_SAFE_POINT, [=](uint64_t userdata) { + editor->Open(filename); + }); + this->SetVisible(false); + }); + button.font_description.params.h_align = wi::font::WIFALIGN_CENTER; + button.font_description.params.v_align = wi::font::WIFALIGN_TOP; + button.font.params.size = 42; + std::string thumbnailName = foldername + "/thumbnail.png"; + if (wi::helper::FileExists(thumbnailName)) + { + wi::Resource thumbnail = wi::resourcemanager::Load(thumbnailName); + if (thumbnail.IsValid()) + { + for (int i = 0; i < arraysize(sprites); ++i) + { + button.sprites[i].textureResource = thumbnail; + } + button.SetText(""); + } + } +} diff --git a/Editor/ContentBrowserWindow.h b/Editor/ContentBrowserWindow.h new file mode 100644 index 00000000000..be9438b7941 --- /dev/null +++ b/Editor/ContentBrowserWindow.h @@ -0,0 +1,36 @@ +#pragma once +class EditorComponent; + +class ContentBrowserWindow : public wi::gui::Window +{ +public: + void Create(EditorComponent* editor); + + EditorComponent* editor = nullptr; + + std::string content_folder; + enum SELECTION + { + SELECTION_RECENT, + SELECTION_SCRIPTS, + SELECTION_MODELS, + + SELECTION_COUNT + }; + SELECTION current_selection = SELECTION_COUNT; + wi::gui::Button folderButtons[SELECTION_COUNT]; + wi::vector itemButtons; + + wi::gui::Button openFolderButton; + + void RefreshContent(); + + void SetSelection(SELECTION selection); + void AddItems(const std::string& folder, const std::string& extension, const std::string& icon); + void AddItem(const std::string& filename, const std::string& icon); + + void Update(const wi::Canvas& canvas, float dt); + void Render(const wi::Canvas& canvas, wi::graphics::CommandList cmd) const override; + void ResizeLayout() override; +}; + diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index 0af441589d8..bc24b1c44d3 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -100,7 +100,6 @@ void Editor::Initialize() loader.addLoadingComponent(&renderComponent, this, 0.2f); ActivatePath(&loader); - } void EditorLoadingScreen::Load() @@ -214,6 +213,9 @@ void EditorComponent::ResizeLayout() aboutWindow.SetSize(XMFLOAT2(screenW / 2.0f, screenH / 1.5f)); aboutWindow.SetPos(XMFLOAT2(screenW / 2.0f - aboutWindow.scale.x / 2.0f, screenH / 2.0f - aboutWindow.scale.y / 2.0f)); + contentBrowserWnd.SetSize(XMFLOAT2(screenW / 1.6f, screenH / 1.2f)); + contentBrowserWnd.SetPos(XMFLOAT2(screenW / 2.0f - contentBrowserWnd.scale.x / 2.0f, screenH / 2.0f - contentBrowserWnd.scale.y / 2.0f)); + } void EditorComponent::Load() { @@ -294,6 +296,15 @@ void EditorComponent::Load() }); GetGUI().AddWidget(&dummyButton); + navtestButton.Create(ICON_NAVIGATION); + navtestButton.SetShadowRadius(2); + navtestButton.SetTooltip("Toggle navigation testing. When enabled, you can visualize path finding results.\nYou can put down START and GOAL waypoints inside voxel grids to test path finding.\nControls:\n----------\nF5 + left click: put START to surface\nF6 + left click: put GOAL to surface\nF7 + left click: put START to air\nF8 + left click: put GOAL to air"); + navtestButton.SetLocalizationEnabled(wi::gui::LocalizationEnabled::Tooltip); + navtestButton.OnClick([&](wi::gui::EventArgs args) { + navtest_enabled = !navtest_enabled; + }); + GetGUI().AddWidget(&navtestButton); + playButton.Create(ICON_PLAY); playButton.font.params.shadowColor = wi::Color::Transparent(); playButton.SetShadowRadius(2); @@ -407,6 +418,23 @@ void EditorComponent::Load() GetGUI().AddWidget(&openButton); + contentBrowserButton.Create("Content Browser"); + contentBrowserButton.SetLocalizationEnabled(wi::gui::LocalizationEnabled::Tooltip); + contentBrowserButton.SetShadowRadius(2); + contentBrowserButton.font.params.shadowColor = wi::Color::Transparent(); + contentBrowserButton.SetTooltip("Browse sample content."); + contentBrowserButton.SetColor(wi::Color(50, 100, 255, 180), wi::gui::WIDGETSTATE::IDLE); + contentBrowserButton.SetColor(wi::Color(120, 160, 255, 255), wi::gui::WIDGETSTATE::FOCUS); + contentBrowserButton.OnClick([&](wi::gui::EventArgs args) { + contentBrowserWnd.SetVisible(!contentBrowserWnd.IsVisible()); + if (contentBrowserWnd.IsVisible()) + { + contentBrowserWnd.RefreshContent(); + } + }); + GetGUI().AddWidget(&contentBrowserButton); + + logButton.Create("Backlog"); logButton.SetLocalizationEnabled(wi::gui::LocalizationEnabled::Tooltip); logButton.SetShadowRadius(2); @@ -651,6 +679,9 @@ void EditorComponent::Load() profilerWnd.Create(); GetGUI().AddWidget(&profilerWnd); + contentBrowserWnd.Create(this); + GetGUI().AddWidget(&contentBrowserWnd); + std::string theme = main->config.GetSection("options").GetText("theme"); if(theme.empty()) { @@ -686,6 +717,14 @@ void EditorComponent::Load() }; wi::helper::GetFileNamesInDirectory("fonts/", load_font, "TTF"); + size_t current_recent = 0; + auto& recent = main->config.GetSection("recent"); + while (recent.Has(std::to_string(current_recent).c_str())) + { + recentFilenames.push_back(recent.GetText(std::to_string(current_recent).c_str())); + current_recent++; + } + RenderPath2D::Load(); } void EditorComponent::Start() @@ -923,7 +962,7 @@ void EditorComponent::Update(float dt) inspector_mode = wi::input::Down((wi::input::BUTTON)'I'); // Begin picking: - Ray pickRay = wi::renderer::GetPickRay((long)currentMouse.x, (long)currentMouse.y, *this, camera); + pickRay = wi::renderer::GetPickRay((long)currentMouse.x, (long)currentMouse.y, *this, camera); { hovered = wi::scene::PickResult(); @@ -1150,6 +1189,25 @@ void EditorComponent::Update(float dt) } } } + if (has_flag(optionsWnd.filter, OptionsWindow::Filter::VoxelGrid)) + { + for (size_t i = 0; i < scene.voxel_grids.GetCount(); ++i) + { + Entity entity = scene.voxel_grids.GetEntity(i); + if (!scene.transforms.Contains(entity)) + continue; + const TransformComponent& transform = *scene.transforms.GetComponent(entity); + + XMVECTOR disV = XMVector3LinePointDistance(XMLoadFloat3(&pickRay.origin), XMLoadFloat3(&pickRay.origin) + XMLoadFloat3(&pickRay.direction), transform.GetPositionV()); + float dis = XMVectorGetX(disV); + if (dis > 0.01f && dis < wi::math::Distance(transform.GetPosition(), pickRay.origin) * 0.05f && dis < hovered.distance) + { + hovered = wi::scene::PickResult(); + hovered.entity = entity; + hovered.distance = dis; + } + } + } if (bone_picking) { for (size_t i = 0; i < scene.armatures.GetCount(); ++i) @@ -1701,6 +1759,7 @@ void EditorComponent::Update(float dt) componentsWnd.terrainWnd.SetEntity(INVALID_ENTITY); componentsWnd.spriteWnd.SetEntity(INVALID_ENTITY); componentsWnd.fontWnd.SetEntity(INVALID_ENTITY); + componentsWnd.voxelGridWnd.SetEntity(INVALID_ENTITY); } else { @@ -1734,6 +1793,7 @@ void EditorComponent::Update(float dt) componentsWnd.terrainWnd.SetEntity(picked.entity); componentsWnd.spriteWnd.SetEntity(picked.entity); componentsWnd.fontWnd.SetEntity(picked.entity); + componentsWnd.voxelGridWnd.SetEntity(picked.entity); if (picked.subsetIndex >= 0) { @@ -1902,6 +1962,75 @@ void EditorComponent::Update(float dt) renderPath->colorspace = colorspace; renderPath->Update(dt); + if (navtest_enabled) + { + if (hovered.entity != INVALID_ENTITY && wi::input::Down(wi::input::KEYBOARD_BUTTON_F5)) + { + navtest_start_pick = hovered; + } + if (hovered.entity != INVALID_ENTITY && wi::input::Down(wi::input::KEYBOARD_BUTTON_F6)) + { + navtest_goal_pick = hovered; + } + if (wi::input::Down(wi::input::KEYBOARD_BUTTON_F7) && wi::input::Down(wi::input::MOUSE_BUTTON_LEFT)) + { + navtest_start_pick.entity = INVALID_ENTITY; + XMStoreFloat3(&navtest_start_pick.position, XMLoadFloat3(&pickRay.origin) + XMLoadFloat3(&pickRay.direction) * 2); + } + if (wi::input::Down(wi::input::KEYBOARD_BUTTON_F8) && wi::input::Down(wi::input::MOUSE_BUTTON_LEFT)) + { + navtest_goal_pick.entity = INVALID_ENTITY; + XMStoreFloat3(&navtest_goal_pick.position, XMLoadFloat3(&pickRay.origin) + XMLoadFloat3(&pickRay.direction) * 2); + } + + navtest_pathquery.flying = false; + if ( + navtest_start_pick.entity != INVALID_ENTITY && + navtest_goal_pick.entity != INVALID_ENTITY + ) + { + navtest_start_pick.position = scene.GetPositionOnSurface( + navtest_start_pick.entity, + navtest_start_pick.vertexID0, + navtest_start_pick.vertexID1, + navtest_start_pick.vertexID2, + navtest_start_pick.bary + ); + navtest_goal_pick.position = scene.GetPositionOnSurface( + navtest_goal_pick.entity, + navtest_goal_pick.vertexID0, + navtest_goal_pick.vertexID1, + navtest_goal_pick.vertexID2, + navtest_goal_pick.bary + ); + } + else if( + navtest_start_pick.entity == INVALID_ENTITY && + navtest_goal_pick.entity == INVALID_ENTITY + ) + { + navtest_pathquery.flying = true; + } + + for (size_t i = 0; i < scene.voxel_grids.GetCount(); ++i) + { + const wi::VoxelGrid& voxelgrid = scene.voxel_grids[i]; + AABB aabb = voxelgrid.get_aabb(); + if (aabb.intersects(navtest_start_pick.position) && aabb.intersects(navtest_goal_pick.position)) + { + auto range = wi::profiler::BeginRangeCPU("NAVTEST PATHQUERY"); + navtest_pathquery.process( + navtest_start_pick.position, + navtest_goal_pick.position, + voxelgrid + ); + wi::profiler::EndRange(range); + wi::renderer::DrawPathQuery(&navtest_pathquery); + break; + } + } + + } bool force_collider_visualizer = false; for (auto& x : translator.selected) @@ -1932,6 +2061,24 @@ void EditorComponent::PostUpdate() { componentsWnd.cameraComponentWnd.preview.RenderPreview(); } + + const Scene& scene = GetCurrentScene(); + if (componentsWnd.voxelGridWnd.debugAllCheckBox.GetCheck()) + { + // Draw all voxel grids: + for (size_t i = 0; i < scene.voxel_grids.GetCount(); ++i) + { + wi::renderer::DrawVoxelGrid(&scene.voxel_grids[i]); + } + } + else + { + // Draw only selected: + if (scene.voxel_grids.Contains(componentsWnd.voxelGridWnd.entity)) + { + wi::renderer::DrawVoxelGrid(scene.voxel_grids.GetComponent(componentsWnd.voxelGridWnd.entity)); + } + } } void EditorComponent::Render() const { @@ -2743,6 +2890,36 @@ void EditorComponent::Render() const wi::font::Draw(ICON_VIDEO, fp, cmd); } } + if (has_flag(optionsWnd.filter, OptionsWindow::Filter::VoxelGrid)) + { + for (size_t i = 0; i < scene.voxel_grids.GetCount(); ++i) + { + Entity entity = scene.voxel_grids.GetEntity(i); + if (!scene.transforms.Contains(entity)) + continue; + const TransformComponent& transform = *scene.transforms.GetComponent(entity); + + fp.position = transform.GetPosition(); + fp.scaling = scaling * wi::math::Distance(transform.GetPosition(), camera.Eye); + fp.color = inactiveEntityColor; + + if (hovered.entity == entity) + { + fp.color = hoveredEntityColor; + } + for (auto& picked : translator.selected) + { + if (picked.entity == entity) + { + fp.color = selectedEntityColor; + break; + } + } + + + wi::font::Draw(ICON_VOXELGRID, fp, cmd); + } + } if (bone_picking) { static PipelineState pso; @@ -3463,6 +3640,32 @@ void EditorComponent::ConsumeHistoryOperation(bool undo) optionsWnd.RefreshEntityTree(); } +void EditorComponent::RegisterRecentlyUsed(const std::string& filename) +{ + for (size_t i = 0; i < recentFilenames.size();) + { + if (recentFilenames[i].compare(filename) == 0) + { + recentFilenames.erase(recentFilenames.begin() + i); + } + else + { + i++; + } + } + while (recentFilenames.size() >= maxRecentFilenames) + { + recentFilenames.erase(recentFilenames.begin()); + } + recentFilenames.push_back(filename); + auto& recent = main->config.GetSection("recent"); + for (size_t i = 0; i < recentFilenames.size(); ++i) + { + recent.Set(std::to_string(i).c_str(), recentFilenames[i]); + } + main->config.Commit(); +} + void EditorComponent::Open(const std::string& filename) { std::string extension = wi::helper::toUpper(wi::helper::GetExtensionFromFileName(filename)); @@ -3484,6 +3687,7 @@ void EditorComponent::Open(const std::string& filename) playButton.SetScriptTip("dofile(\"" + last_script_path + "\")"); wi::lua::RunFile(filename); optionsWnd.RefreshEntityTree(); + RegisterRecentlyUsed(filename); return; } if (type == FileType::VIDEO) @@ -3521,6 +3725,8 @@ void EditorComponent::Open(const std::string& filename) return; } + RegisterRecentlyUsed(filename); + size_t camera_count_prev = GetCurrentScene().cameras.GetCount(); main->loader.addLoadingFunction([=](wi::jobsystem::JobArgs args) { @@ -3640,6 +3846,8 @@ void EditorComponent::Save(const std::string& filename) GetCurrentEditorScene().path = filename; RefreshSceneList(); + RegisterRecentlyUsed(filename); + PostSaveText("Scene saved: ", GetCurrentEditorScene().path); } void EditorComponent::SaveAs() @@ -3751,6 +3959,18 @@ void EditorComponent::UpdateTopMenuAnimation() openButton.SetText(openButton.GetState() > wi::gui::WIDGETSTATE::IDLE ? ICON_OPEN " Open" : ICON_OPEN); } + if (contentBrowserButton.GetState() > wi::gui::WIDGETSTATE::IDLE && current_localization.Get((size_t)EditorLocalization::ContentBrowser) != nullptr) + { + tmp = ICON_CONTENT_BROWSER " "; + tmp += current_localization.Get((size_t)EditorLocalization::ContentBrowser); + contentBrowserButton.SetText(tmp); + } + else + { + contentBrowserButton.SetText(contentBrowserButton.GetState() > wi::gui::WIDGETSTATE::IDLE ? ICON_CONTENT_BROWSER " Content" : ICON_CONTENT_BROWSER); + } + + if (logButton.GetState() > wi::gui::WIDGETSTATE::IDLE && current_localization.Get((size_t)EditorLocalization::Backlog) != nullptr) { tmp = ICON_BACKLOG " "; @@ -3851,6 +4071,7 @@ void EditorComponent::UpdateTopMenuAnimation() profilerButton.SetSize(XMFLOAT2(wi::math::Lerp(profilerButton.GetSize().x, profilerButton.GetState() > wi::gui::WIDGETSTATE::IDLE ? wid_focus : wid_idle, lerp), hei)); cinemaButton.SetSize(XMFLOAT2(wi::math::Lerp(cinemaButton.GetSize().x, cinemaButton.GetState() > wi::gui::WIDGETSTATE::IDLE ? wid_focus : wid_idle, lerp), hei)); logButton.SetSize(XMFLOAT2(wi::math::Lerp(logButton.GetSize().x, logButton.GetState() > wi::gui::WIDGETSTATE::IDLE ? wid_focus : wid_idle, lerp), hei)); + contentBrowserButton.SetSize(XMFLOAT2(wi::math::Lerp(contentBrowserButton.GetSize().x, contentBrowserButton.GetState() > wi::gui::WIDGETSTATE::IDLE ? wid_focus : wid_idle, lerp), hei)); openButton.SetSize(XMFLOAT2(wi::math::Lerp(openButton.GetSize().x, openButton.GetState() > wi::gui::WIDGETSTATE::IDLE ? wid_focus : wid_idle, lerp), hei)); saveButton.SetSize(XMFLOAT2(wi::math::Lerp(saveButton.GetSize().x, saveButton.GetState() > wi::gui::WIDGETSTATE::IDLE ? wid_focus : wid_idle, lerp), hei)); @@ -3861,17 +4082,20 @@ void EditorComponent::UpdateTopMenuAnimation() cinemaButton.SetPos(XMFLOAT2(fullscreenButton.GetPos().x - cinemaButton.GetSize().x - padding, 0)); profilerButton.SetPos(XMFLOAT2(cinemaButton.GetPos().x - profilerButton.GetSize().x - padding, 0)); logButton.SetPos(XMFLOAT2(profilerButton.GetPos().x - logButton.GetSize().x - padding, 0)); - openButton.SetPos(XMFLOAT2(logButton.GetPos().x - openButton.GetSize().x - padding, 0)); + contentBrowserButton.SetPos(XMFLOAT2(logButton.GetPos().x - contentBrowserButton.GetSize().x - padding, 0)); + openButton.SetPos(XMFLOAT2(contentBrowserButton.GetPos().x - openButton.GetSize().x - padding, 0)); saveButton.SetPos(XMFLOAT2(openButton.GetPos().x - saveButton.GetSize().x - padding, 0)); - float static_pos = screenW - wid_idle * 11; + float static_pos = screenW - wid_idle * 12; dummyButton.SetSize(XMFLOAT2(wid_idle * 0.75f, hei)); dummyButton.SetPos(XMFLOAT2(static_pos - dummyButton.GetSize().x - 20, 0)); + navtestButton.SetSize(XMFLOAT2(wid_idle * 0.75f, hei)); + navtestButton.SetPos(XMFLOAT2(dummyButton.GetPos().x - navtestButton.GetSize().x - padding, 0)); physicsButton.SetSize(XMFLOAT2(wid_idle * 0.75f, hei)); - physicsButton.SetPos(XMFLOAT2(dummyButton.GetPos().x - physicsButton.GetSize().x - 20, 0)); + physicsButton.SetPos(XMFLOAT2(navtestButton.GetPos().x - physicsButton.GetSize().x - 20, 0)); stopButton.SetSize(XMFLOAT2(wid_idle * 0.75f, hei)); stopButton.SetPos(XMFLOAT2(physicsButton.GetPos().x - stopButton.GetSize().x - 20, 0)); @@ -3917,6 +4141,15 @@ void EditorComponent::UpdateTopMenuAnimation() dummyButton.sprites[wi::gui::IDLE].params.color = color_off; } + if (navtest_enabled) + { + navtestButton.sprites[wi::gui::IDLE].params.color = color_on; + } + else + { + navtestButton.sprites[wi::gui::IDLE].params.color = color_off; + } + if (wi::physics::IsSimulationEnabled()) { physicsButton.sprites[wi::gui::IDLE].params.color = color_on; @@ -4020,6 +4253,7 @@ void EditorComponent::RefreshSceneList() componentsWnd.terrainWnd.SetEntity(wi::ecs::INVALID_ENTITY); componentsWnd.spriteWnd.SetEntity(wi::ecs::INVALID_ENTITY); componentsWnd.fontWnd.SetEntity(wi::ecs::INVALID_ENTITY); + componentsWnd.voxelGridWnd.SetEntity(wi::ecs::INVALID_ENTITY); optionsWnd.RefreshEntityTree(); ResetHistory(); diff --git a/Editor/Editor.h b/Editor/Editor.h index fa214e17665..461dc299e30 100644 --- a/Editor/Editor.h +++ b/Editor/Editor.h @@ -4,6 +4,7 @@ #include "OptionsWindow.h" #include "ComponentsWindow.h" #include "ProfilerWindow.h" +#include "ContentBrowserWindow.h" #include "IconDefinitions.h" class EditorLoadingScreen : public wi::LoadingScreen @@ -35,11 +36,18 @@ class EditorComponent : public wi::RenderPath2D bool dummy_male = false; XMFLOAT3 dummy_pos = XMFLOAT3(0, 0, 0); + wi::gui::Button navtestButton; + bool navtest_enabled = false; + wi::scene::PickResult navtest_start_pick; + wi::scene::PickResult navtest_goal_pick; + wi::PathQuery navtest_pathquery; + wi::gui::Button playButton; wi::gui::Button stopButton; wi::gui::Button saveButton; wi::gui::Button openButton; + wi::gui::Button contentBrowserButton; wi::gui::Button logButton; wi::gui::Button profilerButton; wi::gui::Button cinemaButton; @@ -53,7 +61,9 @@ class EditorComponent : public wi::RenderPath2D OptionsWindow optionsWnd; ComponentsWindow componentsWnd; ProfilerWindow profilerWnd; + ContentBrowserWindow contentBrowserWnd; + wi::primitive::Ray pickRay; wi::physics::PickDragOperation physicsDragOp; std::unique_ptr renderPath; @@ -129,6 +139,10 @@ class EditorComponent : public wi::RenderPath2D wi::Archive& AdvanceHistory(); void ConsumeHistoryOperation(bool undo); + wi::vector recentFilenames; + size_t maxRecentFilenames = 10; + void RegisterRecentlyUsed(const std::string& filename); + void Open(const std::string& filename); void Save(const std::string& filename); void SaveAs(); @@ -202,6 +216,7 @@ enum class EditorLocalization // Top menu: Save, Open, + ContentBrowser, Backlog, Profiler, Cinema, @@ -220,6 +235,7 @@ static const char* EditorLocalizationStrings[] = { // Top menu: "Save", "Open", + "Content", "Backlog", "Profiler", "Cinema", diff --git a/Editor/Editor_SOURCE.vcxitems b/Editor/Editor_SOURCE.vcxitems index de1bff56c61..215de9b8b61 100644 --- a/Editor/Editor_SOURCE.vcxitems +++ b/Editor/Editor_SOURCE.vcxitems @@ -20,6 +20,7 @@ + @@ -126,6 +127,7 @@ + NotUsing @@ -145,6 +147,7 @@ + @@ -187,6 +190,7 @@ + diff --git a/Editor/Editor_SOURCE.vcxitems.filters b/Editor/Editor_SOURCE.vcxitems.filters index 15b297388a6..7dfd93e12b4 100644 --- a/Editor/Editor_SOURCE.vcxitems.filters +++ b/Editor/Editor_SOURCE.vcxitems.filters @@ -91,6 +91,8 @@ + + @@ -146,6 +148,8 @@ + + diff --git a/Editor/GeneralWindow.cpp b/Editor/GeneralWindow.cpp index 8b3a1e23b3e..fdca17d6b7e 100644 --- a/Editor/GeneralWindow.cpp +++ b/Editor/GeneralWindow.cpp @@ -530,9 +530,11 @@ void GeneralWindow::Create(EditorComponent* _editor) editor->scaleButton.sprites[i].params.corners_rounding[3].radius = 40; editor->dummyButton.sprites[i].params.enableCornerRounding(); - editor->dummyButton.sprites[i].params.corners_rounding[2].radius = 40; editor->dummyButton.sprites[i].params.corners_rounding[3].radius = 40; + editor->navtestButton.sprites[i].params.enableCornerRounding(); + editor->navtestButton.sprites[i].params.corners_rounding[2].radius = 40; + editor->physicsButton.sprites[i].params.enableCornerRounding(); editor->physicsButton.sprites[i].params.corners_rounding[2].radius = 40; editor->physicsButton.sprites[i].params.corners_rounding[3].radius = 40; diff --git a/Editor/GraphicsWindow.cpp b/Editor/GraphicsWindow.cpp index 6eec425f7b1..221082c1e40 100644 --- a/Editor/GraphicsWindow.cpp +++ b/Editor/GraphicsWindow.cpp @@ -13,7 +13,7 @@ void GraphicsWindow::Create(EditorComponent* _editor) wi::renderer::SetToDrawGridHelper(true); wi::renderer::SetToDrawDebugCameras(true); - SetSize(XMFLOAT2(580, 1640)); + SetSize(XMFLOAT2(580, 1660)); float step = 21; float itemheight = 18; @@ -957,6 +957,38 @@ void GraphicsWindow::Create(EditorComponent* _editor) AddWidget(&raytracedDiffuseRangeSlider); raytracedDiffuseRangeSlider.SetEnabled(wi::graphics::GetDevice()->CheckCapability(GraphicsDeviceCapability::RAYTRACING)); + ssgiCheckBox.Create("SSGI: "); + ssgiCheckBox.SetTooltip("Enable Screen Space Global Illumination, this can add a light bounce effect coming from objects on the screen."); + ssgiCheckBox.SetScriptTip("RenderPath3D::SetSSGIEnabled(bool value)"); + ssgiCheckBox.SetSize(XMFLOAT2(hei, hei)); + ssgiCheckBox.SetPos(XMFLOAT2(x + 140, y)); + if (editor->main->config.GetSection("graphics").Has("ssgi")) + { + editor->renderPath->setSSGIEnabled(editor->main->config.GetSection("graphics").GetBool("ssgi")); + } + ssgiCheckBox.OnClick([=](wi::gui::EventArgs args) { + editor->renderPath->setSSGIEnabled(args.bValue); + editor->main->config.GetSection("graphics").Set("ssgi", args.bValue); + editor->main->config.Commit(); + }); + AddWidget(&ssgiCheckBox); + + ssgiDepthRejectionSlider.Create(0.1f, 100.0f, 8, 1000, "SSGI.DepthRejection"); + ssgiDepthRejectionSlider.SetText("Depth: "); + ssgiDepthRejectionSlider.SetTooltip("SSGI depth rejection distance."); + ssgiDepthRejectionSlider.SetSize(XMFLOAT2(mod_wid, hei)); + ssgiDepthRejectionSlider.SetPos(XMFLOAT2(x + 100, y)); + if (editor->main->config.GetSection("graphics").Has("ssgi_depthrejection")) + { + editor->renderPath->setSSGIDepthRejection(editor->main->config.GetSection("graphics").GetFloat("ssgi_depthrejection")); + } + ssgiDepthRejectionSlider.OnSlide([=](wi::gui::EventArgs args) { + editor->renderPath->setSSGIDepthRejection(args.fValue); + editor->main->config.GetSection("graphics").Set("ssgi_depthrejection", args.fValue); + editor->main->config.Commit(); + }); + AddWidget(&ssgiDepthRejectionSlider); + screenSpaceShadowsCheckBox.Create("Screen Shadows: "); screenSpaceShadowsCheckBox.SetTooltip("Enable screen space contact shadows. This can add small shadows details to shadow maps in screen space."); screenSpaceShadowsCheckBox.SetSize(XMFLOAT2(hei, hei)); @@ -1525,9 +1557,11 @@ void GraphicsWindow::Update() raytracedReflectionsCheckBox.SetCheck(editor->renderPath->getRaytracedReflectionEnabled()); raytracedReflectionsRangeSlider.SetValue(editor->renderPath->getRaytracedReflectionsRange()); raytracedDiffuseCheckBox.SetCheck(editor->renderPath->getRaytracedDiffuseEnabled()); + ssgiCheckBox.SetCheck(editor->renderPath->getSSGIEnabled()); raytracedDiffuseRangeSlider.SetValue(editor->renderPath->getRaytracedDiffuseRange()); screenSpaceShadowsCheckBox.SetCheck(wi::renderer::GetScreenSpaceShadowsEnabled()); screenSpaceShadowsRangeSlider.SetValue((float)editor->renderPath->getScreenSpaceShadowRange()); + ssgiDepthRejectionSlider.SetValue((float)editor->renderPath->getSSGIDepthRejection()); screenSpaceShadowsStepCountSlider.SetValue((float)editor->renderPath->getScreenSpaceShadowSampleCount()); eyeAdaptionCheckBox.SetCheck(editor->renderPath->getEyeAdaptionEnabled()); eyeAdaptionKeySlider.SetValue(editor->renderPath->getEyeAdaptionKey()); @@ -1787,6 +1821,8 @@ void GraphicsWindow::ResizeLayout() ssrCheckBox.SetPos(XMFLOAT2(reflectionsRoughnessCutoffSlider.GetPos().x - ssrCheckBox.GetSize().x - 80, reflectionsRoughnessCutoffSlider.GetPos().y)); add_right(raytracedReflectionsRangeSlider); raytracedReflectionsCheckBox.SetPos(XMFLOAT2(raytracedReflectionsRangeSlider.GetPos().x - raytracedReflectionsCheckBox.GetSize().x - 80, raytracedReflectionsRangeSlider.GetPos().y)); + add_right(ssgiDepthRejectionSlider); + ssgiCheckBox.SetPos(XMFLOAT2(ssgiDepthRejectionSlider.GetPos().x - ssgiCheckBox.GetSize().x - 80, ssgiDepthRejectionSlider.GetPos().y)); add_right(raytracedDiffuseRangeSlider); raytracedDiffuseCheckBox.SetPos(XMFLOAT2(raytracedDiffuseRangeSlider.GetPos().x - raytracedDiffuseCheckBox.GetSize().x - 80, raytracedDiffuseRangeSlider.GetPos().y)); add_right(screenSpaceShadowsStepCountSlider); diff --git a/Editor/GraphicsWindow.h b/Editor/GraphicsWindow.h index 2f3dcfe3ad0..3d26b74f25f 100644 --- a/Editor/GraphicsWindow.h +++ b/Editor/GraphicsWindow.h @@ -63,6 +63,8 @@ class GraphicsWindow : public wi::gui::Window wi::gui::Slider raytracedReflectionsRangeSlider; wi::gui::CheckBox raytracedDiffuseCheckBox; wi::gui::Slider raytracedDiffuseRangeSlider; + wi::gui::CheckBox ssgiCheckBox; + wi::gui::Slider ssgiDepthRejectionSlider; wi::gui::CheckBox screenSpaceShadowsCheckBox; wi::gui::Slider screenSpaceShadowsStepCountSlider; wi::gui::Slider screenSpaceShadowsRangeSlider; diff --git a/Editor/HairParticleWindow.cpp b/Editor/HairParticleWindow.cpp index dfbc96502ae..4310c0aefbd 100644 --- a/Editor/HairParticleWindow.cpp +++ b/Editor/HairParticleWindow.cpp @@ -51,6 +51,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) Scene& scene = editor->GetCurrentScene(); hair->meshID = scene.meshes.GetEntity(args.iValue - 1); } + hair->SetDirty(); } }); meshComboBox.SetTooltip("Choose a mesh where hair will grow from..."); @@ -64,6 +65,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) if (hair != nullptr) { hair->strandCount = (uint32_t)args.iValue; + hair->SetDirty(); } }); countSlider.SetEnabled(false); @@ -78,6 +80,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) if (hair != nullptr) { hair->length = args.fValue; + hair->SetDirty(); } }); lengthSlider.SetEnabled(false); @@ -92,6 +95,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) if (hair != nullptr) { hair->stiffness = args.fValue; + hair->SetDirty(); } }); stiffnessSlider.SetEnabled(false); @@ -106,6 +110,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) if (hair != nullptr) { hair->randomness = args.fValue; + hair->SetDirty(); } }); randomnessSlider.SetEnabled(false); @@ -134,6 +139,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) if (hair != nullptr) { hair->randomSeed = (uint32_t)args.iValue; + hair->SetDirty(); } }); randomSeedSlider.SetEnabled(false); @@ -148,6 +154,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) if (hair != nullptr) { hair->viewDistance = args.fValue; + hair->SetDirty(); } }); viewDistanceSlider.SetEnabled(false); @@ -165,6 +172,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) if (hair != nullptr) { hair->framesX = (uint32_t)args.iValue; + hair->SetDirty(); } }); AddWidget(&framesXInput); @@ -179,6 +187,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) if (hair != nullptr) { hair->framesY = (uint32_t)args.iValue; + hair->SetDirty(); } }); AddWidget(&framesYInput); @@ -196,6 +205,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) if (hair != nullptr) { hair->frameCount = (uint32_t)args.iValue; + hair->SetDirty(); } }); AddWidget(&frameCountInput); @@ -211,6 +221,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) if (hair != nullptr) { hair->frameStart = (uint32_t)args.iValue; + hair->SetDirty(); } }); AddWidget(&frameStartInput); diff --git a/Editor/HumanoidWindow.cpp b/Editor/HumanoidWindow.cpp index d17cd04482b..7fb7fa67228 100644 --- a/Editor/HumanoidWindow.cpp +++ b/Editor/HumanoidWindow.cpp @@ -9,7 +9,7 @@ void HumanoidWindow::Create(EditorComponent* _editor) editor = _editor; wi::gui::Window::Create(ICON_HUMANOID " Humanoid", wi::gui::Window::WindowControls::COLLAPSE | wi::gui::Window::WindowControls::CLOSE); - SetSize(XMFLOAT2(670, 540)); + SetSize(XMFLOAT2(670, 580)); closeButton.SetTooltip("Delete HumanoidComponent"); OnClose([=](wi::gui::EventArgs args) { @@ -168,6 +168,34 @@ void HumanoidWindow::Create(EditorComponent* _editor) }); AddWidget(&headSizeSlider); + ragdollFatnessSlider.Create(0.5f, 2, 1, 1000, "Ragdoll fatness: "); + ragdollFatnessSlider.SetTooltip("Adjust overall fatness of ragdoll physics skeleton."); + ragdollFatnessSlider.SetSize(XMFLOAT2(wid, hei)); + ragdollFatnessSlider.OnSlide([=](wi::gui::EventArgs args) { + wi::scene::Scene& scene = editor->GetCurrentScene(); + HumanoidComponent* humanoid = scene.humanoids.GetComponent(entity); + if (humanoid != nullptr) + { + humanoid->ragdoll_fatness = args.fValue; + humanoid->ragdoll = {}; // request recreate + } + }); + AddWidget(&ragdollFatnessSlider); + + ragdollHeadSizeSlider.Create(0.5f, 2, 1, 1000, "Ragdoll head: "); + ragdollHeadSizeSlider.SetTooltip("Adjust overall size of ragdoll physics head."); + ragdollHeadSizeSlider.SetSize(XMFLOAT2(wid, hei)); + ragdollHeadSizeSlider.OnSlide([=](wi::gui::EventArgs args) { + wi::scene::Scene& scene = editor->GetCurrentScene(); + HumanoidComponent* humanoid = scene.humanoids.GetComponent(entity); + if (humanoid != nullptr) + { + humanoid->ragdoll_headsize = args.fValue; + humanoid->ragdoll = {}; // request recreate + } + }); + AddWidget(&ragdollHeadSizeSlider); + boneList.Create("Bones: "); boneList.SetSize(XMFLOAT2(wid, 200)); boneList.SetPos(XMFLOAT2(4, y += step)); @@ -241,6 +269,8 @@ void HumanoidWindow::SetEntity(Entity entity) eyeRotMaxXSlider.SetValue(wi::math::RadiansToDegrees(humanoid->eye_rotation_max.x)); eyeRotMaxYSlider.SetValue(wi::math::RadiansToDegrees(humanoid->eye_rotation_max.y)); eyeRotSpeedSlider.SetValue(humanoid->eye_rotation_speed); + ragdollFatnessSlider.SetValue(humanoid->ragdoll_fatness); + ragdollHeadSizeSlider.SetValue(humanoid->ragdoll_headsize); Entity bone = humanoid->bones[size_t(HumanoidComponent::HumanoidBone::Head)]; const TransformComponent* transform = scene.transforms.GetComponent(bone); @@ -549,6 +579,8 @@ void HumanoidWindow::ResizeLayout() add(eyeRotMaxYSlider); add(eyeRotSpeedSlider); add(headSizeSlider); + add(ragdollFatnessSlider); + add(ragdollHeadSizeSlider); y += jump; diff --git a/Editor/HumanoidWindow.h b/Editor/HumanoidWindow.h index 1f470c4244b..653f8f14258 100644 --- a/Editor/HumanoidWindow.h +++ b/Editor/HumanoidWindow.h @@ -22,6 +22,8 @@ class HumanoidWindow : public wi::gui::Window wi::gui::Slider eyeRotMaxYSlider; wi::gui::Slider eyeRotSpeedSlider; wi::gui::Slider headSizeSlider; + wi::gui::Slider ragdollFatnessSlider; + wi::gui::Slider ragdollHeadSizeSlider; wi::gui::TreeList boneList; void Update(const wi::Canvas& canvas, float dt) override; diff --git a/Editor/IconDefinitions.h b/Editor/IconDefinitions.h index f31f0234e2a..47149ac9181 100644 --- a/Editor/IconDefinitions.h +++ b/Editor/IconDefinitions.h @@ -36,6 +36,10 @@ #define ICON_TERRAIN ICON_FA_MOUNTAIN_SUN #define ICON_SPRITE ICON_FA_IMAGE #define ICON_FONT ICON_FA_FONT +#define ICON_VOXELGRID ICON_FA_TABLE_CELLS +#define ICON_CLEARVOXELS ICON_FA_TRASH_CAN +#define ICON_VOXELIZE ICON_FA_WAVE_SQUARE +#define ICON_VOXELBOUNDS ICON_FA_VECTOR_SQUARE #define ICON_SAVE ICON_FA_FLOPPY_DISK #define ICON_OPEN ICON_FA_FOLDER_OPEN @@ -54,6 +58,8 @@ #define ICON_PROFILER ICON_FA_STOPWATCH #define ICON_CINEMA_MODE ICON_FA_CLAPPERBOARD #define ICON_DUMMY ICON_FA_PERSON_ARROW_UP_FROM_LINE +#define ICON_NAVIGATION ICON_FA_ROUTE +#define ICON_CONTENT_BROWSER ICON_FA_ICONS #define ICON_LEFT_RIGHT ICON_FA_LEFT_RIGHT #define ICON_UP_DOWN ICON_FA_UP_DOWN diff --git a/Editor/MaterialWindow.cpp b/Editor/MaterialWindow.cpp index 201aca9023c..af18d28088c 100644 --- a/Editor/MaterialWindow.cpp +++ b/Editor/MaterialWindow.cpp @@ -280,7 +280,7 @@ void MaterialWindow::Create(EditorComponent* _editor) }); AddWidget(&alphaRefSlider); - emissiveSlider.Create(0, 1, 0.0f, 1000, "Emissive: "); + emissiveSlider.Create(0, 10, 0.0f, 1000, "Emissive: "); emissiveSlider.SetTooltip("Adjust the light emission of the surface. The color of the light emitted is that of the color of the material."); emissiveSlider.SetSize(XMFLOAT2(wid, hei)); emissiveSlider.SetPos(XMFLOAT2(x, y += step)); diff --git a/Editor/ModelImporter_GLTF.cpp b/Editor/ModelImporter_GLTF.cpp index 4d4e029db77..ecb306a53ac 100644 --- a/Editor/ModelImporter_GLTF.cpp +++ b/Editor/ModelImporter_GLTF.cpp @@ -314,8 +314,7 @@ void FlipZAxis(LoaderState& state) v_morph_pos.z *= -1.f; } } - mesh.FlipCulling(); - mesh.CreateRenderData(); + mesh.FlipCulling(); // calls CreateRenderData } // Flip scene's transformComponents @@ -1612,7 +1611,7 @@ void ImportModel_GLTF(const std::string& fileName, Scene& scene) mesh.ComputeNormals(MeshComponent::COMPUTE_NORMALS_SMOOTH_FAST); } - mesh.CreateRenderData(); + mesh.CreateRenderData(); // tangents are generated inside if needed, which must be done before FlipZAxis! } // Create armatures: diff --git a/Editor/OptionsWindow.cpp b/Editor/OptionsWindow.cpp index 39ceddbd700..e9300efb8ea 100644 --- a/Editor/OptionsWindow.cpp +++ b/Editor/OptionsWindow.cpp @@ -37,6 +37,7 @@ void OptionsWindow::Create(EditorComponent* _editor) NEW_TERRAIN, NEW_SPRITE, NEW_FONT, + NEW_VOXELGRID, }; newCombo.Create("New: "); @@ -67,6 +68,7 @@ void OptionsWindow::Create(EditorComponent* _editor) newCombo.AddItem("Terrain " ICON_TERRAIN, NEW_TERRAIN); newCombo.AddItem("Sprite " ICON_SPRITE, NEW_SPRITE); newCombo.AddItem("Font " ICON_FONT, NEW_FONT); + newCombo.AddItem("Voxel Grid " ICON_VOXELGRID, NEW_VOXELGRID); newCombo.OnSelect([&](wi::gui::EventArgs args) { newCombo.SetSelectedWithoutCallback(-1); const EditorComponent::EditorScene& editorscene = editor->GetCurrentEditorScene(); @@ -214,6 +216,7 @@ void OptionsWindow::Create(EditorComponent* _editor) scene.names.Create(pick.entity) = "collider"; break; case NEW_TERRAIN: + editor->componentsWnd.terrainWnd.entity = pick.entity; editor->componentsWnd.terrainWnd.SetupAssets(); pick.entity = CreateEntity(); scene.terrains.Create(pick.entity) = editor->componentsWnd.terrainWnd.terrain_preset; @@ -243,6 +246,14 @@ void OptionsWindow::Create(EditorComponent* _editor) scene.names.Create(pick.entity) = "font"; } break; + case NEW_VOXELGRID: + { + pick.entity = CreateEntity(); + scene.voxel_grids.Create(pick.entity).init(64, 64, 64); + scene.transforms.Create(pick.entity).Scale(XMFLOAT3(0.25f, 0.25f, 0.25f)); + scene.names.Create(pick.entity) = "voxelgrid"; + } + break; default: break; } @@ -295,6 +306,9 @@ void OptionsWindow::Create(EditorComponent* _editor) filterCombo.AddItem(ICON_TERRAIN, (uint64_t)Filter::Terrain); filterCombo.AddItem(ICON_SPRITE, (uint64_t)Filter::Sprite); filterCombo.AddItem(ICON_FONT, (uint64_t)Filter::Font); + filterCombo.AddItem(ICON_VOXELGRID, (uint64_t)Filter::VoxelGrid); + filterCombo.AddItem(ICON_RIGIDBODY, (uint64_t)Filter::RigidBody); + filterCombo.AddItem(ICON_SOFTBODY, (uint64_t)Filter::SoftBody); filterCombo.SetTooltip("Apply filtering to the Entities by components"); filterCombo.OnSelect([&](wi::gui::EventArgs args) { filter = (Filter)args.userdata; @@ -601,6 +615,10 @@ void OptionsWindow::PushToEntityTree(wi::ecs::Entity entity, int level) { item.name += ICON_FONT " "; } + if (scene.voxel_grids.Contains(entity)) + { + item.name += ICON_VOXELGRID " "; + } if (scene.lights.Contains(entity)) { const LightComponent* light = scene.lights.GetComponent(entity); @@ -740,7 +758,10 @@ bool OptionsWindow::CheckEntityFilter(wi::ecs::Entity entity) has_flag(filter, Filter::Humanoid) && scene.humanoids.Contains(entity) || has_flag(filter, Filter::Video) && scene.videos.Contains(entity) || has_flag(filter, Filter::Sprite) && scene.sprites.Contains(entity) || - has_flag(filter, Filter::Font) && scene.fonts.Contains(entity) + has_flag(filter, Filter::Font) && scene.fonts.Contains(entity) || + has_flag(filter, Filter::VoxelGrid) && scene.voxel_grids.Contains(entity) || + has_flag(filter, Filter::RigidBody) && scene.rigidbodies.Contains(entity) || + has_flag(filter, Filter::SoftBody) && scene.softbodies.Contains(entity) ) { valid = true; diff --git a/Editor/OptionsWindow.h b/Editor/OptionsWindow.h index 08c26683802..efe7f9b2abc 100644 --- a/Editor/OptionsWindow.h +++ b/Editor/OptionsWindow.h @@ -49,6 +49,9 @@ class OptionsWindow : public wi::gui::Window Video = 1 << 22, Sprite = 1 << 23, Font = 1 << 24, + VoxelGrid = 1 << 25, + RigidBody = 1 << 26, + SoftBody = 1 << 27, All = ~0ull, } filter = Filter::All; diff --git a/Editor/PaintToolWindow.cpp b/Editor/PaintToolWindow.cpp index c6812254cd0..c8dd4831379 100644 --- a/Editor/PaintToolWindow.cpp +++ b/Editor/PaintToolWindow.cpp @@ -176,6 +176,12 @@ void PaintToolWindow::Create(EditorComponent* _editor) pressureCheckBox.SetCheckText(ICON_PEN); AddWidget(&pressureCheckBox); + alphaCheckBox.Create("Redirect alpha: "); + alphaCheckBox.SetTooltip("The red color will be redirected to write alpha channel. Alpha value controls the blending like normally."); + alphaCheckBox.SetSize(XMFLOAT2(hei, hei)); + alphaCheckBox.SetPos(XMFLOAT2(x - 20 + 200, y)); + AddWidget(&alphaCheckBox); + axisCombo.Create("Axis Lock: "); axisCombo.SetTooltip("You can lock modification to an axis here."); axisCombo.SetPos(XMFLOAT2(x, y)); @@ -508,34 +514,7 @@ void PaintToolWindow::Update(float dt) texturename += ".PNG"; uint64_t sel = textureSlotComboBox.GetItemUserData(textureSlotComboBox.GetSelected()); material->textures[sel].name = texturename; - - TextureDesc desc; - desc.width = 1024; - desc.height = 1024; - desc.format = Format::R8G8B8A8_UNORM; - desc.bind_flags = BindFlag::SHADER_RESOURCE | BindFlag::UNORDERED_ACCESS; - wi::vector whitedata(desc.width * desc.height); - std::fill(whitedata.begin(), whitedata.end(), wi::Color::White()); - SubresourceData initdata; - initdata.data_ptr = whitedata.data(); - initdata.row_pitch = desc.width * GetFormatStride(desc.format); - Texture texture; - GraphicsDevice* device = GetDevice(); - device->CreateTexture(&desc, &initdata, &texture); - device->SetName(&texture, texturename.c_str()); - // This part must be AFTER mip level subresource creation: - int srgb_subresource = -1; - { - Format srgb_format = GetFormatSRGB(desc.format); - srgb_subresource = device->CreateSubresource( - &texture, - SubresourceType::SRV, - 0, -1, - 0, -1, - &srgb_format - ); - } - material->textures[sel].resource.SetTexture(texture, srgb_subresource); + material->textures[sel].resource = wi::renderer::CreatePaintableTexture(1024, 1024, 1, wi::Color::White()); editTexture = GetEditTextureSlot(*material, &uvset); wi::backlog::post("Paint Tool created default texture: " + texturename); @@ -573,54 +552,32 @@ void PaintToolWindow::Update(float dt) // Need to requery this because RecordHistory might swap textures on material: editTexture = GetEditTextureSlot(*material, &uvset); - device->BindComputeShader(wi::renderer::GetShader(wi::enums::CSTYPE_PAINT_TEXTURE), cmd); + wi::renderer::PaintTextureParams paintparams = {}; + paintparams.editTex = editTexture.texture; if (brushTex.IsValid()) { - device->BindResource(&brushTex.GetTexture(), 0, cmd); - } - else - { - device->BindResource(wi::texturehelper::getWhite(), 0, cmd); + paintparams.brushTex = brushTex.GetTexture(); } if (revealTex.IsValid()) { - device->BindResource(&revealTex.GetTexture(), 1, cmd); - } - else - { - device->BindResource(wi::texturehelper::getWhite(), 1, cmd); + paintparams.revealTex = revealTex.GetTexture(); } - device->BindUAV(&editTexture.texture, 0, cmd); - PaintTextureCB cb; - cb.xPaintBrushCenter = center; - cb.xPaintBrushRadius = (uint32_t)pressure_radius; + paintparams.push.xPaintBrushCenter = center; + paintparams.push.xPaintBrushRadius = (uint32_t)pressure_radius; if (brushShapeComboBox.GetSelected() == 1) { - cb.xPaintBrushRadius = (uint)std::ceil((float(cb.xPaintBrushRadius) * 2 / std::sqrt(2.0f))); // square shape, diagonal dispatch size - } - cb.xPaintBrushAmount = amount; - cb.xPaintBrushSmoothness = smoothness; - cb.xPaintBrushColor = color.rgba; - cb.xPaintReveal = revealTex.IsValid() ? 1 : 0; - cb.xPaintBrushRotation = brush_rotation; - cb.xPaintBrushShape = (uint)brushShapeComboBox.GetSelected(); - device->PushConstants(&cb, sizeof(cb), cmd); - - const uint diameter = cb.xPaintBrushRadius * 2; - const uint dispatch_dim = (diameter + PAINT_TEXTURE_BLOCKSIZE - 1) / PAINT_TEXTURE_BLOCKSIZE; - device->Dispatch(dispatch_dim, dispatch_dim, 1, cmd); - - GPUBarrier barriers[] = { - GPUBarrier::Memory(), - }; - device->Barrier(barriers, arraysize(barriers), cmd); - - if (editTexture.texture.desc.mip_levels > 1) - { - wi::renderer::GenerateMipChain(editTexture.texture, wi::renderer::MIPGENFILTER::MIPGENFILTER_LINEAR, cmd); + paintparams.push.xPaintBrushRadius = (uint)std::ceil((float(paintparams.push.xPaintBrushRadius) * 2 / std::sqrt(2.0f))); // square shape, diagonal dispatch size } + paintparams.push.xPaintBrushAmount = amount; + paintparams.push.xPaintBrushSmoothness = smoothness; + paintparams.push.xPaintBrushColor = color.rgba; + paintparams.push.xPaintRedirectAlpha = alphaCheckBox.GetCheck(); + paintparams.push.xPaintBrushRotation = brush_rotation; + paintparams.push.xPaintBrushShape = (uint)brushShapeComboBox.GetSelected(); + + wi::renderer::PaintIntoTexture(paintparams); } if(substep == substep_count - 1) { @@ -1699,6 +1656,7 @@ void PaintToolWindow::ResizeLayout() add_right(backfaceCheckBox); wireCheckBox.SetPos(XMFLOAT2(backfaceCheckBox.GetPos().x - wireCheckBox.GetSize().x - 100, backfaceCheckBox.GetPos().y)); add_right(pressureCheckBox); + alphaCheckBox.SetPos(XMFLOAT2(pressureCheckBox.GetPos().x - alphaCheckBox.GetSize().x - 100, pressureCheckBox.GetPos().y)); add(textureSlotComboBox); add(brushShapeComboBox); add(axisCombo); diff --git a/Editor/PaintToolWindow.h b/Editor/PaintToolWindow.h index 499432db0dc..e6438b1349d 100644 --- a/Editor/PaintToolWindow.h +++ b/Editor/PaintToolWindow.h @@ -52,6 +52,7 @@ class PaintToolWindow : public wi::gui::Window wi::gui::CheckBox backfaceCheckBox; wi::gui::CheckBox wireCheckBox; wi::gui::CheckBox pressureCheckBox; + wi::gui::CheckBox alphaCheckBox; wi::gui::ColorPicker colorPicker; wi::gui::ComboBox textureSlotComboBox; wi::gui::ComboBox brushShapeComboBox; diff --git a/Editor/TerrainWindow.cpp b/Editor/TerrainWindow.cpp index b1b284f7fc5..ef6a620fc7f 100644 --- a/Editor/TerrainWindow.cpp +++ b/Editor/TerrainWindow.cpp @@ -273,6 +273,358 @@ void HeightmapModifierWindow::From(wi::terrain::HeightmapModifier* ptr) scaleSlider.SetValue(ptr->scale); } +PropWindow::PropWindow(wi::terrain::Prop* prop, wi::scene::Scene* scene) + :prop(prop) + ,scene(scene) +{ + std::string windowName = "Prop: "; + std::string propName = "NONE"; + Entity entity = INVALID_ENTITY; + + if(!prop->data.empty()) // extract object name + { + wi::Archive archive = wi::Archive(prop->data.data()); + EntitySerializer serializer; + entity = scene->Entity_Serialize( + archive, + serializer, + INVALID_ENTITY, + wi::scene::Scene::EntitySerializeFlags::RECURSIVE | + wi::scene::Scene::EntitySerializeFlags::KEEP_INTERNAL_ENTITY_REFERENCES + ); + + const NameComponent* name = scene->names.GetComponent(entity); + if (name != nullptr) + { + propName = name->name; + windowName += propName; + } + + scene->Entity_Remove(entity); + } + + wi::gui::Window::Create(windowName, wi::gui::Window::WindowControls::CLOSE_AND_COLLAPSE); + + constexpr auto elementSize = XMFLOAT2(100, 20); + + meshCombo.Create("Object: "); + meshCombo.SetTooltip("Select object component"); + meshCombo.SetSize(elementSize); + meshCombo.AddItem(propName, entity); + for (size_t i = 0; i < scene->objects.GetCount(); ++i) + { + const Entity ent = scene->objects.GetEntity(i); + const auto* name = scene->names.GetComponent(ent); + meshCombo.AddItem(name != nullptr ? name->name : std::to_string(ent), ent); + } + AddWidget(&meshCombo); + + meshCombo.OnSelect([=](wi::gui::EventArgs args) { + if(args.userdata == entity) + { + return; + } + + const auto name = "Prop: " + args.sValue; + SetName(name); + SetText(name); + label.SetText(name); + + const wi::ecs::Entity ent = static_cast(args.userdata); + + wi::Archive archive; + EntitySerializer serializer; + scene->Entity_Serialize( + archive, + serializer, + ent, + wi::scene::Scene::EntitySerializeFlags::RECURSIVE | wi::scene::Scene::EntitySerializeFlags::KEEP_INTERNAL_ENTITY_REFERENCES + ); + archive.WriteData(prop->data); + + generation_callback(); + }); + + minCountPerChunkInput.Create(""); + minCountPerChunkInput.SetDescription("Min count per chunk: "); + minCountPerChunkInput.SetSize(elementSize); + minCountPerChunkInput.SetValue(0); + minCountPerChunkInput.SetTooltip("A chunk will try to generate min this many props of this type"); + minCountPerChunkInput.OnInputAccepted([&](wi::gui::EventArgs args) { + prop->min_count_per_chunk = std::min(prop->max_count_per_chunk, args.iValue); + generation_callback(); + }); + AddWidget(&minCountPerChunkInput); + + maxCountPerChunkInput.Create(""); + maxCountPerChunkInput.SetDescription("Max count per chunk: "); + maxCountPerChunkInput.SetSize(elementSize); + maxCountPerChunkInput.SetValue(5); + maxCountPerChunkInput.SetTooltip("A chunk will try to generate max this many props of this type"); + maxCountPerChunkInput.OnInputAccepted([&](wi::gui::EventArgs args) { + prop->max_count_per_chunk = std::max(prop->min_count_per_chunk, args.iValue); + generation_callback(); + }); + AddWidget(&maxCountPerChunkInput); + + regionCombo.Create("Region: "); + regionCombo.SetTooltip("Select a terrain region"); + regionCombo.SetSize(elementSize); + regionCombo.AddItem("Base", 0); + regionCombo.AddItem("Slopes", 1); + regionCombo.AddItem("Low altitude ", 2); + regionCombo.AddItem("High altitude", 3); + regionCombo.OnSelect([=](wi::gui::EventArgs args) { + prop->region = static_cast(args.userdata); + generation_callback(); + }); + AddWidget(®ionCombo); + + regionPowerSlider.Create(0.0f, 1.0f, 1.0f, 1000, "Region power: "); + regionPowerSlider.SetSize(elementSize); + regionPowerSlider.SetTooltip("Region weight affection power factor"); + regionPowerSlider.OnSlide([=](wi::gui::EventArgs args) { + prop->region_power = args.fValue; + generation_callback(); + }); + AddWidget(®ionPowerSlider); + + noiseFrequencySlider.Create(0.0f, 1.0f, 1.0f, 1000, "Noise frequency: "); + noiseFrequencySlider.SetSize(elementSize); + noiseFrequencySlider.SetTooltip("Perlin noise's frequency for placement factor"); + noiseFrequencySlider.OnSlide([=](wi::gui::EventArgs args) { + prop->noise_frequency = args.fValue; + generation_callback(); + }); + AddWidget(&noiseFrequencySlider); + + noisePowerSlider.Create(0.0f, 1.0f, 1.0f, 1000, "Noise pwer: "); + noisePowerSlider.SetSize(elementSize); + noisePowerSlider.SetTooltip("Perlin noise's power"); + noisePowerSlider.OnSlide([=](wi::gui::EventArgs args) { + prop->noise_power = args.fValue; + generation_callback(); + }); + AddWidget(&noisePowerSlider); + + thresholdSlider.Create(0.0f, 1.0f, 0.5f, 1000, "Threshold: "); + thresholdSlider.SetSize(elementSize); + thresholdSlider.SetTooltip("The chance of placement (higher is less chance)"); + thresholdSlider.OnSlide([=](wi::gui::EventArgs args) { + prop->threshold = args.fValue; + generation_callback(); + }); + AddWidget(&thresholdSlider); + + minSizeSlider.Create(0.0f, 1.0f, 1.0f, 1000, "Min size: "); + minSizeSlider.SetSize(elementSize); + minSizeSlider.SetTooltip("Scaling randomization range min"); + minSizeSlider.OnSlide([=](wi::gui::EventArgs args) { + prop->min_size = std::min(args.fValue, prop->max_size); + generation_callback(); + }); + AddWidget(&minSizeSlider); + + maxSizeSlider.Create(0.0f, 1.0f, 1.0f, 1000, "Max size: "); + maxSizeSlider.SetSize(elementSize); + maxSizeSlider.SetTooltip("Scaling randomization range max"); + maxSizeSlider.OnSlide([=](wi::gui::EventArgs args) { + prop->max_size = std::max(args.fValue, prop->min_size); + generation_callback(); + }); + AddWidget(&maxSizeSlider); + + minYOffsetInput.Create(""); + minYOffsetInput.SetDescription("Min vertical offset: "); + minYOffsetInput.SetSize(elementSize); + minYOffsetInput.SetValue(0); + minYOffsetInput.SetTooltip("Minimal randomized offset on vertical axis"); + minYOffsetInput.OnInputAccepted([=](wi::gui::EventArgs args) { + prop->min_y_offset = std::min(args.fValue, prop->max_y_offset); + generation_callback(); + }); + AddWidget(&minYOffsetInput); + + maxYOffsetInput.Create(""); + maxYOffsetInput.SetDescription("Max vertical offset: "); + maxYOffsetInput.SetSize(elementSize); + maxYOffsetInput.SetValue(0); + maxYOffsetInput.SetTooltip("Maximum randomized offset on vertical axis"); + maxYOffsetInput.OnInputAccepted([=](wi::gui::EventArgs args) { + prop->max_y_offset = std::max(args.fValue, prop->min_y_offset); + generation_callback(); + }); + AddWidget(&maxYOffsetInput); + + SetSize(XMFLOAT2(200, 312)); + SetCollapsed(true); +} + +void PropWindow::ResizeLayout() +{ + wi::gui::Window::ResizeLayout(); + + constexpr float padding = 4; + const float width = GetWidgetAreaSize().x; + float y = padding; + + auto add = [&](wi::gui::Widget& widget) { + constexpr float margin_left = 150; + constexpr float margin_right = 50; + widget.SetPos(XMFLOAT2(margin_left, y)); + widget.SetSize(XMFLOAT2(width - margin_left - margin_right, widget.GetScale().y)); + y += widget.GetSize().y; + y += padding; + }; + + add(meshCombo); + add(minCountPerChunkInput); + add(maxCountPerChunkInput); + add(regionCombo); + add(regionPowerSlider); + add(noiseFrequencySlider); + add(noisePowerSlider); + add(thresholdSlider); + add(minSizeSlider); + add(maxSizeSlider); + add(minYOffsetInput); + add(maxYOffsetInput); +} + +PropsWindow::PropsWindow(EditorComponent* editor) + :editor(editor) +{ + wi::gui::Window::Create("Props", wi::gui::Window::WindowControls::COLLAPSE); + + SetCollapsed(true); + + addButton.Create("Add prop"); + addButton.SetSize(XMFLOAT2(100, 20)); + addButton.OnClick([this](wi::gui::EventArgs args) { + terrain->props.emplace_back(); + AddWindow(terrain->props.back()); + }); + AddWidget(&addButton); + + SetSize(XMFLOAT2(420, 332)); +} + +void PropsWindow::Rebuild() +{ + for(auto& window : windows) + { + RemoveWidget(window.get()); + } + + windows.clear(); + windows_to_remove.clear(); + + if(terrain == nullptr) + { + return; + } + + generation_callback = [&] { + terrain->Generation_Restart(); + }; + + for(auto i = terrain->props.begin(); i != terrain->props.end(); ++i) + { + AddWindow(*i); + } +} + +void PropsWindow::AddWindow(wi::terrain::Prop& prop) +{ + PropWindow* wnd = new PropWindow(&prop, &editor->GetCurrentScene()); + wnd->generation_callback = generation_callback; + wnd->OnClose([&, wnd](wi::gui::EventArgs args) { + windows_to_remove.push_back(wnd); + }); + AddWidget(wnd); + + windows.emplace_back().reset(wnd); + + editor->optionsWnd.generalWnd.themeCombo.SetSelected(editor->optionsWnd.generalWnd.themeCombo.GetSelected()); // theme refresh +} + +void PropsWindow::Update(const wi::Canvas& canvas, float dt) +{ + if(windows.size() != terrain->props.size()) + { + // recreate all windows + Rebuild(); + } + else + { + if(!windows_to_remove.empty()) + { + for(const auto& window : windows_to_remove) + { + for (size_t i = 0; i < windows.size(); ++i) + { + if (windows[i].get() == window) + { + RemoveWidget(window); + + terrain->props.erase(terrain->props.begin() + i); + windows.erase(windows.begin() + i); + + break; + } + } + } + + // updating props pointers + for(size_t i = 0; i < windows.size(); ++i) + { + windows[i]->prop = &terrain->props[i]; + } + + windows_to_remove.clear(); + generation_callback(); + } + } + + Window::Update(canvas, dt); +} + +void PropsWindow::ResizeLayout() +{ + constexpr float padding = 4; + const float width = GetWidgetAreaSize().x; + float y = padding; + + auto add = [&](wi::gui::Widget& widget) { + constexpr float margin_left = 150; + constexpr float margin_right = 50; + widget.SetPos(XMFLOAT2(margin_left, y)); + widget.SetSize(XMFLOAT2(width - margin_left - margin_right, widget.GetScale().y)); + y += widget.GetSize().y; + y += padding; + }; + + auto add_window = [&](wi::gui::Window& widget) { + const float margin_left = padding; + const float margin_right = padding; + widget.SetPos(XMFLOAT2(margin_left, y)); + widget.SetSize(XMFLOAT2(width - margin_left - margin_right, widget.GetScale().y)); + y += widget.GetSize().y; + y += padding; + widget.SetEnabled(true); + }; + + add(addButton); + + for(auto& window : windows) + { + add_window(*window); + } + + SetSize(XMFLOAT2(GetScale().x, control_size + y)); + + wi::gui::Window::ResizeLayout(); +} void TerrainWindow::Create(EditorComponent* _editor) { @@ -281,7 +633,7 @@ void TerrainWindow::Create(EditorComponent* _editor) ClearTransform(); wi::gui::Window::Create(ICON_TERRAIN " Terrain", wi::gui::Window::WindowControls::COLLAPSE | wi::gui::Window::WindowControls::CLOSE); - SetSize(XMFLOAT2(420, 980)); + SetSize(XMFLOAT2(420, 1000)); closeButton.SetTooltip("Delete Terrain."); OnClose([=](wi::gui::EventArgs args) { @@ -450,6 +802,11 @@ void TerrainWindow::Create(EditorComponent* _editor) grassLengthSlider.SetPos(XMFLOAT2(x, y += step)); grassLengthSlider.OnSlide([this](wi::gui::EventArgs args) { terrain->grass_properties.length = args.fValue; + wi::HairParticleSystem* hair = terrain->scene->hairs.GetComponent(terrain->grassEntity); + if (hair != nullptr) + { + hair->length = args.fValue; + } }); AddWidget(&grassLengthSlider); @@ -459,6 +816,11 @@ void TerrainWindow::Create(EditorComponent* _editor) grassDistanceSlider.SetPos(XMFLOAT2(x, y += step)); grassDistanceSlider.OnSlide([this](wi::gui::EventArgs args) { terrain->grass_properties.viewDistance = args.fValue; + wi::HairParticleSystem* hair = terrain->scene->hairs.GetComponent(terrain->grassEntity); + if (hair != nullptr) + { + hair->viewDistance = args.fValue; + } }); AddWidget(&grassDistanceSlider); @@ -715,6 +1077,61 @@ void TerrainWindow::Create(EditorComponent* _editor) }); AddWidget(®ion3Slider); + materialCombos[wi::terrain::MATERIAL_BASE].Create("Base material: "); + materialCombos[wi::terrain::MATERIAL_SLOPE].Create("Slope material: "); + materialCombos[wi::terrain::MATERIAL_LOW_ALTITUDE].Create("Low altitude material: "); + materialCombos[wi::terrain::MATERIAL_HIGH_ALTITUDE].Create("High altitude material: "); + + for (size_t i = 0; i < arraysize(materialCombos); ++i) + { + materialCombos[i].SetTooltip("Select material entity"); + materialCombos[i].SetSize(XMFLOAT2(wid, hei)); + materialCombos[i].SetPos(XMFLOAT2(x, y += step)); + materialCombos[i].OnSelect([&, i](wi::gui::EventArgs args) { + const Scene& scene = editor->GetCurrentScene(); + wi::ecs::Entity entity = static_cast(args.userdata); + if (entity != INVALID_ENTITY && scene.materials.Contains(entity)) + { + if (terrain->materialEntities[i] != entity) + { + terrain->materialEntities[i] = entity; + terrain->Generation_Restart(); + } + } + else + { + terrain->materialEntities[i] = INVALID_ENTITY; + } + }); + + AddWidget(&materialCombos[i]); + } + + materialCombo_GrassParticle.Create("Grass material: "); + materialCombo_GrassParticle.SetTooltip("Select material entity"); + materialCombo_GrassParticle.SetSize(XMFLOAT2(wid, hei)); + materialCombo_GrassParticle.SetPos(XMFLOAT2(x, y += step)); + materialCombo_GrassParticle.OnSelect([&](wi::gui::EventArgs args) { + const Scene& scene = editor->GetCurrentScene(); + wi::ecs::Entity entity = static_cast(args.userdata); + if (entity != INVALID_ENTITY && scene.materials.Contains(entity)) + { + if (terrain->grassEntity != entity) + { + terrain->grassEntity = entity; + terrain->Generation_Restart(); + } + } + else + { + terrain->grassEntity = INVALID_ENTITY; + } + }); + AddWidget(&materialCombo_GrassParticle); + + propsWindow.reset(new PropsWindow(editor)); + AddWidget(propsWindow.get()); + saveHeightmapButton.OnClick([=](wi::gui::EventArgs args) { wi::helper::FileDialogParams params; @@ -878,6 +1295,8 @@ void TerrainWindow::SetEntity(Entity entity) terrain = &terrain_preset; } + propsWindow->terrain = terrain; + if (this->entity == entity) return; @@ -910,6 +1329,35 @@ void TerrainWindow::SetEntity(Entity entity) region2Slider.SetValue(terrain->region2); region3Slider.SetValue(terrain->region3); + auto fillMaterialCombo = [&](wi::gui::ComboBox& comboBox, Entity selected) { + comboBox.ClearItems(); + comboBox.AddItem("NO MATERIAL", INVALID_ENTITY); + for (size_t i = 0; i < scene.materials.GetCount(); ++i) + { + Entity entity = scene.materials.GetEntity(i); + if (scene.names.Contains(entity)) + { + const NameComponent& name = *scene.names.GetComponent(entity); + comboBox.AddItem(name.name, entity); + } + else + { + comboBox.AddItem(std::to_string(entity), entity); + } + + if (selected == entity) + { + comboBox.SetSelectedWithoutCallback(int(i + 1)); + } + } + }; + + for (size_t i = 0; i < arraysize(materialCombos); ++i) + { + fillMaterialCombo(materialCombos[i], terrain->materialEntities[i]); + } + fillMaterialCombo(materialCombo_GrassParticle, terrain->grassEntity); + for (auto& x : terrain->modifiers) { switch (x->type) @@ -938,6 +1386,8 @@ void TerrainWindow::SetEntity(Entity entity) break; } } + + propsWindow->Rebuild(); } void TerrainWindow::AddModifier(ModifierWindow* modifier_window) { @@ -961,23 +1411,37 @@ void TerrainWindow::SetupAssets() return; // Customize terrain generator before it's initialized: - terrain_preset.material_Base.SetRoughness(1); - terrain_preset.material_Base.SetReflectance(0.005f); - terrain_preset.material_Slope.SetRoughness(0.1f); - terrain_preset.material_LowAltitude.SetRoughness(1); - terrain_preset.material_HighAltitude.SetRoughness(1); - terrain_preset.material_Base.textures[MaterialComponent::BASECOLORMAP].name = wi::helper::GetCurrentPath() + "/terrain/base.jpg"; - terrain_preset.material_Base.textures[MaterialComponent::NORMALMAP].name = wi::helper::GetCurrentPath() + "/terrain/base_nor.jpg"; - terrain_preset.material_Slope.textures[MaterialComponent::BASECOLORMAP].name = wi::helper::GetCurrentPath() + "/terrain/slope.jpg"; - terrain_preset.material_Slope.textures[MaterialComponent::NORMALMAP].name = wi::helper::GetCurrentPath() + "/terrain/slope_nor.jpg"; - terrain_preset.material_LowAltitude.textures[MaterialComponent::BASECOLORMAP].name = wi::helper::GetCurrentPath() + "/terrain/low_altitude.jpg"; - terrain_preset.material_LowAltitude.textures[MaterialComponent::NORMALMAP].name = wi::helper::GetCurrentPath() + "/terrain/low_altitude_nor.jpg"; - terrain_preset.material_HighAltitude.textures[MaterialComponent::BASECOLORMAP].name = wi::helper::GetCurrentPath() + "/terrain/high_altitude.jpg"; - terrain_preset.material_HighAltitude.textures[MaterialComponent::NORMALMAP].name = wi::helper::GetCurrentPath() + "/terrain/high_altitude_nor.jpg"; - terrain_preset.material_Base.CreateRenderData(); - terrain_preset.material_Slope.CreateRenderData(); - terrain_preset.material_LowAltitude.CreateRenderData(); - terrain_preset.material_HighAltitude.CreateRenderData(); + Scene& currentScene = editor->GetCurrentScene(); + + for (int i = 0; i < wi::terrain::MATERIAL_COUNT; ++i) + { + terrain_preset.materialEntities[i] = CreateEntity(); + currentScene.materials.Create(terrain_preset.materialEntities[i]); + currentScene.Component_Attach(terrain_preset.materialEntities[i], entity); + } + + MaterialComponent* material_Base = currentScene.materials.GetComponent(terrain_preset.materialEntities[wi::terrain::MATERIAL_BASE]); + MaterialComponent* material_Slope = currentScene.materials.GetComponent(terrain_preset.materialEntities[wi::terrain::MATERIAL_SLOPE]); + MaterialComponent* material_LowAltitude = currentScene.materials.GetComponent(terrain_preset.materialEntities[wi::terrain::MATERIAL_LOW_ALTITUDE]); + MaterialComponent* material_HighAltitude = currentScene.materials.GetComponent(terrain_preset.materialEntities[wi::terrain::MATERIAL_HIGH_ALTITUDE]); + + material_Base->SetRoughness(1); + material_Base->SetReflectance(0.005f); + material_Slope->SetRoughness(0.1f); + material_LowAltitude->SetRoughness(1); + material_HighAltitude->SetRoughness(1); + material_Base->textures[MaterialComponent::BASECOLORMAP].name = wi::helper::GetCurrentPath() + "/terrain/base.jpg"; + material_Base->textures[MaterialComponent::NORMALMAP].name = wi::helper::GetCurrentPath() + "/terrain/base_nor.jpg"; + material_Slope->textures[MaterialComponent::BASECOLORMAP].name = wi::helper::GetCurrentPath() + "/terrain/slope.jpg"; + material_Slope->textures[MaterialComponent::NORMALMAP].name = wi::helper::GetCurrentPath() + "/terrain/slope_nor.jpg"; + material_LowAltitude->textures[MaterialComponent::BASECOLORMAP].name = wi::helper::GetCurrentPath() + "/terrain/low_altitude.jpg"; + material_LowAltitude->textures[MaterialComponent::NORMALMAP].name = wi::helper::GetCurrentPath() + "/terrain/low_altitude_nor.jpg"; + material_HighAltitude->textures[MaterialComponent::BASECOLORMAP].name = wi::helper::GetCurrentPath() + "/terrain/high_altitude.jpg"; + material_HighAltitude->textures[MaterialComponent::NORMALMAP].name = wi::helper::GetCurrentPath() + "/terrain/high_altitude_nor.jpg"; + material_Base->CreateRenderData(); + material_Slope->CreateRenderData(); + material_LowAltitude->CreateRenderData(); + material_HighAltitude->CreateRenderData(); std::string terrain_path = wi::helper::GetCurrentPath() + "/terrain/"; wi::config::File config; @@ -1078,43 +1542,42 @@ void TerrainWindow::SetupAssets() } // Grass config: - terrain_preset.material_GrassParticle.alphaRef = 0.75f; - terrain_preset.grass_properties.length = 2; - terrain_preset.grass_properties.frameCount = 2; - terrain_preset.grass_properties.framesX = 1; - terrain_preset.grass_properties.framesY = 2; - terrain_preset.grass_properties.frameStart = 0; - + terrain_preset.grassEntity = CreateEntity(); + currentScene.Component_Attach(terrain_preset.grassEntity, entity); + currentScene.materials.Create(terrain_preset.grassEntity); + currentScene.hairs.Create(terrain_preset.grassEntity) = terrain_preset.grass_properties; + MaterialComponent* material_Grass = currentScene.materials.GetComponent(terrain_preset.grassEntity); + wi::HairParticleSystem* grass = currentScene.hairs.GetComponent(terrain_preset.grassEntity); wi::config::File grass_config; grass_config.Open(std::string(terrain_path + "grass.ini").c_str()); if (grass_config.Has("texture")) { - terrain_preset.material_GrassParticle.textures[MaterialComponent::BASECOLORMAP].name = terrain_path + grass_config.GetText("texture"); - terrain_preset.material_GrassParticle.CreateRenderData(); + material_Grass->textures[MaterialComponent::BASECOLORMAP].name = terrain_path + grass_config.GetText("texture"); + material_Grass->CreateRenderData(); } if (grass_config.Has("alphaRef")) { - terrain_preset.material_GrassParticle.alphaRef = grass_config.GetFloat("alphaRef"); + material_Grass->alphaRef = grass_config.GetFloat("alphaRef"); } if (grass_config.Has("length")) { - terrain_preset.grass_properties.length = grass_config.GetFloat("length"); + grass->length = grass_config.GetFloat("length"); } if (grass_config.Has("frameCount")) { - terrain_preset.grass_properties.frameCount = grass_config.GetInt("frameCount"); + grass->frameCount = grass_config.GetInt("frameCount"); } if (grass_config.Has("framesX")) { - terrain_preset.grass_properties.framesX = grass_config.GetInt("framesX"); + grass->framesX = grass_config.GetInt("framesX"); } if (grass_config.Has("framesY")) { - terrain_preset.grass_properties.framesY = grass_config.GetInt("framesY"); + grass->framesY = grass_config.GetInt("framesY"); } if (grass_config.Has("frameCount")) { - terrain_preset.grass_properties.frameStart = grass_config.GetInt("frameStart"); + grass->frameStart = grass_config.GetInt("frameStart"); } terrain = &terrain_preset; @@ -1145,7 +1608,6 @@ void TerrainWindow::Update(const wi::Canvas& canvas, float dt) } void TerrainWindow::ResizeLayout() { - wi::gui::Window::ResizeLayout(); const float padding = 4; const float width = GetWidgetAreaSize().x; float y = padding; @@ -1195,6 +1657,11 @@ void TerrainWindow::ResizeLayout() add(region1Slider); add(region2Slider); add(region3Slider); + for (size_t i = 0; i < arraysize(materialCombos); ++i) + { + add(materialCombos[i]); + } + add(materialCombo_GrassParticle); add(saveHeightmapButton); add(saveRegionButton); add(addModifierCombo); @@ -1204,4 +1671,9 @@ void TerrainWindow::ResizeLayout() add_window(*modifier); } + add_window(*propsWindow.get()); + + SetSize(XMFLOAT2(GetScale().x, y + control_size)); + + wi::gui::Window::ResizeLayout(); } diff --git a/Editor/TerrainWindow.h b/Editor/TerrainWindow.h index 3f76e8c08af..0afcb856caa 100644 --- a/Editor/TerrainWindow.h +++ b/Editor/TerrainWindow.h @@ -20,7 +20,7 @@ struct PerlinModifierWindow : public ModifierWindow wi::gui::Slider octavesSlider; PerlinModifierWindow(); - void ResizeLayout(); + void ResizeLayout() override; void Bind(wi::terrain::PerlinModifier* ptr); void From(wi::terrain::PerlinModifier* ptr); }; @@ -47,6 +47,52 @@ struct HeightmapModifierWindow : public ModifierWindow void From(wi::terrain::HeightmapModifier* ptr); }; +struct PropWindow : public wi::gui::Window +{ + wi::gui::ComboBox meshCombo; + wi::gui::TextInputField minCountPerChunkInput; + wi::gui::TextInputField maxCountPerChunkInput; + wi::gui::ComboBox regionCombo; + wi::gui::Slider regionPowerSlider; + wi::gui::Slider noiseFrequencySlider; + wi::gui::Slider noisePowerSlider; + wi::gui::Slider thresholdSlider; + wi::gui::Slider minSizeSlider; + wi::gui::Slider maxSizeSlider; + wi::gui::TextInputField minYOffsetInput; + wi::gui::TextInputField maxYOffsetInput; + + PropWindow(wi::terrain::Prop* prop, wi::scene::Scene* scene); + void ResizeLayout() override; + + wi::terrain::Prop* prop = nullptr; + wi::scene::Scene* scene = nullptr; + + std::function generation_callback; +}; + +struct PropsWindow : public wi::gui::Window +{ + wi::gui::Button addButton; + + PropsWindow(EditorComponent* editor); + + void Rebuild(); + void AddWindow(wi::terrain::Prop& prop); + + void Update(const wi::Canvas& canvas, float dt) override; + + void ResizeLayout() override; + + EditorComponent* editor = nullptr; + wi::terrain::Terrain* terrain = nullptr; + + wi::vector> windows; + wi::vector windows_to_remove; + + std::function generation_callback; +}; + class TerrainWindow : public wi::gui::Window { public: @@ -76,6 +122,11 @@ class TerrainWindow : public wi::gui::Window wi::gui::Slider region2Slider; wi::gui::Slider region3Slider; + wi::gui::ComboBox materialCombos[wi::terrain::MATERIAL_COUNT]; + wi::gui::ComboBox materialCombo_GrassParticle; + + std::unique_ptr propsWindow; + enum PRESET { PRESET_HILLS, diff --git a/Editor/VoxelGridWindow.cpp b/Editor/VoxelGridWindow.cpp new file mode 100644 index 00000000000..b481906f9a5 --- /dev/null +++ b/Editor/VoxelGridWindow.cpp @@ -0,0 +1,239 @@ +#include "stdafx.h" +#include "VoxelGridWindow.h" + +using namespace wi::ecs; +using namespace wi::scene; + +void VoxelGridWindow::Create(EditorComponent* _editor) +{ + editor = _editor; + wi::gui::Window::Create(ICON_VOXELGRID " VoxelGrid", wi::gui::Window::WindowControls::COLLAPSE | wi::gui::Window::WindowControls::CLOSE); + SetSize(XMFLOAT2(520, 400)); + + closeButton.SetTooltip("Delete VoxelGrid"); + OnClose([=](wi::gui::EventArgs args) { + + wi::Archive& archive = editor->AdvanceHistory(); + archive << EditorComponent::HISTORYOP_COMPONENT_DATA; + editor->RecordEntity(archive, entity); + + editor->GetCurrentScene().voxel_grids.Remove(entity); + + editor->RecordEntity(archive, entity); + + editor->optionsWnd.RefreshEntityTree(); + }); + + float x = 80; + float y = 0; + float hei = 18; + float wid = 200; + float step = hei + 4; + + infoLabel.Create(""); + infoLabel.SetSize(XMFLOAT2(100, 150)); + AddWidget(&infoLabel); + + dimXInput.Create("DimX"); + dimXInput.SetSize(XMFLOAT2(100, hei)); + dimXInput.SetDescription("Dimension X: "); + dimXInput.OnInputAccepted([=](wi::gui::EventArgs args) { + Scene& scene = editor->GetCurrentScene(); + wi::VoxelGrid* voxelgrid = scene.voxel_grids.GetComponent(entity); + if (voxelgrid == nullptr) + return; + voxelgrid->init(uint32_t(std::max(1, args.iValue)), voxelgrid->resolution.y, voxelgrid->resolution.z); + }); + AddWidget(&dimXInput); + + dimYInput.Create("DimY"); + dimYInput.SetSize(XMFLOAT2(100, hei)); + dimYInput.SetDescription("Y: "); + dimYInput.OnInputAccepted([=](wi::gui::EventArgs args) { + Scene& scene = editor->GetCurrentScene(); + wi::VoxelGrid* voxelgrid = scene.voxel_grids.GetComponent(entity); + if (voxelgrid == nullptr) + return; + voxelgrid->init(voxelgrid->resolution.x, uint32_t(std::max(1, args.iValue)), voxelgrid->resolution.z); + }); + AddWidget(&dimYInput); + + dimZInput.Create("DimZ"); + dimZInput.SetSize(XMFLOAT2(100, hei)); + dimZInput.SetDescription("Z: "); + dimZInput.OnInputAccepted([=](wi::gui::EventArgs args) { + Scene& scene = editor->GetCurrentScene(); + wi::VoxelGrid* voxelgrid = scene.voxel_grids.GetComponent(entity); + if (voxelgrid == nullptr) + return; + voxelgrid->init(voxelgrid->resolution.x, voxelgrid->resolution.y, uint32_t(std::max(1, args.iValue))); + }); + AddWidget(&dimZInput); + + clearButton.Create("Clear voxels " ICON_CLEARVOXELS); + clearButton.SetSize(XMFLOAT2(100, hei)); + clearButton.OnClick([=](wi::gui::EventArgs args) { + Scene& scene = editor->GetCurrentScene(); + wi::VoxelGrid* voxelgrid = scene.voxel_grids.GetComponent(entity); + if (voxelgrid == nullptr) + return; + voxelgrid->cleardata(); + }); + AddWidget(&clearButton); + + voxelizeObjectsButton.Create("Voxelize objects " ICON_VOXELIZE); + voxelizeObjectsButton.SetTooltip("Generate navigation grid including all meshes."); + voxelizeObjectsButton.SetSize(XMFLOAT2(100, hei)); + voxelizeObjectsButton.OnClick([=](wi::gui::EventArgs args) { + Scene& scene = editor->GetCurrentScene(); + wi::VoxelGrid* voxelgrid = scene.voxel_grids.GetComponent(entity); + if (voxelgrid == nullptr) + return; + scene.VoxelizeScene(*voxelgrid, subtractCheckBox.GetCheck(), wi::enums::FILTER_OBJECT_ALL); + }); + AddWidget(&voxelizeObjectsButton); + + voxelizeNavigationButton.Create("Voxelize navigation " ICON_VOXELIZE); + voxelizeNavigationButton.SetTooltip("Generate navigation grid including all navmeshes (object tagged as navmesh)."); + voxelizeNavigationButton.SetSize(XMFLOAT2(100, hei)); + voxelizeNavigationButton.OnClick([=](wi::gui::EventArgs args) { + Scene& scene = editor->GetCurrentScene(); + wi::VoxelGrid* voxelgrid = scene.voxel_grids.GetComponent(entity); + if (voxelgrid == nullptr) + return; + scene.VoxelizeScene(*voxelgrid, subtractCheckBox.GetCheck(), wi::enums::FILTER_NAVIGATION_MESH); + }); + AddWidget(&voxelizeNavigationButton); + + voxelizeCollidersButton.Create("Voxelize CPU colliders " ICON_VOXELIZE); + voxelizeCollidersButton.SetTooltip("Generate navigation grid including all CPU colliders."); + voxelizeCollidersButton.SetSize(XMFLOAT2(100, hei)); + voxelizeCollidersButton.OnClick([=](wi::gui::EventArgs args) { + Scene& scene = editor->GetCurrentScene(); + wi::VoxelGrid* voxelgrid = scene.voxel_grids.GetComponent(entity); + if (voxelgrid == nullptr) + return; + scene.VoxelizeScene(*voxelgrid, subtractCheckBox.GetCheck(), wi::enums::FILTER_COLLIDER); + }); + AddWidget(&voxelizeCollidersButton); + + fitToSceneButton.Create("Fit bounds to scene " ICON_VOXELBOUNDS); + fitToSceneButton.SetTooltip("Fit the bounds of the voxel grid onto the whole scene."); + fitToSceneButton.SetSize(XMFLOAT2(100, hei)); + fitToSceneButton.OnClick([=](wi::gui::EventArgs args) { + Scene& scene = editor->GetCurrentScene(); + if (scene.bounds.getArea() < 0) + return; + wi::VoxelGrid* voxelgrid = scene.voxel_grids.GetComponent(entity); + if (voxelgrid == nullptr) + return; + voxelgrid->from_aabb(scene.bounds); + TransformComponent* transform = scene.transforms.GetComponent(entity); + if (transform != nullptr) + { + // feed back to transform component if it exists: + transform->translation_local = voxelgrid->center; + transform->scale_local = voxelgrid->voxelSize; + transform->SetDirty(); + } + }); + AddWidget(&fitToSceneButton); + + subtractCheckBox.Create("Subtraction mode: "); + subtractCheckBox.SetTooltip("If enabled, voxelization will be subtractive, so it will remove voxels instead of add."); + subtractCheckBox.SetSize(XMFLOAT2(hei, hei)); + AddWidget(&subtractCheckBox); + + debugAllCheckBox.Create("Debug draw all: "); + debugAllCheckBox.SetTooltip("Draw all voxel grids, whether they are selected or not."); + debugAllCheckBox.SetSize(XMFLOAT2(hei, hei)); + AddWidget(&debugAllCheckBox); + + + SetMinimized(true); + SetVisible(false); + +} + +void VoxelGridWindow::SetEntity(Entity entity) +{ + bool changed = this->entity != entity; + this->entity = entity; + + Scene& scene = editor->GetCurrentScene(); + wi::VoxelGrid* voxelgrid = scene.voxel_grids.GetComponent(entity); + + if (voxelgrid != nullptr) + { + std::string infotext = "Voxel grid can be used for navigation. By voxelizing the scene into the grid, path finding can be used on the resulting voxel grid."; + infotext += "\n\nMemory usage: "; + infotext += wi::helper::GetMemorySizeText(voxelgrid->get_memory_size()); + infoLabel.SetText(infotext); + + dimXInput.SetValue((int)voxelgrid->resolution.x); + dimYInput.SetValue((int)voxelgrid->resolution.y); + dimZInput.SetValue((int)voxelgrid->resolution.z); + } +} + +void VoxelGridWindow::ResizeLayout() +{ + wi::gui::Window::ResizeLayout(); + const float padding = 4; + const float width = GetWidgetAreaSize().x; + float y = padding; + float jump = 20; + + const float margin_left = 90; + const float margin_right = 40; + + auto add = [&](wi::gui::Widget& widget) { + if (!widget.IsVisible()) + return; + widget.SetPos(XMFLOAT2(margin_left, y)); + widget.SetSize(XMFLOAT2(width - margin_left - margin_right, widget.GetScale().y)); + y += widget.GetSize().y; + y += padding; + }; + auto add_right = [&](wi::gui::Widget& widget) { + if (!widget.IsVisible()) + return; + const float margin_right = padding; + widget.SetPos(XMFLOAT2(width - margin_right - widget.GetSize().x, y)); + y += widget.GetSize().y; + y += padding; + }; + auto add_fullwidth = [&](wi::gui::Widget& widget) { + if (!widget.IsVisible()) + return; + const float margin_left = padding; + const float margin_right = padding; + widget.SetPos(XMFLOAT2(margin_left, y)); + widget.SetSize(XMFLOAT2(width - margin_left - margin_right, widget.GetScale().y)); + y += widget.GetSize().y; + y += padding; + }; + + add_fullwidth(infoLabel); + + const float padding2 = 20; + const float l = 95; + const float r = width; + float w = ((r - l) - padding2 * 2) / 3.0f; + dimXInput.SetSize(XMFLOAT2(w, dimXInput.GetSize().y)); + dimYInput.SetSize(XMFLOAT2(w, dimYInput.GetSize().y)); + dimZInput.SetSize(XMFLOAT2(w, dimZInput.GetSize().y)); + dimXInput.SetPos(XMFLOAT2(margin_left, y)); + dimYInput.SetPos(XMFLOAT2(dimXInput.GetPos().x + w + padding2, y)); + dimZInput.SetPos(XMFLOAT2(dimYInput.GetPos().x + w + padding2, y)); + y += dimZInput.GetSize().y; + y += padding; + + add_fullwidth(clearButton); + add_fullwidth(voxelizeObjectsButton); + add_fullwidth(voxelizeCollidersButton); + add_fullwidth(voxelizeNavigationButton); + add_fullwidth(fitToSceneButton); + add_right(subtractCheckBox); + add_right(debugAllCheckBox); +} diff --git a/Editor/VoxelGridWindow.h b/Editor/VoxelGridWindow.h new file mode 100644 index 00000000000..ed9ffe30ee0 --- /dev/null +++ b/Editor/VoxelGridWindow.h @@ -0,0 +1,27 @@ +#pragma once +class EditorComponent; + +class VoxelGridWindow : public wi::gui::Window +{ +public: + void Create(EditorComponent* editor); + + EditorComponent* editor = nullptr; + wi::ecs::Entity entity = wi::ecs::INVALID_ENTITY; + void SetEntity(wi::ecs::Entity entity); + + wi::gui::Label infoLabel; + wi::gui::TextInputField dimXInput; + wi::gui::TextInputField dimYInput; + wi::gui::TextInputField dimZInput; + wi::gui::Button clearButton; + wi::gui::Button voxelizeObjectsButton; + wi::gui::Button voxelizeNavigationButton; + wi::gui::Button voxelizeCollidersButton; + wi::gui::Button fitToSceneButton; + wi::gui::CheckBox subtractCheckBox; + wi::gui::CheckBox debugAllCheckBox; + + void ResizeLayout() override; +}; + diff --git a/WickedEngine/CMakeLists.txt b/WickedEngine/CMakeLists.txt index cca50613771..fd68eb758d2 100644 --- a/WickedEngine/CMakeLists.txt +++ b/WickedEngine/CMakeLists.txt @@ -146,6 +146,12 @@ set(HEADER_FILES wiBVH.h wiLocalization.h wiVideo.h + wiVoxelGrid.h + wiPathQuery.h + wiVoxelGrid_BindLua.h + wiPathQuery_BindLua.h + wiTrailRenderer.h + wiTrailRenderer_BindLua.h ) add_library(${TARGET_NAME} ${WICKED_LIBRARY_TYPE} @@ -220,6 +226,12 @@ add_library(${TARGET_NAME} ${WICKED_LIBRARY_TYPE} wiTerrain.cpp wiLocalization.cpp wiVideo.cpp + wiVoxelGrid.cpp + wiPathQuery.cpp + wiVoxelGrid_BindLua.cpp + wiPathQuery_BindLua.cpp + wiTrailRenderer.cpp + wiTrailRenderer_BindLua.cpp ${HEADER_FILES} ) add_library(WickedEngine ALIAS ${TARGET_NAME}) diff --git a/WickedEngine/CommonInclude.h b/WickedEngine/CommonInclude.h index 0b8ad304fb5..40ab0519409 100644 --- a/WickedEngine/CommonInclude.h +++ b/WickedEngine/CommonInclude.h @@ -13,6 +13,182 @@ #define NOMINMAX #endif // NOMINMAX +// CPU intrinsics: +#if defined(_WIN32) +// Windows, Xbox: +#include +inline long AtomicAnd(volatile long* ptr, long mask) +{ + return _InterlockedAnd(ptr, mask); +} +inline long long AtomicAnd(volatile long long* ptr, long long mask) +{ + return _InterlockedAnd64(ptr, mask); +} +inline long AtomicOr(volatile long* ptr, long mask) +{ + return _InterlockedOr(ptr, mask); +} +inline long long AtomicOr(volatile long long* ptr, long long mask) +{ + return _InterlockedOr64(ptr, mask); +} +inline long AtomicXor(volatile long* ptr, long mask) +{ + return _InterlockedXor(ptr, mask); +} +inline long long AtomicXor(volatile long long* ptr, long long mask) +{ + return _InterlockedXor64(ptr, mask); +} +inline long AtomicAdd(volatile long* ptr, long val) +{ + return _InterlockedExchangeAdd(ptr, val); +} +inline long long AtomicAdd(volatile long long* ptr, long long val) +{ + return _InterlockedExchangeAdd64(ptr, val); +} +inline unsigned int countbits(unsigned int value) +{ + return __popcnt(value); +} +inline unsigned long long countbits(unsigned long long value) +{ + return __popcnt64(value); +} +inline unsigned long firstbithigh(unsigned long value) +{ + unsigned long bit_index; + if (_BitScanReverse(&bit_index, value)) + { + return 31ul - bit_index; + } + return 0; +} +inline unsigned long firstbithigh(unsigned long long value) +{ + unsigned long bit_index; + if (_BitScanReverse64(&bit_index, value)) + { + return 31ull - bit_index; + } + return 0; +} +inline unsigned long firstbitlow(unsigned long value) +{ + unsigned long bit_index; + if (_BitScanForward(&bit_index, value)) + { + return bit_index; + } + return 0; +} +inline unsigned long firstbitlow(unsigned long long value) +{ + unsigned long bit_index; + if (_BitScanForward64(&bit_index, value)) + { + return bit_index; + } + return 0; +} +#else +// Linux, PlayStation: +inline long AtomicAnd(volatile long* ptr, long mask) +{ + return __atomic_fetch_and(ptr, mask, __ATOMIC_SEQ_CST); +} +inline long long AtomicAnd(volatile long long* ptr, long long mask) +{ + return __atomic_fetch_and(ptr, mask, __ATOMIC_SEQ_CST); +} +inline long AtomicOr(volatile long* ptr, long mask) +{ + return __atomic_fetch_or(ptr, mask, __ATOMIC_SEQ_CST); +} +inline long long AtomicOr(volatile long long* ptr, long long mask) +{ + return __atomic_fetch_or(ptr, mask, __ATOMIC_SEQ_CST); +} +inline long AtomicXor(volatile long* ptr, long mask) +{ + return __atomic_fetch_xor(ptr, mask, __ATOMIC_SEQ_CST); +} +inline long long AtomicXor(volatile long long* ptr, long long mask) +{ + return __atomic_fetch_xor(ptr, mask, __ATOMIC_SEQ_CST); +} +inline long AtomicAdd(volatile long* ptr, long val) +{ + return __atomic_fetch_add(ptr, val, __ATOMIC_SEQ_CST); +} +inline long long AtomicAdd(volatile long long* ptr, long long val) +{ + return __atomic_fetch_add(ptr, val, __ATOMIC_SEQ_CST); +} +inline unsigned int countbits(unsigned int value) +{ + return __builtin_popcount(value); +} +inline unsigned long long countbits(unsigned long value) +{ + return __builtin_popcountl(value); +} +inline unsigned long long countbits(unsigned long long value) +{ + return __builtin_popcountll(value); +} +inline unsigned long firstbithigh(unsigned int value) +{ + if (value == 0) + { + return 0; + } + return __builtin_clz(value); +} +inline unsigned long firstbithigh(unsigned long value) +{ + if (value == 0) + { + return 0; + } + return __builtin_clzl(value); +} +inline unsigned long firstbithigh(unsigned long long value) +{ + if (value == 0) + { + return 0; + } + return __builtin_clzll(value); +} +inline unsigned long firstbitlow(unsigned int value) +{ + if (value == 0) + { + return 0; + } + return __builtin_ctz(value); +} +inline unsigned long firstbitlow(unsigned long value) +{ + if (value == 0) + { + return 0; + } + return __builtin_ctzl(value); +} +inline unsigned long firstbitlow(unsigned long long value) +{ + if (value == 0) + { + return 0; + } + return __builtin_ctzll(value); +} +#endif // _WIN32 + // Enable enum flags: // https://www.justsoftwaresolutions.co.uk/cplusplus/using-enum-classes-as-bitfields.html template diff --git a/WickedEngine/Utility/CMakeLists.txt b/WickedEngine/Utility/CMakeLists.txt index 4ed150ae490..958088bbd16 100644 --- a/WickedEngine/Utility/CMakeLists.txt +++ b/WickedEngine/Utility/CMakeLists.txt @@ -27,6 +27,7 @@ set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/stb_truetype.h ${CMAKE_CURRENT_SOURCE_DIR}/qoi.h ${CMAKE_CURRENT_SOURCE_DIR}/dxcapi.h + ${CMAKE_CURRENT_SOURCE_DIR}/WinAdapter.h ${CMAKE_CURRENT_SOURCE_DIR}/D3D12MemAlloc.h ${CMAKE_CURRENT_SOURCE_DIR}/volk.h ${CMAKE_CURRENT_SOURCE_DIR}/vk_mem_alloc.h @@ -109,13 +110,6 @@ install(FILES ${HEADER_FILES_vulkan} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/WickedEngine/Utility/vulkan/vk_video/") -set(HEADER_FILES_dxc - ${CMAKE_CURRENT_SOURCE_DIR}/dxc/Support/WinAdapter.h - ) -install(FILES ${HEADER_FILES_dxc} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/WickedEngine/Utility/dxc/Support/") - - set (SOURCE_FILES utility_common.cpp spirv_reflect.c diff --git a/WickedEngine/Utility/DirectXMath.h b/WickedEngine/Utility/DirectXMath.h index fac99b1b738..6fad6e99b66 100644 --- a/WickedEngine/Utility/DirectXMath.h +++ b/WickedEngine/Utility/DirectXMath.h @@ -173,7 +173,7 @@ #ifdef __SCE__ #include "sal.h" #else -#include "dxc/Support/WinAdapter.h" +#include "WinAdapter.h" #endif // __SCE__ #endif diff --git a/WickedEngine/Utility/dxc/Support/WinAdapter.h b/WickedEngine/Utility/WinAdapter.h similarity index 92% rename from WickedEngine/Utility/dxc/Support/WinAdapter.h rename to WickedEngine/Utility/WinAdapter.h index 55910e38aef..a0e3e6c3f1d 100644 --- a/WickedEngine/Utility/dxc/Support/WinAdapter.h +++ b/WickedEngine/Utility/WinAdapter.h @@ -68,11 +68,10 @@ #define STDMETHODCALLTYPE #define STDMETHODIMP_(type) type STDMETHODCALLTYPE #define STDMETHODIMP STDMETHODIMP_(HRESULT) -#define STDMETHOD_(type,name) virtual STDMETHODIMP_(type) name +#define STDMETHOD_(type, name) virtual STDMETHODIMP_(type) name #define STDMETHOD(name) STDMETHOD_(HRESULT, name) #define EXTERN_C extern "C" - #define UNREFERENCED_PARAMETER(P) (void)(P) #define RtlEqualMemory(Destination, Source, Length) \ @@ -122,6 +121,7 @@ #define ERROR_NOT_CAPABLE EPERM #define ERROR_NOT_FOUND ENOTSUP #define ERROR_UNHANDLED_EXCEPTION EBADF +#define ERROR_BROKEN_PIPE EPIPE // Used by HRESULT <--> WIN32 error code conversion #define SEVERITY_ERROR 1 @@ -183,7 +183,7 @@ #define _strdup strdup #define _strnicmp strnicmp -#define vsprintf_s vsprintf +#define vsnprintf_s vsnprintf #define strcat_s strcat #define strcpy_s(dst, n, src) strncpy(dst, src, n) #define _vscwprintf vwprintf @@ -325,14 +325,11 @@ #define _COM_Outptr_result_maybenull_ #define _COM_Outptr_opt_result_maybenull_ -#define _Null_ -#define _Notnull_ -#define _Maybenull_ #define THIS_ #define THIS #define PURE = 0 -#define _Outptr_result_bytebuffer_(size) +#define _Maybenull_ #define __debugbreak() @@ -619,17 +616,18 @@ template inline void **IID_PPV_ARGS_Helper(T **pp) { #endif // __EMULATE_UUID // Needed for d3d headers, but fail to create actual interfaces -#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } +#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ + const GUID name = {l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}} #define DECLSPEC_UUID(x) #define MIDL_INTERFACE(x) struct DECLSPEC_UUID(x) -#define DECLARE_INTERFACE(iface) struct iface -#define DECLARE_INTERFACE_(iface, parent) DECLARE_INTERFACE(iface) : parent +#define DECLARE_INTERFACE(iface) struct iface +#define DECLARE_INTERFACE_(iface, parent) DECLARE_INTERFACE(iface) : parent //===--------------------- COM Interfaces ---------------------------------===// CROSS_PLATFORM_UUIDOF(IUnknown, "00000000-0000-0000-C000-000000000046") struct IUnknown { - IUnknown() {}; + IUnknown(){}; virtual HRESULT QueryInterface(REFIID riid, void **ppvObject) = 0; virtual ULONG AddRef() = 0; virtual ULONG Release() = 0; @@ -643,10 +641,10 @@ struct INoMarshal : public IUnknown {}; CROSS_PLATFORM_UUIDOF(IMalloc, "00000002-0000-0000-C000-000000000046") struct IMalloc : public IUnknown { - virtual void *Alloc(size_t size) = 0; - virtual void *Realloc(void *ptr, size_t size) = 0; + virtual void *Alloc(SIZE_T size) = 0; + virtual void *Realloc(void *ptr, SIZE_T size) = 0; virtual void Free(void *ptr) = 0; - virtual size_t GetSize(void *pv) = 0; + virtual SIZE_T GetSize(void *pv) = 0; virtual int DidAlloc(void *pv) = 0; virtual void HeapMinimize(void) = 0; }; @@ -683,8 +681,10 @@ struct IStream : public ISequentialStream { // These don't need stub implementations as they come from the DirectX Headers // They still need the __uuidof() though -CROSS_PLATFORM_UUIDOF(ID3D12LibraryReflection, "8E349D19-54DB-4A56-9DC9-119D87BDB804") -CROSS_PLATFORM_UUIDOF(ID3D12ShaderReflection, "5A58797D-A72C-478D-8BA2-EFC6B0EFE88E") +CROSS_PLATFORM_UUIDOF(ID3D12LibraryReflection, + "8E349D19-54DB-4A56-9DC9-119D87BDB804") +CROSS_PLATFORM_UUIDOF(ID3D12ShaderReflection, + "5A58797D-A72C-478D-8BA2-EFC6B0EFE88E") //===--------------------- COM Pointer Types ------------------------------===// @@ -816,6 +816,14 @@ template class CComPtr : public CComPtrBase { return *this; } + // NOTE: This conversion constructor is not part of the official CComPtr spec; + // however, it is needed to convert CComPtr to CComPtr where T derives + // from Q on Clang. MSVC compiles this conversion as first a call to + // CComPtr::operator T*, followed by CComPtr(T*), but Clang fails to + // compile with error: no viable conversion from 'CComPtr' to 'CComPtr'. + template + CComPtr(const CComPtr &lp) throw() : CComPtrBase(lp.p) {} + T *operator=(const CComPtr &lp) throw() { if (*this != lp) { CComPtr(lp).Swap(*this); @@ -951,6 +959,9 @@ void SysFreeString(BSTR bstrString); // Allocate string with length prefix BSTR SysAllocStringLen(const OLECHAR *strIn, UINT ui); +//===--------------------------- BSTR Length ------------------------------===// +unsigned int SysStringLen(const BSTR bstrString); + //===--------------------- UTF-8 Related Types ----------------------------===// // Code Page @@ -1039,6 +1050,44 @@ class CHandle { HANDLE m_h; }; +///////////////////////////////////////////////////////////////////////////// +// CComBSTR + +class CComBSTR { +public: + BSTR m_str; + CComBSTR() : m_str(nullptr){}; + CComBSTR(int nSize, LPCWSTR sz); + ~CComBSTR() throw() { SysFreeString(m_str); } + unsigned int Length() const throw() { return SysStringLen(m_str); } + operator BSTR() const throw() { return m_str; } + + bool operator==(const CComBSTR &bstrSrc) const throw(); + + BSTR *operator&() throw() { return &m_str; } + + BSTR Detach() throw() { + BSTR s = m_str; + m_str = NULL; + return s; + } + + void Empty() throw() { + SysFreeString(m_str); + m_str = NULL; + } +}; + +//===--------- Convert argv to wchar ----------------===// +class WArgV { + std::vector WStringVector; + std::vector WCharPtrVector; + +public: + WArgV(int argc, const char **argv); + const wchar_t **argv() { return WCharPtrVector.data(); } +}; + #endif // __cplusplus #endif // _WIN32 diff --git a/WickedEngine/Utility/dx12/D3D12TokenizedProgramFormat.hpp b/WickedEngine/Utility/dx12/D3D12TokenizedProgramFormat.hpp index 4d04c3a7a50..b95145430ff 100644 --- a/WickedEngine/Utility/dx12/D3D12TokenizedProgramFormat.hpp +++ b/WickedEngine/Utility/dx12/D3D12TokenizedProgramFormat.hpp @@ -2212,7 +2212,14 @@ typedef enum D3D10_SB_REGISTER_COMPONENT_TYPE D3D10_SB_REGISTER_COMPONENT_UNKNOWN = 0, D3D10_SB_REGISTER_COMPONENT_UINT32 = 1, D3D10_SB_REGISTER_COMPONENT_SINT32 = 2, - D3D10_SB_REGISTER_COMPONENT_FLOAT32 = 3 + D3D10_SB_REGISTER_COMPONENT_FLOAT32 = 3, + // Below types aren't used in DXBC, only signatures from DXIL shaders + D3D10_SB_REGISTER_COMPONENT_UINT16 = 4, + D3D10_SB_REGISTER_COMPONENT_SINT16 = 5, + D3D10_SB_REGISTER_COMPONENT_FLOAT16 = 6, + D3D10_SB_REGISTER_COMPONENT_UINT64 = 7, + D3D10_SB_REGISTER_COMPONENT_SINT64 = 8, + D3D10_SB_REGISTER_COMPONENT_FLOAT64 = 9, } D3D10_SB_REGISTER_COMPONENT_TYPE; typedef enum D3D10_SB_INSTRUCTION_RETURN_TYPE diff --git a/WickedEngine/Utility/dx12/d3d12.h b/WickedEngine/Utility/dx12/d3d12.h index d57513b7f80..4941356e653 100644 --- a/WickedEngine/Utility/dx12/d3d12.h +++ b/WickedEngine/Utility/dx12/d3d12.h @@ -290,6 +290,20 @@ typedef interface ID3D12StateObjectProperties ID3D12StateObjectProperties; #endif /* __ID3D12StateObjectProperties_FWD_DEFINED__ */ +#ifndef __ID3D12StateObjectProperties1_FWD_DEFINED__ +#define __ID3D12StateObjectProperties1_FWD_DEFINED__ +typedef interface ID3D12StateObjectProperties1 ID3D12StateObjectProperties1; + +#endif /* __ID3D12StateObjectProperties1_FWD_DEFINED__ */ + + +#ifndef __ID3D12WorkGraphProperties_FWD_DEFINED__ +#define __ID3D12WorkGraphProperties_FWD_DEFINED__ +typedef interface ID3D12WorkGraphProperties ID3D12WorkGraphProperties; + +#endif /* __ID3D12WorkGraphProperties_FWD_DEFINED__ */ + + #ifndef __ID3D12Device5_FWD_DEFINED__ #define __ID3D12Device5_FWD_DEFINED__ typedef interface ID3D12Device5 ID3D12Device5; @@ -451,6 +465,13 @@ typedef interface ID3D12Device13 ID3D12Device13; #endif /* __ID3D12Device13_FWD_DEFINED__ */ +#ifndef __ID3D12Device14_FWD_DEFINED__ +#define __ID3D12Device14_FWD_DEFINED__ +typedef interface ID3D12Device14 ID3D12Device14; + +#endif /* __ID3D12Device14_FWD_DEFINED__ */ + + #ifndef __ID3D12VirtualizationGuestDevice_FWD_DEFINED__ #define __ID3D12VirtualizationGuestDevice_FWD_DEFINED__ typedef interface ID3D12VirtualizationGuestDevice ID3D12VirtualizationGuestDevice; @@ -493,6 +514,13 @@ typedef interface ID3D12DeviceConfiguration ID3D12DeviceConfiguration; #endif /* __ID3D12DeviceConfiguration_FWD_DEFINED__ */ +#ifndef __ID3D12DeviceConfiguration1_FWD_DEFINED__ +#define __ID3D12DeviceConfiguration1_FWD_DEFINED__ +typedef interface ID3D12DeviceConfiguration1 ID3D12DeviceConfiguration1; + +#endif /* __ID3D12DeviceConfiguration1_FWD_DEFINED__ */ + + #ifndef __ID3D12GraphicsCommandList5_FWD_DEFINED__ #define __ID3D12GraphicsCommandList5_FWD_DEFINED__ typedef interface ID3D12GraphicsCommandList5 ID3D12GraphicsCommandList5; @@ -528,6 +556,20 @@ typedef interface ID3D12GraphicsCommandList9 ID3D12GraphicsCommandList9; #endif /* __ID3D12GraphicsCommandList9_FWD_DEFINED__ */ +#ifndef __ID3D12GraphicsCommandList10_FWD_DEFINED__ +#define __ID3D12GraphicsCommandList10_FWD_DEFINED__ +typedef interface ID3D12GraphicsCommandList10 ID3D12GraphicsCommandList10; + +#endif /* __ID3D12GraphicsCommandList10_FWD_DEFINED__ */ + + +#ifndef __ID3D12GBVDiagnostics_FWD_DEFINED__ +#define __ID3D12GBVDiagnostics_FWD_DEFINED__ +typedef interface ID3D12GBVDiagnostics ID3D12GBVDiagnostics; + +#endif /* __ID3D12GBVDiagnostics_FWD_DEFINED__ */ + + /* header files for imported files */ #include "oaidl.h" #include "ocidl.h" @@ -1060,7 +1102,7 @@ extern "C"{ #define D3D12_PIXEL_ADDRESS_RANGE_BIT_COUNT ( 15 ) -#define D3D12_PREVIEW_SDK_VERSION ( 712 ) +#define D3D12_PREVIEW_SDK_VERSION ( 713 ) #define D3D12_PRE_SCISSOR_PIXEL_ADDRESS_RANGE_BIT_COUNT ( 16 ) @@ -1193,7 +1235,7 @@ extern "C"{ #define D3D12_RS_SET_SHADING_RATE_COMBINER_COUNT ( 2 ) -#define D3D12_SDK_VERSION ( 611 ) +#define D3D12_SDK_VERSION ( 613 ) #define D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES ( 32 ) @@ -1355,6 +1397,10 @@ extern "C"{ #define D3D12_WHQL_DRAW_VERTEX_COUNT_2_TO_EXP ( 25 ) +#define D3D12_WORK_GRAPHS_BACKING_MEMORY_ALIGNMENT_IN_BYTES ( 8 ) + +#define D3D12_WORK_GRAPHS_MAX_NODE_DEPTH ( 32 ) + #endif typedef UINT64 D3D12_GPU_VIRTUAL_ADDRESS; @@ -2117,6 +2163,13 @@ enum D3D12_INDEX_BUFFER_STRIP_CUT_VALUE D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFFFFFF = 2 } D3D12_INDEX_BUFFER_STRIP_CUT_VALUE; +typedef +enum D3D12_STANDARD_MULTISAMPLE_QUALITY_LEVELS + { + D3D12_STANDARD_MULTISAMPLE_PATTERN = 0xffffffff, + D3D12_CENTER_MULTISAMPLE_PATTERN = 0xfffffffe + } D3D12_STANDARD_MULTISAMPLE_QUALITY_LEVELS; + typedef struct D3D12_CACHED_PIPELINE_STATE { _Field_size_bytes_full_(CachedBlobSizeInBytes) const void *pCachedBlob; @@ -2257,7 +2310,8 @@ enum D3D12_FEATURE D3D12_FEATURE_D3D12_OPTIONS20 = 49, D3D12_FEATURE_PREDICATION = 50, D3D12_FEATURE_PLACED_RESOURCE_SUPPORT_INFO = 51, - D3D12_FEATURE_HARDWARE_COPY = 52 + D3D12_FEATURE_HARDWARE_COPY = 52, + D3D12_FEATURE_D3D12_OPTIONS21 = 53 } D3D12_FEATURE; typedef @@ -2393,6 +2447,13 @@ enum D3D12_VIEW_INSTANCING_TIER D3D12_VIEW_INSTANCING_TIER_3 = 3 } D3D12_VIEW_INSTANCING_TIER; +typedef +enum D3D12_WORK_GRAPHS_TIER + { + D3D12_WORK_GRAPHS_TIER_NOT_SUPPORTED = 0, + D3D12_WORK_GRAPHS_TIER_1_0 = 10 + } D3D12_WORK_GRAPHS_TIER; + typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS { _Out_ BOOL DoublePrecisionFloatShaderOps; @@ -2469,6 +2530,7 @@ typedef struct D3D12_FEATURE_DATA_FEATURE_LEVELS typedef enum D3D_SHADER_MODEL { + D3D_SHADER_MODEL_NONE = 0, D3D_SHADER_MODEL_5_1 = 0x51, D3D_SHADER_MODEL_6_0 = 0x60, D3D_SHADER_MODEL_6_1 = 0x61, @@ -2479,7 +2541,8 @@ enum D3D_SHADER_MODEL D3D_SHADER_MODEL_6_6 = 0x66, D3D_SHADER_MODEL_6_7 = 0x67, D3D_SHADER_MODEL_6_8 = 0x68, - D3D_HIGHEST_SHADER_MODEL = D3D_SHADER_MODEL_6_8 + D3D_SHADER_MODEL_6_9 = 0x69, + D3D_HIGHEST_SHADER_MODEL = D3D_SHADER_MODEL_6_9 } D3D_SHADER_MODEL; typedef struct D3D12_FEATURE_DATA_SHADER_MODEL @@ -2794,6 +2857,21 @@ typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS20 D3D12_RECREATE_AT_TIER RecreateAtTier; } D3D12_FEATURE_DATA_D3D12_OPTIONS20; +typedef +enum D3D12_EXECUTE_INDIRECT_TIER + { + D3D12_EXECUTE_INDIRECT_TIER_1_0 = 10, + D3D12_EXECUTE_INDIRECT_TIER_1_1 = 11 + } D3D12_EXECUTE_INDIRECT_TIER; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS21 + { + _Out_ D3D12_WORK_GRAPHS_TIER WorkGraphsTier; + _Out_ D3D12_EXECUTE_INDIRECT_TIER ExecuteIndirectTier; + _Out_ BOOL SampleCmpGradientAndBiasSupported; + _Out_ BOOL ExtendedCommandInfoSupported; + } D3D12_FEATURE_DATA_D3D12_OPTIONS21; + typedef struct D3D12_FEATURE_DATA_PREDICATION { _Out_ BOOL Supported; @@ -4455,7 +4533,8 @@ enum D3D12_INDIRECT_ARGUMENT_TYPE D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW = ( D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW + 1 ) , D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW = ( D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW + 1 ) , D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_RAYS = ( D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW + 1 ) , - D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH = ( D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_RAYS + 1 ) + D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH = ( D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_RAYS + 1 ) , + D3D12_INDIRECT_ARGUMENT_TYPE_INCREMENTING_CONSTANT = ( D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH + 1 ) } D3D12_INDIRECT_ARGUMENT_TYPE; typedef struct D3D12_INDIRECT_ARGUMENT_DESC @@ -4485,6 +4564,11 @@ typedef struct D3D12_INDIRECT_ARGUMENT_DESC { UINT RootParameterIndex; } UnorderedAccessView; + struct + { + UINT RootParameterIndex; + UINT DestOffsetIn32BitValues; + } IncrementingConstant; } ; } D3D12_INDIRECT_ARGUMENT_DESC; @@ -13653,460 +13737,1056 @@ EXTERN_C const IID IID_ID3D12StateObjectProperties; /* interface __MIDL_itf_d3d12_0000_0034 */ /* [local] */ -typedef -enum D3D12_STATE_SUBOBJECT_TYPE +typedef struct D3D12_PROGRAM_IDENTIFIER { - D3D12_STATE_SUBOBJECT_TYPE_STATE_OBJECT_CONFIG = 0, - D3D12_STATE_SUBOBJECT_TYPE_GLOBAL_ROOT_SIGNATURE = 1, - D3D12_STATE_SUBOBJECT_TYPE_LOCAL_ROOT_SIGNATURE = 2, - D3D12_STATE_SUBOBJECT_TYPE_NODE_MASK = 3, - D3D12_STATE_SUBOBJECT_TYPE_DXIL_LIBRARY = 5, - D3D12_STATE_SUBOBJECT_TYPE_EXISTING_COLLECTION = 6, - D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION = 7, - D3D12_STATE_SUBOBJECT_TYPE_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION = 8, - D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_SHADER_CONFIG = 9, - D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG = 10, - D3D12_STATE_SUBOBJECT_TYPE_HIT_GROUP = 11, - D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG1 = 12, - D3D12_STATE_SUBOBJECT_TYPE_MAX_VALID = ( D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG1 + 1 ) - } D3D12_STATE_SUBOBJECT_TYPE; + UINT64 OpaqueData[ 4 ]; + } D3D12_PROGRAM_IDENTIFIER; -typedef struct D3D12_STATE_SUBOBJECT - { - D3D12_STATE_SUBOBJECT_TYPE Type; - const void *pDesc; - } D3D12_STATE_SUBOBJECT; -typedef -enum D3D12_STATE_OBJECT_FLAGS - { - D3D12_STATE_OBJECT_FLAG_NONE = 0, - D3D12_STATE_OBJECT_FLAG_ALLOW_LOCAL_DEPENDENCIES_ON_EXTERNAL_DEFINITIONS = 0x1, - D3D12_STATE_OBJECT_FLAG_ALLOW_EXTERNAL_DEPENDENCIES_ON_LOCAL_DEFINITIONS = 0x2, - D3D12_STATE_OBJECT_FLAG_ALLOW_STATE_OBJECT_ADDITIONS = 0x4 - } D3D12_STATE_OBJECT_FLAGS; -DEFINE_ENUM_FLAG_OPERATORS( D3D12_STATE_OBJECT_FLAGS ); -typedef struct D3D12_STATE_OBJECT_CONFIG - { - D3D12_STATE_OBJECT_FLAGS Flags; - } D3D12_STATE_OBJECT_CONFIG; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0034_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0034_v0_0_s_ifspec; -typedef struct D3D12_GLOBAL_ROOT_SIGNATURE - { - ID3D12RootSignature *pGlobalRootSignature; - } D3D12_GLOBAL_ROOT_SIGNATURE; +#ifndef __ID3D12StateObjectProperties1_INTERFACE_DEFINED__ +#define __ID3D12StateObjectProperties1_INTERFACE_DEFINED__ -typedef struct D3D12_LOCAL_ROOT_SIGNATURE - { - ID3D12RootSignature *pLocalRootSignature; - } D3D12_LOCAL_ROOT_SIGNATURE; +/* interface ID3D12StateObjectProperties1 */ +/* [unique][local][object][uuid] */ -typedef struct D3D12_NODE_MASK - { - UINT NodeMask; - } D3D12_NODE_MASK; -typedef -enum D3D12_EXPORT_FLAGS - { - D3D12_EXPORT_FLAG_NONE = 0 - } D3D12_EXPORT_FLAGS; +EXTERN_C const IID IID_ID3D12StateObjectProperties1; -DEFINE_ENUM_FLAG_OPERATORS( D3D12_EXPORT_FLAGS ); -typedef struct D3D12_EXPORT_DESC +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("460caac7-1d24-446a-a184-ca67db494138") + ID3D12StateObjectProperties1 : public ID3D12StateObjectProperties { - LPCWSTR Name; - _In_opt_ LPCWSTR ExportToRename; - D3D12_EXPORT_FLAGS Flags; - } D3D12_EXPORT_DESC; + public: +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_PROGRAM_IDENTIFIER STDMETHODCALLTYPE GetProgramIdentifier( + LPCWSTR pProgramName) = 0; +#else + virtual D3D12_PROGRAM_IDENTIFIER *STDMETHODCALLTYPE GetProgramIdentifier( + D3D12_PROGRAM_IDENTIFIER * RetVal, + LPCWSTR pProgramName) = 0; +#endif + + }; + + +#else /* C style interface */ -typedef struct D3D12_DXIL_LIBRARY_DESC + typedef struct ID3D12StateObjectProperties1Vtbl { - D3D12_SHADER_BYTECODE DXILLibrary; - UINT NumExports; - _In_reads_(NumExports) const D3D12_EXPORT_DESC *pExports; - } D3D12_DXIL_LIBRARY_DESC; + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12StateObjectProperties1 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12StateObjectProperties1 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12StateObjectProperties1 * This); + + DECLSPEC_XFGVIRT(ID3D12StateObjectProperties, GetShaderIdentifier) + void *( STDMETHODCALLTYPE *GetShaderIdentifier )( + ID3D12StateObjectProperties1 * This, + _In_ LPCWSTR pExportName); + + DECLSPEC_XFGVIRT(ID3D12StateObjectProperties, GetShaderStackSize) + UINT64 ( STDMETHODCALLTYPE *GetShaderStackSize )( + ID3D12StateObjectProperties1 * This, + _In_ LPCWSTR pExportName); + + DECLSPEC_XFGVIRT(ID3D12StateObjectProperties, GetPipelineStackSize) + UINT64 ( STDMETHODCALLTYPE *GetPipelineStackSize )( + ID3D12StateObjectProperties1 * This); + + DECLSPEC_XFGVIRT(ID3D12StateObjectProperties, SetPipelineStackSize) + void ( STDMETHODCALLTYPE *SetPipelineStackSize )( + ID3D12StateObjectProperties1 * This, + UINT64 PipelineStackSizeInBytes); + + DECLSPEC_XFGVIRT(ID3D12StateObjectProperties1, GetProgramIdentifier) +#if !defined(_WIN32) + D3D12_PROGRAM_IDENTIFIER ( STDMETHODCALLTYPE *GetProgramIdentifier )( + ID3D12StateObjectProperties1 * This, + LPCWSTR pProgramName); + +#else + D3D12_PROGRAM_IDENTIFIER *( STDMETHODCALLTYPE *GetProgramIdentifier )( + ID3D12StateObjectProperties1 * This, + D3D12_PROGRAM_IDENTIFIER * RetVal, + LPCWSTR pProgramName); + +#endif + + END_INTERFACE + } ID3D12StateObjectProperties1Vtbl; -typedef struct D3D12_EXISTING_COLLECTION_DESC + interface ID3D12StateObjectProperties1 { - ID3D12StateObject *pExistingCollection; - UINT NumExports; - _In_reads_(NumExports) const D3D12_EXPORT_DESC *pExports; - } D3D12_EXISTING_COLLECTION_DESC; + CONST_VTBL struct ID3D12StateObjectProperties1Vtbl *lpVtbl; + }; -typedef struct D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION - { - const D3D12_STATE_SUBOBJECT *pSubobjectToAssociate; - UINT NumExports; - _In_reads_(NumExports) LPCWSTR *pExports; - } D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION; + -typedef struct D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION - { - LPCWSTR SubobjectToAssociate; - UINT NumExports; - _In_reads_(NumExports) LPCWSTR *pExports; - } D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION; +#ifdef COBJMACROS -typedef -enum D3D12_HIT_GROUP_TYPE - { - D3D12_HIT_GROUP_TYPE_TRIANGLES = 0, - D3D12_HIT_GROUP_TYPE_PROCEDURAL_PRIMITIVE = 0x1 - } D3D12_HIT_GROUP_TYPE; -typedef struct D3D12_HIT_GROUP_DESC - { - LPCWSTR HitGroupExport; - D3D12_HIT_GROUP_TYPE Type; - _In_opt_ LPCWSTR AnyHitShaderImport; - _In_opt_ LPCWSTR ClosestHitShaderImport; - _In_opt_ LPCWSTR IntersectionShaderImport; - } D3D12_HIT_GROUP_DESC; +#define ID3D12StateObjectProperties1_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) -typedef struct D3D12_RAYTRACING_SHADER_CONFIG - { - UINT MaxPayloadSizeInBytes; - UINT MaxAttributeSizeInBytes; - } D3D12_RAYTRACING_SHADER_CONFIG; +#define ID3D12StateObjectProperties1_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) -typedef struct D3D12_RAYTRACING_PIPELINE_CONFIG - { - UINT MaxTraceRecursionDepth; - } D3D12_RAYTRACING_PIPELINE_CONFIG; +#define ID3D12StateObjectProperties1_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) -typedef -enum D3D12_RAYTRACING_PIPELINE_FLAGS - { - D3D12_RAYTRACING_PIPELINE_FLAG_NONE = 0, - D3D12_RAYTRACING_PIPELINE_FLAG_SKIP_TRIANGLES = 0x100, - D3D12_RAYTRACING_PIPELINE_FLAG_SKIP_PROCEDURAL_PRIMITIVES = 0x200 - } D3D12_RAYTRACING_PIPELINE_FLAGS; -DEFINE_ENUM_FLAG_OPERATORS( D3D12_RAYTRACING_PIPELINE_FLAGS ); -typedef struct D3D12_RAYTRACING_PIPELINE_CONFIG1 - { - UINT MaxTraceRecursionDepth; - D3D12_RAYTRACING_PIPELINE_FLAGS Flags; - } D3D12_RAYTRACING_PIPELINE_CONFIG1; +#define ID3D12StateObjectProperties1_GetShaderIdentifier(This,pExportName) \ + ( (This)->lpVtbl -> GetShaderIdentifier(This,pExportName) ) -typedef -enum D3D12_STATE_OBJECT_TYPE - { - D3D12_STATE_OBJECT_TYPE_COLLECTION = 0, - D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE = 3 - } D3D12_STATE_OBJECT_TYPE; +#define ID3D12StateObjectProperties1_GetShaderStackSize(This,pExportName) \ + ( (This)->lpVtbl -> GetShaderStackSize(This,pExportName) ) -typedef struct D3D12_STATE_OBJECT_DESC - { - D3D12_STATE_OBJECT_TYPE Type; - UINT NumSubobjects; - _In_reads_(NumSubobjects) const D3D12_STATE_SUBOBJECT *pSubobjects; - } D3D12_STATE_OBJECT_DESC; +#define ID3D12StateObjectProperties1_GetPipelineStackSize(This) \ + ( (This)->lpVtbl -> GetPipelineStackSize(This) ) -typedef -enum D3D12_RAYTRACING_GEOMETRY_FLAGS - { - D3D12_RAYTRACING_GEOMETRY_FLAG_NONE = 0, - D3D12_RAYTRACING_GEOMETRY_FLAG_OPAQUE = 0x1, - D3D12_RAYTRACING_GEOMETRY_FLAG_NO_DUPLICATE_ANYHIT_INVOCATION = 0x2 - } D3D12_RAYTRACING_GEOMETRY_FLAGS; +#define ID3D12StateObjectProperties1_SetPipelineStackSize(This,PipelineStackSizeInBytes) \ + ( (This)->lpVtbl -> SetPipelineStackSize(This,PipelineStackSizeInBytes) ) -DEFINE_ENUM_FLAG_OPERATORS( D3D12_RAYTRACING_GEOMETRY_FLAGS ); -typedef -enum D3D12_RAYTRACING_GEOMETRY_TYPE - { - D3D12_RAYTRACING_GEOMETRY_TYPE_TRIANGLES = 0, - D3D12_RAYTRACING_GEOMETRY_TYPE_PROCEDURAL_PRIMITIVE_AABBS = ( D3D12_RAYTRACING_GEOMETRY_TYPE_TRIANGLES + 1 ) - } D3D12_RAYTRACING_GEOMETRY_TYPE; +#if !defined(_WIN32) -typedef -enum D3D12_RAYTRACING_INSTANCE_FLAGS - { - D3D12_RAYTRACING_INSTANCE_FLAG_NONE = 0, - D3D12_RAYTRACING_INSTANCE_FLAG_TRIANGLE_CULL_DISABLE = 0x1, - D3D12_RAYTRACING_INSTANCE_FLAG_TRIANGLE_FRONT_COUNTERCLOCKWISE = 0x2, - D3D12_RAYTRACING_INSTANCE_FLAG_FORCE_OPAQUE = 0x4, - D3D12_RAYTRACING_INSTANCE_FLAG_FORCE_NON_OPAQUE = 0x8 - } D3D12_RAYTRACING_INSTANCE_FLAGS; +#define ID3D12StateObjectProperties1_GetProgramIdentifier(This,pProgramName) \ + ( (This)->lpVtbl -> GetProgramIdentifier(This,pProgramName) ) +#else +#define ID3D12StateObjectProperties1_GetProgramIdentifier(This,RetVal,pProgramName) \ + ( (This)->lpVtbl -> GetProgramIdentifier(This,RetVal,pProgramName) ) +#endif -DEFINE_ENUM_FLAG_OPERATORS( D3D12_RAYTRACING_INSTANCE_FLAGS ); -typedef struct D3D12_GPU_VIRTUAL_ADDRESS_AND_STRIDE - { - D3D12_GPU_VIRTUAL_ADDRESS StartAddress; - UINT64 StrideInBytes; - } D3D12_GPU_VIRTUAL_ADDRESS_AND_STRIDE; +#endif /* COBJMACROS */ -typedef struct D3D12_GPU_VIRTUAL_ADDRESS_RANGE - { - D3D12_GPU_VIRTUAL_ADDRESS StartAddress; - UINT64 SizeInBytes; - } D3D12_GPU_VIRTUAL_ADDRESS_RANGE; -typedef struct D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE - { - D3D12_GPU_VIRTUAL_ADDRESS StartAddress; - UINT64 SizeInBytes; - UINT64 StrideInBytes; - } D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE; +#endif /* C style interface */ -typedef struct D3D12_RAYTRACING_GEOMETRY_TRIANGLES_DESC + + + +#endif /* __ID3D12StateObjectProperties1_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0035 */ +/* [local] */ + +typedef struct D3D12_NODE_ID { - D3D12_GPU_VIRTUAL_ADDRESS Transform3x4; - DXGI_FORMAT IndexFormat; - DXGI_FORMAT VertexFormat; - UINT IndexCount; - UINT VertexCount; - D3D12_GPU_VIRTUAL_ADDRESS IndexBuffer; - D3D12_GPU_VIRTUAL_ADDRESS_AND_STRIDE VertexBuffer; - } D3D12_RAYTRACING_GEOMETRY_TRIANGLES_DESC; + LPCWSTR Name; + UINT ArrayIndex; + } D3D12_NODE_ID; -typedef struct D3D12_RAYTRACING_AABB +typedef struct D3D12_WORK_GRAPH_MEMORY_REQUIREMENTS { - FLOAT MinX; - FLOAT MinY; - FLOAT MinZ; - FLOAT MaxX; - FLOAT MaxY; - FLOAT MaxZ; - } D3D12_RAYTRACING_AABB; + UINT64 MinSizeInBytes; + UINT64 MaxSizeInBytes; + UINT SizeGranularityInBytes; + } D3D12_WORK_GRAPH_MEMORY_REQUIREMENTS; -typedef struct D3D12_RAYTRACING_GEOMETRY_AABBS_DESC + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0035_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0035_v0_0_s_ifspec; + +#ifndef __ID3D12WorkGraphProperties_INTERFACE_DEFINED__ +#define __ID3D12WorkGraphProperties_INTERFACE_DEFINED__ + +/* interface ID3D12WorkGraphProperties */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12WorkGraphProperties; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("065acf71-f863-4b89-82f4-02e4d5886757") + ID3D12WorkGraphProperties : public IUnknown { - UINT64 AABBCount; - D3D12_GPU_VIRTUAL_ADDRESS_AND_STRIDE AABBs; - } D3D12_RAYTRACING_GEOMETRY_AABBS_DESC; + public: + virtual UINT STDMETHODCALLTYPE GetNumWorkGraphs( void) = 0; + + virtual LPCWSTR STDMETHODCALLTYPE GetProgramName( + UINT WorkGraphIndex) = 0; + + virtual UINT STDMETHODCALLTYPE GetWorkGraphIndex( + LPCWSTR pProgramName) = 0; + + virtual UINT STDMETHODCALLTYPE GetNumNodes( + UINT WorkGraphIndex) = 0; + +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_NODE_ID STDMETHODCALLTYPE GetNodeID( + UINT WorkGraphIndex, + UINT NodeIndex) = 0; +#else + virtual D3D12_NODE_ID *STDMETHODCALLTYPE GetNodeID( + D3D12_NODE_ID * RetVal, + UINT WorkGraphIndex, + UINT NodeIndex) = 0; +#endif + + virtual UINT STDMETHODCALLTYPE GetNodeIndex( + UINT WorkGraphIndex, + D3D12_NODE_ID NodeID) = 0; + + virtual UINT STDMETHODCALLTYPE GetNodeLocalRootArgumentsTableIndex( + UINT WorkGraphIndex, + UINT NodeIndex) = 0; + + virtual UINT STDMETHODCALLTYPE GetNumEntrypoints( + UINT WorkGraphIndex) = 0; + +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_NODE_ID STDMETHODCALLTYPE GetEntrypointID( + UINT WorkGraphIndex, + UINT EntrypointIndex) = 0; +#else + virtual D3D12_NODE_ID *STDMETHODCALLTYPE GetEntrypointID( + D3D12_NODE_ID * RetVal, + UINT WorkGraphIndex, + UINT EntrypointIndex) = 0; +#endif + + virtual UINT STDMETHODCALLTYPE GetEntrypointIndex( + UINT WorkGraphIndex, + D3D12_NODE_ID NodeID) = 0; + + virtual UINT STDMETHODCALLTYPE GetEntrypointRecordSizeInBytes( + UINT WorkGraphIndex, + UINT EntrypointIndex) = 0; + + virtual void STDMETHODCALLTYPE GetWorkGraphMemoryRequirements( + UINT WorkGraphIndex, + _Out_ D3D12_WORK_GRAPH_MEMORY_REQUIREMENTS *pWorkGraphMemoryRequirements) = 0; + + virtual UINT STDMETHODCALLTYPE GetEntrypointRecordAlignmentInBytes( + UINT WorkGraphIndex, + UINT EntrypointIndex) = 0; + + }; + + +#else /* C style interface */ -typedef -enum D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS + typedef struct ID3D12WorkGraphPropertiesVtbl { - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_NONE = 0, - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_ALLOW_UPDATE = 0x1, - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_ALLOW_COMPACTION = 0x2, - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PREFER_FAST_TRACE = 0x4, - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PREFER_FAST_BUILD = 0x8, - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_MINIMIZE_MEMORY = 0x10, - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PERFORM_UPDATE = 0x20 - } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS; + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12WorkGraphProperties * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12WorkGraphProperties * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12WorkGraphProperties * This); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetNumWorkGraphs) + UINT ( STDMETHODCALLTYPE *GetNumWorkGraphs )( + ID3D12WorkGraphProperties * This); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetProgramName) + LPCWSTR ( STDMETHODCALLTYPE *GetProgramName )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetWorkGraphIndex) + UINT ( STDMETHODCALLTYPE *GetWorkGraphIndex )( + ID3D12WorkGraphProperties * This, + LPCWSTR pProgramName); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetNumNodes) + UINT ( STDMETHODCALLTYPE *GetNumNodes )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetNodeID) +#if !defined(_WIN32) + D3D12_NODE_ID ( STDMETHODCALLTYPE *GetNodeID )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex, + UINT NodeIndex); + +#else + D3D12_NODE_ID *( STDMETHODCALLTYPE *GetNodeID )( + ID3D12WorkGraphProperties * This, + D3D12_NODE_ID * RetVal, + UINT WorkGraphIndex, + UINT NodeIndex); + +#endif + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetNodeIndex) + UINT ( STDMETHODCALLTYPE *GetNodeIndex )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex, + D3D12_NODE_ID NodeID); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetNodeLocalRootArgumentsTableIndex) + UINT ( STDMETHODCALLTYPE *GetNodeLocalRootArgumentsTableIndex )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex, + UINT NodeIndex); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetNumEntrypoints) + UINT ( STDMETHODCALLTYPE *GetNumEntrypoints )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetEntrypointID) +#if !defined(_WIN32) + D3D12_NODE_ID ( STDMETHODCALLTYPE *GetEntrypointID )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex, + UINT EntrypointIndex); + +#else + D3D12_NODE_ID *( STDMETHODCALLTYPE *GetEntrypointID )( + ID3D12WorkGraphProperties * This, + D3D12_NODE_ID * RetVal, + UINT WorkGraphIndex, + UINT EntrypointIndex); + +#endif + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetEntrypointIndex) + UINT ( STDMETHODCALLTYPE *GetEntrypointIndex )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex, + D3D12_NODE_ID NodeID); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetEntrypointRecordSizeInBytes) + UINT ( STDMETHODCALLTYPE *GetEntrypointRecordSizeInBytes )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex, + UINT EntrypointIndex); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetWorkGraphMemoryRequirements) + void ( STDMETHODCALLTYPE *GetWorkGraphMemoryRequirements )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex, + _Out_ D3D12_WORK_GRAPH_MEMORY_REQUIREMENTS *pWorkGraphMemoryRequirements); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetEntrypointRecordAlignmentInBytes) + UINT ( STDMETHODCALLTYPE *GetEntrypointRecordAlignmentInBytes )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex, + UINT EntrypointIndex); + + END_INTERFACE + } ID3D12WorkGraphPropertiesVtbl; -DEFINE_ENUM_FLAG_OPERATORS( D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS ); -typedef -enum D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE + interface ID3D12WorkGraphProperties { - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE_CLONE = 0, - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE_COMPACT = 0x1, - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE_VISUALIZATION_DECODE_FOR_TOOLS = 0x2, - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE_SERIALIZE = 0x3, - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE_DESERIALIZE = 0x4 - } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE; + CONST_VTBL struct ID3D12WorkGraphPropertiesVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12WorkGraphProperties_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12WorkGraphProperties_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12WorkGraphProperties_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12WorkGraphProperties_GetNumWorkGraphs(This) \ + ( (This)->lpVtbl -> GetNumWorkGraphs(This) ) + +#define ID3D12WorkGraphProperties_GetProgramName(This,WorkGraphIndex) \ + ( (This)->lpVtbl -> GetProgramName(This,WorkGraphIndex) ) + +#define ID3D12WorkGraphProperties_GetWorkGraphIndex(This,pProgramName) \ + ( (This)->lpVtbl -> GetWorkGraphIndex(This,pProgramName) ) + +#define ID3D12WorkGraphProperties_GetNumNodes(This,WorkGraphIndex) \ + ( (This)->lpVtbl -> GetNumNodes(This,WorkGraphIndex) ) +#if !defined(_WIN32) + +#define ID3D12WorkGraphProperties_GetNodeID(This,WorkGraphIndex,NodeIndex) \ + ( (This)->lpVtbl -> GetNodeID(This,WorkGraphIndex,NodeIndex) ) +#else +#define ID3D12WorkGraphProperties_GetNodeID(This,RetVal,WorkGraphIndex,NodeIndex) \ + ( (This)->lpVtbl -> GetNodeID(This,RetVal,WorkGraphIndex,NodeIndex) ) +#endif + +#define ID3D12WorkGraphProperties_GetNodeIndex(This,WorkGraphIndex,NodeID) \ + ( (This)->lpVtbl -> GetNodeIndex(This,WorkGraphIndex,NodeID) ) + +#define ID3D12WorkGraphProperties_GetNodeLocalRootArgumentsTableIndex(This,WorkGraphIndex,NodeIndex) \ + ( (This)->lpVtbl -> GetNodeLocalRootArgumentsTableIndex(This,WorkGraphIndex,NodeIndex) ) + +#define ID3D12WorkGraphProperties_GetNumEntrypoints(This,WorkGraphIndex) \ + ( (This)->lpVtbl -> GetNumEntrypoints(This,WorkGraphIndex) ) +#if !defined(_WIN32) + +#define ID3D12WorkGraphProperties_GetEntrypointID(This,WorkGraphIndex,EntrypointIndex) \ + ( (This)->lpVtbl -> GetEntrypointID(This,WorkGraphIndex,EntrypointIndex) ) +#else +#define ID3D12WorkGraphProperties_GetEntrypointID(This,RetVal,WorkGraphIndex,EntrypointIndex) \ + ( (This)->lpVtbl -> GetEntrypointID(This,RetVal,WorkGraphIndex,EntrypointIndex) ) +#endif + +#define ID3D12WorkGraphProperties_GetEntrypointIndex(This,WorkGraphIndex,NodeID) \ + ( (This)->lpVtbl -> GetEntrypointIndex(This,WorkGraphIndex,NodeID) ) + +#define ID3D12WorkGraphProperties_GetEntrypointRecordSizeInBytes(This,WorkGraphIndex,EntrypointIndex) \ + ( (This)->lpVtbl -> GetEntrypointRecordSizeInBytes(This,WorkGraphIndex,EntrypointIndex) ) + +#define ID3D12WorkGraphProperties_GetWorkGraphMemoryRequirements(This,WorkGraphIndex,pWorkGraphMemoryRequirements) \ + ( (This)->lpVtbl -> GetWorkGraphMemoryRequirements(This,WorkGraphIndex,pWorkGraphMemoryRequirements) ) + +#define ID3D12WorkGraphProperties_GetEntrypointRecordAlignmentInBytes(This,WorkGraphIndex,EntrypointIndex) \ + ( (This)->lpVtbl -> GetEntrypointRecordAlignmentInBytes(This,WorkGraphIndex,EntrypointIndex) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12WorkGraphProperties_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0036 */ +/* [local] */ typedef -enum D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE +enum D3D12_STATE_SUBOBJECT_TYPE { - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL = 0, - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL = 0x1 - } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE; + D3D12_STATE_SUBOBJECT_TYPE_STATE_OBJECT_CONFIG = 0, + D3D12_STATE_SUBOBJECT_TYPE_GLOBAL_ROOT_SIGNATURE = 1, + D3D12_STATE_SUBOBJECT_TYPE_LOCAL_ROOT_SIGNATURE = 2, + D3D12_STATE_SUBOBJECT_TYPE_NODE_MASK = 3, + D3D12_STATE_SUBOBJECT_TYPE_DXIL_LIBRARY = 5, + D3D12_STATE_SUBOBJECT_TYPE_EXISTING_COLLECTION = 6, + D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION = 7, + D3D12_STATE_SUBOBJECT_TYPE_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION = 8, + D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_SHADER_CONFIG = 9, + D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG = 10, + D3D12_STATE_SUBOBJECT_TYPE_HIT_GROUP = 11, + D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG1 = 12, + D3D12_STATE_SUBOBJECT_TYPE_WORK_GRAPH = 13, + D3D12_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT = 14, + D3D12_STATE_SUBOBJECT_TYPE_BLEND = 15, + D3D12_STATE_SUBOBJECT_TYPE_SAMPLE_MASK = 16, + D3D12_STATE_SUBOBJECT_TYPE_RASTERIZER = 17, + D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL = 18, + D3D12_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT = 19, + D3D12_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE = 20, + D3D12_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY = 21, + D3D12_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS = 22, + D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT = 23, + D3D12_STATE_SUBOBJECT_TYPE_SAMPLE_DESC = 24, + D3D12_STATE_SUBOBJECT_TYPE_FLAGS = 26, + D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1 = 27, + D3D12_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING = 28, + D3D12_STATE_SUBOBJECT_TYPE_GENERIC_PROGRAM = 29, + D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL2 = 30, + D3D12_STATE_SUBOBJECT_TYPE_MAX_VALID = ( D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL2 + 1 ) + } D3D12_STATE_SUBOBJECT_TYPE; -typedef -enum D3D12_ELEMENTS_LAYOUT +typedef struct D3D12_STATE_SUBOBJECT { - D3D12_ELEMENTS_LAYOUT_ARRAY = 0, - D3D12_ELEMENTS_LAYOUT_ARRAY_OF_POINTERS = 0x1 - } D3D12_ELEMENTS_LAYOUT; + D3D12_STATE_SUBOBJECT_TYPE Type; + const void *pDesc; + } D3D12_STATE_SUBOBJECT; typedef -enum D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_TYPE +enum D3D12_STATE_OBJECT_FLAGS { - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_COMPACTED_SIZE = 0, - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_TOOLS_VISUALIZATION = 0x1, - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_SERIALIZATION = 0x2, - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_CURRENT_SIZE = 0x3 - } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_TYPE; + D3D12_STATE_OBJECT_FLAG_NONE = 0, + D3D12_STATE_OBJECT_FLAG_ALLOW_LOCAL_DEPENDENCIES_ON_EXTERNAL_DEFINITIONS = 0x1, + D3D12_STATE_OBJECT_FLAG_ALLOW_EXTERNAL_DEPENDENCIES_ON_LOCAL_DEFINITIONS = 0x2, + D3D12_STATE_OBJECT_FLAG_ALLOW_STATE_OBJECT_ADDITIONS = 0x4 + } D3D12_STATE_OBJECT_FLAGS; -typedef struct D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC +DEFINE_ENUM_FLAG_OPERATORS( D3D12_STATE_OBJECT_FLAGS ); +typedef struct D3D12_STATE_OBJECT_CONFIG { - D3D12_GPU_VIRTUAL_ADDRESS DestBuffer; - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_TYPE InfoType; - } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC; + D3D12_STATE_OBJECT_FLAGS Flags; + } D3D12_STATE_OBJECT_CONFIG; -typedef struct D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_COMPACTED_SIZE_DESC +typedef struct D3D12_GLOBAL_ROOT_SIGNATURE { - UINT64 CompactedSizeInBytes; - } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_COMPACTED_SIZE_DESC; + ID3D12RootSignature *pGlobalRootSignature; + } D3D12_GLOBAL_ROOT_SIGNATURE; -typedef struct D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_TOOLS_VISUALIZATION_DESC +typedef struct D3D12_LOCAL_ROOT_SIGNATURE { - UINT64 DecodedSizeInBytes; - } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_TOOLS_VISUALIZATION_DESC; + ID3D12RootSignature *pLocalRootSignature; + } D3D12_LOCAL_ROOT_SIGNATURE; -typedef struct D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_TOOLS_VISUALIZATION_HEADER +typedef struct D3D12_NODE_MASK { - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE Type; - UINT NumDescs; - } D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_TOOLS_VISUALIZATION_HEADER; + UINT NodeMask; + } D3D12_NODE_MASK; -// Regarding D3D12_BUILD_RAY_TRACING_ACCELERATION_STRUCTURE_TOOLS_VISUALIZATION_HEADER above, -// depending on Type field, NumDescs above is followed by either: -// D3D12_RAY_TRACING_INSTANCE_DESC InstanceDescs[NumDescs] -// or D3D12_RAY_TRACING_GEOMETRY_DESC GeometryDescs[NumDescs]. -// There is 4 bytes of padding between GeometryDesc structs in the array so alignment is natural when viewed by CPU. +typedef struct D3D12_SAMPLE_MASK + { + UINT SampleMask; + } D3D12_SAMPLE_MASK; -typedef struct D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_SERIALIZATION_DESC +typedef struct D3D12_IB_STRIP_CUT_VALUE { - UINT64 SerializedSizeInBytes; - UINT64 NumBottomLevelAccelerationStructurePointers; - } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_SERIALIZATION_DESC; + D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IndexBufferStripCutValue; + } D3D12_IB_STRIP_CUT_VALUE; -typedef struct D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER +typedef struct D3D12_PRIMITIVE_TOPOLOGY_DESC { - GUID DriverOpaqueGUID; - BYTE DriverOpaqueVersioningData[ 16 ]; - } D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER; + D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopology; + } D3D12_PRIMITIVE_TOPOLOGY_DESC; -typedef -enum D3D12_SERIALIZED_DATA_TYPE +typedef struct D3D12_DEPTH_STENCIL_FORMAT { - D3D12_SERIALIZED_DATA_RAYTRACING_ACCELERATION_STRUCTURE = 0 - } D3D12_SERIALIZED_DATA_TYPE; + DXGI_FORMAT DepthStencilFormat; + } D3D12_DEPTH_STENCIL_FORMAT; typedef -enum D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS +enum D3D12_EXPORT_FLAGS { - D3D12_DRIVER_MATCHING_IDENTIFIER_COMPATIBLE_WITH_DEVICE = 0, - D3D12_DRIVER_MATCHING_IDENTIFIER_UNSUPPORTED_TYPE = 0x1, - D3D12_DRIVER_MATCHING_IDENTIFIER_UNRECOGNIZED = 0x2, - D3D12_DRIVER_MATCHING_IDENTIFIER_INCOMPATIBLE_VERSION = 0x3, - D3D12_DRIVER_MATCHING_IDENTIFIER_INCOMPATIBLE_TYPE = 0x4 - } D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS; + D3D12_EXPORT_FLAG_NONE = 0 + } D3D12_EXPORT_FLAGS; -typedef struct D3D12_SERIALIZED_RAYTRACING_ACCELERATION_STRUCTURE_HEADER +DEFINE_ENUM_FLAG_OPERATORS( D3D12_EXPORT_FLAGS ); +typedef struct D3D12_EXPORT_DESC { - D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER DriverMatchingIdentifier; - UINT64 SerializedSizeInBytesIncludingHeader; - UINT64 DeserializedSizeInBytes; - UINT64 NumBottomLevelAccelerationStructurePointersAfterHeader; - } D3D12_SERIALIZED_RAYTRACING_ACCELERATION_STRUCTURE_HEADER; + LPCWSTR Name; + _In_opt_ LPCWSTR ExportToRename; + D3D12_EXPORT_FLAGS Flags; + } D3D12_EXPORT_DESC; -typedef struct D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_CURRENT_SIZE_DESC +typedef struct D3D12_DXIL_LIBRARY_DESC { - UINT64 CurrentSizeInBytes; - } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_CURRENT_SIZE_DESC; + D3D12_SHADER_BYTECODE DXILLibrary; + UINT NumExports; + _In_reads_(NumExports) const D3D12_EXPORT_DESC *pExports; + } D3D12_DXIL_LIBRARY_DESC; -typedef struct D3D12_RAYTRACING_INSTANCE_DESC +typedef struct D3D12_EXISTING_COLLECTION_DESC { - FLOAT Transform[ 3 ][ 4 ]; - UINT InstanceID : 24; - UINT InstanceMask : 8; - UINT InstanceContributionToHitGroupIndex : 24; - UINT Flags : 8; - D3D12_GPU_VIRTUAL_ADDRESS AccelerationStructure; - } D3D12_RAYTRACING_INSTANCE_DESC; + ID3D12StateObject *pExistingCollection; + UINT NumExports; + _In_reads_(NumExports) const D3D12_EXPORT_DESC *pExports; + } D3D12_EXISTING_COLLECTION_DESC; -typedef struct D3D12_RAYTRACING_GEOMETRY_DESC +typedef struct D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION { - D3D12_RAYTRACING_GEOMETRY_TYPE Type; - D3D12_RAYTRACING_GEOMETRY_FLAGS Flags; + const D3D12_STATE_SUBOBJECT *pSubobjectToAssociate; + UINT NumExports; + _In_reads_(NumExports) LPCWSTR *pExports; + } D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION; + +typedef struct D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION + { + LPCWSTR SubobjectToAssociate; + UINT NumExports; + _In_reads_(NumExports) LPCWSTR *pExports; + } D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION; + +typedef +enum D3D12_HIT_GROUP_TYPE + { + D3D12_HIT_GROUP_TYPE_TRIANGLES = 0, + D3D12_HIT_GROUP_TYPE_PROCEDURAL_PRIMITIVE = 0x1 + } D3D12_HIT_GROUP_TYPE; + +typedef struct D3D12_HIT_GROUP_DESC + { + LPCWSTR HitGroupExport; + D3D12_HIT_GROUP_TYPE Type; + _In_opt_ LPCWSTR AnyHitShaderImport; + _In_opt_ LPCWSTR ClosestHitShaderImport; + _In_opt_ LPCWSTR IntersectionShaderImport; + } D3D12_HIT_GROUP_DESC; + +typedef struct D3D12_RAYTRACING_SHADER_CONFIG + { + UINT MaxPayloadSizeInBytes; + UINT MaxAttributeSizeInBytes; + } D3D12_RAYTRACING_SHADER_CONFIG; + +typedef struct D3D12_RAYTRACING_PIPELINE_CONFIG + { + UINT MaxTraceRecursionDepth; + } D3D12_RAYTRACING_PIPELINE_CONFIG; + +typedef +enum D3D12_RAYTRACING_PIPELINE_FLAGS + { + D3D12_RAYTRACING_PIPELINE_FLAG_NONE = 0, + D3D12_RAYTRACING_PIPELINE_FLAG_SKIP_TRIANGLES = 0x100, + D3D12_RAYTRACING_PIPELINE_FLAG_SKIP_PROCEDURAL_PRIMITIVES = 0x200 + } D3D12_RAYTRACING_PIPELINE_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_RAYTRACING_PIPELINE_FLAGS ); +typedef struct D3D12_RAYTRACING_PIPELINE_CONFIG1 + { + UINT MaxTraceRecursionDepth; + D3D12_RAYTRACING_PIPELINE_FLAGS Flags; + } D3D12_RAYTRACING_PIPELINE_CONFIG1; + +typedef struct D3D12_NODE_OUTPUT_OVERRIDES + { + UINT OutputIndex; + _In_opt_ const D3D12_NODE_ID *pNewName; + _In_opt_ const BOOL *pAllowSparseNodes; + _In_opt_ const UINT *pMaxRecords; + _In_opt_ const UINT *pMaxRecordsSharedWithOutputIndex; + } D3D12_NODE_OUTPUT_OVERRIDES; + +typedef struct D3D12_BROADCASTING_LAUNCH_OVERRIDES + { + _In_opt_ const UINT *pLocalRootArgumentsTableIndex; + _In_opt_ const BOOL *pProgramEntry; + _In_opt_ const D3D12_NODE_ID *pNewName; + _In_opt_ const D3D12_NODE_ID *pShareInputOf; + _In_reads_opt_(3) const UINT *pDispatchGrid; + _In_reads_opt_(3) const UINT *pMaxDispatchGrid; + UINT NumOutputOverrides; + _In_reads_opt_(NumOutputOverrides) const D3D12_NODE_OUTPUT_OVERRIDES *pOutputOverrides; + } D3D12_BROADCASTING_LAUNCH_OVERRIDES; + +typedef struct D3D12_COALESCING_LAUNCH_OVERRIDES + { + _In_opt_ const UINT *pLocalRootArgumentsTableIndex; + _In_opt_ const BOOL *pProgramEntry; + _In_opt_ const D3D12_NODE_ID *pNewName; + _In_opt_ const D3D12_NODE_ID *pShareInputOf; + UINT NumOutputOverrides; + _In_reads_opt_(NumOutputOverrides) const D3D12_NODE_OUTPUT_OVERRIDES *pOutputOverrides; + } D3D12_COALESCING_LAUNCH_OVERRIDES; + +typedef struct D3D12_THREAD_LAUNCH_OVERRIDES + { + _In_opt_ const UINT *pLocalRootArgumentsTableIndex; + _In_opt_ const BOOL *pProgramEntry; + _In_opt_ const D3D12_NODE_ID *pNewName; + _In_opt_ const D3D12_NODE_ID *pShareInputOf; + UINT NumOutputOverrides; + _In_reads_opt_(NumOutputOverrides) const D3D12_NODE_OUTPUT_OVERRIDES *pOutputOverrides; + } D3D12_THREAD_LAUNCH_OVERRIDES; + +typedef struct D3D12_COMMON_COMPUTE_NODE_OVERRIDES + { + _In_opt_ const UINT *pLocalRootArgumentsTableIndex; + _In_opt_ const BOOL *pProgramEntry; + _In_opt_ const D3D12_NODE_ID *pNewName; + _In_opt_ const D3D12_NODE_ID *pShareInputOf; + UINT NumOutputOverrides; + _In_reads_opt_(NumOutputOverrides) const D3D12_NODE_OUTPUT_OVERRIDES *pOutputOverrides; + } D3D12_COMMON_COMPUTE_NODE_OVERRIDES; + +typedef +enum D3D12_NODE_OVERRIDES_TYPE + { + D3D12_NODE_OVERRIDES_TYPE_NONE = 0, + D3D12_NODE_OVERRIDES_TYPE_BROADCASTING_LAUNCH = 1, + D3D12_NODE_OVERRIDES_TYPE_COALESCING_LAUNCH = 2, + D3D12_NODE_OVERRIDES_TYPE_THREAD_LAUNCH = 3, + D3D12_NODE_OVERRIDES_TYPE_COMMON_COMPUTE = 4 + } D3D12_NODE_OVERRIDES_TYPE; + +typedef struct D3D12_SHADER_NODE + { + LPCWSTR Shader; + D3D12_NODE_OVERRIDES_TYPE OverridesType; union { - D3D12_RAYTRACING_GEOMETRY_TRIANGLES_DESC Triangles; - D3D12_RAYTRACING_GEOMETRY_AABBS_DESC AABBs; + const D3D12_BROADCASTING_LAUNCH_OVERRIDES *pBroadcastingLaunchOverrides; + const D3D12_COALESCING_LAUNCH_OVERRIDES *pCoalescingLaunchOverrides; + const D3D12_THREAD_LAUNCH_OVERRIDES *pThreadLaunchOverrides; + const D3D12_COMMON_COMPUTE_NODE_OVERRIDES *pCommonComputeNodeOverrides; } ; - } D3D12_RAYTRACING_GEOMETRY_DESC; + } D3D12_SHADER_NODE; -typedef struct D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS +typedef +enum D3D12_NODE_TYPE { - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE Type; - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS Flags; - UINT NumDescs; - D3D12_ELEMENTS_LAYOUT DescsLayout; + D3D12_NODE_TYPE_SHADER = 0 + } D3D12_NODE_TYPE; + +typedef struct D3D12_NODE + { + D3D12_NODE_TYPE NodeType; union { - D3D12_GPU_VIRTUAL_ADDRESS InstanceDescs; - const D3D12_RAYTRACING_GEOMETRY_DESC *pGeometryDescs; - const D3D12_RAYTRACING_GEOMETRY_DESC *const *ppGeometryDescs; + D3D12_SHADER_NODE Shader; } ; - } D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS; + } D3D12_NODE; -typedef struct D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC +typedef +enum D3D12_WORK_GRAPH_FLAGS { - D3D12_GPU_VIRTUAL_ADDRESS DestAccelerationStructureData; - D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS Inputs; - _In_opt_ D3D12_GPU_VIRTUAL_ADDRESS SourceAccelerationStructureData; - D3D12_GPU_VIRTUAL_ADDRESS ScratchAccelerationStructureData; - } D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC; + D3D12_WORK_GRAPH_FLAG_NONE = 0, + D3D12_WORK_GRAPH_FLAG_INCLUDE_ALL_AVAILABLE_NODES = 0x1 + } D3D12_WORK_GRAPH_FLAGS; -typedef struct D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO +DEFINE_ENUM_FLAG_OPERATORS( D3D12_WORK_GRAPH_FLAGS ); +typedef struct D3D12_WORK_GRAPH_DESC { - UINT64 ResultDataMaxSizeInBytes; - UINT64 ScratchDataSizeInBytes; - UINT64 UpdateScratchDataSizeInBytes; - } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO; + LPCWSTR ProgramName; + D3D12_WORK_GRAPH_FLAGS Flags; + UINT NumEntrypoints; + _In_reads_opt_(NumEntrypoints) const D3D12_NODE_ID *pEntrypoints; + UINT NumExplicitlyDefinedNodes; + _In_reads_opt_(NumExplicitlyDefinedNodes) const D3D12_NODE *pExplicitlyDefinedNodes; + } D3D12_WORK_GRAPH_DESC; + +typedef struct D3D12_GENERIC_PROGRAM_DESC + { + LPCWSTR ProgramName; + UINT NumExports; + _In_reads_(NumExports) LPCWSTR *pExports; + UINT NumSubobjects; + _In_reads_opt_(NumSubobjects) const D3D12_STATE_SUBOBJECT *const *ppSubobjects; + } D3D12_GENERIC_PROGRAM_DESC; typedef -enum D3D12_RAY_FLAGS +enum D3D12_STATE_OBJECT_TYPE { - D3D12_RAY_FLAG_NONE = 0, - D3D12_RAY_FLAG_FORCE_OPAQUE = 0x1, - D3D12_RAY_FLAG_FORCE_NON_OPAQUE = 0x2, - D3D12_RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH = 0x4, - D3D12_RAY_FLAG_SKIP_CLOSEST_HIT_SHADER = 0x8, - D3D12_RAY_FLAG_CULL_BACK_FACING_TRIANGLES = 0x10, - D3D12_RAY_FLAG_CULL_FRONT_FACING_TRIANGLES = 0x20, - D3D12_RAY_FLAG_CULL_OPAQUE = 0x40, - D3D12_RAY_FLAG_CULL_NON_OPAQUE = 0x80, - D3D12_RAY_FLAG_SKIP_TRIANGLES = 0x100, - D3D12_RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES = 0x200 - } D3D12_RAY_FLAGS; + D3D12_STATE_OBJECT_TYPE_COLLECTION = 0, + D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE = 3, + D3D12_STATE_OBJECT_TYPE_EXECUTABLE = 4 + } D3D12_STATE_OBJECT_TYPE; + +typedef struct D3D12_STATE_OBJECT_DESC + { + D3D12_STATE_OBJECT_TYPE Type; + UINT NumSubobjects; + _In_reads_(NumSubobjects) const D3D12_STATE_SUBOBJECT *pSubobjects; + } D3D12_STATE_OBJECT_DESC; -DEFINE_ENUM_FLAG_OPERATORS( D3D12_RAY_FLAGS ); typedef -enum D3D12_HIT_KIND +enum D3D12_RAYTRACING_GEOMETRY_FLAGS { - D3D12_HIT_KIND_TRIANGLE_FRONT_FACE = 0xfe, - D3D12_HIT_KIND_TRIANGLE_BACK_FACE = 0xff - } D3D12_HIT_KIND; + D3D12_RAYTRACING_GEOMETRY_FLAG_NONE = 0, + D3D12_RAYTRACING_GEOMETRY_FLAG_OPAQUE = 0x1, + D3D12_RAYTRACING_GEOMETRY_FLAG_NO_DUPLICATE_ANYHIT_INVOCATION = 0x2 + } D3D12_RAYTRACING_GEOMETRY_FLAGS; +DEFINE_ENUM_FLAG_OPERATORS( D3D12_RAYTRACING_GEOMETRY_FLAGS ); +typedef +enum D3D12_RAYTRACING_GEOMETRY_TYPE + { + D3D12_RAYTRACING_GEOMETRY_TYPE_TRIANGLES = 0, + D3D12_RAYTRACING_GEOMETRY_TYPE_PROCEDURAL_PRIMITIVE_AABBS = ( D3D12_RAYTRACING_GEOMETRY_TYPE_TRIANGLES + 1 ) + } D3D12_RAYTRACING_GEOMETRY_TYPE; +typedef +enum D3D12_RAYTRACING_INSTANCE_FLAGS + { + D3D12_RAYTRACING_INSTANCE_FLAG_NONE = 0, + D3D12_RAYTRACING_INSTANCE_FLAG_TRIANGLE_CULL_DISABLE = 0x1, + D3D12_RAYTRACING_INSTANCE_FLAG_TRIANGLE_FRONT_COUNTERCLOCKWISE = 0x2, + D3D12_RAYTRACING_INSTANCE_FLAG_FORCE_OPAQUE = 0x4, + D3D12_RAYTRACING_INSTANCE_FLAG_FORCE_NON_OPAQUE = 0x8 + } D3D12_RAYTRACING_INSTANCE_FLAGS; -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0034_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0034_v0_0_s_ifspec; +DEFINE_ENUM_FLAG_OPERATORS( D3D12_RAYTRACING_INSTANCE_FLAGS ); +typedef struct D3D12_GPU_VIRTUAL_ADDRESS_AND_STRIDE + { + D3D12_GPU_VIRTUAL_ADDRESS StartAddress; + UINT64 StrideInBytes; + } D3D12_GPU_VIRTUAL_ADDRESS_AND_STRIDE; -#ifndef __ID3D12Device5_INTERFACE_DEFINED__ -#define __ID3D12Device5_INTERFACE_DEFINED__ +typedef struct D3D12_GPU_VIRTUAL_ADDRESS_RANGE + { + D3D12_GPU_VIRTUAL_ADDRESS StartAddress; + UINT64 SizeInBytes; + } D3D12_GPU_VIRTUAL_ADDRESS_RANGE; -/* interface ID3D12Device5 */ -/* [unique][local][object][uuid] */ +typedef struct D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE + { + D3D12_GPU_VIRTUAL_ADDRESS StartAddress; + UINT64 SizeInBytes; + UINT64 StrideInBytes; + } D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE; +typedef struct D3D12_RAYTRACING_GEOMETRY_TRIANGLES_DESC + { + D3D12_GPU_VIRTUAL_ADDRESS Transform3x4; + DXGI_FORMAT IndexFormat; + DXGI_FORMAT VertexFormat; + UINT IndexCount; + UINT VertexCount; + D3D12_GPU_VIRTUAL_ADDRESS IndexBuffer; + D3D12_GPU_VIRTUAL_ADDRESS_AND_STRIDE VertexBuffer; + } D3D12_RAYTRACING_GEOMETRY_TRIANGLES_DESC; -EXTERN_C const IID IID_ID3D12Device5; +typedef struct D3D12_RAYTRACING_AABB + { + FLOAT MinX; + FLOAT MinY; + FLOAT MinZ; + FLOAT MaxX; + FLOAT MaxY; + FLOAT MaxZ; + } D3D12_RAYTRACING_AABB; -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("8b4f173b-2fea-4b80-8f58-4307191ab95d") - ID3D12Device5 : public ID3D12Device4 +typedef struct D3D12_RAYTRACING_GEOMETRY_AABBS_DESC { - public: - virtual HRESULT STDMETHODCALLTYPE CreateLifetimeTracker( - _In_ ID3D12LifetimeOwner *pOwner, - REFIID riid, - _COM_Outptr_ void **ppvTracker) = 0; - - virtual void STDMETHODCALLTYPE RemoveDevice( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE EnumerateMetaCommands( - _Inout_ UINT *pNumMetaCommands, - _Out_writes_opt_(*pNumMetaCommands) D3D12_META_COMMAND_DESC *pDescs) = 0; - - virtual HRESULT STDMETHODCALLTYPE EnumerateMetaCommandParameters( - _In_ REFGUID CommandId, - _In_ D3D12_META_COMMAND_PARAMETER_STAGE Stage, - _Out_opt_ UINT *pTotalStructureSizeInBytes, - _Inout_ UINT *pParameterCount, - _Out_writes_opt_(*pParameterCount) D3D12_META_COMMAND_PARAMETER_DESC *pParameterDescs) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateMetaCommand( - _In_ REFGUID CommandId, + UINT64 AABBCount; + D3D12_GPU_VIRTUAL_ADDRESS_AND_STRIDE AABBs; + } D3D12_RAYTRACING_GEOMETRY_AABBS_DESC; + +typedef +enum D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS + { + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_NONE = 0, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_ALLOW_UPDATE = 0x1, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_ALLOW_COMPACTION = 0x2, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PREFER_FAST_TRACE = 0x4, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PREFER_FAST_BUILD = 0x8, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_MINIMIZE_MEMORY = 0x10, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PERFORM_UPDATE = 0x20 + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS ); +typedef +enum D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE + { + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE_CLONE = 0, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE_COMPACT = 0x1, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE_VISUALIZATION_DECODE_FOR_TOOLS = 0x2, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE_SERIALIZE = 0x3, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE_DESERIALIZE = 0x4 + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE; + +typedef +enum D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE + { + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL = 0, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL = 0x1 + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE; + +typedef +enum D3D12_ELEMENTS_LAYOUT + { + D3D12_ELEMENTS_LAYOUT_ARRAY = 0, + D3D12_ELEMENTS_LAYOUT_ARRAY_OF_POINTERS = 0x1 + } D3D12_ELEMENTS_LAYOUT; + +typedef +enum D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_TYPE + { + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_COMPACTED_SIZE = 0, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_TOOLS_VISUALIZATION = 0x1, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_SERIALIZATION = 0x2, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_CURRENT_SIZE = 0x3 + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_TYPE; + +typedef struct D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC + { + D3D12_GPU_VIRTUAL_ADDRESS DestBuffer; + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_TYPE InfoType; + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC; + +typedef struct D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_COMPACTED_SIZE_DESC + { + UINT64 CompactedSizeInBytes; + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_COMPACTED_SIZE_DESC; + +typedef struct D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_TOOLS_VISUALIZATION_DESC + { + UINT64 DecodedSizeInBytes; + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_TOOLS_VISUALIZATION_DESC; + +typedef struct D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_TOOLS_VISUALIZATION_HEADER + { + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE Type; + UINT NumDescs; + } D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_TOOLS_VISUALIZATION_HEADER; + +// Regarding D3D12_BUILD_RAY_TRACING_ACCELERATION_STRUCTURE_TOOLS_VISUALIZATION_HEADER above, +// depending on Type field, NumDescs above is followed by either: +// D3D12_RAY_TRACING_INSTANCE_DESC InstanceDescs[NumDescs] +// or D3D12_RAY_TRACING_GEOMETRY_DESC GeometryDescs[NumDescs]. +// There is 4 bytes of padding between GeometryDesc structs in the array so alignment is natural when viewed by CPU. + +typedef struct D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_SERIALIZATION_DESC + { + UINT64 SerializedSizeInBytes; + UINT64 NumBottomLevelAccelerationStructurePointers; + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_SERIALIZATION_DESC; + +typedef struct D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER + { + GUID DriverOpaqueGUID; + BYTE DriverOpaqueVersioningData[ 16 ]; + } D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER; + +typedef +enum D3D12_SERIALIZED_DATA_TYPE + { + D3D12_SERIALIZED_DATA_RAYTRACING_ACCELERATION_STRUCTURE = 0 + } D3D12_SERIALIZED_DATA_TYPE; + +typedef +enum D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS + { + D3D12_DRIVER_MATCHING_IDENTIFIER_COMPATIBLE_WITH_DEVICE = 0, + D3D12_DRIVER_MATCHING_IDENTIFIER_UNSUPPORTED_TYPE = 0x1, + D3D12_DRIVER_MATCHING_IDENTIFIER_UNRECOGNIZED = 0x2, + D3D12_DRIVER_MATCHING_IDENTIFIER_INCOMPATIBLE_VERSION = 0x3, + D3D12_DRIVER_MATCHING_IDENTIFIER_INCOMPATIBLE_TYPE = 0x4 + } D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS; + +typedef struct D3D12_SERIALIZED_RAYTRACING_ACCELERATION_STRUCTURE_HEADER + { + D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER DriverMatchingIdentifier; + UINT64 SerializedSizeInBytesIncludingHeader; + UINT64 DeserializedSizeInBytes; + UINT64 NumBottomLevelAccelerationStructurePointersAfterHeader; + } D3D12_SERIALIZED_RAYTRACING_ACCELERATION_STRUCTURE_HEADER; + +typedef struct D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_CURRENT_SIZE_DESC + { + UINT64 CurrentSizeInBytes; + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_CURRENT_SIZE_DESC; + +typedef struct D3D12_RAYTRACING_INSTANCE_DESC + { + FLOAT Transform[ 3 ][ 4 ]; + UINT InstanceID : 24; + UINT InstanceMask : 8; + UINT InstanceContributionToHitGroupIndex : 24; + UINT Flags : 8; + D3D12_GPU_VIRTUAL_ADDRESS AccelerationStructure; + } D3D12_RAYTRACING_INSTANCE_DESC; + +typedef struct D3D12_RAYTRACING_GEOMETRY_DESC + { + D3D12_RAYTRACING_GEOMETRY_TYPE Type; + D3D12_RAYTRACING_GEOMETRY_FLAGS Flags; + union + { + D3D12_RAYTRACING_GEOMETRY_TRIANGLES_DESC Triangles; + D3D12_RAYTRACING_GEOMETRY_AABBS_DESC AABBs; + } ; + } D3D12_RAYTRACING_GEOMETRY_DESC; + +typedef struct D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS + { + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE Type; + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS Flags; + UINT NumDescs; + D3D12_ELEMENTS_LAYOUT DescsLayout; + union + { + D3D12_GPU_VIRTUAL_ADDRESS InstanceDescs; + const D3D12_RAYTRACING_GEOMETRY_DESC *pGeometryDescs; + const D3D12_RAYTRACING_GEOMETRY_DESC *const *ppGeometryDescs; + } ; + } D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS; + +typedef struct D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC + { + D3D12_GPU_VIRTUAL_ADDRESS DestAccelerationStructureData; + D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS Inputs; + _In_opt_ D3D12_GPU_VIRTUAL_ADDRESS SourceAccelerationStructureData; + D3D12_GPU_VIRTUAL_ADDRESS ScratchAccelerationStructureData; + } D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC; + +typedef struct D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO + { + UINT64 ResultDataMaxSizeInBytes; + UINT64 ScratchDataSizeInBytes; + UINT64 UpdateScratchDataSizeInBytes; + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO; + +typedef +enum D3D12_RAY_FLAGS + { + D3D12_RAY_FLAG_NONE = 0, + D3D12_RAY_FLAG_FORCE_OPAQUE = 0x1, + D3D12_RAY_FLAG_FORCE_NON_OPAQUE = 0x2, + D3D12_RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH = 0x4, + D3D12_RAY_FLAG_SKIP_CLOSEST_HIT_SHADER = 0x8, + D3D12_RAY_FLAG_CULL_BACK_FACING_TRIANGLES = 0x10, + D3D12_RAY_FLAG_CULL_FRONT_FACING_TRIANGLES = 0x20, + D3D12_RAY_FLAG_CULL_OPAQUE = 0x40, + D3D12_RAY_FLAG_CULL_NON_OPAQUE = 0x80, + D3D12_RAY_FLAG_SKIP_TRIANGLES = 0x100, + D3D12_RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES = 0x200 + } D3D12_RAY_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_RAY_FLAGS ); +typedef +enum D3D12_HIT_KIND + { + D3D12_HIT_KIND_TRIANGLE_FRONT_FACE = 0xfe, + D3D12_HIT_KIND_TRIANGLE_BACK_FACE = 0xff + } D3D12_HIT_KIND; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0036_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0036_v0_0_s_ifspec; + +#ifndef __ID3D12Device5_INTERFACE_DEFINED__ +#define __ID3D12Device5_INTERFACE_DEFINED__ + +/* interface ID3D12Device5 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Device5; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("8b4f173b-2fea-4b80-8f58-4307191ab95d") + ID3D12Device5 : public ID3D12Device4 + { + public: + virtual HRESULT STDMETHODCALLTYPE CreateLifetimeTracker( + _In_ ID3D12LifetimeOwner *pOwner, + REFIID riid, + _COM_Outptr_ void **ppvTracker) = 0; + + virtual void STDMETHODCALLTYPE RemoveDevice( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE EnumerateMetaCommands( + _Inout_ UINT *pNumMetaCommands, + _Out_writes_opt_(*pNumMetaCommands) D3D12_META_COMMAND_DESC *pDescs) = 0; + + virtual HRESULT STDMETHODCALLTYPE EnumerateMetaCommandParameters( + _In_ REFGUID CommandId, + _In_ D3D12_META_COMMAND_PARAMETER_STAGE Stage, + _Out_opt_ UINT *pTotalStructureSizeInBytes, + _Inout_ UINT *pParameterCount, + _Out_writes_opt_(*pParameterCount) D3D12_META_COMMAND_PARAMETER_DESC *pParameterDescs) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateMetaCommand( + _In_ REFGUID CommandId, _In_ UINT NodeMask, _In_reads_bytes_opt_(CreationParametersDataSizeInBytes) const void *pCreationParametersData, _In_ SIZE_T CreationParametersDataSizeInBytes, @@ -14900,7 +15580,7 @@ EXTERN_C const IID IID_ID3D12Device5; #endif /* __ID3D12Device5_INTERFACE_DEFINED__ */ -/* interface __MIDL_itf_d3d12_0000_0035 */ +/* interface __MIDL_itf_d3d12_0000_0037 */ /* [local] */ typedef @@ -14952,7 +15632,9 @@ enum D3D12_AUTO_BREADCRUMB_OP D3D12_AUTO_BREADCRUMB_OP_ENCODEFRAME = 43, D3D12_AUTO_BREADCRUMB_OP_RESOLVEENCODEROUTPUTMETADATA = 44, D3D12_AUTO_BREADCRUMB_OP_BARRIER = 45, - D3D12_AUTO_BREADCRUMB_OP_BEGIN_COMMAND_LIST = 46 + D3D12_AUTO_BREADCRUMB_OP_BEGIN_COMMAND_LIST = 46, + D3D12_AUTO_BREADCRUMB_OP_DISPATCHGRAPH = 47, + D3D12_AUTO_BREADCRUMB_OP_SETPROGRAM = 48 } D3D12_AUTO_BREADCRUMB_OP; typedef struct D3D12_AUTO_BREADCRUMB_NODE @@ -15158,8 +15840,8 @@ typedef struct D3D12_VERSIONED_DEVICE_REMOVED_EXTENDED_DATA -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0035_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0035_v0_0_s_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0037_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0037_v0_0_s_ifspec; #ifndef __ID3D12DeviceRemovedExtendedDataSettings_INTERFACE_DEFINED__ #define __ID3D12DeviceRemovedExtendedDataSettings_INTERFACE_DEFINED__ @@ -15822,7 +16504,7 @@ EXTERN_C const IID IID_ID3D12DeviceRemovedExtendedData2; #endif /* __ID3D12DeviceRemovedExtendedData2_INTERFACE_DEFINED__ */ -/* interface __MIDL_itf_d3d12_0000_0041 */ +/* interface __MIDL_itf_d3d12_0000_0043 */ /* [local] */ typedef @@ -15845,8 +16527,8 @@ enum D3D12_MEASUREMENTS_ACTION -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0041_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0041_v0_0_s_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0043_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0043_v0_0_s_ifspec; #ifndef __ID3D12Device6_INTERFACE_DEFINED__ #define __ID3D12Device6_INTERFACE_DEFINED__ @@ -16655,7 +17337,7 @@ EXTERN_C const IID IID_ID3D12Device6; #endif /* __ID3D12Device6_INTERFACE_DEFINED__ */ -/* interface __MIDL_itf_d3d12_0000_0042 */ +/* interface __MIDL_itf_d3d12_0000_0044 */ /* [local] */ DEFINE_GUID(D3D12_PROTECTED_RESOURCES_SESSION_HARDWARE_PROTECTED, 0x62B0084E, 0xC70E, 0x4DAA, 0xA1, 0x09, 0x30, 0xFF, 0x8D, 0x5A, 0x04, 0x82); @@ -16681,8 +17363,8 @@ typedef struct D3D12_PROTECTED_RESOURCE_SESSION_DESC1 -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0042_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0042_v0_0_s_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0044_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0044_v0_0_s_ifspec; #ifndef __ID3D12ProtectedResourceSession1_INTERFACE_DEFINED__ #define __ID3D12ProtectedResourceSession1_INTERFACE_DEFINED__ @@ -19991,7 +20673,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList3; #endif /* __ID3D12GraphicsCommandList3_INTERFACE_DEFINED__ */ -/* interface __MIDL_itf_d3d12_0000_0049 */ +/* interface __MIDL_itf_d3d12_0000_0051 */ /* [local] */ typedef @@ -20105,8 +20787,8 @@ enum D3D12_RENDER_PASS_FLAGS DEFINE_ENUM_FLAG_OPERATORS( D3D12_RENDER_PASS_FLAGS ); -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0049_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0049_v0_0_s_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0051_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0051_v0_0_s_ifspec; #ifndef __ID3D12MetaCommand_INTERFACE_DEFINED__ #define __ID3D12MetaCommand_INTERFACE_DEFINED__ @@ -20242,7 +20924,7 @@ EXTERN_C const IID IID_ID3D12MetaCommand; #endif /* __ID3D12MetaCommand_INTERFACE_DEFINED__ */ -/* interface __MIDL_itf_d3d12_0000_0050 */ +/* interface __MIDL_itf_d3d12_0000_0052 */ /* [local] */ typedef struct D3D12_DISPATCH_RAYS_DESC @@ -20256,19 +20938,113 @@ typedef struct D3D12_DISPATCH_RAYS_DESC UINT Depth; } D3D12_DISPATCH_RAYS_DESC; +typedef +enum D3D12_SET_WORK_GRAPH_FLAGS + { + D3D12_SET_WORK_GRAPH_FLAG_NONE = 0, + D3D12_SET_WORK_GRAPH_FLAG_INITIALIZE = 0x1 + } D3D12_SET_WORK_GRAPH_FLAGS; +DEFINE_ENUM_FLAG_OPERATORS( D3D12_SET_WORK_GRAPH_FLAGS ); +typedef struct D3D12_SET_WORK_GRAPH_DESC + { + D3D12_PROGRAM_IDENTIFIER ProgramIdentifier; + D3D12_SET_WORK_GRAPH_FLAGS Flags; + D3D12_GPU_VIRTUAL_ADDRESS_RANGE BackingMemory; + D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE NodeLocalRootArgumentsTable; + } D3D12_SET_WORK_GRAPH_DESC; -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0050_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0050_v0_0_s_ifspec; +typedef struct D3D12_SET_RAYTRACING_PIPELINE_DESC + { + D3D12_PROGRAM_IDENTIFIER ProgramIdentifier; + } D3D12_SET_RAYTRACING_PIPELINE_DESC; -#ifndef __ID3D12GraphicsCommandList4_INTERFACE_DEFINED__ -#define __ID3D12GraphicsCommandList4_INTERFACE_DEFINED__ +typedef struct D3D12_SET_GENERIC_PIPELINE_DESC + { + D3D12_PROGRAM_IDENTIFIER ProgramIdentifier; + } D3D12_SET_GENERIC_PIPELINE_DESC; -/* interface ID3D12GraphicsCommandList4 */ -/* [unique][local][object][uuid] */ +typedef +enum D3D12_PROGRAM_TYPE + { + D3D12_PROGRAM_TYPE_GENERIC_PIPELINE = 1, + D3D12_PROGRAM_TYPE_RAYTRACING_PIPELINE = 4, + D3D12_PROGRAM_TYPE_WORK_GRAPH = 5 + } D3D12_PROGRAM_TYPE; +typedef struct D3D12_SET_PROGRAM_DESC + { + D3D12_PROGRAM_TYPE Type; + union + { + D3D12_SET_GENERIC_PIPELINE_DESC GenericPipeline; + D3D12_SET_RAYTRACING_PIPELINE_DESC RaytracingPipeline; + D3D12_SET_WORK_GRAPH_DESC WorkGraph; + } ; + } D3D12_SET_PROGRAM_DESC; -EXTERN_C const IID IID_ID3D12GraphicsCommandList4; +typedef +enum D3D12_DISPATCH_MODE + { + D3D12_DISPATCH_MODE_NODE_CPU_INPUT = 0, + D3D12_DISPATCH_MODE_NODE_GPU_INPUT = 1, + D3D12_DISPATCH_MODE_MULTI_NODE_CPU_INPUT = 2, + D3D12_DISPATCH_MODE_MULTI_NODE_GPU_INPUT = 3 + } D3D12_DISPATCH_MODE; + +typedef struct D3D12_NODE_CPU_INPUT + { + UINT EntrypointIndex; + UINT NumRecords; + void *pRecords; + UINT64 RecordStrideInBytes; + } D3D12_NODE_CPU_INPUT; + +typedef struct D3D12_NODE_GPU_INPUT + { + UINT EntrypointIndex; + UINT NumRecords; + D3D12_GPU_VIRTUAL_ADDRESS_AND_STRIDE Records; + } D3D12_NODE_GPU_INPUT; + +typedef struct D3D12_MULTI_NODE_CPU_INPUT + { + UINT NumNodeInputs; + D3D12_NODE_CPU_INPUT *pNodeInputs; + UINT64 NodeInputStrideInBytes; + } D3D12_MULTI_NODE_CPU_INPUT; + +typedef struct D3D12_MULTI_NODE_GPU_INPUT + { + UINT NumNodeInputs; + D3D12_GPU_VIRTUAL_ADDRESS_AND_STRIDE NodeInputs; + } D3D12_MULTI_NODE_GPU_INPUT; + +typedef struct D3D12_DISPATCH_GRAPH_DESC + { + D3D12_DISPATCH_MODE Mode; + union + { + D3D12_NODE_CPU_INPUT NodeCPUInput; + D3D12_GPU_VIRTUAL_ADDRESS NodeGPUInput; + D3D12_MULTI_NODE_CPU_INPUT MultiNodeCPUInput; + D3D12_GPU_VIRTUAL_ADDRESS MultiNodeGPUInput; + } ; + } D3D12_DISPATCH_GRAPH_DESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0052_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0052_v0_0_s_ifspec; + +#ifndef __ID3D12GraphicsCommandList4_INTERFACE_DEFINED__ +#define __ID3D12GraphicsCommandList4_INTERFACE_DEFINED__ + +/* interface ID3D12GraphicsCommandList4 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12GraphicsCommandList4; #if defined(__cplusplus) && !defined(CINTERFACE) @@ -21108,7 +21884,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList4; #endif /* __ID3D12GraphicsCommandList4_INTERFACE_DEFINED__ */ -/* interface __MIDL_itf_d3d12_0000_0051 */ +/* interface __MIDL_itf_d3d12_0000_0053 */ /* [local] */ typedef @@ -21310,8 +22086,8 @@ typedef struct D3D12_BARRIER_GROUP -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0051_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0051_v0_0_s_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0053_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0053_v0_0_s_ifspec; #ifndef __ID3D12ShaderCacheSession_INTERFACE_DEFINED__ #define __ID3D12ShaderCacheSession_INTERFACE_DEFINED__ @@ -21511,7 +22287,7 @@ EXTERN_C const IID IID_ID3D12ShaderCacheSession; #endif /* __ID3D12ShaderCacheSession_INTERFACE_DEFINED__ */ -/* interface __MIDL_itf_d3d12_0000_0052 */ +/* interface __MIDL_itf_d3d12_0000_0054 */ /* [local] */ typedef @@ -21535,8 +22311,8 @@ enum D3D12_SHADER_CACHE_CONTROL_FLAGS DEFINE_ENUM_FLAG_OPERATORS( D3D12_SHADER_CACHE_CONTROL_FLAGS ); -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0052_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0052_v0_0_s_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0054_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0054_v0_0_s_ifspec; #ifndef __ID3D12Device9_INTERFACE_DEFINED__ #define __ID3D12Device9_INTERFACE_DEFINED__ @@ -26604,220 +27380,1283 @@ EXTERN_C const IID IID_ID3D12Device13; #endif /* __ID3D12Device13_INTERFACE_DEFINED__ */ -#ifndef __ID3D12VirtualizationGuestDevice_INTERFACE_DEFINED__ -#define __ID3D12VirtualizationGuestDevice_INTERFACE_DEFINED__ +#ifndef __ID3D12Device14_INTERFACE_DEFINED__ +#define __ID3D12Device14_INTERFACE_DEFINED__ -/* interface ID3D12VirtualizationGuestDevice */ +/* interface ID3D12Device14 */ /* [unique][local][object][uuid] */ -EXTERN_C const IID IID_ID3D12VirtualizationGuestDevice; +EXTERN_C const IID IID_ID3D12Device14; #if defined(__cplusplus) && !defined(CINTERFACE) - MIDL_INTERFACE("bc66d368-7373-4943-8757-fc87dc79e476") - ID3D12VirtualizationGuestDevice : public IUnknown + MIDL_INTERFACE("5f6e592d-d895-44c2-8e4a-88ad4926d323") + ID3D12Device14 : public ID3D12Device13 { public: - virtual HRESULT STDMETHODCALLTYPE ShareWithHost( - _In_ ID3D12DeviceChild *pObject, - _Out_ HANDLE *pHandle) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateFenceFd( - _In_ ID3D12Fence *pFence, - UINT64 FenceValue, - _Out_ int *pFenceFd) = 0; + virtual HRESULT STDMETHODCALLTYPE CreateRootSignatureFromSubobjectInLibrary( + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pLibraryBlob, + _In_ SIZE_T blobLengthInBytes, + _In_opt_ LPCWSTR subobjectName, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature) = 0; }; #else /* C style interface */ - typedef struct ID3D12VirtualizationGuestDeviceVtbl + typedef struct ID3D12Device14Vtbl { BEGIN_INTERFACE DECLSPEC_XFGVIRT(IUnknown, QueryInterface) HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D12VirtualizationGuestDevice * This, + ID3D12Device14 * This, REFIID riid, _COM_Outptr_ void **ppvObject); DECLSPEC_XFGVIRT(IUnknown, AddRef) ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D12VirtualizationGuestDevice * This); + ID3D12Device14 * This); DECLSPEC_XFGVIRT(IUnknown, Release) ULONG ( STDMETHODCALLTYPE *Release )( - ID3D12VirtualizationGuestDevice * This); + ID3D12Device14 * This); - DECLSPEC_XFGVIRT(ID3D12VirtualizationGuestDevice, ShareWithHost) - HRESULT ( STDMETHODCALLTYPE *ShareWithHost )( - ID3D12VirtualizationGuestDevice * This, - _In_ ID3D12DeviceChild *pObject, - _Out_ HANDLE *pHandle); + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Device14 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); - DECLSPEC_XFGVIRT(ID3D12VirtualizationGuestDevice, CreateFenceFd) - HRESULT ( STDMETHODCALLTYPE *CreateFenceFd )( - ID3D12VirtualizationGuestDevice * This, - _In_ ID3D12Fence *pFence, - UINT64 FenceValue, - _Out_ int *pFenceFd); + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Device14 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); - END_INTERFACE - } ID3D12VirtualizationGuestDeviceVtbl; - - interface ID3D12VirtualizationGuestDevice - { - CONST_VTBL struct ID3D12VirtualizationGuestDeviceVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D12VirtualizationGuestDevice_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D12VirtualizationGuestDevice_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D12VirtualizationGuestDevice_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D12VirtualizationGuestDevice_ShareWithHost(This,pObject,pHandle) \ - ( (This)->lpVtbl -> ShareWithHost(This,pObject,pHandle) ) - -#define ID3D12VirtualizationGuestDevice_CreateFenceFd(This,pFence,FenceValue,pFenceFd) \ - ( (This)->lpVtbl -> CreateFenceFd(This,pFence,FenceValue,pFenceFd) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D12VirtualizationGuestDevice_INTERFACE_DEFINED__ */ - - -#ifndef __ID3D12Tools_INTERFACE_DEFINED__ -#define __ID3D12Tools_INTERFACE_DEFINED__ - -/* interface ID3D12Tools */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D12Tools; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("7071e1f0-e84b-4b33-974f-12fa49de65c5") - ID3D12Tools : public IUnknown - { - public: - virtual void STDMETHODCALLTYPE EnableShaderInstrumentation( - BOOL bEnable) = 0; + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Device14 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); - virtual BOOL STDMETHODCALLTYPE ShaderInstrumentationEnabled( void) = 0; + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Device14 * This, + _In_z_ LPCWSTR Name); - }; - - -#else /* C style interface */ - - typedef struct ID3D12ToolsVtbl - { - BEGIN_INTERFACE + DECLSPEC_XFGVIRT(ID3D12Device, GetNodeCount) + UINT ( STDMETHODCALLTYPE *GetNodeCount )( + ID3D12Device14 * This); - DECLSPEC_XFGVIRT(IUnknown, QueryInterface) - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D12Tools * This, + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandQueue) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue )( + ID3D12Device14 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, REFIID riid, - _COM_Outptr_ void **ppvObject); + _COM_Outptr_ void **ppCommandQueue); - DECLSPEC_XFGVIRT(IUnknown, AddRef) - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D12Tools * This); + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandAllocator) + HRESULT ( STDMETHODCALLTYPE *CreateCommandAllocator )( + ID3D12Device14 * This, + _In_ D3D12_COMMAND_LIST_TYPE type, + REFIID riid, + _COM_Outptr_ void **ppCommandAllocator); - DECLSPEC_XFGVIRT(IUnknown, Release) - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D12Tools * This); + DECLSPEC_XFGVIRT(ID3D12Device, CreateGraphicsPipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateGraphicsPipelineState )( + ID3D12Device14 * This, + _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); - DECLSPEC_XFGVIRT(ID3D12Tools, EnableShaderInstrumentation) - void ( STDMETHODCALLTYPE *EnableShaderInstrumentation )( - ID3D12Tools * This, - BOOL bEnable); + DECLSPEC_XFGVIRT(ID3D12Device, CreateComputePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateComputePipelineState )( + ID3D12Device14 * This, + _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); - DECLSPEC_XFGVIRT(ID3D12Tools, ShaderInstrumentationEnabled) - BOOL ( STDMETHODCALLTYPE *ShaderInstrumentationEnabled )( - ID3D12Tools * This); + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandList) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList )( + ID3D12Device14 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ ID3D12CommandAllocator *pCommandAllocator, + _In_opt_ ID3D12PipelineState *pInitialState, + REFIID riid, + _COM_Outptr_ void **ppCommandList); - END_INTERFACE - } ID3D12ToolsVtbl; - - interface ID3D12Tools - { - CONST_VTBL struct ID3D12ToolsVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D12Tools_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D12Tools_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D12Tools_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D12Tools_EnableShaderInstrumentation(This,bEnable) \ - ( (This)->lpVtbl -> EnableShaderInstrumentation(This,bEnable) ) - -#define ID3D12Tools_ShaderInstrumentationEnabled(This) \ - ( (This)->lpVtbl -> ShaderInstrumentationEnabled(This) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D12Tools_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d12_0000_0059 */ -/* [local] */ - -typedef struct D3D12_SUBRESOURCE_DATA - { - const void *pData; - LONG_PTR RowPitch; - LONG_PTR SlicePitch; - } D3D12_SUBRESOURCE_DATA; - -typedef struct D3D12_MEMCPY_DEST - { - void *pData; - SIZE_T RowPitch; - SIZE_T SlicePitch; - } D3D12_MEMCPY_DEST; - -#if !defined( D3D12_IGNORE_SDK_LAYERS ) -#include "d3d12sdklayers.h" -#endif - -/////////////////////////////////////////////////////////////////////////// + DECLSPEC_XFGVIRT(ID3D12Device, CheckFeatureSupport) + HRESULT ( STDMETHODCALLTYPE *CheckFeatureSupport )( + ID3D12Device14 * This, + D3D12_FEATURE Feature, + _Inout_updates_bytes_(FeatureSupportDataSize) void *pFeatureSupportData, + UINT FeatureSupportDataSize); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDescriptorHeap) + HRESULT ( STDMETHODCALLTYPE *CreateDescriptorHeap )( + ID3D12Device14 * This, + _In_ const D3D12_DESCRIPTOR_HEAP_DESC *pDescriptorHeapDesc, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDescriptorHandleIncrementSize) + UINT ( STDMETHODCALLTYPE *GetDescriptorHandleIncrementSize )( + ID3D12Device14 * This, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRootSignature) + HRESULT ( STDMETHODCALLTYPE *CreateRootSignature )( + ID3D12Device14 * This, + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pBlobWithRootSignature, + _In_ SIZE_T blobLengthInBytes, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateConstantBufferView) + void ( STDMETHODCALLTYPE *CreateConstantBufferView )( + ID3D12Device14 * This, + _In_opt_ const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateShaderResourceView) + void ( STDMETHODCALLTYPE *CreateShaderResourceView )( + ID3D12Device14 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateUnorderedAccessView )( + ID3D12Device14 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ ID3D12Resource *pCounterResource, + _In_opt_ const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRenderTargetView) + void ( STDMETHODCALLTYPE *CreateRenderTargetView )( + ID3D12Device14 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDepthStencilView) + void ( STDMETHODCALLTYPE *CreateDepthStencilView )( + ID3D12Device14 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSampler) + void ( STDMETHODCALLTYPE *CreateSampler )( + ID3D12Device14 * This, + _In_ const D3D12_SAMPLER_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptors) + void ( STDMETHODCALLTYPE *CopyDescriptors )( + ID3D12Device14 * This, + _In_ UINT NumDestDescriptorRanges, + _In_reads_(NumDestDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pDestDescriptorRangeStarts, + _In_reads_opt_(NumDestDescriptorRanges) const UINT *pDestDescriptorRangeSizes, + _In_ UINT NumSrcDescriptorRanges, + _In_reads_(NumSrcDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pSrcDescriptorRangeStarts, + _In_reads_opt_(NumSrcDescriptorRanges) const UINT *pSrcDescriptorRangeSizes, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptorsSimple) + void ( STDMETHODCALLTYPE *CopyDescriptorsSimple )( + ID3D12Device14 * This, + _In_ UINT NumDescriptors, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptorRangeStart, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE SrcDescriptorRangeStart, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceAllocationInfo) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device14 * This, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device14 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, GetCustomHeapProperties) +#if !defined(_WIN32) + D3D12_HEAP_PROPERTIES ( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device14 * This, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#else + D3D12_HEAP_PROPERTIES *( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device14 * This, + D3D12_HEAP_PROPERTIES * RetVal, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommittedResource) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource )( + ID3D12Device14 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateHeap) + HRESULT ( STDMETHODCALLTYPE *CreateHeap )( + ID3D12Device14 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, CreatePlacedResource) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource )( + ID3D12Device14 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateReservedResource) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource )( + ID3D12Device14 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSharedHandle) + HRESULT ( STDMETHODCALLTYPE *CreateSharedHandle )( + ID3D12Device14 * This, + _In_ ID3D12DeviceChild *pObject, + _In_opt_ const SECURITY_ATTRIBUTES *pAttributes, + DWORD Access, + _In_opt_ LPCWSTR Name, + _Out_ HANDLE *pHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandle) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandle )( + ID3D12Device14 * This, + _In_ HANDLE NTHandle, + REFIID riid, + _COM_Outptr_opt_ void **ppvObj); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandleByName) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandleByName )( + ID3D12Device14 * This, + _In_ LPCWSTR Name, + DWORD Access, + /* [annotation][out] */ + _Out_ HANDLE *pNTHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, MakeResident) + HRESULT ( STDMETHODCALLTYPE *MakeResident )( + ID3D12Device14 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, Evict) + HRESULT ( STDMETHODCALLTYPE *Evict )( + ID3D12Device14 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateFence) + HRESULT ( STDMETHODCALLTYPE *CreateFence )( + ID3D12Device14 * This, + UINT64 InitialValue, + D3D12_FENCE_FLAGS Flags, + REFIID riid, + _COM_Outptr_ void **ppFence); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDeviceRemovedReason) + HRESULT ( STDMETHODCALLTYPE *GetDeviceRemovedReason )( + ID3D12Device14 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, GetCopyableFootprints) + void ( STDMETHODCALLTYPE *GetCopyableFootprints )( + ID3D12Device14 * This, + _In_ const D3D12_RESOURCE_DESC *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateQueryHeap) + HRESULT ( STDMETHODCALLTYPE *CreateQueryHeap )( + ID3D12Device14 * This, + _In_ const D3D12_QUERY_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, SetStablePowerState) + HRESULT ( STDMETHODCALLTYPE *SetStablePowerState )( + ID3D12Device14 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandSignature) + HRESULT ( STDMETHODCALLTYPE *CreateCommandSignature )( + ID3D12Device14 * This, + _In_ const D3D12_COMMAND_SIGNATURE_DESC *pDesc, + _In_opt_ ID3D12RootSignature *pRootSignature, + REFIID riid, + _COM_Outptr_opt_ void **ppvCommandSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceTiling) + void ( STDMETHODCALLTYPE *GetResourceTiling )( + ID3D12Device14 * This, + _In_ ID3D12Resource *pTiledResource, + _Out_opt_ UINT *pNumTilesForEntireResource, + _Out_opt_ D3D12_PACKED_MIP_INFO *pPackedMipDesc, + _Out_opt_ D3D12_TILE_SHAPE *pStandardTileShapeForNonPackedMips, + _Inout_opt_ UINT *pNumSubresourceTilings, + _In_ UINT FirstSubresourceTilingToGet, + _Out_writes_(*pNumSubresourceTilings) D3D12_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips); + + DECLSPEC_XFGVIRT(ID3D12Device, GetAdapterLuid) +#if !defined(_WIN32) + LUID ( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device14 * This); + +#else + LUID *( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device14 * This, + LUID * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device1, CreatePipelineLibrary) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineLibrary )( + ID3D12Device14 * This, + _In_reads_(BlobLength) const void *pLibraryBlob, + SIZE_T BlobLength, + REFIID riid, + _COM_Outptr_ void **ppPipelineLibrary); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetEventOnMultipleFenceCompletion) + HRESULT ( STDMETHODCALLTYPE *SetEventOnMultipleFenceCompletion )( + ID3D12Device14 * This, + _In_reads_(NumFences) ID3D12Fence *const *ppFences, + _In_reads_(NumFences) const UINT64 *pFenceValues, + UINT NumFences, + D3D12_MULTIPLE_FENCE_WAIT_FLAGS Flags, + HANDLE hEvent); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetResidencyPriority) + HRESULT ( STDMETHODCALLTYPE *SetResidencyPriority )( + ID3D12Device14 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_reads_(NumObjects) const D3D12_RESIDENCY_PRIORITY *pPriorities); + + DECLSPEC_XFGVIRT(ID3D12Device2, CreatePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineState )( + ID3D12Device14 * This, + const D3D12_PIPELINE_STATE_STREAM_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromAddress) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromAddress )( + ID3D12Device14 * This, + _In_ const void *pAddress, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromFileMapping) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromFileMapping )( + ID3D12Device14 * This, + _In_ HANDLE hFileMapping, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, EnqueueMakeResident) + HRESULT ( STDMETHODCALLTYPE *EnqueueMakeResident )( + ID3D12Device14 * This, + D3D12_RESIDENCY_FLAGS Flags, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_ ID3D12Fence *pFenceToSignal, + UINT64 FenceValueToSignal); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommandList1) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList1 )( + ID3D12Device14 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ D3D12_COMMAND_LIST_FLAGS flags, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateProtectedResourceSession) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession )( + ID3D12Device14 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommittedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource1 )( + ID3D12Device14 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateHeap1) + HRESULT ( STDMETHODCALLTYPE *CreateHeap1 )( + ID3D12Device14 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateReservedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource1 )( + ID3D12Device14 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, GetResourceAllocationInfo1) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device14 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device14 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateLifetimeTracker) + HRESULT ( STDMETHODCALLTYPE *CreateLifetimeTracker )( + ID3D12Device14 * This, + _In_ ID3D12LifetimeOwner *pOwner, + REFIID riid, + _COM_Outptr_ void **ppvTracker); + + DECLSPEC_XFGVIRT(ID3D12Device5, RemoveDevice) + void ( STDMETHODCALLTYPE *RemoveDevice )( + ID3D12Device14 * This); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommands) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommands )( + ID3D12Device14 * This, + _Inout_ UINT *pNumMetaCommands, + _Out_writes_opt_(*pNumMetaCommands) D3D12_META_COMMAND_DESC *pDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommandParameters) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommandParameters )( + ID3D12Device14 * This, + _In_ REFGUID CommandId, + _In_ D3D12_META_COMMAND_PARAMETER_STAGE Stage, + _Out_opt_ UINT *pTotalStructureSizeInBytes, + _Inout_ UINT *pParameterCount, + _Out_writes_opt_(*pParameterCount) D3D12_META_COMMAND_PARAMETER_DESC *pParameterDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateMetaCommand) + HRESULT ( STDMETHODCALLTYPE *CreateMetaCommand )( + ID3D12Device14 * This, + _In_ REFGUID CommandId, + _In_ UINT NodeMask, + _In_reads_bytes_opt_(CreationParametersDataSizeInBytes) const void *pCreationParametersData, + _In_ SIZE_T CreationParametersDataSizeInBytes, + REFIID riid, + _COM_Outptr_ void **ppMetaCommand); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateStateObject) + HRESULT ( STDMETHODCALLTYPE *CreateStateObject )( + ID3D12Device14 * This, + const D3D12_STATE_OBJECT_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppStateObject); + + DECLSPEC_XFGVIRT(ID3D12Device5, GetRaytracingAccelerationStructurePrebuildInfo) + void ( STDMETHODCALLTYPE *GetRaytracingAccelerationStructurePrebuildInfo )( + ID3D12Device14 * This, + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS *pDesc, + _Out_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO *pInfo); + + DECLSPEC_XFGVIRT(ID3D12Device5, CheckDriverMatchingIdentifier) + D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS ( STDMETHODCALLTYPE *CheckDriverMatchingIdentifier )( + ID3D12Device14 * This, + _In_ D3D12_SERIALIZED_DATA_TYPE SerializedDataType, + _In_ const D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER *pIdentifierToCheck); + + DECLSPEC_XFGVIRT(ID3D12Device6, SetBackgroundProcessingMode) + HRESULT ( STDMETHODCALLTYPE *SetBackgroundProcessingMode )( + ID3D12Device14 * This, + D3D12_BACKGROUND_PROCESSING_MODE Mode, + D3D12_MEASUREMENTS_ACTION MeasurementsAction, + _In_opt_ HANDLE hEventToSignalUponCompletion, + _Out_opt_ BOOL *pbFurtherMeasurementsDesired); + + DECLSPEC_XFGVIRT(ID3D12Device7, AddToStateObject) + HRESULT ( STDMETHODCALLTYPE *AddToStateObject )( + ID3D12Device14 * This, + const D3D12_STATE_OBJECT_DESC *pAddition, + ID3D12StateObject *pStateObjectToGrowFrom, + REFIID riid, + _COM_Outptr_ void **ppNewStateObject); + + DECLSPEC_XFGVIRT(ID3D12Device7, CreateProtectedResourceSession1) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession1 )( + ID3D12Device14 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC1 *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + DECLSPEC_XFGVIRT(ID3D12Device8, GetResourceAllocationInfo2) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo2 )( + ID3D12Device14 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo2 )( + ID3D12Device14 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device8, CreateCommittedResource2) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource2 )( + ID3D12Device14 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device8, CreatePlacedResource1) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource1 )( + ID3D12Device14 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device8, CreateSamplerFeedbackUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateSamplerFeedbackUnorderedAccessView )( + ID3D12Device14 * This, + _In_opt_ ID3D12Resource *pTargetedResource, + _In_opt_ ID3D12Resource *pFeedbackResource, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device8, GetCopyableFootprints1) + void ( STDMETHODCALLTYPE *GetCopyableFootprints1 )( + ID3D12Device14 * This, + _In_ const D3D12_RESOURCE_DESC1 *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device9, CreateShaderCacheSession) + HRESULT ( STDMETHODCALLTYPE *CreateShaderCacheSession )( + ID3D12Device14 * This, + _In_ const D3D12_SHADER_CACHE_SESSION_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvSession); + + DECLSPEC_XFGVIRT(ID3D12Device9, ShaderCacheControl) + HRESULT ( STDMETHODCALLTYPE *ShaderCacheControl )( + ID3D12Device14 * This, + D3D12_SHADER_CACHE_KIND_FLAGS Kinds, + D3D12_SHADER_CACHE_CONTROL_FLAGS Control); + + DECLSPEC_XFGVIRT(ID3D12Device9, CreateCommandQueue1) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue1 )( + ID3D12Device14 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID CreatorID, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device10, CreateCommittedResource3) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource3 )( + ID3D12Device14 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device10, CreatePlacedResource2) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource2 )( + ID3D12Device14 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device10, CreateReservedResource2) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource2 )( + ID3D12Device14 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device11, CreateSampler2) + void ( STDMETHODCALLTYPE *CreateSampler2 )( + ID3D12Device14 * This, + _In_ const D3D12_SAMPLER_DESC2 *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device12, GetResourceAllocationInfo3) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo3 )( + ID3D12Device14 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _In_opt_count_(numResourceDescs) const UINT32 *pNumCastableFormats, + _In_opt_count_(numResourceDescs) const DXGI_FORMAT *const *ppCastableFormats, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo3 )( + ID3D12Device14 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _In_opt_count_(numResourceDescs) const UINT32 *pNumCastableFormats, + _In_opt_count_(numResourceDescs) const DXGI_FORMAT *const *ppCastableFormats, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device13, OpenExistingHeapFromAddress1) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromAddress1 )( + ID3D12Device14 * This, + _In_ const void *pAddress, + SIZE_T size, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device14, CreateRootSignatureFromSubobjectInLibrary) + HRESULT ( STDMETHODCALLTYPE *CreateRootSignatureFromSubobjectInLibrary )( + ID3D12Device14 * This, + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pLibraryBlob, + _In_ SIZE_T blobLengthInBytes, + _In_opt_ LPCWSTR subobjectName, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature); + + END_INTERFACE + } ID3D12Device14Vtbl; + + interface ID3D12Device14 + { + CONST_VTBL struct ID3D12Device14Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Device14_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Device14_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Device14_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Device14_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Device14_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Device14_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Device14_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Device14_GetNodeCount(This) \ + ( (This)->lpVtbl -> GetNodeCount(This) ) + +#define ID3D12Device14_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue(This,pDesc,riid,ppCommandQueue) ) + +#define ID3D12Device14_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->lpVtbl -> CreateCommandAllocator(This,type,riid,ppCommandAllocator) ) + +#define ID3D12Device14_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device14_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateComputePipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device14_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) + +#define ID3D12Device14_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->lpVtbl -> CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) ) + +#define ID3D12Device14_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) ) + +#define ID3D12Device14_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->lpVtbl -> GetDescriptorHandleIncrementSize(This,DescriptorHeapType) ) + +#define ID3D12Device14_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->lpVtbl -> CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) + +#define ID3D12Device14_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateConstantBufferView(This,pDesc,DestDescriptor) ) + +#define ID3D12Device14_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device14_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) ) + +#define ID3D12Device14_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device14_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device14_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler(This,pDesc,DestDescriptor) ) + +#define ID3D12Device14_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) + +#define ID3D12Device14_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#if !defined(_WIN32) + +#define ID3D12Device14_GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) ) +#else +#define ID3D12Device14_GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) ) +#endif +#if !defined(_WIN32) + +#define ID3D12Device14_GetCustomHeapProperties(This,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,nodeMask,heapType) ) +#else +#define ID3D12Device14_GetCustomHeapProperties(This,RetVal,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,RetVal,nodeMask,heapType) ) +#endif + +#define ID3D12Device14_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) + +#define ID3D12Device14_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device14_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device14_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device14_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->lpVtbl -> CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) ) + +#define ID3D12Device14_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->lpVtbl -> OpenSharedHandle(This,NTHandle,riid,ppvObj) ) + +#define ID3D12Device14_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->lpVtbl -> OpenSharedHandleByName(This,Name,Access,pNTHandle) ) + +#define ID3D12Device14_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> MakeResident(This,NumObjects,ppObjects) ) + +#define ID3D12Device14_Evict(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> Evict(This,NumObjects,ppObjects) ) + +#define ID3D12Device14_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->lpVtbl -> CreateFence(This,InitialValue,Flags,riid,ppFence) ) + +#define ID3D12Device14_GetDeviceRemovedReason(This) \ + ( (This)->lpVtbl -> GetDeviceRemovedReason(This) ) + +#define ID3D12Device14_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + +#define ID3D12Device14_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateQueryHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device14_SetStablePowerState(This,Enable) \ + ( (This)->lpVtbl -> SetStablePowerState(This,Enable) ) + +#define ID3D12Device14_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->lpVtbl -> CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) ) + +#define ID3D12Device14_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->lpVtbl -> GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#if !defined(_WIN32) + +#define ID3D12Device14_GetAdapterLuid(This) \ + ( (This)->lpVtbl -> GetAdapterLuid(This) ) +#else +#define ID3D12Device14_GetAdapterLuid(This,RetVal) \ + ( (This)->lpVtbl -> GetAdapterLuid(This,RetVal) ) +#endif + + +#define ID3D12Device14_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->lpVtbl -> CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) + +#define ID3D12Device14_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->lpVtbl -> SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) ) + +#define ID3D12Device14_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->lpVtbl -> SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) ) + + +#define ID3D12Device14_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreatePipelineState(This,pDesc,riid,ppPipelineState) ) + + +#define ID3D12Device14_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) ) + +#define ID3D12Device14_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) ) + +#define ID3D12Device14_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->lpVtbl -> EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) + + +#define ID3D12Device14_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) ) + +#define ID3D12Device14_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession(This,pDesc,riid,ppSession) ) + +#define ID3D12Device14_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) + +#define ID3D12Device14_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) ) + +#define ID3D12Device14_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#if !defined(_WIN32) + +#define ID3D12Device14_GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#else +#define ID3D12Device14_GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#endif + + +#define ID3D12Device14_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->lpVtbl -> CreateLifetimeTracker(This,pOwner,riid,ppvTracker) ) + +#define ID3D12Device14_RemoveDevice(This) \ + ( (This)->lpVtbl -> RemoveDevice(This) ) + +#define ID3D12Device14_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommands(This,pNumMetaCommands,pDescs) ) + +#define ID3D12Device14_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) + +#define ID3D12Device14_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->lpVtbl -> CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) + +#define ID3D12Device14_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->lpVtbl -> CreateStateObject(This,pDesc,riid,ppStateObject) ) + +#define ID3D12Device14_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->lpVtbl -> GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) ) + +#define ID3D12Device14_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->lpVtbl -> CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) ) + + +#define ID3D12Device14_SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) \ + ( (This)->lpVtbl -> SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) ) + + +#define ID3D12Device14_AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) \ + ( (This)->lpVtbl -> AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) ) + +#define ID3D12Device14_CreateProtectedResourceSession1(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession1(This,pDesc,riid,ppSession) ) + +#if !defined(_WIN32) + +#define ID3D12Device14_GetResourceAllocationInfo2(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo2(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#else +#define ID3D12Device14_GetResourceAllocationInfo2(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo2(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#endif + +#define ID3D12Device14_CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) + +#define ID3D12Device14_CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device14_CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) ) + +#define ID3D12Device14_GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + + +#define ID3D12Device14_CreateShaderCacheSession(This,pDesc,riid,ppvSession) \ + ( (This)->lpVtbl -> CreateShaderCacheSession(This,pDesc,riid,ppvSession) ) + +#define ID3D12Device14_ShaderCacheControl(This,Kinds,Control) \ + ( (This)->lpVtbl -> ShaderCacheControl(This,Kinds,Control) ) + +#define ID3D12Device14_CreateCommandQueue1(This,pDesc,CreatorID,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue1(This,pDesc,CreatorID,riid,ppCommandQueue) ) + + +#define ID3D12Device14_CreateCommittedResource3(This,pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource3(This,pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) ) + +#define ID3D12Device14_CreatePlacedResource2(This,pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource2(This,pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) ) + +#define ID3D12Device14_CreateReservedResource2(This,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource2(This,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) ) + + +#define ID3D12Device14_CreateSampler2(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler2(This,pDesc,DestDescriptor) ) + +#if !defined(_WIN32) + +#define ID3D12Device14_GetResourceAllocationInfo3(This,visibleMask,numResourceDescs,pResourceDescs,pNumCastableFormats,ppCastableFormats,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo3(This,visibleMask,numResourceDescs,pResourceDescs,pNumCastableFormats,ppCastableFormats,pResourceAllocationInfo1) ) +#else +#define ID3D12Device14_GetResourceAllocationInfo3(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pNumCastableFormats,ppCastableFormats,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo3(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pNumCastableFormats,ppCastableFormats,pResourceAllocationInfo1) ) +#endif + + +#define ID3D12Device14_OpenExistingHeapFromAddress1(This,pAddress,size,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromAddress1(This,pAddress,size,riid,ppvHeap) ) + + +#define ID3D12Device14_CreateRootSignatureFromSubobjectInLibrary(This,nodeMask,pLibraryBlob,blobLengthInBytes,subobjectName,riid,ppvRootSignature) \ + ( (This)->lpVtbl -> CreateRootSignatureFromSubobjectInLibrary(This,nodeMask,pLibraryBlob,blobLengthInBytes,subobjectName,riid,ppvRootSignature) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Device14_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12VirtualizationGuestDevice_INTERFACE_DEFINED__ +#define __ID3D12VirtualizationGuestDevice_INTERFACE_DEFINED__ + +/* interface ID3D12VirtualizationGuestDevice */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12VirtualizationGuestDevice; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("bc66d368-7373-4943-8757-fc87dc79e476") + ID3D12VirtualizationGuestDevice : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE ShareWithHost( + _In_ ID3D12DeviceChild *pObject, + _Out_ HANDLE *pHandle) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateFenceFd( + _In_ ID3D12Fence *pFence, + UINT64 FenceValue, + _Out_ int *pFenceFd) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12VirtualizationGuestDeviceVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12VirtualizationGuestDevice * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12VirtualizationGuestDevice * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12VirtualizationGuestDevice * This); + + DECLSPEC_XFGVIRT(ID3D12VirtualizationGuestDevice, ShareWithHost) + HRESULT ( STDMETHODCALLTYPE *ShareWithHost )( + ID3D12VirtualizationGuestDevice * This, + _In_ ID3D12DeviceChild *pObject, + _Out_ HANDLE *pHandle); + + DECLSPEC_XFGVIRT(ID3D12VirtualizationGuestDevice, CreateFenceFd) + HRESULT ( STDMETHODCALLTYPE *CreateFenceFd )( + ID3D12VirtualizationGuestDevice * This, + _In_ ID3D12Fence *pFence, + UINT64 FenceValue, + _Out_ int *pFenceFd); + + END_INTERFACE + } ID3D12VirtualizationGuestDeviceVtbl; + + interface ID3D12VirtualizationGuestDevice + { + CONST_VTBL struct ID3D12VirtualizationGuestDeviceVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12VirtualizationGuestDevice_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12VirtualizationGuestDevice_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12VirtualizationGuestDevice_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12VirtualizationGuestDevice_ShareWithHost(This,pObject,pHandle) \ + ( (This)->lpVtbl -> ShareWithHost(This,pObject,pHandle) ) + +#define ID3D12VirtualizationGuestDevice_CreateFenceFd(This,pFence,FenceValue,pFenceFd) \ + ( (This)->lpVtbl -> CreateFenceFd(This,pFence,FenceValue,pFenceFd) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12VirtualizationGuestDevice_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Tools_INTERFACE_DEFINED__ +#define __ID3D12Tools_INTERFACE_DEFINED__ + +/* interface ID3D12Tools */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Tools; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("7071e1f0-e84b-4b33-974f-12fa49de65c5") + ID3D12Tools : public IUnknown + { + public: + virtual void STDMETHODCALLTYPE EnableShaderInstrumentation( + BOOL bEnable) = 0; + + virtual BOOL STDMETHODCALLTYPE ShaderInstrumentationEnabled( void) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12ToolsVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Tools * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Tools * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Tools * This); + + DECLSPEC_XFGVIRT(ID3D12Tools, EnableShaderInstrumentation) + void ( STDMETHODCALLTYPE *EnableShaderInstrumentation )( + ID3D12Tools * This, + BOOL bEnable); + + DECLSPEC_XFGVIRT(ID3D12Tools, ShaderInstrumentationEnabled) + BOOL ( STDMETHODCALLTYPE *ShaderInstrumentationEnabled )( + ID3D12Tools * This); + + END_INTERFACE + } ID3D12ToolsVtbl; + + interface ID3D12Tools + { + CONST_VTBL struct ID3D12ToolsVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Tools_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Tools_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Tools_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Tools_EnableShaderInstrumentation(This,bEnable) \ + ( (This)->lpVtbl -> EnableShaderInstrumentation(This,bEnable) ) + +#define ID3D12Tools_ShaderInstrumentationEnabled(This) \ + ( (This)->lpVtbl -> ShaderInstrumentationEnabled(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Tools_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0062 */ +/* [local] */ + +typedef struct D3D12_SUBRESOURCE_DATA + { + const void *pData; + LONG_PTR RowPitch; + LONG_PTR SlicePitch; + } D3D12_SUBRESOURCE_DATA; + +typedef struct D3D12_MEMCPY_DEST + { + void *pData; + SIZE_T RowPitch; + SIZE_T SlicePitch; + } D3D12_MEMCPY_DEST; + +#if !defined( D3D12_IGNORE_SDK_LAYERS ) +#include "d3d12sdklayers.h" +#endif + +/////////////////////////////////////////////////////////////////////////// // D3D12CreateDevice // ------------------ // @@ -26842,253 +28681,1400 @@ typedef HRESULT (WINAPI* PFN_D3D12_CREATE_DEVICE)( _In_opt_ IUnknown*, D3D_FEATURE_LEVEL, _In_ REFIID, _COM_Outptr_opt_ void** ); -HRESULT WINAPI D3D12CreateDevice( - _In_opt_ IUnknown* pAdapter, - D3D_FEATURE_LEVEL MinimumFeatureLevel, - _In_ REFIID riid, // Expected: ID3D12Device - _COM_Outptr_opt_ void** ppDevice ); +HRESULT WINAPI D3D12CreateDevice( + _In_opt_ IUnknown* pAdapter, + D3D_FEATURE_LEVEL MinimumFeatureLevel, + _In_ REFIID riid, // Expected: ID3D12Device + _COM_Outptr_opt_ void** ppDevice ); + + +typedef HRESULT (WINAPI* PFN_D3D12_GET_DEBUG_INTERFACE)( _In_ REFIID, _COM_Outptr_opt_ void** ); + +HRESULT WINAPI D3D12GetDebugInterface( _In_ REFIID riid, _COM_Outptr_opt_ void** ppvDebug ); + +// -------------------------------------------------------------------------------------------------------------------------------- +// D3D12EnableExperimentalFeatures +// +// Pass in a list of feature GUIDs to be enabled together. +// +// If a particular feature requires some configuration information on enablement, it will have +// a configuration struct that can be passed alongside the GUID. +// +// Some features might use an interface IID as the GUID. For these, once the feature is enabled via +// D3D12EnableExperimentalFeatures, D3D12GetDebugInterface can then be called with the IID to retrieve the interface +// for manipulating the feature. This allows for control that might not cleanly be expressed by just +// the configuration struct that D3D12EnableExperimentalFeatures provides. +// +// If this method is called and a change to existing feature enablement is made, +// all current D3D12 devices are set to DEVICE_REMOVED state, since under the covers there is really only one +// singleton device for a process. Removing the devices when configuration changes prevents +// mismatched expectations of how a device is supposed to work after it has been created from the app's point of view. +// +// The call returns E_NOINTERFACE if an unrecognized feature is passed in or Windows Developer mode is not on. +// The call returns E_INVALIDARG if the configuration of a feature is incorrect, the set of features passed +// in are known to be incompatible with each other, or other errors. +// Returns S_OK otherwise. +// +// -------------------------------------------------------------------------------------------------------------------------------- +HRESULT WINAPI D3D12EnableExperimentalFeatures( + UINT NumFeatures, + _In_count_(NumFeatures) const IID* pIIDs, + _In_opt_count_(NumFeatures) void* pConfigurationStructs, + _In_opt_count_(NumFeatures) UINT* pConfigurationStructSizes); + +// -------------------------------------------------------------------------------------------------------------------------------- +// Experimental Feature: D3D12ExperimentalShaderModels +// +// Use with D3D12EnableExperimentalFeatures to enable experimental shader model support, +// meaning shader models that haven't been finalized for use in retail. +// +// Enabling D3D12ExperimentalShaderModels needs no configuration struct, pass NULL in the pConfigurationStructs array. +// +// -------------------------------------------------------------------------------------------------------------------------------- +static const UUID D3D12ExperimentalShaderModels = { /* 76f5573e-f13a-40f5-b297-81ce9e18933f */ + 0x76f5573e, + 0xf13a, + 0x40f5, + { 0xb2, 0x97, 0x81, 0xce, 0x9e, 0x18, 0x93, 0x3f } +}; +// -------------------------------------------------------------------------------------------------------------------------------- +// Experimental Feature: D3D12TiledResourceTier4 +// +// Use with D3D12EnableExperimentalFeatures to enable tiled resource tier 4 support, +// meaning texture tile data-inheritance is allowed. +// +// Enabling D3D12TiledResourceTier4 needs no configuration struct, pass NULL in the pConfigurationStructs array. +// +// -------------------------------------------------------------------------------------------------------------------------------- +static const UUID D3D12TiledResourceTier4 = { /* c9c4725f-a81a-4f56-8c5b-c51039d694fb */ + 0xc9c4725f, + 0xa81a, + 0x4f56, + { 0x8c, 0x5b, 0xc5, 0x10, 0x39, 0xd6, 0x94, 0xfb } +}; +// -------------------------------------------------------------------------------------------------------------------------------- +// D3D12GetInterface +// +// Retrieve Global D3D12 Interface. +// + +DEFINE_GUID(CLSID_D3D12Debug, 0xf2352aeb, 0xdd84, 0x49fe, 0xb9, 0x7b, 0xa9, 0xdc, 0xfd, 0xcc, 0x1b, 0x4f); +DEFINE_GUID(CLSID_D3D12Tools, 0xe38216b1, 0x3c8c, 0x4833, 0xaa, 0x09, 0x0a, 0x06, 0xb6, 0x5d, 0x96, 0xc8); +DEFINE_GUID(CLSID_D3D12DeviceRemovedExtendedData, 0x4a75bbc4, 0x9ff4, 0x4ad8, 0x9f, 0x18, 0xab, 0xae, 0x84, 0xdc, 0x5f, 0xf2); +DEFINE_GUID(CLSID_D3D12SDKConfiguration, 0x7cda6aca, 0xa03e, 0x49c8, 0x94, 0x58, 0x03, 0x34, 0xd2, 0x0e, 0x07, 0xce); +DEFINE_GUID(CLSID_D3D12DeviceFactory, 0x114863bf, 0xc386, 0x4aee, 0xb3, 0x9d, 0x8f, 0x0b, 0xbb, 0x06, 0x29, 0x55); + +typedef HRESULT (WINAPI* PFN_D3D12_GET_INTERFACE)( _In_ REFCLSID, _In_ REFIID, _COM_Outptr_opt_ void** ); + +HRESULT WINAPI D3D12GetInterface( _In_ REFCLSID rclsid, _In_ REFIID riid, _COM_Outptr_opt_ void** ppvDebug ); + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0062_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0062_v0_0_s_ifspec; + +#ifndef __ID3D12SDKConfiguration_INTERFACE_DEFINED__ +#define __ID3D12SDKConfiguration_INTERFACE_DEFINED__ + +/* interface ID3D12SDKConfiguration */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12SDKConfiguration; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("e9eb5314-33aa-42b2-a718-d77f58b1f1c7") + ID3D12SDKConfiguration : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE SetSDKVersion( + UINT SDKVersion, + _In_z_ LPCSTR SDKPath) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12SDKConfigurationVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12SDKConfiguration * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12SDKConfiguration * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12SDKConfiguration * This); + + DECLSPEC_XFGVIRT(ID3D12SDKConfiguration, SetSDKVersion) + HRESULT ( STDMETHODCALLTYPE *SetSDKVersion )( + ID3D12SDKConfiguration * This, + UINT SDKVersion, + _In_z_ LPCSTR SDKPath); + + END_INTERFACE + } ID3D12SDKConfigurationVtbl; + + interface ID3D12SDKConfiguration + { + CONST_VTBL struct ID3D12SDKConfigurationVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12SDKConfiguration_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12SDKConfiguration_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12SDKConfiguration_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12SDKConfiguration_SetSDKVersion(This,SDKVersion,SDKPath) \ + ( (This)->lpVtbl -> SetSDKVersion(This,SDKVersion,SDKPath) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12SDKConfiguration_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12SDKConfiguration1_INTERFACE_DEFINED__ +#define __ID3D12SDKConfiguration1_INTERFACE_DEFINED__ + +/* interface ID3D12SDKConfiguration1 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12SDKConfiguration1; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("8aaf9303-ad25-48b9-9a57-d9c37e009d9f") + ID3D12SDKConfiguration1 : public ID3D12SDKConfiguration + { + public: + virtual HRESULT STDMETHODCALLTYPE CreateDeviceFactory( + UINT SDKVersion, + _In_ LPCSTR SDKPath, + REFIID riid, + _COM_Outptr_ void **ppvFactory) = 0; + + virtual void STDMETHODCALLTYPE FreeUnusedSDKs( void) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12SDKConfiguration1Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12SDKConfiguration1 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12SDKConfiguration1 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12SDKConfiguration1 * This); + + DECLSPEC_XFGVIRT(ID3D12SDKConfiguration, SetSDKVersion) + HRESULT ( STDMETHODCALLTYPE *SetSDKVersion )( + ID3D12SDKConfiguration1 * This, + UINT SDKVersion, + _In_z_ LPCSTR SDKPath); + + DECLSPEC_XFGVIRT(ID3D12SDKConfiguration1, CreateDeviceFactory) + HRESULT ( STDMETHODCALLTYPE *CreateDeviceFactory )( + ID3D12SDKConfiguration1 * This, + UINT SDKVersion, + _In_ LPCSTR SDKPath, + REFIID riid, + _COM_Outptr_ void **ppvFactory); + + DECLSPEC_XFGVIRT(ID3D12SDKConfiguration1, FreeUnusedSDKs) + void ( STDMETHODCALLTYPE *FreeUnusedSDKs )( + ID3D12SDKConfiguration1 * This); + + END_INTERFACE + } ID3D12SDKConfiguration1Vtbl; + + interface ID3D12SDKConfiguration1 + { + CONST_VTBL struct ID3D12SDKConfiguration1Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12SDKConfiguration1_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12SDKConfiguration1_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12SDKConfiguration1_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12SDKConfiguration1_SetSDKVersion(This,SDKVersion,SDKPath) \ + ( (This)->lpVtbl -> SetSDKVersion(This,SDKVersion,SDKPath) ) + + +#define ID3D12SDKConfiguration1_CreateDeviceFactory(This,SDKVersion,SDKPath,riid,ppvFactory) \ + ( (This)->lpVtbl -> CreateDeviceFactory(This,SDKVersion,SDKPath,riid,ppvFactory) ) + +#define ID3D12SDKConfiguration1_FreeUnusedSDKs(This) \ + ( (This)->lpVtbl -> FreeUnusedSDKs(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12SDKConfiguration1_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0064 */ +/* [local] */ + +typedef +enum D3D12_DEVICE_FACTORY_FLAGS + { + D3D12_DEVICE_FACTORY_FLAG_NONE = 0, + D3D12_DEVICE_FACTORY_FLAG_ALLOW_RETURNING_EXISTING_DEVICE = 0x1, + D3D12_DEVICE_FACTORY_FLAG_ALLOW_RETURNING_INCOMPATIBLE_EXISTING_DEVICE = 0x2, + D3D12_DEVICE_FACTORY_FLAG_DISALLOW_STORING_NEW_DEVICE_AS_SINGLETON = 0x4 + } D3D12_DEVICE_FACTORY_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_DEVICE_FACTORY_FLAGS ); + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0064_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0064_v0_0_s_ifspec; + +#ifndef __ID3D12DeviceFactory_INTERFACE_DEFINED__ +#define __ID3D12DeviceFactory_INTERFACE_DEFINED__ + +/* interface ID3D12DeviceFactory */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DeviceFactory; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("61f307d3-d34e-4e7c-8374-3ba4de23cccb") + ID3D12DeviceFactory : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE InitializeFromGlobalState( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE ApplyToGlobalState( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetFlags( + D3D12_DEVICE_FACTORY_FLAGS flags) = 0; + + virtual D3D12_DEVICE_FACTORY_FLAGS STDMETHODCALLTYPE GetFlags( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetConfigurationInterface( + REFCLSID clsid, + REFIID iid, + _COM_Outptr_ void **ppv) = 0; + + virtual HRESULT STDMETHODCALLTYPE EnableExperimentalFeatures( + UINT NumFeatures, + _In_reads_(NumFeatures) const IID *pIIDs, + _In_reads_opt_(NumFeatures) void *pConfigurationStructs, + _In_reads_opt_(NumFeatures) UINT *pConfigurationStructSizes) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateDevice( + _In_opt_ IUnknown *adapter, + D3D_FEATURE_LEVEL FeatureLevel, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DeviceFactoryVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DeviceFactory * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DeviceFactory * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DeviceFactory * This); + + DECLSPEC_XFGVIRT(ID3D12DeviceFactory, InitializeFromGlobalState) + HRESULT ( STDMETHODCALLTYPE *InitializeFromGlobalState )( + ID3D12DeviceFactory * This); + + DECLSPEC_XFGVIRT(ID3D12DeviceFactory, ApplyToGlobalState) + HRESULT ( STDMETHODCALLTYPE *ApplyToGlobalState )( + ID3D12DeviceFactory * This); + + DECLSPEC_XFGVIRT(ID3D12DeviceFactory, SetFlags) + HRESULT ( STDMETHODCALLTYPE *SetFlags )( + ID3D12DeviceFactory * This, + D3D12_DEVICE_FACTORY_FLAGS flags); + + DECLSPEC_XFGVIRT(ID3D12DeviceFactory, GetFlags) + D3D12_DEVICE_FACTORY_FLAGS ( STDMETHODCALLTYPE *GetFlags )( + ID3D12DeviceFactory * This); + + DECLSPEC_XFGVIRT(ID3D12DeviceFactory, GetConfigurationInterface) + HRESULT ( STDMETHODCALLTYPE *GetConfigurationInterface )( + ID3D12DeviceFactory * This, + REFCLSID clsid, + REFIID iid, + _COM_Outptr_ void **ppv); + + DECLSPEC_XFGVIRT(ID3D12DeviceFactory, EnableExperimentalFeatures) + HRESULT ( STDMETHODCALLTYPE *EnableExperimentalFeatures )( + ID3D12DeviceFactory * This, + UINT NumFeatures, + _In_reads_(NumFeatures) const IID *pIIDs, + _In_reads_opt_(NumFeatures) void *pConfigurationStructs, + _In_reads_opt_(NumFeatures) UINT *pConfigurationStructSizes); + + DECLSPEC_XFGVIRT(ID3D12DeviceFactory, CreateDevice) + HRESULT ( STDMETHODCALLTYPE *CreateDevice )( + ID3D12DeviceFactory * This, + _In_opt_ IUnknown *adapter, + D3D_FEATURE_LEVEL FeatureLevel, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + END_INTERFACE + } ID3D12DeviceFactoryVtbl; + + interface ID3D12DeviceFactory + { + CONST_VTBL struct ID3D12DeviceFactoryVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DeviceFactory_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DeviceFactory_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DeviceFactory_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12DeviceFactory_InitializeFromGlobalState(This) \ + ( (This)->lpVtbl -> InitializeFromGlobalState(This) ) + +#define ID3D12DeviceFactory_ApplyToGlobalState(This) \ + ( (This)->lpVtbl -> ApplyToGlobalState(This) ) + +#define ID3D12DeviceFactory_SetFlags(This,flags) \ + ( (This)->lpVtbl -> SetFlags(This,flags) ) + +#define ID3D12DeviceFactory_GetFlags(This) \ + ( (This)->lpVtbl -> GetFlags(This) ) + +#define ID3D12DeviceFactory_GetConfigurationInterface(This,clsid,iid,ppv) \ + ( (This)->lpVtbl -> GetConfigurationInterface(This,clsid,iid,ppv) ) + +#define ID3D12DeviceFactory_EnableExperimentalFeatures(This,NumFeatures,pIIDs,pConfigurationStructs,pConfigurationStructSizes) \ + ( (This)->lpVtbl -> EnableExperimentalFeatures(This,NumFeatures,pIIDs,pConfigurationStructs,pConfigurationStructSizes) ) + +#define ID3D12DeviceFactory_CreateDevice(This,adapter,FeatureLevel,riid,ppvDevice) \ + ( (This)->lpVtbl -> CreateDevice(This,adapter,FeatureLevel,riid,ppvDevice) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DeviceFactory_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0065 */ +/* [local] */ + +typedef +enum D3D12_DEVICE_FLAGS + { + D3D12_DEVICE_FLAG_NONE = 0, + D3D12_DEVICE_FLAG_DEBUG_LAYER_ENABLED = 0x1, + D3D12_DEVICE_FLAG_GPU_BASED_VALIDATION_ENABLED = 0x2, + D3D12_DEVICE_FLAG_SYNCHRONIZED_COMMAND_QUEUE_VALIDATION_DISABLED = 0x4, + D3D12_DEVICE_FLAG_DRED_AUTO_BREADCRUMBS_ENABLED = 0x8, + D3D12_DEVICE_FLAG_DRED_PAGE_FAULT_REPORTING_ENABLED = 0x10, + D3D12_DEVICE_FLAG_DRED_WATSON_REPORTING_ENABLED = 0x20, + D3D12_DEVICE_FLAG_DRED_BREADCRUMB_CONTEXT_ENABLED = 0x40, + D3D12_DEVICE_FLAG_DRED_USE_MARKERS_ONLY_BREADCRUMBS = 0x80, + D3D12_DEVICE_FLAG_SHADER_INSTRUMENTATION_ENABLED = 0x100, + D3D12_DEVICE_FLAG_AUTO_DEBUG_NAME_ENABLED = 0x200, + D3D12_DEVICE_FLAG_FORCE_LEGACY_STATE_VALIDATION = 0x400 + } D3D12_DEVICE_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_DEVICE_FLAGS ); +typedef struct D3D12_DEVICE_CONFIGURATION_DESC + { + D3D12_DEVICE_FLAGS Flags; + UINT GpuBasedValidationFlags; + UINT SDKVersion; + UINT NumEnabledExperimentalFeatures; + } D3D12_DEVICE_CONFIGURATION_DESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0065_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0065_v0_0_s_ifspec; + +#ifndef __ID3D12DeviceConfiguration_INTERFACE_DEFINED__ +#define __ID3D12DeviceConfiguration_INTERFACE_DEFINED__ + +/* interface ID3D12DeviceConfiguration */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DeviceConfiguration; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("78dbf87b-f766-422b-a61c-c8c446bdb9ad") + ID3D12DeviceConfiguration : public IUnknown + { + public: +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_DEVICE_CONFIGURATION_DESC STDMETHODCALLTYPE GetDesc( void) = 0; +#else + virtual D3D12_DEVICE_CONFIGURATION_DESC *STDMETHODCALLTYPE GetDesc( + D3D12_DEVICE_CONFIGURATION_DESC * RetVal) = 0; +#endif + + virtual HRESULT STDMETHODCALLTYPE GetEnabledExperimentalFeatures( + _Out_writes_(NumGuids) GUID *pGuids, + UINT NumGuids) = 0; + + virtual HRESULT STDMETHODCALLTYPE SerializeVersionedRootSignature( + _In_ const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *pDesc, + _COM_Outptr_ ID3DBlob **ppResult, + _Always_(_Outptr_opt_result_maybenull_) ID3DBlob **ppError) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateVersionedRootSignatureDeserializer( + _In_reads_bytes_(Size) const void *pBlob, + SIZE_T Size, + REFIID riid, + _COM_Outptr_ void **ppvDeserializer) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DeviceConfigurationVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DeviceConfiguration * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DeviceConfiguration * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DeviceConfiguration * This); + + DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration, GetDesc) +#if !defined(_WIN32) + D3D12_DEVICE_CONFIGURATION_DESC ( STDMETHODCALLTYPE *GetDesc )( + ID3D12DeviceConfiguration * This); + +#else + D3D12_DEVICE_CONFIGURATION_DESC *( STDMETHODCALLTYPE *GetDesc )( + ID3D12DeviceConfiguration * This, + D3D12_DEVICE_CONFIGURATION_DESC * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration, GetEnabledExperimentalFeatures) + HRESULT ( STDMETHODCALLTYPE *GetEnabledExperimentalFeatures )( + ID3D12DeviceConfiguration * This, + _Out_writes_(NumGuids) GUID *pGuids, + UINT NumGuids); + + DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration, SerializeVersionedRootSignature) + HRESULT ( STDMETHODCALLTYPE *SerializeVersionedRootSignature )( + ID3D12DeviceConfiguration * This, + _In_ const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *pDesc, + _COM_Outptr_ ID3DBlob **ppResult, + _Always_(_Outptr_opt_result_maybenull_) ID3DBlob **ppError); + + DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration, CreateVersionedRootSignatureDeserializer) + HRESULT ( STDMETHODCALLTYPE *CreateVersionedRootSignatureDeserializer )( + ID3D12DeviceConfiguration * This, + _In_reads_bytes_(Size) const void *pBlob, + SIZE_T Size, + REFIID riid, + _COM_Outptr_ void **ppvDeserializer); + + END_INTERFACE + } ID3D12DeviceConfigurationVtbl; + + interface ID3D12DeviceConfiguration + { + CONST_VTBL struct ID3D12DeviceConfigurationVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DeviceConfiguration_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DeviceConfiguration_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DeviceConfiguration_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + +#if !defined(_WIN32) + +#define ID3D12DeviceConfiguration_GetDesc(This) \ + ( (This)->lpVtbl -> GetDesc(This) ) +#else +#define ID3D12DeviceConfiguration_GetDesc(This,RetVal) \ + ( (This)->lpVtbl -> GetDesc(This,RetVal) ) +#endif + +#define ID3D12DeviceConfiguration_GetEnabledExperimentalFeatures(This,pGuids,NumGuids) \ + ( (This)->lpVtbl -> GetEnabledExperimentalFeatures(This,pGuids,NumGuids) ) + +#define ID3D12DeviceConfiguration_SerializeVersionedRootSignature(This,pDesc,ppResult,ppError) \ + ( (This)->lpVtbl -> SerializeVersionedRootSignature(This,pDesc,ppResult,ppError) ) + +#define ID3D12DeviceConfiguration_CreateVersionedRootSignatureDeserializer(This,pBlob,Size,riid,ppvDeserializer) \ + ( (This)->lpVtbl -> CreateVersionedRootSignatureDeserializer(This,pBlob,Size,riid,ppvDeserializer) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DeviceConfiguration_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12DeviceConfiguration1_INTERFACE_DEFINED__ +#define __ID3D12DeviceConfiguration1_INTERFACE_DEFINED__ + +/* interface ID3D12DeviceConfiguration1 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DeviceConfiguration1; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("ed342442-6343-4e16-bb82-a3a577874e56") + ID3D12DeviceConfiguration1 : public ID3D12DeviceConfiguration + { + public: + virtual HRESULT STDMETHODCALLTYPE CreateVersionedRootSignatureDeserializerFromSubobjectInLibrary( + _In_reads_bytes_(Size) const void *pLibraryBlob, + SIZE_T Size, + LPCWSTR RootSignatureSubobjectName, + REFIID riid, + _COM_Outptr_ void **ppvDeserializer) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DeviceConfiguration1Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DeviceConfiguration1 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DeviceConfiguration1 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DeviceConfiguration1 * This); + + DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration, GetDesc) +#if !defined(_WIN32) + D3D12_DEVICE_CONFIGURATION_DESC ( STDMETHODCALLTYPE *GetDesc )( + ID3D12DeviceConfiguration1 * This); + +#else + D3D12_DEVICE_CONFIGURATION_DESC *( STDMETHODCALLTYPE *GetDesc )( + ID3D12DeviceConfiguration1 * This, + D3D12_DEVICE_CONFIGURATION_DESC * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration, GetEnabledExperimentalFeatures) + HRESULT ( STDMETHODCALLTYPE *GetEnabledExperimentalFeatures )( + ID3D12DeviceConfiguration1 * This, + _Out_writes_(NumGuids) GUID *pGuids, + UINT NumGuids); + + DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration, SerializeVersionedRootSignature) + HRESULT ( STDMETHODCALLTYPE *SerializeVersionedRootSignature )( + ID3D12DeviceConfiguration1 * This, + _In_ const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *pDesc, + _COM_Outptr_ ID3DBlob **ppResult, + _Always_(_Outptr_opt_result_maybenull_) ID3DBlob **ppError); + + DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration, CreateVersionedRootSignatureDeserializer) + HRESULT ( STDMETHODCALLTYPE *CreateVersionedRootSignatureDeserializer )( + ID3D12DeviceConfiguration1 * This, + _In_reads_bytes_(Size) const void *pBlob, + SIZE_T Size, + REFIID riid, + _COM_Outptr_ void **ppvDeserializer); + + DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration1, CreateVersionedRootSignatureDeserializerFromSubobjectInLibrary) + HRESULT ( STDMETHODCALLTYPE *CreateVersionedRootSignatureDeserializerFromSubobjectInLibrary )( + ID3D12DeviceConfiguration1 * This, + _In_reads_bytes_(Size) const void *pLibraryBlob, + SIZE_T Size, + LPCWSTR RootSignatureSubobjectName, + REFIID riid, + _COM_Outptr_ void **ppvDeserializer); + + END_INTERFACE + } ID3D12DeviceConfiguration1Vtbl; + + interface ID3D12DeviceConfiguration1 + { + CONST_VTBL struct ID3D12DeviceConfiguration1Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS -typedef HRESULT (WINAPI* PFN_D3D12_GET_DEBUG_INTERFACE)( _In_ REFIID, _COM_Outptr_opt_ void** ); +#define ID3D12DeviceConfiguration1_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) -HRESULT WINAPI D3D12GetDebugInterface( _In_ REFIID riid, _COM_Outptr_opt_ void** ppvDebug ); +#define ID3D12DeviceConfiguration1_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) -// -------------------------------------------------------------------------------------------------------------------------------- -// D3D12EnableExperimentalFeatures -// -// Pass in a list of feature GUIDs to be enabled together. -// -// If a particular feature requires some configuration information on enablement, it will have -// a configuration struct that can be passed alongside the GUID. -// -// Some features might use an interface IID as the GUID. For these, once the feature is enabled via -// D3D12EnableExperimentalFeatures, D3D12GetDebugInterface can then be called with the IID to retrieve the interface -// for manipulating the feature. This allows for control that might not cleanly be expressed by just -// the configuration struct that D3D12EnableExperimentalFeatures provides. -// -// If this method is called and a change to existing feature enablement is made, -// all current D3D12 devices are set to DEVICE_REMOVED state, since under the covers there is really only one -// singleton device for a process. Removing the devices when configuration changes prevents -// mismatched expectations of how a device is supposed to work after it has been created from the app's point of view. -// -// The call returns E_NOINTERFACE if an unrecognized feature is passed in or Windows Developer mode is not on. -// The call returns E_INVALIDARG if the configuration of a feature is incorrect, the set of features passed -// in are known to be incompatible with each other, or other errors. -// Returns S_OK otherwise. -// -// -------------------------------------------------------------------------------------------------------------------------------- -HRESULT WINAPI D3D12EnableExperimentalFeatures( - UINT NumFeatures, - _In_count_(NumFeatures) const IID* pIIDs, - _In_opt_count_(NumFeatures) void* pConfigurationStructs, - _In_opt_count_(NumFeatures) UINT* pConfigurationStructSizes); +#define ID3D12DeviceConfiguration1_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) -// -------------------------------------------------------------------------------------------------------------------------------- -// Experimental Feature: D3D12ExperimentalShaderModels -// -// Use with D3D12EnableExperimentalFeatures to enable experimental shader model support, -// meaning shader models that haven't been finalized for use in retail. -// -// Enabling D3D12ExperimentalShaderModels needs no configuration struct, pass NULL in the pConfigurationStructs array. -// -// -------------------------------------------------------------------------------------------------------------------------------- -static const UUID D3D12ExperimentalShaderModels = { /* 76f5573e-f13a-40f5-b297-81ce9e18933f */ - 0x76f5573e, - 0xf13a, - 0x40f5, - { 0xb2, 0x97, 0x81, 0xce, 0x9e, 0x18, 0x93, 0x3f } -}; -// -------------------------------------------------------------------------------------------------------------------------------- -// Experimental Feature: D3D12TiledResourceTier4 -// -// Use with D3D12EnableExperimentalFeatures to enable tiled resource tier 4 support, -// meaning texture tile data-inheritance is allowed. -// -// Enabling D3D12TiledResourceTier4 needs no configuration struct, pass NULL in the pConfigurationStructs array. -// -// -------------------------------------------------------------------------------------------------------------------------------- -static const UUID D3D12TiledResourceTier4 = { /* c9c4725f-a81a-4f56-8c5b-c51039d694fb */ - 0xc9c4725f, - 0xa81a, - 0x4f56, - { 0x8c, 0x5b, 0xc5, 0x10, 0x39, 0xd6, 0x94, 0xfb } -}; -// -------------------------------------------------------------------------------------------------------------------------------- -// D3D12GetInterface -// -// Retrieve Global D3D12 Interface. -// +#if !defined(_WIN32) -DEFINE_GUID(CLSID_D3D12Debug, 0xf2352aeb, 0xdd84, 0x49fe, 0xb9, 0x7b, 0xa9, 0xdc, 0xfd, 0xcc, 0x1b, 0x4f); -DEFINE_GUID(CLSID_D3D12Tools, 0xe38216b1, 0x3c8c, 0x4833, 0xaa, 0x09, 0x0a, 0x06, 0xb6, 0x5d, 0x96, 0xc8); -DEFINE_GUID(CLSID_D3D12DeviceRemovedExtendedData, 0x4a75bbc4, 0x9ff4, 0x4ad8, 0x9f, 0x18, 0xab, 0xae, 0x84, 0xdc, 0x5f, 0xf2); -DEFINE_GUID(CLSID_D3D12SDKConfiguration, 0x7cda6aca, 0xa03e, 0x49c8, 0x94, 0x58, 0x03, 0x34, 0xd2, 0x0e, 0x07, 0xce); -DEFINE_GUID(CLSID_D3D12DeviceFactory, 0x114863bf, 0xc386, 0x4aee, 0xb3, 0x9d, 0x8f, 0x0b, 0xbb, 0x06, 0x29, 0x55); +#define ID3D12DeviceConfiguration1_GetDesc(This) \ + ( (This)->lpVtbl -> GetDesc(This) ) +#else +#define ID3D12DeviceConfiguration1_GetDesc(This,RetVal) \ + ( (This)->lpVtbl -> GetDesc(This,RetVal) ) +#endif -typedef HRESULT (WINAPI* PFN_D3D12_GET_INTERFACE)( _In_ REFCLSID, _In_ REFIID, _COM_Outptr_opt_ void** ); +#define ID3D12DeviceConfiguration1_GetEnabledExperimentalFeatures(This,pGuids,NumGuids) \ + ( (This)->lpVtbl -> GetEnabledExperimentalFeatures(This,pGuids,NumGuids) ) -HRESULT WINAPI D3D12GetInterface( _In_ REFCLSID rclsid, _In_ REFIID riid, _COM_Outptr_opt_ void** ppvDebug ); +#define ID3D12DeviceConfiguration1_SerializeVersionedRootSignature(This,pDesc,ppResult,ppError) \ + ( (This)->lpVtbl -> SerializeVersionedRootSignature(This,pDesc,ppResult,ppError) ) +#define ID3D12DeviceConfiguration1_CreateVersionedRootSignatureDeserializer(This,pBlob,Size,riid,ppvDeserializer) \ + ( (This)->lpVtbl -> CreateVersionedRootSignatureDeserializer(This,pBlob,Size,riid,ppvDeserializer) ) -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0059_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0059_v0_0_s_ifspec; +#define ID3D12DeviceConfiguration1_CreateVersionedRootSignatureDeserializerFromSubobjectInLibrary(This,pLibraryBlob,Size,RootSignatureSubobjectName,riid,ppvDeserializer) \ + ( (This)->lpVtbl -> CreateVersionedRootSignatureDeserializerFromSubobjectInLibrary(This,pLibraryBlob,Size,RootSignatureSubobjectName,riid,ppvDeserializer) ) -#ifndef __ID3D12SDKConfiguration_INTERFACE_DEFINED__ -#define __ID3D12SDKConfiguration_INTERFACE_DEFINED__ +#endif /* COBJMACROS */ -/* interface ID3D12SDKConfiguration */ + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DeviceConfiguration1_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0067 */ +/* [local] */ + +typedef +enum D3D12_AXIS_SHADING_RATE + { + D3D12_AXIS_SHADING_RATE_1X = 0, + D3D12_AXIS_SHADING_RATE_2X = 0x1, + D3D12_AXIS_SHADING_RATE_4X = 0x2 + } D3D12_AXIS_SHADING_RATE; + +#define D3D12_SHADING_RATE_X_AXIS_SHIFT 2 +#define D3D12_SHADING_RATE_VALID_MASK 3 +#define D3D12_MAKE_COARSE_SHADING_RATE(x,y) ((x) << D3D12_SHADING_RATE_X_AXIS_SHIFT | (y)) +#define D3D12_GET_COARSE_SHADING_RATE_X_AXIS(x) (((x) >> D3D12_SHADING_RATE_X_AXIS_SHIFT) & D3D12_SHADING_RATE_VALID_MASK) +#define D3D12_GET_COARSE_SHADING_RATE_Y_AXIS(y) ((y) & D3D12_SHADING_RATE_VALID_MASK) +typedef +enum D3D12_SHADING_RATE + { + D3D12_SHADING_RATE_1X1 = 0, + D3D12_SHADING_RATE_1X2 = 0x1, + D3D12_SHADING_RATE_2X1 = 0x4, + D3D12_SHADING_RATE_2X2 = 0x5, + D3D12_SHADING_RATE_2X4 = 0x6, + D3D12_SHADING_RATE_4X2 = 0x9, + D3D12_SHADING_RATE_4X4 = 0xa + } D3D12_SHADING_RATE; + +typedef +enum D3D12_SHADING_RATE_COMBINER + { + D3D12_SHADING_RATE_COMBINER_PASSTHROUGH = 0, + D3D12_SHADING_RATE_COMBINER_OVERRIDE = 1, + D3D12_SHADING_RATE_COMBINER_MIN = 2, + D3D12_SHADING_RATE_COMBINER_MAX = 3, + D3D12_SHADING_RATE_COMBINER_SUM = 4 + } D3D12_SHADING_RATE_COMBINER; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0067_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0067_v0_0_s_ifspec; + +#ifndef __ID3D12GraphicsCommandList5_INTERFACE_DEFINED__ +#define __ID3D12GraphicsCommandList5_INTERFACE_DEFINED__ + +/* interface ID3D12GraphicsCommandList5 */ /* [unique][local][object][uuid] */ -EXTERN_C const IID IID_ID3D12SDKConfiguration; +EXTERN_C const IID IID_ID3D12GraphicsCommandList5; #if defined(__cplusplus) && !defined(CINTERFACE) - MIDL_INTERFACE("e9eb5314-33aa-42b2-a718-d77f58b1f1c7") - ID3D12SDKConfiguration : public IUnknown + MIDL_INTERFACE("55050859-4024-474c-87f5-6472eaee44ea") + ID3D12GraphicsCommandList5 : public ID3D12GraphicsCommandList4 { public: - virtual HRESULT STDMETHODCALLTYPE SetSDKVersion( - UINT SDKVersion, - _In_z_ LPCSTR SDKPath) = 0; + virtual void STDMETHODCALLTYPE RSSetShadingRate( + _In_ D3D12_SHADING_RATE baseShadingRate, + _In_reads_opt_(D3D12_RS_SET_SHADING_RATE_COMBINER_COUNT) const D3D12_SHADING_RATE_COMBINER *combiners) = 0; + + virtual void STDMETHODCALLTYPE RSSetShadingRateImage( + _In_opt_ ID3D12Resource *shadingRateImage) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12GraphicsCommandList5Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12GraphicsCommandList5 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12GraphicsCommandList5 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12GraphicsCommandList5 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12GraphicsCommandList5 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12GraphicsCommandList5 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12GraphicsCommandList5 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12GraphicsCommandList5 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12GraphicsCommandList5 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12CommandList, GetType) + D3D12_COMMAND_LIST_TYPE ( STDMETHODCALLTYPE *GetType )( + ID3D12GraphicsCommandList5 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Close) + HRESULT ( STDMETHODCALLTYPE *Close )( + ID3D12GraphicsCommandList5 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Reset) + HRESULT ( STDMETHODCALLTYPE *Reset )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12CommandAllocator *pAllocator, + _In_opt_ ID3D12PipelineState *pInitialState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearState) + void ( STDMETHODCALLTYPE *ClearState )( + ID3D12GraphicsCommandList5 * This, + _In_opt_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawInstanced) + void ( STDMETHODCALLTYPE *DrawInstanced )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT VertexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawIndexedInstanced) + void ( STDMETHODCALLTYPE *DrawIndexedInstanced )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT IndexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartIndexLocation, + _In_ INT BaseVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Dispatch) + void ( STDMETHODCALLTYPE *Dispatch )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyBufferRegion) + void ( STDMETHODCALLTYPE *CopyBufferRegion )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT64 NumBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTextureRegion) + void ( STDMETHODCALLTYPE *CopyTextureRegion )( + ID3D12GraphicsCommandList5 * This, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pDst, + UINT DstX, + UINT DstY, + UINT DstZ, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pSrc, + _In_opt_ const D3D12_BOX *pSrcBox); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyResource) + void ( STDMETHODCALLTYPE *CopyResource )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12Resource *pDstResource, + _In_ ID3D12Resource *pSrcResource); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTiles) + void ( STDMETHODCALLTYPE *CopyTiles )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12Resource *pTiledResource, + _In_ const D3D12_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate, + _In_ const D3D12_TILE_REGION_SIZE *pTileRegionSize, + _In_ ID3D12Resource *pBuffer, + UINT64 BufferStartOffsetInBytes, + D3D12_TILE_COPY_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveSubresource) + void ( STDMETHODCALLTYPE *ResolveSubresource )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_ DXGI_FORMAT Format); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetPrimitiveTopology) + void ( STDMETHODCALLTYPE *IASetPrimitiveTopology )( + ID3D12GraphicsCommandList5 * This, + _In_ D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetViewports) + void ( STDMETHODCALLTYPE *RSSetViewports )( + ID3D12GraphicsCommandList5 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports, + _In_reads_( NumViewports) const D3D12_VIEWPORT *pViewports); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetScissorRects) + void ( STDMETHODCALLTYPE *RSSetScissorRects )( + ID3D12GraphicsCommandList5 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects, + _In_reads_( NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetBlendFactor) + void ( STDMETHODCALLTYPE *OMSetBlendFactor )( + ID3D12GraphicsCommandList5 * This, + _In_reads_opt_(4) const FLOAT BlendFactor[ 4 ]); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetStencilRef) + void ( STDMETHODCALLTYPE *OMSetStencilRef )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT StencilRef); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPipelineState) + void ( STDMETHODCALLTYPE *SetPipelineState )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResourceBarrier) + void ( STDMETHODCALLTYPE *ResourceBarrier )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT NumBarriers, + _In_reads_(NumBarriers) const D3D12_RESOURCE_BARRIER *pBarriers); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteBundle) + void ( STDMETHODCALLTYPE *ExecuteBundle )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12GraphicsCommandList *pCommandList); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetDescriptorHeaps) + void ( STDMETHODCALLTYPE *SetDescriptorHeaps )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT NumDescriptorHeaps, + _In_reads_(NumDescriptorHeaps) ID3D12DescriptorHeap *const *ppDescriptorHeaps); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootSignature) + void ( STDMETHODCALLTYPE *SetComputeRootSignature )( + ID3D12GraphicsCommandList5 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootSignature) + void ( STDMETHODCALLTYPE *SetGraphicsRootSignature )( + ID3D12GraphicsCommandList5 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetComputeRootDescriptorTable )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetGraphicsRootDescriptorTable )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstant )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstant )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstants )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstants )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetComputeRootConstantBufferView )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetGraphicsRootConstantBufferView )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetComputeRootShaderResourceView )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetGraphicsRootShaderResourceView )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetComputeRootUnorderedAccessView )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetGraphicsRootUnorderedAccessView )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetIndexBuffer) + void ( STDMETHODCALLTYPE *IASetIndexBuffer )( + ID3D12GraphicsCommandList5 * This, + _In_opt_ const D3D12_INDEX_BUFFER_VIEW *pView); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetVertexBuffers) + void ( STDMETHODCALLTYPE *IASetVertexBuffers )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_VERTEX_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SOSetTargets) + void ( STDMETHODCALLTYPE *SOSetTargets )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetRenderTargets) + void ( STDMETHODCALLTYPE *OMSetRenderTargets )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT NumRenderTargetDescriptors, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors, + _In_ BOOL RTsSingleHandleToDescriptorRange, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pDepthStencilDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearDepthStencilView) + void ( STDMETHODCALLTYPE *ClearDepthStencilView )( + ID3D12GraphicsCommandList5 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, + _In_ D3D12_CLEAR_FLAGS ClearFlags, + _In_ FLOAT Depth, + _In_ UINT8 Stencil, + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearRenderTargetView) + void ( STDMETHODCALLTYPE *ClearRenderTargetView )( + ID3D12GraphicsCommandList5 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, + _In_ const FLOAT ColorRGBA[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewUint) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewUint )( + ID3D12GraphicsCommandList5 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const UINT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewFloat) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewFloat )( + ID3D12GraphicsCommandList5 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const FLOAT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DiscardResource) + void ( STDMETHODCALLTYPE *DiscardResource )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DISCARD_REGION *pRegion); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginQuery) + void ( STDMETHODCALLTYPE *BeginQuery )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); - }; - - -#else /* C style interface */ - - typedef struct ID3D12SDKConfigurationVtbl - { - BEGIN_INTERFACE + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndQuery) + void ( STDMETHODCALLTYPE *EndQuery )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); - DECLSPEC_XFGVIRT(IUnknown, QueryInterface) - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D12SDKConfiguration * This, - REFIID riid, - _COM_Outptr_ void **ppvObject); + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveQueryData) + void ( STDMETHODCALLTYPE *ResolveQueryData )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT StartIndex, + _In_ UINT NumQueries, + _In_ ID3D12Resource *pDestinationBuffer, + _In_ UINT64 AlignedDestinationBufferOffset); - DECLSPEC_XFGVIRT(IUnknown, AddRef) - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D12SDKConfiguration * This); + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPredication) + void ( STDMETHODCALLTYPE *SetPredication )( + ID3D12GraphicsCommandList5 * This, + _In_opt_ ID3D12Resource *pBuffer, + _In_ UINT64 AlignedBufferOffset, + _In_ D3D12_PREDICATION_OP Operation); - DECLSPEC_XFGVIRT(IUnknown, Release) - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D12SDKConfiguration * This); + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetMarker) + void ( STDMETHODCALLTYPE *SetMarker )( + ID3D12GraphicsCommandList5 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); - DECLSPEC_XFGVIRT(ID3D12SDKConfiguration, SetSDKVersion) - HRESULT ( STDMETHODCALLTYPE *SetSDKVersion )( - ID3D12SDKConfiguration * This, - UINT SDKVersion, - _In_z_ LPCSTR SDKPath); + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginEvent) + void ( STDMETHODCALLTYPE *BeginEvent )( + ID3D12GraphicsCommandList5 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); - END_INTERFACE - } ID3D12SDKConfigurationVtbl; - - interface ID3D12SDKConfiguration - { - CONST_VTBL struct ID3D12SDKConfigurationVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ID3D12SDKConfiguration_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define ID3D12SDKConfiguration_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define ID3D12SDKConfiguration_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define ID3D12SDKConfiguration_SetSDKVersion(This,SDKVersion,SDKPath) \ - ( (This)->lpVtbl -> SetSDKVersion(This,SDKVersion,SDKPath) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __ID3D12SDKConfiguration_INTERFACE_DEFINED__ */ - - -#ifndef __ID3D12SDKConfiguration1_INTERFACE_DEFINED__ -#define __ID3D12SDKConfiguration1_INTERFACE_DEFINED__ - -/* interface ID3D12SDKConfiguration1 */ -/* [unique][local][object][uuid] */ - - -EXTERN_C const IID IID_ID3D12SDKConfiguration1; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("8aaf9303-ad25-48b9-9a57-d9c37e009d9f") - ID3D12SDKConfiguration1 : public ID3D12SDKConfiguration - { - public: - virtual HRESULT STDMETHODCALLTYPE CreateDeviceFactory( - UINT SDKVersion, - _In_ LPCSTR SDKPath, - REFIID riid, - _COM_Outptr_ void **ppvFactory) = 0; + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndEvent) + void ( STDMETHODCALLTYPE *EndEvent )( + ID3D12GraphicsCommandList5 * This); - virtual void STDMETHODCALLTYPE FreeUnusedSDKs( void) = 0; + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteIndirect) + void ( STDMETHODCALLTYPE *ExecuteIndirect )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12CommandSignature *pCommandSignature, + _In_ UINT MaxCommandCount, + _In_ ID3D12Resource *pArgumentBuffer, + _In_ UINT64 ArgumentBufferOffset, + _In_opt_ ID3D12Resource *pCountBuffer, + _In_ UINT64 CountBufferOffset); - }; - - -#else /* C style interface */ - - typedef struct ID3D12SDKConfiguration1Vtbl - { - BEGIN_INTERFACE + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); - DECLSPEC_XFGVIRT(IUnknown, QueryInterface) - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D12SDKConfiguration1 * This, - REFIID riid, - _COM_Outptr_ void **ppvObject); + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT64) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT64 )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); - DECLSPEC_XFGVIRT(IUnknown, AddRef) - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D12SDKConfiguration1 * This); + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, OMSetDepthBounds) + void ( STDMETHODCALLTYPE *OMSetDepthBounds )( + ID3D12GraphicsCommandList5 * This, + _In_ FLOAT Min, + _In_ FLOAT Max); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetSamplePositions) + void ( STDMETHODCALLTYPE *SetSamplePositions )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT NumSamplesPerPixel, + _In_ UINT NumPixels, + _In_reads_(NumSamplesPerPixel*NumPixels) D3D12_SAMPLE_POSITION *pSamplePositions); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, ResolveSubresourceRegion) + void ( STDMETHODCALLTYPE *ResolveSubresourceRegion )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ UINT DstX, + _In_ UINT DstY, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_opt_ D3D12_RECT *pSrcRect, + _In_ DXGI_FORMAT Format, + _In_ D3D12_RESOLVE_MODE ResolveMode); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetViewInstanceMask) + void ( STDMETHODCALLTYPE *SetViewInstanceMask )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT Mask); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList2, WriteBufferImmediate) + void ( STDMETHODCALLTYPE *WriteBufferImmediate )( + ID3D12GraphicsCommandList5 * This, + UINT Count, + _In_reads_(Count) const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER *pParams, + _In_reads_opt_(Count) const D3D12_WRITEBUFFERIMMEDIATE_MODE *pModes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList3, SetProtectedResourceSession) + void ( STDMETHODCALLTYPE *SetProtectedResourceSession )( + ID3D12GraphicsCommandList5 * This, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedResourceSession); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BeginRenderPass) + void ( STDMETHODCALLTYPE *BeginRenderPass )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT NumRenderTargets, + _In_reads_opt_(NumRenderTargets) const D3D12_RENDER_PASS_RENDER_TARGET_DESC *pRenderTargets, + _In_opt_ const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *pDepthStencil, + D3D12_RENDER_PASS_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EndRenderPass) + void ( STDMETHODCALLTYPE *EndRenderPass )( + ID3D12GraphicsCommandList5 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, InitializeMetaCommand) + void ( STDMETHODCALLTYPE *InitializeMetaCommand )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12MetaCommand *pMetaCommand, + _In_reads_bytes_opt_(InitializationParametersDataSizeInBytes) const void *pInitializationParametersData, + _In_ SIZE_T InitializationParametersDataSizeInBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, ExecuteMetaCommand) + void ( STDMETHODCALLTYPE *ExecuteMetaCommand )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12MetaCommand *pMetaCommand, + _In_reads_bytes_opt_(ExecutionParametersDataSizeInBytes) const void *pExecutionParametersData, + _In_ SIZE_T ExecutionParametersDataSizeInBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BuildRaytracingAccelerationStructure) + void ( STDMETHODCALLTYPE *BuildRaytracingAccelerationStructure )( + ID3D12GraphicsCommandList5 * This, + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC *pDesc, + _In_ UINT NumPostbuildInfoDescs, + _In_reads_opt_(NumPostbuildInfoDescs) const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pPostbuildInfoDescs); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EmitRaytracingAccelerationStructurePostbuildInfo) + void ( STDMETHODCALLTYPE *EmitRaytracingAccelerationStructurePostbuildInfo )( + ID3D12GraphicsCommandList5 * This, + _In_ const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pDesc, + _In_ UINT NumSourceAccelerationStructures, + _In_reads_( NumSourceAccelerationStructures ) const D3D12_GPU_VIRTUAL_ADDRESS *pSourceAccelerationStructureData); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, CopyRaytracingAccelerationStructure) + void ( STDMETHODCALLTYPE *CopyRaytracingAccelerationStructure )( + ID3D12GraphicsCommandList5 * This, + _In_ D3D12_GPU_VIRTUAL_ADDRESS DestAccelerationStructureData, + _In_ D3D12_GPU_VIRTUAL_ADDRESS SourceAccelerationStructureData, + _In_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE Mode); - DECLSPEC_XFGVIRT(IUnknown, Release) - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D12SDKConfiguration1 * This); + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, SetPipelineState1) + void ( STDMETHODCALLTYPE *SetPipelineState1 )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12StateObject *pStateObject); - DECLSPEC_XFGVIRT(ID3D12SDKConfiguration, SetSDKVersion) - HRESULT ( STDMETHODCALLTYPE *SetSDKVersion )( - ID3D12SDKConfiguration1 * This, - UINT SDKVersion, - _In_z_ LPCSTR SDKPath); + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, DispatchRays) + void ( STDMETHODCALLTYPE *DispatchRays )( + ID3D12GraphicsCommandList5 * This, + _In_ const D3D12_DISPATCH_RAYS_DESC *pDesc); - DECLSPEC_XFGVIRT(ID3D12SDKConfiguration1, CreateDeviceFactory) - HRESULT ( STDMETHODCALLTYPE *CreateDeviceFactory )( - ID3D12SDKConfiguration1 * This, - UINT SDKVersion, - _In_ LPCSTR SDKPath, - REFIID riid, - _COM_Outptr_ void **ppvFactory); + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRate) + void ( STDMETHODCALLTYPE *RSSetShadingRate )( + ID3D12GraphicsCommandList5 * This, + _In_ D3D12_SHADING_RATE baseShadingRate, + _In_reads_opt_(D3D12_RS_SET_SHADING_RATE_COMBINER_COUNT) const D3D12_SHADING_RATE_COMBINER *combiners); - DECLSPEC_XFGVIRT(ID3D12SDKConfiguration1, FreeUnusedSDKs) - void ( STDMETHODCALLTYPE *FreeUnusedSDKs )( - ID3D12SDKConfiguration1 * This); + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRateImage) + void ( STDMETHODCALLTYPE *RSSetShadingRateImage )( + ID3D12GraphicsCommandList5 * This, + _In_opt_ ID3D12Resource *shadingRateImage); END_INTERFACE - } ID3D12SDKConfiguration1Vtbl; + } ID3D12GraphicsCommandList5Vtbl; - interface ID3D12SDKConfiguration1 + interface ID3D12GraphicsCommandList5 { - CONST_VTBL struct ID3D12SDKConfiguration1Vtbl *lpVtbl; + CONST_VTBL struct ID3D12GraphicsCommandList5Vtbl *lpVtbl; }; @@ -27096,380 +30082,251 @@ EXTERN_C const IID IID_ID3D12SDKConfiguration1; #ifdef COBJMACROS -#define ID3D12SDKConfiguration1_QueryInterface(This,riid,ppvObject) \ +#define ID3D12GraphicsCommandList5_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) -#define ID3D12SDKConfiguration1_AddRef(This) \ +#define ID3D12GraphicsCommandList5_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) -#define ID3D12SDKConfiguration1_Release(This) \ +#define ID3D12GraphicsCommandList5_Release(This) \ ( (This)->lpVtbl -> Release(This) ) -#define ID3D12SDKConfiguration1_SetSDKVersion(This,SDKVersion,SDKPath) \ - ( (This)->lpVtbl -> SetSDKVersion(This,SDKVersion,SDKPath) ) +#define ID3D12GraphicsCommandList5_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) +#define ID3D12GraphicsCommandList5_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) -#define ID3D12SDKConfiguration1_CreateDeviceFactory(This,SDKVersion,SDKPath,riid,ppvFactory) \ - ( (This)->lpVtbl -> CreateDeviceFactory(This,SDKVersion,SDKPath,riid,ppvFactory) ) +#define ID3D12GraphicsCommandList5_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) -#define ID3D12SDKConfiguration1_FreeUnusedSDKs(This) \ - ( (This)->lpVtbl -> FreeUnusedSDKs(This) ) +#define ID3D12GraphicsCommandList5_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) -#endif /* COBJMACROS */ +#define ID3D12GraphicsCommandList5_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) -#endif /* C style interface */ +#define ID3D12GraphicsCommandList5_GetType(This) \ + ( (This)->lpVtbl -> GetType(This) ) +#define ID3D12GraphicsCommandList5_Close(This) \ + ( (This)->lpVtbl -> Close(This) ) -#endif /* __ID3D12SDKConfiguration1_INTERFACE_DEFINED__ */ +#define ID3D12GraphicsCommandList5_Reset(This,pAllocator,pInitialState) \ + ( (This)->lpVtbl -> Reset(This,pAllocator,pInitialState) ) +#define ID3D12GraphicsCommandList5_ClearState(This,pPipelineState) \ + ( (This)->lpVtbl -> ClearState(This,pPipelineState) ) -/* interface __MIDL_itf_d3d12_0000_0061 */ -/* [local] */ +#define ID3D12GraphicsCommandList5_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) -typedef -enum D3D12_DEVICE_FACTORY_FLAGS - { - D3D12_DEVICE_FACTORY_FLAG_NONE = 0, - D3D12_DEVICE_FACTORY_FLAG_ALLOW_RETURNING_EXISTING_DEVICE = 0x1, - D3D12_DEVICE_FACTORY_FLAG_ALLOW_RETURNING_INCOMPATIBLE_EXISTING_DEVICE = 0x2, - D3D12_DEVICE_FACTORY_FLAG_DISALLOW_STORING_NEW_DEVICE_AS_SINGLETON = 0x4 - } D3D12_DEVICE_FACTORY_FLAGS; +#define ID3D12GraphicsCommandList5_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) -DEFINE_ENUM_FLAG_OPERATORS( D3D12_DEVICE_FACTORY_FLAGS ); +#define ID3D12GraphicsCommandList5_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->lpVtbl -> Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) +#define ID3D12GraphicsCommandList5_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->lpVtbl -> CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0061_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0061_v0_0_s_ifspec; +#define ID3D12GraphicsCommandList5_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->lpVtbl -> CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) -#ifndef __ID3D12DeviceFactory_INTERFACE_DEFINED__ -#define __ID3D12DeviceFactory_INTERFACE_DEFINED__ +#define ID3D12GraphicsCommandList5_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->lpVtbl -> CopyResource(This,pDstResource,pSrcResource) ) -/* interface ID3D12DeviceFactory */ -/* [unique][local][object][uuid] */ +#define ID3D12GraphicsCommandList5_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->lpVtbl -> CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) +#define ID3D12GraphicsCommandList5_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->lpVtbl -> ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) -EXTERN_C const IID IID_ID3D12DeviceFactory; +#define ID3D12GraphicsCommandList5_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->lpVtbl -> IASetPrimitiveTopology(This,PrimitiveTopology) ) -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("61f307d3-d34e-4e7c-8374-3ba4de23cccb") - ID3D12DeviceFactory : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE InitializeFromGlobalState( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE ApplyToGlobalState( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetFlags( - D3D12_DEVICE_FACTORY_FLAGS flags) = 0; - - virtual D3D12_DEVICE_FACTORY_FLAGS STDMETHODCALLTYPE GetFlags( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetConfigurationInterface( - REFCLSID clsid, - REFIID iid, - _COM_Outptr_ void **ppv) = 0; - - virtual HRESULT STDMETHODCALLTYPE EnableExperimentalFeatures( - UINT NumFeatures, - _In_reads_(NumFeatures) const IID *pIIDs, - _In_reads_opt_(NumFeatures) void *pConfigurationStructs, - _In_reads_opt_(NumFeatures) UINT *pConfigurationStructSizes) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateDevice( - _In_opt_ IUnknown *adapter, - D3D_FEATURE_LEVEL FeatureLevel, - REFIID riid, - _COM_Outptr_opt_ void **ppvDevice) = 0; - - }; - - -#else /* C style interface */ +#define ID3D12GraphicsCommandList5_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->lpVtbl -> RSSetViewports(This,NumViewports,pViewports) ) - typedef struct ID3D12DeviceFactoryVtbl - { - BEGIN_INTERFACE - - DECLSPEC_XFGVIRT(IUnknown, QueryInterface) - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D12DeviceFactory * This, - REFIID riid, - _COM_Outptr_ void **ppvObject); - - DECLSPEC_XFGVIRT(IUnknown, AddRef) - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D12DeviceFactory * This); - - DECLSPEC_XFGVIRT(IUnknown, Release) - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D12DeviceFactory * This); - - DECLSPEC_XFGVIRT(ID3D12DeviceFactory, InitializeFromGlobalState) - HRESULT ( STDMETHODCALLTYPE *InitializeFromGlobalState )( - ID3D12DeviceFactory * This); - - DECLSPEC_XFGVIRT(ID3D12DeviceFactory, ApplyToGlobalState) - HRESULT ( STDMETHODCALLTYPE *ApplyToGlobalState )( - ID3D12DeviceFactory * This); - - DECLSPEC_XFGVIRT(ID3D12DeviceFactory, SetFlags) - HRESULT ( STDMETHODCALLTYPE *SetFlags )( - ID3D12DeviceFactory * This, - D3D12_DEVICE_FACTORY_FLAGS flags); - - DECLSPEC_XFGVIRT(ID3D12DeviceFactory, GetFlags) - D3D12_DEVICE_FACTORY_FLAGS ( STDMETHODCALLTYPE *GetFlags )( - ID3D12DeviceFactory * This); - - DECLSPEC_XFGVIRT(ID3D12DeviceFactory, GetConfigurationInterface) - HRESULT ( STDMETHODCALLTYPE *GetConfigurationInterface )( - ID3D12DeviceFactory * This, - REFCLSID clsid, - REFIID iid, - _COM_Outptr_ void **ppv); - - DECLSPEC_XFGVIRT(ID3D12DeviceFactory, EnableExperimentalFeatures) - HRESULT ( STDMETHODCALLTYPE *EnableExperimentalFeatures )( - ID3D12DeviceFactory * This, - UINT NumFeatures, - _In_reads_(NumFeatures) const IID *pIIDs, - _In_reads_opt_(NumFeatures) void *pConfigurationStructs, - _In_reads_opt_(NumFeatures) UINT *pConfigurationStructSizes); - - DECLSPEC_XFGVIRT(ID3D12DeviceFactory, CreateDevice) - HRESULT ( STDMETHODCALLTYPE *CreateDevice )( - ID3D12DeviceFactory * This, - _In_opt_ IUnknown *adapter, - D3D_FEATURE_LEVEL FeatureLevel, - REFIID riid, - _COM_Outptr_opt_ void **ppvDevice); - - END_INTERFACE - } ID3D12DeviceFactoryVtbl; +#define ID3D12GraphicsCommandList5_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->lpVtbl -> RSSetScissorRects(This,NumRects,pRects) ) - interface ID3D12DeviceFactory - { - CONST_VTBL struct ID3D12DeviceFactoryVtbl *lpVtbl; - }; +#define ID3D12GraphicsCommandList5_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->lpVtbl -> OMSetBlendFactor(This,BlendFactor) ) + +#define ID3D12GraphicsCommandList5_OMSetStencilRef(This,StencilRef) \ + ( (This)->lpVtbl -> OMSetStencilRef(This,StencilRef) ) + +#define ID3D12GraphicsCommandList5_SetPipelineState(This,pPipelineState) \ + ( (This)->lpVtbl -> SetPipelineState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList5_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->lpVtbl -> ResourceBarrier(This,NumBarriers,pBarriers) ) + +#define ID3D12GraphicsCommandList5_ExecuteBundle(This,pCommandList) \ + ( (This)->lpVtbl -> ExecuteBundle(This,pCommandList) ) + +#define ID3D12GraphicsCommandList5_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->lpVtbl -> SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) ) + +#define ID3D12GraphicsCommandList5_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetComputeRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList5_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetGraphicsRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList5_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList5_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList5_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList5_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList5_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList5_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList5_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) - +#define ID3D12GraphicsCommandList5_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) -#ifdef COBJMACROS +#define ID3D12GraphicsCommandList5_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList5_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12DeviceFactory_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) +#define ID3D12GraphicsCommandList5_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12DeviceFactory_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) +#define ID3D12GraphicsCommandList5_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12DeviceFactory_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) +#define ID3D12GraphicsCommandList5_IASetIndexBuffer(This,pView) \ + ( (This)->lpVtbl -> IASetIndexBuffer(This,pView) ) +#define ID3D12GraphicsCommandList5_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> IASetVertexBuffers(This,StartSlot,NumViews,pViews) ) -#define ID3D12DeviceFactory_InitializeFromGlobalState(This) \ - ( (This)->lpVtbl -> InitializeFromGlobalState(This) ) +#define ID3D12GraphicsCommandList5_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> SOSetTargets(This,StartSlot,NumViews,pViews) ) -#define ID3D12DeviceFactory_ApplyToGlobalState(This) \ - ( (This)->lpVtbl -> ApplyToGlobalState(This) ) +#define ID3D12GraphicsCommandList5_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->lpVtbl -> OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) -#define ID3D12DeviceFactory_SetFlags(This,flags) \ - ( (This)->lpVtbl -> SetFlags(This,flags) ) +#define ID3D12GraphicsCommandList5_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) -#define ID3D12DeviceFactory_GetFlags(This) \ - ( (This)->lpVtbl -> GetFlags(This) ) +#define ID3D12GraphicsCommandList5_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) ) -#define ID3D12DeviceFactory_GetConfigurationInterface(This,clsid,iid,ppv) \ - ( (This)->lpVtbl -> GetConfigurationInterface(This,clsid,iid,ppv) ) +#define ID3D12GraphicsCommandList5_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) -#define ID3D12DeviceFactory_EnableExperimentalFeatures(This,NumFeatures,pIIDs,pConfigurationStructs,pConfigurationStructSizes) \ - ( (This)->lpVtbl -> EnableExperimentalFeatures(This,NumFeatures,pIIDs,pConfigurationStructs,pConfigurationStructSizes) ) +#define ID3D12GraphicsCommandList5_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) -#define ID3D12DeviceFactory_CreateDevice(This,adapter,FeatureLevel,riid,ppvDevice) \ - ( (This)->lpVtbl -> CreateDevice(This,adapter,FeatureLevel,riid,ppvDevice) ) +#define ID3D12GraphicsCommandList5_DiscardResource(This,pResource,pRegion) \ + ( (This)->lpVtbl -> DiscardResource(This,pResource,pRegion) ) -#endif /* COBJMACROS */ +#define ID3D12GraphicsCommandList5_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> BeginQuery(This,pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList5_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> EndQuery(This,pQueryHeap,Type,Index) ) -#endif /* C style interface */ +#define ID3D12GraphicsCommandList5_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->lpVtbl -> ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) +#define ID3D12GraphicsCommandList5_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->lpVtbl -> SetPredication(This,pBuffer,AlignedBufferOffset,Operation) ) +#define ID3D12GraphicsCommandList5_SetMarker(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> SetMarker(This,Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList5_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> BeginEvent(This,Metadata,pData,Size) ) -#endif /* __ID3D12DeviceFactory_INTERFACE_DEFINED__ */ +#define ID3D12GraphicsCommandList5_EndEvent(This) \ + ( (This)->lpVtbl -> EndEvent(This) ) +#define ID3D12GraphicsCommandList5_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->lpVtbl -> ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) -/* interface __MIDL_itf_d3d12_0000_0062 */ -/* [local] */ -typedef -enum D3D12_DEVICE_FLAGS - { - D3D12_DEVICE_FLAG_NONE = 0, - D3D12_DEVICE_FLAG_DEBUG_LAYER_ENABLED = 0x1, - D3D12_DEVICE_FLAG_GPU_BASED_VALIDATION_ENABLED = 0x2, - D3D12_DEVICE_FLAG_SYNCHRONIZED_COMMAND_QUEUE_VALIDATION_DISABLED = 0x4, - D3D12_DEVICE_FLAG_DRED_AUTO_BREADCRUMBS_ENABLED = 0x8, - D3D12_DEVICE_FLAG_DRED_PAGE_FAULT_REPORTING_ENABLED = 0x10, - D3D12_DEVICE_FLAG_DRED_WATSON_REPORTING_ENABLED = 0x20, - D3D12_DEVICE_FLAG_DRED_BREADCRUMB_CONTEXT_ENABLED = 0x40, - D3D12_DEVICE_FLAG_DRED_USE_MARKERS_ONLY_BREADCRUMBS = 0x80, - D3D12_DEVICE_FLAG_SHADER_INSTRUMENTATION_ENABLED = 0x100, - D3D12_DEVICE_FLAG_AUTO_DEBUG_NAME_ENABLED = 0x200, - D3D12_DEVICE_FLAG_FORCE_LEGACY_STATE_VALIDATION = 0x400 - } D3D12_DEVICE_FLAGS; +#define ID3D12GraphicsCommandList5_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) -DEFINE_ENUM_FLAG_OPERATORS( D3D12_DEVICE_FLAGS ); -typedef struct D3D12_DEVICE_CONFIGURATION_DESC - { - D3D12_DEVICE_FLAGS Flags; - UINT GpuBasedValidationFlags; - UINT SDKVersion; - UINT NumEnabledExperimentalFeatures; - } D3D12_DEVICE_CONFIGURATION_DESC; +#define ID3D12GraphicsCommandList5_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList5_OMSetDepthBounds(This,Min,Max) \ + ( (This)->lpVtbl -> OMSetDepthBounds(This,Min,Max) ) +#define ID3D12GraphicsCommandList5_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->lpVtbl -> SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) ) -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0062_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0062_v0_0_s_ifspec; +#define ID3D12GraphicsCommandList5_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->lpVtbl -> ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) -#ifndef __ID3D12DeviceConfiguration_INTERFACE_DEFINED__ -#define __ID3D12DeviceConfiguration_INTERFACE_DEFINED__ +#define ID3D12GraphicsCommandList5_SetViewInstanceMask(This,Mask) \ + ( (This)->lpVtbl -> SetViewInstanceMask(This,Mask) ) -/* interface ID3D12DeviceConfiguration */ -/* [unique][local][object][uuid] */ +#define ID3D12GraphicsCommandList5_WriteBufferImmediate(This,Count,pParams,pModes) \ + ( (This)->lpVtbl -> WriteBufferImmediate(This,Count,pParams,pModes) ) -EXTERN_C const IID IID_ID3D12DeviceConfiguration; -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("78dbf87b-f766-422b-a61c-c8c446bdb9ad") - ID3D12DeviceConfiguration : public IUnknown - { - public: -#if defined(_MSC_VER) || !defined(_WIN32) - virtual D3D12_DEVICE_CONFIGURATION_DESC STDMETHODCALLTYPE GetDesc( void) = 0; -#else - virtual D3D12_DEVICE_CONFIGURATION_DESC *STDMETHODCALLTYPE GetDesc( - D3D12_DEVICE_CONFIGURATION_DESC * RetVal) = 0; -#endif - - virtual HRESULT STDMETHODCALLTYPE GetEnabledExperimentalFeatures( - _Out_writes_(NumGuids) GUID *pGuids, - UINT NumGuids) = 0; - - virtual HRESULT STDMETHODCALLTYPE SerializeVersionedRootSignature( - _In_ const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *pDesc, - _COM_Outptr_ ID3DBlob **ppResult, - _Always_(_Outptr_opt_result_maybenull_) ID3DBlob **ppError) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateVersionedRootSignatureDeserializer( - _In_reads_bytes_(Size) const void *pBlob, - SIZE_T Size, - REFIID riid, - _COM_Outptr_ void **ppvDeserializer) = 0; - - }; - - -#else /* C style interface */ +#define ID3D12GraphicsCommandList5_SetProtectedResourceSession(This,pProtectedResourceSession) \ + ( (This)->lpVtbl -> SetProtectedResourceSession(This,pProtectedResourceSession) ) - typedef struct ID3D12DeviceConfigurationVtbl - { - BEGIN_INTERFACE - - DECLSPEC_XFGVIRT(IUnknown, QueryInterface) - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D12DeviceConfiguration * This, - REFIID riid, - _COM_Outptr_ void **ppvObject); - - DECLSPEC_XFGVIRT(IUnknown, AddRef) - ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D12DeviceConfiguration * This); - - DECLSPEC_XFGVIRT(IUnknown, Release) - ULONG ( STDMETHODCALLTYPE *Release )( - ID3D12DeviceConfiguration * This); - - DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration, GetDesc) -#if !defined(_WIN32) - D3D12_DEVICE_CONFIGURATION_DESC ( STDMETHODCALLTYPE *GetDesc )( - ID3D12DeviceConfiguration * This); - -#else - D3D12_DEVICE_CONFIGURATION_DESC *( STDMETHODCALLTYPE *GetDesc )( - ID3D12DeviceConfiguration * This, - D3D12_DEVICE_CONFIGURATION_DESC * RetVal); - -#endif - - DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration, GetEnabledExperimentalFeatures) - HRESULT ( STDMETHODCALLTYPE *GetEnabledExperimentalFeatures )( - ID3D12DeviceConfiguration * This, - _Out_writes_(NumGuids) GUID *pGuids, - UINT NumGuids); - - DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration, SerializeVersionedRootSignature) - HRESULT ( STDMETHODCALLTYPE *SerializeVersionedRootSignature )( - ID3D12DeviceConfiguration * This, - _In_ const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *pDesc, - _COM_Outptr_ ID3DBlob **ppResult, - _Always_(_Outptr_opt_result_maybenull_) ID3DBlob **ppError); - - DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration, CreateVersionedRootSignatureDeserializer) - HRESULT ( STDMETHODCALLTYPE *CreateVersionedRootSignatureDeserializer )( - ID3D12DeviceConfiguration * This, - _In_reads_bytes_(Size) const void *pBlob, - SIZE_T Size, - REFIID riid, - _COM_Outptr_ void **ppvDeserializer); - - END_INTERFACE - } ID3D12DeviceConfigurationVtbl; - interface ID3D12DeviceConfiguration - { - CONST_VTBL struct ID3D12DeviceConfigurationVtbl *lpVtbl; - }; +#define ID3D12GraphicsCommandList5_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ + ( (This)->lpVtbl -> BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) ) - +#define ID3D12GraphicsCommandList5_EndRenderPass(This) \ + ( (This)->lpVtbl -> EndRenderPass(This) ) -#ifdef COBJMACROS +#define ID3D12GraphicsCommandList5_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ + ( (This)->lpVtbl -> InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) ) +#define ID3D12GraphicsCommandList5_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ + ( (This)->lpVtbl -> ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) ) -#define ID3D12DeviceConfiguration_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) +#define ID3D12GraphicsCommandList5_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ + ( (This)->lpVtbl -> BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) ) -#define ID3D12DeviceConfiguration_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) +#define ID3D12GraphicsCommandList5_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ + ( (This)->lpVtbl -> EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) ) -#define ID3D12DeviceConfiguration_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) +#define ID3D12GraphicsCommandList5_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ + ( (This)->lpVtbl -> CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) ) -#if !defined(_WIN32) +#define ID3D12GraphicsCommandList5_SetPipelineState1(This,pStateObject) \ + ( (This)->lpVtbl -> SetPipelineState1(This,pStateObject) ) -#define ID3D12DeviceConfiguration_GetDesc(This) \ - ( (This)->lpVtbl -> GetDesc(This) ) -#else -#define ID3D12DeviceConfiguration_GetDesc(This,RetVal) \ - ( (This)->lpVtbl -> GetDesc(This,RetVal) ) -#endif +#define ID3D12GraphicsCommandList5_DispatchRays(This,pDesc) \ + ( (This)->lpVtbl -> DispatchRays(This,pDesc) ) -#define ID3D12DeviceConfiguration_GetEnabledExperimentalFeatures(This,pGuids,NumGuids) \ - ( (This)->lpVtbl -> GetEnabledExperimentalFeatures(This,pGuids,NumGuids) ) -#define ID3D12DeviceConfiguration_SerializeVersionedRootSignature(This,pDesc,ppResult,ppError) \ - ( (This)->lpVtbl -> SerializeVersionedRootSignature(This,pDesc,ppResult,ppError) ) +#define ID3D12GraphicsCommandList5_RSSetShadingRate(This,baseShadingRate,combiners) \ + ( (This)->lpVtbl -> RSSetShadingRate(This,baseShadingRate,combiners) ) -#define ID3D12DeviceConfiguration_CreateVersionedRootSignatureDeserializer(This,pBlob,Size,riid,ppvDeserializer) \ - ( (This)->lpVtbl -> CreateVersionedRootSignatureDeserializer(This,pBlob,Size,riid,ppvDeserializer) ) +#define ID3D12GraphicsCommandList5_RSSetShadingRateImage(This,shadingRateImage) \ + ( (This)->lpVtbl -> RSSetShadingRateImage(This,shadingRateImage) ) #endif /* COBJMACROS */ @@ -27479,150 +30336,120 @@ EXTERN_C const IID IID_ID3D12DeviceConfiguration; -#endif /* __ID3D12DeviceConfiguration_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_d3d12_0000_0063 */ -/* [local] */ +#endif /* __ID3D12GraphicsCommandList5_INTERFACE_DEFINED__ */ -typedef -enum D3D12_AXIS_SHADING_RATE - { - D3D12_AXIS_SHADING_RATE_1X = 0, - D3D12_AXIS_SHADING_RATE_2X = 0x1, - D3D12_AXIS_SHADING_RATE_4X = 0x2 - } D3D12_AXIS_SHADING_RATE; -#define D3D12_SHADING_RATE_X_AXIS_SHIFT 2 -#define D3D12_SHADING_RATE_VALID_MASK 3 -#define D3D12_MAKE_COARSE_SHADING_RATE(x,y) ((x) << D3D12_SHADING_RATE_X_AXIS_SHIFT | (y)) -#define D3D12_GET_COARSE_SHADING_RATE_X_AXIS(x) (((x) >> D3D12_SHADING_RATE_X_AXIS_SHIFT) & D3D12_SHADING_RATE_VALID_MASK) -#define D3D12_GET_COARSE_SHADING_RATE_Y_AXIS(y) ((y) & D3D12_SHADING_RATE_VALID_MASK) -typedef -enum D3D12_SHADING_RATE - { - D3D12_SHADING_RATE_1X1 = 0, - D3D12_SHADING_RATE_1X2 = 0x1, - D3D12_SHADING_RATE_2X1 = 0x4, - D3D12_SHADING_RATE_2X2 = 0x5, - D3D12_SHADING_RATE_2X4 = 0x6, - D3D12_SHADING_RATE_4X2 = 0x9, - D3D12_SHADING_RATE_4X4 = 0xa - } D3D12_SHADING_RATE; +/* interface __MIDL_itf_d3d12_0000_0068 */ +/* [local] */ -typedef -enum D3D12_SHADING_RATE_COMBINER +typedef struct D3D12_DISPATCH_MESH_ARGUMENTS { - D3D12_SHADING_RATE_COMBINER_PASSTHROUGH = 0, - D3D12_SHADING_RATE_COMBINER_OVERRIDE = 1, - D3D12_SHADING_RATE_COMBINER_MIN = 2, - D3D12_SHADING_RATE_COMBINER_MAX = 3, - D3D12_SHADING_RATE_COMBINER_SUM = 4 - } D3D12_SHADING_RATE_COMBINER; + UINT ThreadGroupCountX; + UINT ThreadGroupCountY; + UINT ThreadGroupCountZ; + } D3D12_DISPATCH_MESH_ARGUMENTS; -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0063_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0063_v0_0_s_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0068_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0068_v0_0_s_ifspec; -#ifndef __ID3D12GraphicsCommandList5_INTERFACE_DEFINED__ -#define __ID3D12GraphicsCommandList5_INTERFACE_DEFINED__ +#ifndef __ID3D12GraphicsCommandList6_INTERFACE_DEFINED__ +#define __ID3D12GraphicsCommandList6_INTERFACE_DEFINED__ -/* interface ID3D12GraphicsCommandList5 */ +/* interface ID3D12GraphicsCommandList6 */ /* [unique][local][object][uuid] */ -EXTERN_C const IID IID_ID3D12GraphicsCommandList5; +EXTERN_C const IID IID_ID3D12GraphicsCommandList6; #if defined(__cplusplus) && !defined(CINTERFACE) - MIDL_INTERFACE("55050859-4024-474c-87f5-6472eaee44ea") - ID3D12GraphicsCommandList5 : public ID3D12GraphicsCommandList4 + MIDL_INTERFACE("c3827890-e548-4cfa-96cf-5689a9370f80") + ID3D12GraphicsCommandList6 : public ID3D12GraphicsCommandList5 { public: - virtual void STDMETHODCALLTYPE RSSetShadingRate( - _In_ D3D12_SHADING_RATE baseShadingRate, - _In_reads_opt_(D3D12_RS_SET_SHADING_RATE_COMBINER_COUNT) const D3D12_SHADING_RATE_COMBINER *combiners) = 0; - - virtual void STDMETHODCALLTYPE RSSetShadingRateImage( - _In_opt_ ID3D12Resource *shadingRateImage) = 0; + virtual void STDMETHODCALLTYPE DispatchMesh( + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ) = 0; }; #else /* C style interface */ - typedef struct ID3D12GraphicsCommandList5Vtbl + typedef struct ID3D12GraphicsCommandList6Vtbl { BEGIN_INTERFACE DECLSPEC_XFGVIRT(IUnknown, QueryInterface) HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, REFIID riid, _COM_Outptr_ void **ppvObject); DECLSPEC_XFGVIRT(IUnknown, AddRef) ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D12GraphicsCommandList5 * This); + ID3D12GraphicsCommandList6 * This); DECLSPEC_XFGVIRT(IUnknown, Release) ULONG ( STDMETHODCALLTYPE *Release )( - ID3D12GraphicsCommandList5 * This); + ID3D12GraphicsCommandList6 * This); DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ REFGUID guid, _Inout_ UINT *pDataSize, _Out_writes_bytes_opt_( *pDataSize ) void *pData); DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ REFGUID guid, _In_ UINT DataSize, _In_reads_bytes_opt_( DataSize ) const void *pData); DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ REFGUID guid, _In_opt_ const IUnknown *pData); DECLSPEC_XFGVIRT(ID3D12Object, SetName) HRESULT ( STDMETHODCALLTYPE *SetName )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_z_ LPCWSTR Name); DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) HRESULT ( STDMETHODCALLTYPE *GetDevice )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, REFIID riid, _COM_Outptr_opt_ void **ppvDevice); DECLSPEC_XFGVIRT(ID3D12CommandList, GetType) D3D12_COMMAND_LIST_TYPE ( STDMETHODCALLTYPE *GetType )( - ID3D12GraphicsCommandList5 * This); + ID3D12GraphicsCommandList6 * This); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Close) HRESULT ( STDMETHODCALLTYPE *Close )( - ID3D12GraphicsCommandList5 * This); + ID3D12GraphicsCommandList6 * This); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Reset) HRESULT ( STDMETHODCALLTYPE *Reset )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ ID3D12CommandAllocator *pAllocator, _In_opt_ ID3D12PipelineState *pInitialState); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearState) void ( STDMETHODCALLTYPE *ClearState )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_opt_ ID3D12PipelineState *pPipelineState); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawInstanced) void ( STDMETHODCALLTYPE *DrawInstanced )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT VertexCountPerInstance, _In_ UINT InstanceCount, _In_ UINT StartVertexLocation, @@ -27630,7 +30457,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList5; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawIndexedInstanced) void ( STDMETHODCALLTYPE *DrawIndexedInstanced )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT IndexCountPerInstance, _In_ UINT InstanceCount, _In_ UINT StartIndexLocation, @@ -27639,14 +30466,14 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList5; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Dispatch) void ( STDMETHODCALLTYPE *Dispatch )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT ThreadGroupCountX, _In_ UINT ThreadGroupCountY, _In_ UINT ThreadGroupCountZ); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyBufferRegion) void ( STDMETHODCALLTYPE *CopyBufferRegion )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ ID3D12Resource *pDstBuffer, UINT64 DstOffset, _In_ ID3D12Resource *pSrcBuffer, @@ -27655,7 +30482,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList5; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTextureRegion) void ( STDMETHODCALLTYPE *CopyTextureRegion )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ const D3D12_TEXTURE_COPY_LOCATION *pDst, UINT DstX, UINT DstY, @@ -27665,13 +30492,13 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList5; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyResource) void ( STDMETHODCALLTYPE *CopyResource )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ ID3D12Resource *pDstResource, _In_ ID3D12Resource *pSrcResource); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTiles) void ( STDMETHODCALLTYPE *CopyTiles )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ ID3D12Resource *pTiledResource, _In_ const D3D12_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate, _In_ const D3D12_TILE_REGION_SIZE *pTileRegionSize, @@ -27681,7 +30508,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList5; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveSubresource) void ( STDMETHODCALLTYPE *ResolveSubresource )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ ID3D12Resource *pDstResource, _In_ UINT DstSubresource, _In_ ID3D12Resource *pSrcResource, @@ -27690,92 +30517,92 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList5; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetPrimitiveTopology) void ( STDMETHODCALLTYPE *IASetPrimitiveTopology )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetViewports) void ( STDMETHODCALLTYPE *RSSetViewports )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports, _In_reads_( NumViewports) const D3D12_VIEWPORT *pViewports); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetScissorRects) void ( STDMETHODCALLTYPE *RSSetScissorRects )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects, _In_reads_( NumRects) const D3D12_RECT *pRects); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetBlendFactor) void ( STDMETHODCALLTYPE *OMSetBlendFactor )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_reads_opt_(4) const FLOAT BlendFactor[ 4 ]); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetStencilRef) void ( STDMETHODCALLTYPE *OMSetStencilRef )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT StencilRef); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPipelineState) void ( STDMETHODCALLTYPE *SetPipelineState )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ ID3D12PipelineState *pPipelineState); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResourceBarrier) void ( STDMETHODCALLTYPE *ResourceBarrier )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT NumBarriers, _In_reads_(NumBarriers) const D3D12_RESOURCE_BARRIER *pBarriers); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteBundle) void ( STDMETHODCALLTYPE *ExecuteBundle )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ ID3D12GraphicsCommandList *pCommandList); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetDescriptorHeaps) void ( STDMETHODCALLTYPE *SetDescriptorHeaps )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT NumDescriptorHeaps, _In_reads_(NumDescriptorHeaps) ID3D12DescriptorHeap *const *ppDescriptorHeaps); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootSignature) void ( STDMETHODCALLTYPE *SetComputeRootSignature )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_opt_ ID3D12RootSignature *pRootSignature); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootSignature) void ( STDMETHODCALLTYPE *SetGraphicsRootSignature )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_opt_ ID3D12RootSignature *pRootSignature); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootDescriptorTable) void ( STDMETHODCALLTYPE *SetComputeRootDescriptorTable )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootDescriptorTable) void ( STDMETHODCALLTYPE *SetGraphicsRootDescriptorTable )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstant) void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstant )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT RootParameterIndex, _In_ UINT SrcData, _In_ UINT DestOffsetIn32BitValues); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstant) void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstant )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT RootParameterIndex, _In_ UINT SrcData, _In_ UINT DestOffsetIn32BitValues); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstants) void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstants )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT RootParameterIndex, _In_ UINT Num32BitValuesToSet, _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, @@ -27783,7 +30610,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList5; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstants) void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstants )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT RootParameterIndex, _In_ UINT Num32BitValuesToSet, _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, @@ -27791,62 +30618,62 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList5; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootConstantBufferView) void ( STDMETHODCALLTYPE *SetComputeRootConstantBufferView )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootConstantBufferView) void ( STDMETHODCALLTYPE *SetGraphicsRootConstantBufferView )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootShaderResourceView) void ( STDMETHODCALLTYPE *SetComputeRootShaderResourceView )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootShaderResourceView) void ( STDMETHODCALLTYPE *SetGraphicsRootShaderResourceView )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootUnorderedAccessView) void ( STDMETHODCALLTYPE *SetComputeRootUnorderedAccessView )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootUnorderedAccessView) void ( STDMETHODCALLTYPE *SetGraphicsRootUnorderedAccessView )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetIndexBuffer) void ( STDMETHODCALLTYPE *IASetIndexBuffer )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_opt_ const D3D12_INDEX_BUFFER_VIEW *pView); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetVertexBuffers) void ( STDMETHODCALLTYPE *IASetVertexBuffers )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT StartSlot, _In_ UINT NumViews, _In_reads_opt_(NumViews) const D3D12_VERTEX_BUFFER_VIEW *pViews); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SOSetTargets) void ( STDMETHODCALLTYPE *SOSetTargets )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT StartSlot, _In_ UINT NumViews, _In_reads_opt_(NumViews) const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetRenderTargets) void ( STDMETHODCALLTYPE *OMSetRenderTargets )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT NumRenderTargetDescriptors, _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors, _In_ BOOL RTsSingleHandleToDescriptorRange, @@ -27854,7 +30681,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList5; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearDepthStencilView) void ( STDMETHODCALLTYPE *ClearDepthStencilView )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, _In_ D3D12_CLEAR_FLAGS ClearFlags, _In_ FLOAT Depth, @@ -27864,7 +30691,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList5; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearRenderTargetView) void ( STDMETHODCALLTYPE *ClearRenderTargetView )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, _In_ const FLOAT ColorRGBA[ 4 ], _In_ UINT NumRects, @@ -27872,7 +30699,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList5; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewUint) void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewUint )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, _In_ ID3D12Resource *pResource, @@ -27882,7 +30709,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList5; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewFloat) void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewFloat )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, _In_ ID3D12Resource *pResource, @@ -27892,27 +30719,27 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList5; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DiscardResource) void ( STDMETHODCALLTYPE *DiscardResource )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ ID3D12Resource *pResource, _In_opt_ const D3D12_DISCARD_REGION *pRegion); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginQuery) void ( STDMETHODCALLTYPE *BeginQuery )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ ID3D12QueryHeap *pQueryHeap, _In_ D3D12_QUERY_TYPE Type, _In_ UINT Index); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndQuery) void ( STDMETHODCALLTYPE *EndQuery )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ ID3D12QueryHeap *pQueryHeap, _In_ D3D12_QUERY_TYPE Type, _In_ UINT Index); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveQueryData) void ( STDMETHODCALLTYPE *ResolveQueryData )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ ID3D12QueryHeap *pQueryHeap, _In_ D3D12_QUERY_TYPE Type, _In_ UINT StartIndex, @@ -27922,32 +30749,32 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList5; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPredication) void ( STDMETHODCALLTYPE *SetPredication )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_opt_ ID3D12Resource *pBuffer, _In_ UINT64 AlignedBufferOffset, _In_ D3D12_PREDICATION_OP Operation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetMarker) void ( STDMETHODCALLTYPE *SetMarker )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, UINT Metadata, _In_reads_bytes_opt_(Size) const void *pData, UINT Size); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginEvent) void ( STDMETHODCALLTYPE *BeginEvent )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, UINT Metadata, _In_reads_bytes_opt_(Size) const void *pData, UINT Size); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndEvent) void ( STDMETHODCALLTYPE *EndEvent )( - ID3D12GraphicsCommandList5 * This); + ID3D12GraphicsCommandList6 * This); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteIndirect) void ( STDMETHODCALLTYPE *ExecuteIndirect )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ ID3D12CommandSignature *pCommandSignature, _In_ UINT MaxCommandCount, _In_ ID3D12Resource *pArgumentBuffer, @@ -27957,7 +30784,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList5; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT) void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ ID3D12Resource *pDstBuffer, UINT64 DstOffset, _In_ ID3D12Resource *pSrcBuffer, @@ -27968,7 +30795,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList5; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT64) void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT64 )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ ID3D12Resource *pDstBuffer, UINT64 DstOffset, _In_ ID3D12Resource *pSrcBuffer, @@ -27979,20 +30806,20 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList5; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, OMSetDepthBounds) void ( STDMETHODCALLTYPE *OMSetDepthBounds )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ FLOAT Min, _In_ FLOAT Max); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetSamplePositions) void ( STDMETHODCALLTYPE *SetSamplePositions )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT NumSamplesPerPixel, _In_ UINT NumPixels, _In_reads_(NumSamplesPerPixel*NumPixels) D3D12_SAMPLE_POSITION *pSamplePositions); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, ResolveSubresourceRegion) void ( STDMETHODCALLTYPE *ResolveSubresourceRegion )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ ID3D12Resource *pDstResource, _In_ UINT DstSubresource, _In_ UINT DstX, @@ -28005,24 +30832,24 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList5; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetViewInstanceMask) void ( STDMETHODCALLTYPE *SetViewInstanceMask )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT Mask); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList2, WriteBufferImmediate) void ( STDMETHODCALLTYPE *WriteBufferImmediate )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, UINT Count, _In_reads_(Count) const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER *pParams, _In_reads_opt_(Count) const D3D12_WRITEBUFFERIMMEDIATE_MODE *pModes); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList3, SetProtectedResourceSession) void ( STDMETHODCALLTYPE *SetProtectedResourceSession )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_opt_ ID3D12ProtectedResourceSession *pProtectedResourceSession); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BeginRenderPass) void ( STDMETHODCALLTYPE *BeginRenderPass )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ UINT NumRenderTargets, _In_reads_opt_(NumRenderTargets) const D3D12_RENDER_PASS_RENDER_TARGET_DESC *pRenderTargets, _In_opt_ const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *pDepthStencil, @@ -28030,70 +30857,77 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList5; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EndRenderPass) void ( STDMETHODCALLTYPE *EndRenderPass )( - ID3D12GraphicsCommandList5 * This); + ID3D12GraphicsCommandList6 * This); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, InitializeMetaCommand) void ( STDMETHODCALLTYPE *InitializeMetaCommand )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ ID3D12MetaCommand *pMetaCommand, _In_reads_bytes_opt_(InitializationParametersDataSizeInBytes) const void *pInitializationParametersData, _In_ SIZE_T InitializationParametersDataSizeInBytes); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, ExecuteMetaCommand) void ( STDMETHODCALLTYPE *ExecuteMetaCommand )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ ID3D12MetaCommand *pMetaCommand, _In_reads_bytes_opt_(ExecutionParametersDataSizeInBytes) const void *pExecutionParametersData, _In_ SIZE_T ExecutionParametersDataSizeInBytes); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BuildRaytracingAccelerationStructure) void ( STDMETHODCALLTYPE *BuildRaytracingAccelerationStructure )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC *pDesc, _In_ UINT NumPostbuildInfoDescs, _In_reads_opt_(NumPostbuildInfoDescs) const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pPostbuildInfoDescs); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EmitRaytracingAccelerationStructurePostbuildInfo) void ( STDMETHODCALLTYPE *EmitRaytracingAccelerationStructurePostbuildInfo )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pDesc, _In_ UINT NumSourceAccelerationStructures, _In_reads_( NumSourceAccelerationStructures ) const D3D12_GPU_VIRTUAL_ADDRESS *pSourceAccelerationStructureData); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, CopyRaytracingAccelerationStructure) void ( STDMETHODCALLTYPE *CopyRaytracingAccelerationStructure )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ D3D12_GPU_VIRTUAL_ADDRESS DestAccelerationStructureData, _In_ D3D12_GPU_VIRTUAL_ADDRESS SourceAccelerationStructureData, _In_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE Mode); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, SetPipelineState1) void ( STDMETHODCALLTYPE *SetPipelineState1 )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ ID3D12StateObject *pStateObject); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, DispatchRays) void ( STDMETHODCALLTYPE *DispatchRays )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ const D3D12_DISPATCH_RAYS_DESC *pDesc); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRate) void ( STDMETHODCALLTYPE *RSSetShadingRate )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_ D3D12_SHADING_RATE baseShadingRate, _In_reads_opt_(D3D12_RS_SET_SHADING_RATE_COMBINER_COUNT) const D3D12_SHADING_RATE_COMBINER *combiners); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRateImage) void ( STDMETHODCALLTYPE *RSSetShadingRateImage )( - ID3D12GraphicsCommandList5 * This, + ID3D12GraphicsCommandList6 * This, _In_opt_ ID3D12Resource *shadingRateImage); + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList6, DispatchMesh) + void ( STDMETHODCALLTYPE *DispatchMesh )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ); + END_INTERFACE - } ID3D12GraphicsCommandList5Vtbl; + } ID3D12GraphicsCommandList6Vtbl; - interface ID3D12GraphicsCommandList5 + interface ID3D12GraphicsCommandList6 { - CONST_VTBL struct ID3D12GraphicsCommandList5Vtbl *lpVtbl; + CONST_VTBL struct ID3D12GraphicsCommandList6Vtbl *lpVtbl; }; @@ -28101,374 +30935,362 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList5; #ifdef COBJMACROS -#define ID3D12GraphicsCommandList5_QueryInterface(This,riid,ppvObject) \ +#define ID3D12GraphicsCommandList6_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) -#define ID3D12GraphicsCommandList5_AddRef(This) \ +#define ID3D12GraphicsCommandList6_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) -#define ID3D12GraphicsCommandList5_Release(This) \ +#define ID3D12GraphicsCommandList6_Release(This) \ ( (This)->lpVtbl -> Release(This) ) -#define ID3D12GraphicsCommandList5_GetPrivateData(This,guid,pDataSize,pData) \ +#define ID3D12GraphicsCommandList6_GetPrivateData(This,guid,pDataSize,pData) \ ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) -#define ID3D12GraphicsCommandList5_SetPrivateData(This,guid,DataSize,pData) \ +#define ID3D12GraphicsCommandList6_SetPrivateData(This,guid,DataSize,pData) \ ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) -#define ID3D12GraphicsCommandList5_SetPrivateDataInterface(This,guid,pData) \ +#define ID3D12GraphicsCommandList6_SetPrivateDataInterface(This,guid,pData) \ ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) -#define ID3D12GraphicsCommandList5_SetName(This,Name) \ +#define ID3D12GraphicsCommandList6_SetName(This,Name) \ ( (This)->lpVtbl -> SetName(This,Name) ) -#define ID3D12GraphicsCommandList5_GetDevice(This,riid,ppvDevice) \ +#define ID3D12GraphicsCommandList6_GetDevice(This,riid,ppvDevice) \ ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) -#define ID3D12GraphicsCommandList5_GetType(This) \ +#define ID3D12GraphicsCommandList6_GetType(This) \ ( (This)->lpVtbl -> GetType(This) ) -#define ID3D12GraphicsCommandList5_Close(This) \ +#define ID3D12GraphicsCommandList6_Close(This) \ ( (This)->lpVtbl -> Close(This) ) -#define ID3D12GraphicsCommandList5_Reset(This,pAllocator,pInitialState) \ +#define ID3D12GraphicsCommandList6_Reset(This,pAllocator,pInitialState) \ ( (This)->lpVtbl -> Reset(This,pAllocator,pInitialState) ) -#define ID3D12GraphicsCommandList5_ClearState(This,pPipelineState) \ +#define ID3D12GraphicsCommandList6_ClearState(This,pPipelineState) \ ( (This)->lpVtbl -> ClearState(This,pPipelineState) ) -#define ID3D12GraphicsCommandList5_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ +#define ID3D12GraphicsCommandList6_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ ( (This)->lpVtbl -> DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) -#define ID3D12GraphicsCommandList5_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ +#define ID3D12GraphicsCommandList6_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ ( (This)->lpVtbl -> DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) -#define ID3D12GraphicsCommandList5_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ +#define ID3D12GraphicsCommandList6_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ ( (This)->lpVtbl -> Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) -#define ID3D12GraphicsCommandList5_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ +#define ID3D12GraphicsCommandList6_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ ( (This)->lpVtbl -> CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) -#define ID3D12GraphicsCommandList5_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ +#define ID3D12GraphicsCommandList6_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ ( (This)->lpVtbl -> CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) -#define ID3D12GraphicsCommandList5_CopyResource(This,pDstResource,pSrcResource) \ +#define ID3D12GraphicsCommandList6_CopyResource(This,pDstResource,pSrcResource) \ ( (This)->lpVtbl -> CopyResource(This,pDstResource,pSrcResource) ) -#define ID3D12GraphicsCommandList5_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ +#define ID3D12GraphicsCommandList6_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ ( (This)->lpVtbl -> CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) -#define ID3D12GraphicsCommandList5_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ +#define ID3D12GraphicsCommandList6_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ ( (This)->lpVtbl -> ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) -#define ID3D12GraphicsCommandList5_IASetPrimitiveTopology(This,PrimitiveTopology) \ +#define ID3D12GraphicsCommandList6_IASetPrimitiveTopology(This,PrimitiveTopology) \ ( (This)->lpVtbl -> IASetPrimitiveTopology(This,PrimitiveTopology) ) -#define ID3D12GraphicsCommandList5_RSSetViewports(This,NumViewports,pViewports) \ +#define ID3D12GraphicsCommandList6_RSSetViewports(This,NumViewports,pViewports) \ ( (This)->lpVtbl -> RSSetViewports(This,NumViewports,pViewports) ) -#define ID3D12GraphicsCommandList5_RSSetScissorRects(This,NumRects,pRects) \ +#define ID3D12GraphicsCommandList6_RSSetScissorRects(This,NumRects,pRects) \ ( (This)->lpVtbl -> RSSetScissorRects(This,NumRects,pRects) ) -#define ID3D12GraphicsCommandList5_OMSetBlendFactor(This,BlendFactor) \ +#define ID3D12GraphicsCommandList6_OMSetBlendFactor(This,BlendFactor) \ ( (This)->lpVtbl -> OMSetBlendFactor(This,BlendFactor) ) -#define ID3D12GraphicsCommandList5_OMSetStencilRef(This,StencilRef) \ +#define ID3D12GraphicsCommandList6_OMSetStencilRef(This,StencilRef) \ ( (This)->lpVtbl -> OMSetStencilRef(This,StencilRef) ) -#define ID3D12GraphicsCommandList5_SetPipelineState(This,pPipelineState) \ +#define ID3D12GraphicsCommandList6_SetPipelineState(This,pPipelineState) \ ( (This)->lpVtbl -> SetPipelineState(This,pPipelineState) ) -#define ID3D12GraphicsCommandList5_ResourceBarrier(This,NumBarriers,pBarriers) \ +#define ID3D12GraphicsCommandList6_ResourceBarrier(This,NumBarriers,pBarriers) \ ( (This)->lpVtbl -> ResourceBarrier(This,NumBarriers,pBarriers) ) -#define ID3D12GraphicsCommandList5_ExecuteBundle(This,pCommandList) \ +#define ID3D12GraphicsCommandList6_ExecuteBundle(This,pCommandList) \ ( (This)->lpVtbl -> ExecuteBundle(This,pCommandList) ) -#define ID3D12GraphicsCommandList5_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ +#define ID3D12GraphicsCommandList6_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ ( (This)->lpVtbl -> SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) ) -#define ID3D12GraphicsCommandList5_SetComputeRootSignature(This,pRootSignature) \ +#define ID3D12GraphicsCommandList6_SetComputeRootSignature(This,pRootSignature) \ ( (This)->lpVtbl -> SetComputeRootSignature(This,pRootSignature) ) -#define ID3D12GraphicsCommandList5_SetGraphicsRootSignature(This,pRootSignature) \ +#define ID3D12GraphicsCommandList6_SetGraphicsRootSignature(This,pRootSignature) \ ( (This)->lpVtbl -> SetGraphicsRootSignature(This,pRootSignature) ) -#define ID3D12GraphicsCommandList5_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ +#define ID3D12GraphicsCommandList6_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ ( (This)->lpVtbl -> SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) -#define ID3D12GraphicsCommandList5_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ +#define ID3D12GraphicsCommandList6_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ ( (This)->lpVtbl -> SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) -#define ID3D12GraphicsCommandList5_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ +#define ID3D12GraphicsCommandList6_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ ( (This)->lpVtbl -> SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) -#define ID3D12GraphicsCommandList5_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ +#define ID3D12GraphicsCommandList6_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ ( (This)->lpVtbl -> SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) -#define ID3D12GraphicsCommandList5_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ +#define ID3D12GraphicsCommandList6_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ ( (This)->lpVtbl -> SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) -#define ID3D12GraphicsCommandList5_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ +#define ID3D12GraphicsCommandList6_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ ( (This)->lpVtbl -> SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) -#define ID3D12GraphicsCommandList5_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList6_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList5_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList6_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList5_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList6_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList5_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList6_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList5_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList6_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList5_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList6_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList5_IASetIndexBuffer(This,pView) \ +#define ID3D12GraphicsCommandList6_IASetIndexBuffer(This,pView) \ ( (This)->lpVtbl -> IASetIndexBuffer(This,pView) ) -#define ID3D12GraphicsCommandList5_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ +#define ID3D12GraphicsCommandList6_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ ( (This)->lpVtbl -> IASetVertexBuffers(This,StartSlot,NumViews,pViews) ) -#define ID3D12GraphicsCommandList5_SOSetTargets(This,StartSlot,NumViews,pViews) \ +#define ID3D12GraphicsCommandList6_SOSetTargets(This,StartSlot,NumViews,pViews) \ ( (This)->lpVtbl -> SOSetTargets(This,StartSlot,NumViews,pViews) ) -#define ID3D12GraphicsCommandList5_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ +#define ID3D12GraphicsCommandList6_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ ( (This)->lpVtbl -> OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) -#define ID3D12GraphicsCommandList5_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ +#define ID3D12GraphicsCommandList6_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ ( (This)->lpVtbl -> ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) -#define ID3D12GraphicsCommandList5_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ +#define ID3D12GraphicsCommandList6_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ ( (This)->lpVtbl -> ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) ) -#define ID3D12GraphicsCommandList5_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ +#define ID3D12GraphicsCommandList6_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ ( (This)->lpVtbl -> ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) -#define ID3D12GraphicsCommandList5_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ +#define ID3D12GraphicsCommandList6_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ ( (This)->lpVtbl -> ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) -#define ID3D12GraphicsCommandList5_DiscardResource(This,pResource,pRegion) \ +#define ID3D12GraphicsCommandList6_DiscardResource(This,pResource,pRegion) \ ( (This)->lpVtbl -> DiscardResource(This,pResource,pRegion) ) -#define ID3D12GraphicsCommandList5_BeginQuery(This,pQueryHeap,Type,Index) \ +#define ID3D12GraphicsCommandList6_BeginQuery(This,pQueryHeap,Type,Index) \ ( (This)->lpVtbl -> BeginQuery(This,pQueryHeap,Type,Index) ) -#define ID3D12GraphicsCommandList5_EndQuery(This,pQueryHeap,Type,Index) \ +#define ID3D12GraphicsCommandList6_EndQuery(This,pQueryHeap,Type,Index) \ ( (This)->lpVtbl -> EndQuery(This,pQueryHeap,Type,Index) ) -#define ID3D12GraphicsCommandList5_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ +#define ID3D12GraphicsCommandList6_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ ( (This)->lpVtbl -> ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) -#define ID3D12GraphicsCommandList5_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ +#define ID3D12GraphicsCommandList6_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ ( (This)->lpVtbl -> SetPredication(This,pBuffer,AlignedBufferOffset,Operation) ) -#define ID3D12GraphicsCommandList5_SetMarker(This,Metadata,pData,Size) \ +#define ID3D12GraphicsCommandList6_SetMarker(This,Metadata,pData,Size) \ ( (This)->lpVtbl -> SetMarker(This,Metadata,pData,Size) ) -#define ID3D12GraphicsCommandList5_BeginEvent(This,Metadata,pData,Size) \ +#define ID3D12GraphicsCommandList6_BeginEvent(This,Metadata,pData,Size) \ ( (This)->lpVtbl -> BeginEvent(This,Metadata,pData,Size) ) -#define ID3D12GraphicsCommandList5_EndEvent(This) \ +#define ID3D12GraphicsCommandList6_EndEvent(This) \ ( (This)->lpVtbl -> EndEvent(This) ) -#define ID3D12GraphicsCommandList5_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ +#define ID3D12GraphicsCommandList6_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ ( (This)->lpVtbl -> ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) -#define ID3D12GraphicsCommandList5_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ +#define ID3D12GraphicsCommandList6_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ ( (This)->lpVtbl -> AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) -#define ID3D12GraphicsCommandList5_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ +#define ID3D12GraphicsCommandList6_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ ( (This)->lpVtbl -> AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) -#define ID3D12GraphicsCommandList5_OMSetDepthBounds(This,Min,Max) \ +#define ID3D12GraphicsCommandList6_OMSetDepthBounds(This,Min,Max) \ ( (This)->lpVtbl -> OMSetDepthBounds(This,Min,Max) ) -#define ID3D12GraphicsCommandList5_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ +#define ID3D12GraphicsCommandList6_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ ( (This)->lpVtbl -> SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) ) -#define ID3D12GraphicsCommandList5_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ +#define ID3D12GraphicsCommandList6_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ ( (This)->lpVtbl -> ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) -#define ID3D12GraphicsCommandList5_SetViewInstanceMask(This,Mask) \ +#define ID3D12GraphicsCommandList6_SetViewInstanceMask(This,Mask) \ ( (This)->lpVtbl -> SetViewInstanceMask(This,Mask) ) -#define ID3D12GraphicsCommandList5_WriteBufferImmediate(This,Count,pParams,pModes) \ +#define ID3D12GraphicsCommandList6_WriteBufferImmediate(This,Count,pParams,pModes) \ ( (This)->lpVtbl -> WriteBufferImmediate(This,Count,pParams,pModes) ) -#define ID3D12GraphicsCommandList5_SetProtectedResourceSession(This,pProtectedResourceSession) \ +#define ID3D12GraphicsCommandList6_SetProtectedResourceSession(This,pProtectedResourceSession) \ ( (This)->lpVtbl -> SetProtectedResourceSession(This,pProtectedResourceSession) ) -#define ID3D12GraphicsCommandList5_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ +#define ID3D12GraphicsCommandList6_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ ( (This)->lpVtbl -> BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) ) -#define ID3D12GraphicsCommandList5_EndRenderPass(This) \ +#define ID3D12GraphicsCommandList6_EndRenderPass(This) \ ( (This)->lpVtbl -> EndRenderPass(This) ) -#define ID3D12GraphicsCommandList5_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ +#define ID3D12GraphicsCommandList6_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ ( (This)->lpVtbl -> InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) ) -#define ID3D12GraphicsCommandList5_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ +#define ID3D12GraphicsCommandList6_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ ( (This)->lpVtbl -> ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) ) -#define ID3D12GraphicsCommandList5_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ +#define ID3D12GraphicsCommandList6_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ ( (This)->lpVtbl -> BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) ) -#define ID3D12GraphicsCommandList5_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ +#define ID3D12GraphicsCommandList6_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ ( (This)->lpVtbl -> EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) ) -#define ID3D12GraphicsCommandList5_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ +#define ID3D12GraphicsCommandList6_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ ( (This)->lpVtbl -> CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) ) -#define ID3D12GraphicsCommandList5_SetPipelineState1(This,pStateObject) \ +#define ID3D12GraphicsCommandList6_SetPipelineState1(This,pStateObject) \ ( (This)->lpVtbl -> SetPipelineState1(This,pStateObject) ) -#define ID3D12GraphicsCommandList5_DispatchRays(This,pDesc) \ +#define ID3D12GraphicsCommandList6_DispatchRays(This,pDesc) \ ( (This)->lpVtbl -> DispatchRays(This,pDesc) ) -#define ID3D12GraphicsCommandList5_RSSetShadingRate(This,baseShadingRate,combiners) \ +#define ID3D12GraphicsCommandList6_RSSetShadingRate(This,baseShadingRate,combiners) \ ( (This)->lpVtbl -> RSSetShadingRate(This,baseShadingRate,combiners) ) -#define ID3D12GraphicsCommandList5_RSSetShadingRateImage(This,shadingRateImage) \ +#define ID3D12GraphicsCommandList6_RSSetShadingRateImage(This,shadingRateImage) \ ( (This)->lpVtbl -> RSSetShadingRateImage(This,shadingRateImage) ) -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - +#define ID3D12GraphicsCommandList6_DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->lpVtbl -> DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) +#endif /* COBJMACROS */ -#endif /* __ID3D12GraphicsCommandList5_INTERFACE_DEFINED__ */ +#endif /* C style interface */ -/* interface __MIDL_itf_d3d12_0000_0064 */ -/* [local] */ -typedef struct D3D12_DISPATCH_MESH_ARGUMENTS - { - UINT ThreadGroupCountX; - UINT ThreadGroupCountY; - UINT ThreadGroupCountZ; - } D3D12_DISPATCH_MESH_ARGUMENTS; +#endif /* __ID3D12GraphicsCommandList6_INTERFACE_DEFINED__ */ -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0064_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0064_v0_0_s_ifspec; -#ifndef __ID3D12GraphicsCommandList6_INTERFACE_DEFINED__ -#define __ID3D12GraphicsCommandList6_INTERFACE_DEFINED__ +#ifndef __ID3D12GraphicsCommandList7_INTERFACE_DEFINED__ +#define __ID3D12GraphicsCommandList7_INTERFACE_DEFINED__ -/* interface ID3D12GraphicsCommandList6 */ +/* interface ID3D12GraphicsCommandList7 */ /* [unique][local][object][uuid] */ -EXTERN_C const IID IID_ID3D12GraphicsCommandList6; +EXTERN_C const IID IID_ID3D12GraphicsCommandList7; #if defined(__cplusplus) && !defined(CINTERFACE) - MIDL_INTERFACE("c3827890-e548-4cfa-96cf-5689a9370f80") - ID3D12GraphicsCommandList6 : public ID3D12GraphicsCommandList5 + MIDL_INTERFACE("dd171223-8b61-4769-90e3-160ccde4e2c1") + ID3D12GraphicsCommandList7 : public ID3D12GraphicsCommandList6 { public: - virtual void STDMETHODCALLTYPE DispatchMesh( - _In_ UINT ThreadGroupCountX, - _In_ UINT ThreadGroupCountY, - _In_ UINT ThreadGroupCountZ) = 0; + virtual void STDMETHODCALLTYPE Barrier( + UINT32 NumBarrierGroups, + _In_reads_(NumBarrierGroups) const D3D12_BARRIER_GROUP *pBarrierGroups) = 0; }; #else /* C style interface */ - typedef struct ID3D12GraphicsCommandList6Vtbl + typedef struct ID3D12GraphicsCommandList7Vtbl { BEGIN_INTERFACE DECLSPEC_XFGVIRT(IUnknown, QueryInterface) HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, REFIID riid, _COM_Outptr_ void **ppvObject); DECLSPEC_XFGVIRT(IUnknown, AddRef) ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D12GraphicsCommandList6 * This); + ID3D12GraphicsCommandList7 * This); DECLSPEC_XFGVIRT(IUnknown, Release) ULONG ( STDMETHODCALLTYPE *Release )( - ID3D12GraphicsCommandList6 * This); + ID3D12GraphicsCommandList7 * This); DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ REFGUID guid, _Inout_ UINT *pDataSize, _Out_writes_bytes_opt_( *pDataSize ) void *pData); DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ REFGUID guid, _In_ UINT DataSize, _In_reads_bytes_opt_( DataSize ) const void *pData); DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ REFGUID guid, _In_opt_ const IUnknown *pData); DECLSPEC_XFGVIRT(ID3D12Object, SetName) HRESULT ( STDMETHODCALLTYPE *SetName )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_z_ LPCWSTR Name); DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) HRESULT ( STDMETHODCALLTYPE *GetDevice )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, REFIID riid, _COM_Outptr_opt_ void **ppvDevice); DECLSPEC_XFGVIRT(ID3D12CommandList, GetType) D3D12_COMMAND_LIST_TYPE ( STDMETHODCALLTYPE *GetType )( - ID3D12GraphicsCommandList6 * This); + ID3D12GraphicsCommandList7 * This); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Close) HRESULT ( STDMETHODCALLTYPE *Close )( - ID3D12GraphicsCommandList6 * This); + ID3D12GraphicsCommandList7 * This); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Reset) HRESULT ( STDMETHODCALLTYPE *Reset )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ ID3D12CommandAllocator *pAllocator, _In_opt_ ID3D12PipelineState *pInitialState); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearState) void ( STDMETHODCALLTYPE *ClearState )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_opt_ ID3D12PipelineState *pPipelineState); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawInstanced) void ( STDMETHODCALLTYPE *DrawInstanced )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT VertexCountPerInstance, _In_ UINT InstanceCount, _In_ UINT StartVertexLocation, @@ -28476,7 +31298,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawIndexedInstanced) void ( STDMETHODCALLTYPE *DrawIndexedInstanced )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT IndexCountPerInstance, _In_ UINT InstanceCount, _In_ UINT StartIndexLocation, @@ -28485,14 +31307,14 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Dispatch) void ( STDMETHODCALLTYPE *Dispatch )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT ThreadGroupCountX, _In_ UINT ThreadGroupCountY, _In_ UINT ThreadGroupCountZ); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyBufferRegion) void ( STDMETHODCALLTYPE *CopyBufferRegion )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ ID3D12Resource *pDstBuffer, UINT64 DstOffset, _In_ ID3D12Resource *pSrcBuffer, @@ -28501,7 +31323,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTextureRegion) void ( STDMETHODCALLTYPE *CopyTextureRegion )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ const D3D12_TEXTURE_COPY_LOCATION *pDst, UINT DstX, UINT DstY, @@ -28511,13 +31333,13 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyResource) void ( STDMETHODCALLTYPE *CopyResource )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ ID3D12Resource *pDstResource, _In_ ID3D12Resource *pSrcResource); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTiles) void ( STDMETHODCALLTYPE *CopyTiles )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ ID3D12Resource *pTiledResource, _In_ const D3D12_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate, _In_ const D3D12_TILE_REGION_SIZE *pTileRegionSize, @@ -28527,7 +31349,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveSubresource) void ( STDMETHODCALLTYPE *ResolveSubresource )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ ID3D12Resource *pDstResource, _In_ UINT DstSubresource, _In_ ID3D12Resource *pSrcResource, @@ -28536,92 +31358,92 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetPrimitiveTopology) void ( STDMETHODCALLTYPE *IASetPrimitiveTopology )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetViewports) void ( STDMETHODCALLTYPE *RSSetViewports )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports, _In_reads_( NumViewports) const D3D12_VIEWPORT *pViewports); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetScissorRects) void ( STDMETHODCALLTYPE *RSSetScissorRects )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects, _In_reads_( NumRects) const D3D12_RECT *pRects); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetBlendFactor) void ( STDMETHODCALLTYPE *OMSetBlendFactor )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_reads_opt_(4) const FLOAT BlendFactor[ 4 ]); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetStencilRef) void ( STDMETHODCALLTYPE *OMSetStencilRef )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT StencilRef); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPipelineState) void ( STDMETHODCALLTYPE *SetPipelineState )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ ID3D12PipelineState *pPipelineState); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResourceBarrier) void ( STDMETHODCALLTYPE *ResourceBarrier )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT NumBarriers, _In_reads_(NumBarriers) const D3D12_RESOURCE_BARRIER *pBarriers); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteBundle) void ( STDMETHODCALLTYPE *ExecuteBundle )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ ID3D12GraphicsCommandList *pCommandList); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetDescriptorHeaps) void ( STDMETHODCALLTYPE *SetDescriptorHeaps )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT NumDescriptorHeaps, _In_reads_(NumDescriptorHeaps) ID3D12DescriptorHeap *const *ppDescriptorHeaps); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootSignature) void ( STDMETHODCALLTYPE *SetComputeRootSignature )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_opt_ ID3D12RootSignature *pRootSignature); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootSignature) void ( STDMETHODCALLTYPE *SetGraphicsRootSignature )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_opt_ ID3D12RootSignature *pRootSignature); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootDescriptorTable) void ( STDMETHODCALLTYPE *SetComputeRootDescriptorTable )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootDescriptorTable) void ( STDMETHODCALLTYPE *SetGraphicsRootDescriptorTable )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstant) void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstant )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT RootParameterIndex, _In_ UINT SrcData, _In_ UINT DestOffsetIn32BitValues); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstant) void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstant )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT RootParameterIndex, _In_ UINT SrcData, _In_ UINT DestOffsetIn32BitValues); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstants) void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstants )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT RootParameterIndex, _In_ UINT Num32BitValuesToSet, _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, @@ -28629,7 +31451,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstants) void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstants )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT RootParameterIndex, _In_ UINT Num32BitValuesToSet, _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, @@ -28637,62 +31459,62 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootConstantBufferView) void ( STDMETHODCALLTYPE *SetComputeRootConstantBufferView )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootConstantBufferView) void ( STDMETHODCALLTYPE *SetGraphicsRootConstantBufferView )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootShaderResourceView) void ( STDMETHODCALLTYPE *SetComputeRootShaderResourceView )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootShaderResourceView) void ( STDMETHODCALLTYPE *SetGraphicsRootShaderResourceView )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootUnorderedAccessView) void ( STDMETHODCALLTYPE *SetComputeRootUnorderedAccessView )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootUnorderedAccessView) void ( STDMETHODCALLTYPE *SetGraphicsRootUnorderedAccessView )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetIndexBuffer) void ( STDMETHODCALLTYPE *IASetIndexBuffer )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_opt_ const D3D12_INDEX_BUFFER_VIEW *pView); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetVertexBuffers) void ( STDMETHODCALLTYPE *IASetVertexBuffers )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT StartSlot, _In_ UINT NumViews, _In_reads_opt_(NumViews) const D3D12_VERTEX_BUFFER_VIEW *pViews); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SOSetTargets) void ( STDMETHODCALLTYPE *SOSetTargets )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT StartSlot, _In_ UINT NumViews, _In_reads_opt_(NumViews) const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetRenderTargets) void ( STDMETHODCALLTYPE *OMSetRenderTargets )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT NumRenderTargetDescriptors, _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors, _In_ BOOL RTsSingleHandleToDescriptorRange, @@ -28700,7 +31522,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearDepthStencilView) void ( STDMETHODCALLTYPE *ClearDepthStencilView )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, _In_ D3D12_CLEAR_FLAGS ClearFlags, _In_ FLOAT Depth, @@ -28710,7 +31532,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearRenderTargetView) void ( STDMETHODCALLTYPE *ClearRenderTargetView )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, _In_ const FLOAT ColorRGBA[ 4 ], _In_ UINT NumRects, @@ -28718,7 +31540,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewUint) void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewUint )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, _In_ ID3D12Resource *pResource, @@ -28728,7 +31550,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewFloat) void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewFloat )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, _In_ ID3D12Resource *pResource, @@ -28738,27 +31560,27 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DiscardResource) void ( STDMETHODCALLTYPE *DiscardResource )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ ID3D12Resource *pResource, _In_opt_ const D3D12_DISCARD_REGION *pRegion); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginQuery) void ( STDMETHODCALLTYPE *BeginQuery )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ ID3D12QueryHeap *pQueryHeap, _In_ D3D12_QUERY_TYPE Type, _In_ UINT Index); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndQuery) void ( STDMETHODCALLTYPE *EndQuery )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ ID3D12QueryHeap *pQueryHeap, _In_ D3D12_QUERY_TYPE Type, _In_ UINT Index); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveQueryData) void ( STDMETHODCALLTYPE *ResolveQueryData )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ ID3D12QueryHeap *pQueryHeap, _In_ D3D12_QUERY_TYPE Type, _In_ UINT StartIndex, @@ -28768,32 +31590,32 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPredication) void ( STDMETHODCALLTYPE *SetPredication )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_opt_ ID3D12Resource *pBuffer, _In_ UINT64 AlignedBufferOffset, _In_ D3D12_PREDICATION_OP Operation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetMarker) void ( STDMETHODCALLTYPE *SetMarker )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, UINT Metadata, _In_reads_bytes_opt_(Size) const void *pData, UINT Size); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginEvent) void ( STDMETHODCALLTYPE *BeginEvent )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, UINT Metadata, _In_reads_bytes_opt_(Size) const void *pData, UINT Size); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndEvent) void ( STDMETHODCALLTYPE *EndEvent )( - ID3D12GraphicsCommandList6 * This); + ID3D12GraphicsCommandList7 * This); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteIndirect) void ( STDMETHODCALLTYPE *ExecuteIndirect )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ ID3D12CommandSignature *pCommandSignature, _In_ UINT MaxCommandCount, _In_ ID3D12Resource *pArgumentBuffer, @@ -28803,7 +31625,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT) void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ ID3D12Resource *pDstBuffer, UINT64 DstOffset, _In_ ID3D12Resource *pSrcBuffer, @@ -28814,7 +31636,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT64) void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT64 )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ ID3D12Resource *pDstBuffer, UINT64 DstOffset, _In_ ID3D12Resource *pSrcBuffer, @@ -28825,20 +31647,20 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, OMSetDepthBounds) void ( STDMETHODCALLTYPE *OMSetDepthBounds )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ FLOAT Min, _In_ FLOAT Max); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetSamplePositions) void ( STDMETHODCALLTYPE *SetSamplePositions )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT NumSamplesPerPixel, _In_ UINT NumPixels, _In_reads_(NumSamplesPerPixel*NumPixels) D3D12_SAMPLE_POSITION *pSamplePositions); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, ResolveSubresourceRegion) void ( STDMETHODCALLTYPE *ResolveSubresourceRegion )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ ID3D12Resource *pDstResource, _In_ UINT DstSubresource, _In_ UINT DstX, @@ -28851,24 +31673,24 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetViewInstanceMask) void ( STDMETHODCALLTYPE *SetViewInstanceMask )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT Mask); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList2, WriteBufferImmediate) void ( STDMETHODCALLTYPE *WriteBufferImmediate )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, UINT Count, _In_reads_(Count) const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER *pParams, _In_reads_opt_(Count) const D3D12_WRITEBUFFERIMMEDIATE_MODE *pModes); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList3, SetProtectedResourceSession) void ( STDMETHODCALLTYPE *SetProtectedResourceSession )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_opt_ ID3D12ProtectedResourceSession *pProtectedResourceSession); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BeginRenderPass) void ( STDMETHODCALLTYPE *BeginRenderPass )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT NumRenderTargets, _In_reads_opt_(NumRenderTargets) const D3D12_RENDER_PASS_RENDER_TARGET_DESC *pRenderTargets, _In_opt_ const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *pDepthStencil, @@ -28876,77 +31698,83 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EndRenderPass) void ( STDMETHODCALLTYPE *EndRenderPass )( - ID3D12GraphicsCommandList6 * This); + ID3D12GraphicsCommandList7 * This); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, InitializeMetaCommand) void ( STDMETHODCALLTYPE *InitializeMetaCommand )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ ID3D12MetaCommand *pMetaCommand, _In_reads_bytes_opt_(InitializationParametersDataSizeInBytes) const void *pInitializationParametersData, _In_ SIZE_T InitializationParametersDataSizeInBytes); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, ExecuteMetaCommand) void ( STDMETHODCALLTYPE *ExecuteMetaCommand )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ ID3D12MetaCommand *pMetaCommand, _In_reads_bytes_opt_(ExecutionParametersDataSizeInBytes) const void *pExecutionParametersData, _In_ SIZE_T ExecutionParametersDataSizeInBytes); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BuildRaytracingAccelerationStructure) void ( STDMETHODCALLTYPE *BuildRaytracingAccelerationStructure )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC *pDesc, _In_ UINT NumPostbuildInfoDescs, _In_reads_opt_(NumPostbuildInfoDescs) const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pPostbuildInfoDescs); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EmitRaytracingAccelerationStructurePostbuildInfo) void ( STDMETHODCALLTYPE *EmitRaytracingAccelerationStructurePostbuildInfo )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pDesc, _In_ UINT NumSourceAccelerationStructures, _In_reads_( NumSourceAccelerationStructures ) const D3D12_GPU_VIRTUAL_ADDRESS *pSourceAccelerationStructureData); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, CopyRaytracingAccelerationStructure) void ( STDMETHODCALLTYPE *CopyRaytracingAccelerationStructure )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ D3D12_GPU_VIRTUAL_ADDRESS DestAccelerationStructureData, _In_ D3D12_GPU_VIRTUAL_ADDRESS SourceAccelerationStructureData, _In_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE Mode); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, SetPipelineState1) void ( STDMETHODCALLTYPE *SetPipelineState1 )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ ID3D12StateObject *pStateObject); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, DispatchRays) void ( STDMETHODCALLTYPE *DispatchRays )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ const D3D12_DISPATCH_RAYS_DESC *pDesc); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRate) void ( STDMETHODCALLTYPE *RSSetShadingRate )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ D3D12_SHADING_RATE baseShadingRate, _In_reads_opt_(D3D12_RS_SET_SHADING_RATE_COMBINER_COUNT) const D3D12_SHADING_RATE_COMBINER *combiners); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRateImage) void ( STDMETHODCALLTYPE *RSSetShadingRateImage )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_opt_ ID3D12Resource *shadingRateImage); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList6, DispatchMesh) void ( STDMETHODCALLTYPE *DispatchMesh )( - ID3D12GraphicsCommandList6 * This, + ID3D12GraphicsCommandList7 * This, _In_ UINT ThreadGroupCountX, _In_ UINT ThreadGroupCountY, _In_ UINT ThreadGroupCountZ); + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList7, Barrier) + void ( STDMETHODCALLTYPE *Barrier )( + ID3D12GraphicsCommandList7 * This, + UINT32 NumBarrierGroups, + _In_reads_(NumBarrierGroups) const D3D12_BARRIER_GROUP *pBarrierGroups); + END_INTERFACE - } ID3D12GraphicsCommandList6Vtbl; + } ID3D12GraphicsCommandList7Vtbl; - interface ID3D12GraphicsCommandList6 + interface ID3D12GraphicsCommandList7 { - CONST_VTBL struct ID3D12GraphicsCommandList6Vtbl *lpVtbl; + CONST_VTBL struct ID3D12GraphicsCommandList7Vtbl *lpVtbl; }; @@ -28954,255 +31782,259 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; #ifdef COBJMACROS -#define ID3D12GraphicsCommandList6_QueryInterface(This,riid,ppvObject) \ +#define ID3D12GraphicsCommandList7_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) -#define ID3D12GraphicsCommandList6_AddRef(This) \ +#define ID3D12GraphicsCommandList7_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) -#define ID3D12GraphicsCommandList6_Release(This) \ +#define ID3D12GraphicsCommandList7_Release(This) \ ( (This)->lpVtbl -> Release(This) ) -#define ID3D12GraphicsCommandList6_GetPrivateData(This,guid,pDataSize,pData) \ +#define ID3D12GraphicsCommandList7_GetPrivateData(This,guid,pDataSize,pData) \ ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) -#define ID3D12GraphicsCommandList6_SetPrivateData(This,guid,DataSize,pData) \ +#define ID3D12GraphicsCommandList7_SetPrivateData(This,guid,DataSize,pData) \ ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) -#define ID3D12GraphicsCommandList6_SetPrivateDataInterface(This,guid,pData) \ +#define ID3D12GraphicsCommandList7_SetPrivateDataInterface(This,guid,pData) \ ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) -#define ID3D12GraphicsCommandList6_SetName(This,Name) \ +#define ID3D12GraphicsCommandList7_SetName(This,Name) \ ( (This)->lpVtbl -> SetName(This,Name) ) -#define ID3D12GraphicsCommandList6_GetDevice(This,riid,ppvDevice) \ +#define ID3D12GraphicsCommandList7_GetDevice(This,riid,ppvDevice) \ ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) -#define ID3D12GraphicsCommandList6_GetType(This) \ +#define ID3D12GraphicsCommandList7_GetType(This) \ ( (This)->lpVtbl -> GetType(This) ) -#define ID3D12GraphicsCommandList6_Close(This) \ +#define ID3D12GraphicsCommandList7_Close(This) \ ( (This)->lpVtbl -> Close(This) ) -#define ID3D12GraphicsCommandList6_Reset(This,pAllocator,pInitialState) \ +#define ID3D12GraphicsCommandList7_Reset(This,pAllocator,pInitialState) \ ( (This)->lpVtbl -> Reset(This,pAllocator,pInitialState) ) -#define ID3D12GraphicsCommandList6_ClearState(This,pPipelineState) \ +#define ID3D12GraphicsCommandList7_ClearState(This,pPipelineState) \ ( (This)->lpVtbl -> ClearState(This,pPipelineState) ) -#define ID3D12GraphicsCommandList6_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ +#define ID3D12GraphicsCommandList7_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ ( (This)->lpVtbl -> DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) -#define ID3D12GraphicsCommandList6_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ +#define ID3D12GraphicsCommandList7_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ ( (This)->lpVtbl -> DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) -#define ID3D12GraphicsCommandList6_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ +#define ID3D12GraphicsCommandList7_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ ( (This)->lpVtbl -> Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) -#define ID3D12GraphicsCommandList6_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ +#define ID3D12GraphicsCommandList7_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ ( (This)->lpVtbl -> CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) -#define ID3D12GraphicsCommandList6_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ +#define ID3D12GraphicsCommandList7_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ ( (This)->lpVtbl -> CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) -#define ID3D12GraphicsCommandList6_CopyResource(This,pDstResource,pSrcResource) \ +#define ID3D12GraphicsCommandList7_CopyResource(This,pDstResource,pSrcResource) \ ( (This)->lpVtbl -> CopyResource(This,pDstResource,pSrcResource) ) -#define ID3D12GraphicsCommandList6_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ +#define ID3D12GraphicsCommandList7_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ ( (This)->lpVtbl -> CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) -#define ID3D12GraphicsCommandList6_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ +#define ID3D12GraphicsCommandList7_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ ( (This)->lpVtbl -> ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) -#define ID3D12GraphicsCommandList6_IASetPrimitiveTopology(This,PrimitiveTopology) \ +#define ID3D12GraphicsCommandList7_IASetPrimitiveTopology(This,PrimitiveTopology) \ ( (This)->lpVtbl -> IASetPrimitiveTopology(This,PrimitiveTopology) ) -#define ID3D12GraphicsCommandList6_RSSetViewports(This,NumViewports,pViewports) \ +#define ID3D12GraphicsCommandList7_RSSetViewports(This,NumViewports,pViewports) \ ( (This)->lpVtbl -> RSSetViewports(This,NumViewports,pViewports) ) -#define ID3D12GraphicsCommandList6_RSSetScissorRects(This,NumRects,pRects) \ +#define ID3D12GraphicsCommandList7_RSSetScissorRects(This,NumRects,pRects) \ ( (This)->lpVtbl -> RSSetScissorRects(This,NumRects,pRects) ) -#define ID3D12GraphicsCommandList6_OMSetBlendFactor(This,BlendFactor) \ +#define ID3D12GraphicsCommandList7_OMSetBlendFactor(This,BlendFactor) \ ( (This)->lpVtbl -> OMSetBlendFactor(This,BlendFactor) ) -#define ID3D12GraphicsCommandList6_OMSetStencilRef(This,StencilRef) \ +#define ID3D12GraphicsCommandList7_OMSetStencilRef(This,StencilRef) \ ( (This)->lpVtbl -> OMSetStencilRef(This,StencilRef) ) -#define ID3D12GraphicsCommandList6_SetPipelineState(This,pPipelineState) \ +#define ID3D12GraphicsCommandList7_SetPipelineState(This,pPipelineState) \ ( (This)->lpVtbl -> SetPipelineState(This,pPipelineState) ) -#define ID3D12GraphicsCommandList6_ResourceBarrier(This,NumBarriers,pBarriers) \ +#define ID3D12GraphicsCommandList7_ResourceBarrier(This,NumBarriers,pBarriers) \ ( (This)->lpVtbl -> ResourceBarrier(This,NumBarriers,pBarriers) ) -#define ID3D12GraphicsCommandList6_ExecuteBundle(This,pCommandList) \ +#define ID3D12GraphicsCommandList7_ExecuteBundle(This,pCommandList) \ ( (This)->lpVtbl -> ExecuteBundle(This,pCommandList) ) -#define ID3D12GraphicsCommandList6_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ +#define ID3D12GraphicsCommandList7_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ ( (This)->lpVtbl -> SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) ) -#define ID3D12GraphicsCommandList6_SetComputeRootSignature(This,pRootSignature) \ +#define ID3D12GraphicsCommandList7_SetComputeRootSignature(This,pRootSignature) \ ( (This)->lpVtbl -> SetComputeRootSignature(This,pRootSignature) ) -#define ID3D12GraphicsCommandList6_SetGraphicsRootSignature(This,pRootSignature) \ +#define ID3D12GraphicsCommandList7_SetGraphicsRootSignature(This,pRootSignature) \ ( (This)->lpVtbl -> SetGraphicsRootSignature(This,pRootSignature) ) -#define ID3D12GraphicsCommandList6_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ +#define ID3D12GraphicsCommandList7_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ ( (This)->lpVtbl -> SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) -#define ID3D12GraphicsCommandList6_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ +#define ID3D12GraphicsCommandList7_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ ( (This)->lpVtbl -> SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) -#define ID3D12GraphicsCommandList6_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ +#define ID3D12GraphicsCommandList7_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ ( (This)->lpVtbl -> SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) -#define ID3D12GraphicsCommandList6_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ +#define ID3D12GraphicsCommandList7_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ ( (This)->lpVtbl -> SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) -#define ID3D12GraphicsCommandList6_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ +#define ID3D12GraphicsCommandList7_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ ( (This)->lpVtbl -> SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) -#define ID3D12GraphicsCommandList6_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ +#define ID3D12GraphicsCommandList7_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ ( (This)->lpVtbl -> SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) -#define ID3D12GraphicsCommandList6_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList7_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList6_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList7_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList6_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList7_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList6_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList7_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList6_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList7_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList6_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList7_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList6_IASetIndexBuffer(This,pView) \ +#define ID3D12GraphicsCommandList7_IASetIndexBuffer(This,pView) \ ( (This)->lpVtbl -> IASetIndexBuffer(This,pView) ) -#define ID3D12GraphicsCommandList6_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ +#define ID3D12GraphicsCommandList7_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ ( (This)->lpVtbl -> IASetVertexBuffers(This,StartSlot,NumViews,pViews) ) -#define ID3D12GraphicsCommandList6_SOSetTargets(This,StartSlot,NumViews,pViews) \ +#define ID3D12GraphicsCommandList7_SOSetTargets(This,StartSlot,NumViews,pViews) \ ( (This)->lpVtbl -> SOSetTargets(This,StartSlot,NumViews,pViews) ) -#define ID3D12GraphicsCommandList6_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ +#define ID3D12GraphicsCommandList7_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ ( (This)->lpVtbl -> OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) -#define ID3D12GraphicsCommandList6_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ +#define ID3D12GraphicsCommandList7_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ ( (This)->lpVtbl -> ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) -#define ID3D12GraphicsCommandList6_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ +#define ID3D12GraphicsCommandList7_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ ( (This)->lpVtbl -> ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) ) -#define ID3D12GraphicsCommandList6_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ +#define ID3D12GraphicsCommandList7_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ ( (This)->lpVtbl -> ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) -#define ID3D12GraphicsCommandList6_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ +#define ID3D12GraphicsCommandList7_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ ( (This)->lpVtbl -> ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) -#define ID3D12GraphicsCommandList6_DiscardResource(This,pResource,pRegion) \ +#define ID3D12GraphicsCommandList7_DiscardResource(This,pResource,pRegion) \ ( (This)->lpVtbl -> DiscardResource(This,pResource,pRegion) ) -#define ID3D12GraphicsCommandList6_BeginQuery(This,pQueryHeap,Type,Index) \ +#define ID3D12GraphicsCommandList7_BeginQuery(This,pQueryHeap,Type,Index) \ ( (This)->lpVtbl -> BeginQuery(This,pQueryHeap,Type,Index) ) -#define ID3D12GraphicsCommandList6_EndQuery(This,pQueryHeap,Type,Index) \ +#define ID3D12GraphicsCommandList7_EndQuery(This,pQueryHeap,Type,Index) \ ( (This)->lpVtbl -> EndQuery(This,pQueryHeap,Type,Index) ) -#define ID3D12GraphicsCommandList6_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ +#define ID3D12GraphicsCommandList7_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ ( (This)->lpVtbl -> ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) -#define ID3D12GraphicsCommandList6_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ +#define ID3D12GraphicsCommandList7_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ ( (This)->lpVtbl -> SetPredication(This,pBuffer,AlignedBufferOffset,Operation) ) -#define ID3D12GraphicsCommandList6_SetMarker(This,Metadata,pData,Size) \ +#define ID3D12GraphicsCommandList7_SetMarker(This,Metadata,pData,Size) \ ( (This)->lpVtbl -> SetMarker(This,Metadata,pData,Size) ) -#define ID3D12GraphicsCommandList6_BeginEvent(This,Metadata,pData,Size) \ +#define ID3D12GraphicsCommandList7_BeginEvent(This,Metadata,pData,Size) \ ( (This)->lpVtbl -> BeginEvent(This,Metadata,pData,Size) ) -#define ID3D12GraphicsCommandList6_EndEvent(This) \ +#define ID3D12GraphicsCommandList7_EndEvent(This) \ ( (This)->lpVtbl -> EndEvent(This) ) -#define ID3D12GraphicsCommandList6_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ +#define ID3D12GraphicsCommandList7_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ ( (This)->lpVtbl -> ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) -#define ID3D12GraphicsCommandList6_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ +#define ID3D12GraphicsCommandList7_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ ( (This)->lpVtbl -> AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) -#define ID3D12GraphicsCommandList6_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ +#define ID3D12GraphicsCommandList7_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ ( (This)->lpVtbl -> AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) -#define ID3D12GraphicsCommandList6_OMSetDepthBounds(This,Min,Max) \ +#define ID3D12GraphicsCommandList7_OMSetDepthBounds(This,Min,Max) \ ( (This)->lpVtbl -> OMSetDepthBounds(This,Min,Max) ) -#define ID3D12GraphicsCommandList6_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ +#define ID3D12GraphicsCommandList7_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ ( (This)->lpVtbl -> SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) ) -#define ID3D12GraphicsCommandList6_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ +#define ID3D12GraphicsCommandList7_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ ( (This)->lpVtbl -> ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) -#define ID3D12GraphicsCommandList6_SetViewInstanceMask(This,Mask) \ +#define ID3D12GraphicsCommandList7_SetViewInstanceMask(This,Mask) \ ( (This)->lpVtbl -> SetViewInstanceMask(This,Mask) ) -#define ID3D12GraphicsCommandList6_WriteBufferImmediate(This,Count,pParams,pModes) \ +#define ID3D12GraphicsCommandList7_WriteBufferImmediate(This,Count,pParams,pModes) \ ( (This)->lpVtbl -> WriteBufferImmediate(This,Count,pParams,pModes) ) -#define ID3D12GraphicsCommandList6_SetProtectedResourceSession(This,pProtectedResourceSession) \ +#define ID3D12GraphicsCommandList7_SetProtectedResourceSession(This,pProtectedResourceSession) \ ( (This)->lpVtbl -> SetProtectedResourceSession(This,pProtectedResourceSession) ) -#define ID3D12GraphicsCommandList6_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ +#define ID3D12GraphicsCommandList7_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ ( (This)->lpVtbl -> BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) ) -#define ID3D12GraphicsCommandList6_EndRenderPass(This) \ +#define ID3D12GraphicsCommandList7_EndRenderPass(This) \ ( (This)->lpVtbl -> EndRenderPass(This) ) -#define ID3D12GraphicsCommandList6_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ +#define ID3D12GraphicsCommandList7_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ ( (This)->lpVtbl -> InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) ) -#define ID3D12GraphicsCommandList6_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ +#define ID3D12GraphicsCommandList7_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ ( (This)->lpVtbl -> ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) ) -#define ID3D12GraphicsCommandList6_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ +#define ID3D12GraphicsCommandList7_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ ( (This)->lpVtbl -> BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) ) -#define ID3D12GraphicsCommandList6_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ +#define ID3D12GraphicsCommandList7_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ ( (This)->lpVtbl -> EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) ) -#define ID3D12GraphicsCommandList6_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ +#define ID3D12GraphicsCommandList7_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ ( (This)->lpVtbl -> CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) ) -#define ID3D12GraphicsCommandList6_SetPipelineState1(This,pStateObject) \ +#define ID3D12GraphicsCommandList7_SetPipelineState1(This,pStateObject) \ ( (This)->lpVtbl -> SetPipelineState1(This,pStateObject) ) -#define ID3D12GraphicsCommandList6_DispatchRays(This,pDesc) \ +#define ID3D12GraphicsCommandList7_DispatchRays(This,pDesc) \ ( (This)->lpVtbl -> DispatchRays(This,pDesc) ) -#define ID3D12GraphicsCommandList6_RSSetShadingRate(This,baseShadingRate,combiners) \ +#define ID3D12GraphicsCommandList7_RSSetShadingRate(This,baseShadingRate,combiners) \ ( (This)->lpVtbl -> RSSetShadingRate(This,baseShadingRate,combiners) ) -#define ID3D12GraphicsCommandList6_RSSetShadingRateImage(This,shadingRateImage) \ +#define ID3D12GraphicsCommandList7_RSSetShadingRateImage(This,shadingRateImage) \ ( (This)->lpVtbl -> RSSetShadingRateImage(This,shadingRateImage) ) -#define ID3D12GraphicsCommandList6_DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ - ( (This)->lpVtbl -> DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) +#define ID3D12GraphicsCommandList7_DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->lpVtbl -> DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) + + +#define ID3D12GraphicsCommandList7_Barrier(This,NumBarrierGroups,pBarrierGroups) \ + ( (This)->lpVtbl -> Barrier(This,NumBarrierGroups,pBarrierGroups) ) #endif /* COBJMACROS */ @@ -29212,104 +32044,104 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList6; -#endif /* __ID3D12GraphicsCommandList6_INTERFACE_DEFINED__ */ +#endif /* __ID3D12GraphicsCommandList7_INTERFACE_DEFINED__ */ -#ifndef __ID3D12GraphicsCommandList7_INTERFACE_DEFINED__ -#define __ID3D12GraphicsCommandList7_INTERFACE_DEFINED__ +#ifndef __ID3D12GraphicsCommandList8_INTERFACE_DEFINED__ +#define __ID3D12GraphicsCommandList8_INTERFACE_DEFINED__ -/* interface ID3D12GraphicsCommandList7 */ +/* interface ID3D12GraphicsCommandList8 */ /* [unique][local][object][uuid] */ -EXTERN_C const IID IID_ID3D12GraphicsCommandList7; +EXTERN_C const IID IID_ID3D12GraphicsCommandList8; #if defined(__cplusplus) && !defined(CINTERFACE) - MIDL_INTERFACE("dd171223-8b61-4769-90e3-160ccde4e2c1") - ID3D12GraphicsCommandList7 : public ID3D12GraphicsCommandList6 + MIDL_INTERFACE("ee936ef9-599d-4d28-938e-23c4ad05ce51") + ID3D12GraphicsCommandList8 : public ID3D12GraphicsCommandList7 { public: - virtual void STDMETHODCALLTYPE Barrier( - UINT32 NumBarrierGroups, - _In_reads_(NumBarrierGroups) const D3D12_BARRIER_GROUP *pBarrierGroups) = 0; + virtual void STDMETHODCALLTYPE OMSetFrontAndBackStencilRef( + _In_ UINT FrontStencilRef, + _In_ UINT BackStencilRef) = 0; }; #else /* C style interface */ - typedef struct ID3D12GraphicsCommandList7Vtbl + typedef struct ID3D12GraphicsCommandList8Vtbl { BEGIN_INTERFACE DECLSPEC_XFGVIRT(IUnknown, QueryInterface) HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, REFIID riid, _COM_Outptr_ void **ppvObject); DECLSPEC_XFGVIRT(IUnknown, AddRef) ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D12GraphicsCommandList7 * This); + ID3D12GraphicsCommandList8 * This); DECLSPEC_XFGVIRT(IUnknown, Release) ULONG ( STDMETHODCALLTYPE *Release )( - ID3D12GraphicsCommandList7 * This); + ID3D12GraphicsCommandList8 * This); DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ REFGUID guid, _Inout_ UINT *pDataSize, _Out_writes_bytes_opt_( *pDataSize ) void *pData); DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ REFGUID guid, _In_ UINT DataSize, _In_reads_bytes_opt_( DataSize ) const void *pData); DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ REFGUID guid, _In_opt_ const IUnknown *pData); DECLSPEC_XFGVIRT(ID3D12Object, SetName) HRESULT ( STDMETHODCALLTYPE *SetName )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_z_ LPCWSTR Name); DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) HRESULT ( STDMETHODCALLTYPE *GetDevice )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, REFIID riid, _COM_Outptr_opt_ void **ppvDevice); DECLSPEC_XFGVIRT(ID3D12CommandList, GetType) D3D12_COMMAND_LIST_TYPE ( STDMETHODCALLTYPE *GetType )( - ID3D12GraphicsCommandList7 * This); + ID3D12GraphicsCommandList8 * This); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Close) HRESULT ( STDMETHODCALLTYPE *Close )( - ID3D12GraphicsCommandList7 * This); + ID3D12GraphicsCommandList8 * This); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Reset) HRESULT ( STDMETHODCALLTYPE *Reset )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ ID3D12CommandAllocator *pAllocator, _In_opt_ ID3D12PipelineState *pInitialState); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearState) void ( STDMETHODCALLTYPE *ClearState )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_opt_ ID3D12PipelineState *pPipelineState); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawInstanced) void ( STDMETHODCALLTYPE *DrawInstanced )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT VertexCountPerInstance, _In_ UINT InstanceCount, _In_ UINT StartVertexLocation, @@ -29317,7 +32149,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawIndexedInstanced) void ( STDMETHODCALLTYPE *DrawIndexedInstanced )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT IndexCountPerInstance, _In_ UINT InstanceCount, _In_ UINT StartIndexLocation, @@ -29326,14 +32158,14 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Dispatch) void ( STDMETHODCALLTYPE *Dispatch )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT ThreadGroupCountX, _In_ UINT ThreadGroupCountY, _In_ UINT ThreadGroupCountZ); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyBufferRegion) void ( STDMETHODCALLTYPE *CopyBufferRegion )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ ID3D12Resource *pDstBuffer, UINT64 DstOffset, _In_ ID3D12Resource *pSrcBuffer, @@ -29342,7 +32174,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTextureRegion) void ( STDMETHODCALLTYPE *CopyTextureRegion )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ const D3D12_TEXTURE_COPY_LOCATION *pDst, UINT DstX, UINT DstY, @@ -29352,13 +32184,13 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyResource) void ( STDMETHODCALLTYPE *CopyResource )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ ID3D12Resource *pDstResource, _In_ ID3D12Resource *pSrcResource); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTiles) void ( STDMETHODCALLTYPE *CopyTiles )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ ID3D12Resource *pTiledResource, _In_ const D3D12_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate, _In_ const D3D12_TILE_REGION_SIZE *pTileRegionSize, @@ -29368,7 +32200,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveSubresource) void ( STDMETHODCALLTYPE *ResolveSubresource )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ ID3D12Resource *pDstResource, _In_ UINT DstSubresource, _In_ ID3D12Resource *pSrcResource, @@ -29377,92 +32209,92 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetPrimitiveTopology) void ( STDMETHODCALLTYPE *IASetPrimitiveTopology )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetViewports) void ( STDMETHODCALLTYPE *RSSetViewports )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports, _In_reads_( NumViewports) const D3D12_VIEWPORT *pViewports); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetScissorRects) void ( STDMETHODCALLTYPE *RSSetScissorRects )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects, _In_reads_( NumRects) const D3D12_RECT *pRects); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetBlendFactor) void ( STDMETHODCALLTYPE *OMSetBlendFactor )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_reads_opt_(4) const FLOAT BlendFactor[ 4 ]); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetStencilRef) void ( STDMETHODCALLTYPE *OMSetStencilRef )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT StencilRef); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPipelineState) void ( STDMETHODCALLTYPE *SetPipelineState )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ ID3D12PipelineState *pPipelineState); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResourceBarrier) void ( STDMETHODCALLTYPE *ResourceBarrier )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT NumBarriers, _In_reads_(NumBarriers) const D3D12_RESOURCE_BARRIER *pBarriers); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteBundle) void ( STDMETHODCALLTYPE *ExecuteBundle )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ ID3D12GraphicsCommandList *pCommandList); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetDescriptorHeaps) void ( STDMETHODCALLTYPE *SetDescriptorHeaps )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT NumDescriptorHeaps, _In_reads_(NumDescriptorHeaps) ID3D12DescriptorHeap *const *ppDescriptorHeaps); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootSignature) void ( STDMETHODCALLTYPE *SetComputeRootSignature )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_opt_ ID3D12RootSignature *pRootSignature); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootSignature) void ( STDMETHODCALLTYPE *SetGraphicsRootSignature )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_opt_ ID3D12RootSignature *pRootSignature); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootDescriptorTable) void ( STDMETHODCALLTYPE *SetComputeRootDescriptorTable )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootDescriptorTable) void ( STDMETHODCALLTYPE *SetGraphicsRootDescriptorTable )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstant) void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstant )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT RootParameterIndex, _In_ UINT SrcData, _In_ UINT DestOffsetIn32BitValues); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstant) void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstant )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT RootParameterIndex, _In_ UINT SrcData, _In_ UINT DestOffsetIn32BitValues); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstants) void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstants )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT RootParameterIndex, _In_ UINT Num32BitValuesToSet, _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, @@ -29470,7 +32302,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstants) void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstants )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT RootParameterIndex, _In_ UINT Num32BitValuesToSet, _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, @@ -29478,62 +32310,62 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootConstantBufferView) void ( STDMETHODCALLTYPE *SetComputeRootConstantBufferView )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootConstantBufferView) void ( STDMETHODCALLTYPE *SetGraphicsRootConstantBufferView )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootShaderResourceView) void ( STDMETHODCALLTYPE *SetComputeRootShaderResourceView )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootShaderResourceView) void ( STDMETHODCALLTYPE *SetGraphicsRootShaderResourceView )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootUnorderedAccessView) void ( STDMETHODCALLTYPE *SetComputeRootUnorderedAccessView )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootUnorderedAccessView) void ( STDMETHODCALLTYPE *SetGraphicsRootUnorderedAccessView )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetIndexBuffer) void ( STDMETHODCALLTYPE *IASetIndexBuffer )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_opt_ const D3D12_INDEX_BUFFER_VIEW *pView); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetVertexBuffers) void ( STDMETHODCALLTYPE *IASetVertexBuffers )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT StartSlot, _In_ UINT NumViews, _In_reads_opt_(NumViews) const D3D12_VERTEX_BUFFER_VIEW *pViews); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SOSetTargets) void ( STDMETHODCALLTYPE *SOSetTargets )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT StartSlot, _In_ UINT NumViews, _In_reads_opt_(NumViews) const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetRenderTargets) void ( STDMETHODCALLTYPE *OMSetRenderTargets )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT NumRenderTargetDescriptors, _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors, _In_ BOOL RTsSingleHandleToDescriptorRange, @@ -29541,7 +32373,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearDepthStencilView) void ( STDMETHODCALLTYPE *ClearDepthStencilView )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, _In_ D3D12_CLEAR_FLAGS ClearFlags, _In_ FLOAT Depth, @@ -29551,7 +32383,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearRenderTargetView) void ( STDMETHODCALLTYPE *ClearRenderTargetView )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, _In_ const FLOAT ColorRGBA[ 4 ], _In_ UINT NumRects, @@ -29559,7 +32391,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewUint) void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewUint )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, _In_ ID3D12Resource *pResource, @@ -29569,7 +32401,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewFloat) void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewFloat )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, _In_ ID3D12Resource *pResource, @@ -29579,27 +32411,27 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DiscardResource) void ( STDMETHODCALLTYPE *DiscardResource )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ ID3D12Resource *pResource, _In_opt_ const D3D12_DISCARD_REGION *pRegion); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginQuery) void ( STDMETHODCALLTYPE *BeginQuery )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ ID3D12QueryHeap *pQueryHeap, _In_ D3D12_QUERY_TYPE Type, _In_ UINT Index); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndQuery) void ( STDMETHODCALLTYPE *EndQuery )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ ID3D12QueryHeap *pQueryHeap, _In_ D3D12_QUERY_TYPE Type, _In_ UINT Index); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveQueryData) void ( STDMETHODCALLTYPE *ResolveQueryData )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ ID3D12QueryHeap *pQueryHeap, _In_ D3D12_QUERY_TYPE Type, _In_ UINT StartIndex, @@ -29609,32 +32441,32 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPredication) void ( STDMETHODCALLTYPE *SetPredication )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_opt_ ID3D12Resource *pBuffer, _In_ UINT64 AlignedBufferOffset, _In_ D3D12_PREDICATION_OP Operation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetMarker) void ( STDMETHODCALLTYPE *SetMarker )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, UINT Metadata, _In_reads_bytes_opt_(Size) const void *pData, UINT Size); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginEvent) void ( STDMETHODCALLTYPE *BeginEvent )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, UINT Metadata, _In_reads_bytes_opt_(Size) const void *pData, UINT Size); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndEvent) void ( STDMETHODCALLTYPE *EndEvent )( - ID3D12GraphicsCommandList7 * This); + ID3D12GraphicsCommandList8 * This); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteIndirect) void ( STDMETHODCALLTYPE *ExecuteIndirect )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ ID3D12CommandSignature *pCommandSignature, _In_ UINT MaxCommandCount, _In_ ID3D12Resource *pArgumentBuffer, @@ -29644,7 +32476,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT) void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ ID3D12Resource *pDstBuffer, UINT64 DstOffset, _In_ ID3D12Resource *pSrcBuffer, @@ -29655,7 +32487,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT64) void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT64 )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ ID3D12Resource *pDstBuffer, UINT64 DstOffset, _In_ ID3D12Resource *pSrcBuffer, @@ -29666,20 +32498,20 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, OMSetDepthBounds) void ( STDMETHODCALLTYPE *OMSetDepthBounds )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ FLOAT Min, _In_ FLOAT Max); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetSamplePositions) void ( STDMETHODCALLTYPE *SetSamplePositions )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT NumSamplesPerPixel, _In_ UINT NumPixels, _In_reads_(NumSamplesPerPixel*NumPixels) D3D12_SAMPLE_POSITION *pSamplePositions); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, ResolveSubresourceRegion) void ( STDMETHODCALLTYPE *ResolveSubresourceRegion )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ ID3D12Resource *pDstResource, _In_ UINT DstSubresource, _In_ UINT DstX, @@ -29692,24 +32524,24 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetViewInstanceMask) void ( STDMETHODCALLTYPE *SetViewInstanceMask )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT Mask); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList2, WriteBufferImmediate) void ( STDMETHODCALLTYPE *WriteBufferImmediate )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, UINT Count, _In_reads_(Count) const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER *pParams, _In_reads_opt_(Count) const D3D12_WRITEBUFFERIMMEDIATE_MODE *pModes); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList3, SetProtectedResourceSession) void ( STDMETHODCALLTYPE *SetProtectedResourceSession )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_opt_ ID3D12ProtectedResourceSession *pProtectedResourceSession); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BeginRenderPass) void ( STDMETHODCALLTYPE *BeginRenderPass )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT NumRenderTargets, _In_reads_opt_(NumRenderTargets) const D3D12_RENDER_PASS_RENDER_TARGET_DESC *pRenderTargets, _In_opt_ const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *pDepthStencil, @@ -29717,83 +32549,89 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EndRenderPass) void ( STDMETHODCALLTYPE *EndRenderPass )( - ID3D12GraphicsCommandList7 * This); + ID3D12GraphicsCommandList8 * This); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, InitializeMetaCommand) void ( STDMETHODCALLTYPE *InitializeMetaCommand )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ ID3D12MetaCommand *pMetaCommand, _In_reads_bytes_opt_(InitializationParametersDataSizeInBytes) const void *pInitializationParametersData, _In_ SIZE_T InitializationParametersDataSizeInBytes); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, ExecuteMetaCommand) void ( STDMETHODCALLTYPE *ExecuteMetaCommand )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ ID3D12MetaCommand *pMetaCommand, _In_reads_bytes_opt_(ExecutionParametersDataSizeInBytes) const void *pExecutionParametersData, _In_ SIZE_T ExecutionParametersDataSizeInBytes); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BuildRaytracingAccelerationStructure) void ( STDMETHODCALLTYPE *BuildRaytracingAccelerationStructure )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC *pDesc, _In_ UINT NumPostbuildInfoDescs, _In_reads_opt_(NumPostbuildInfoDescs) const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pPostbuildInfoDescs); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EmitRaytracingAccelerationStructurePostbuildInfo) void ( STDMETHODCALLTYPE *EmitRaytracingAccelerationStructurePostbuildInfo )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pDesc, _In_ UINT NumSourceAccelerationStructures, _In_reads_( NumSourceAccelerationStructures ) const D3D12_GPU_VIRTUAL_ADDRESS *pSourceAccelerationStructureData); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, CopyRaytracingAccelerationStructure) void ( STDMETHODCALLTYPE *CopyRaytracingAccelerationStructure )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ D3D12_GPU_VIRTUAL_ADDRESS DestAccelerationStructureData, _In_ D3D12_GPU_VIRTUAL_ADDRESS SourceAccelerationStructureData, _In_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE Mode); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, SetPipelineState1) void ( STDMETHODCALLTYPE *SetPipelineState1 )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ ID3D12StateObject *pStateObject); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, DispatchRays) void ( STDMETHODCALLTYPE *DispatchRays )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ const D3D12_DISPATCH_RAYS_DESC *pDesc); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRate) void ( STDMETHODCALLTYPE *RSSetShadingRate )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ D3D12_SHADING_RATE baseShadingRate, _In_reads_opt_(D3D12_RS_SET_SHADING_RATE_COMBINER_COUNT) const D3D12_SHADING_RATE_COMBINER *combiners); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRateImage) void ( STDMETHODCALLTYPE *RSSetShadingRateImage )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_opt_ ID3D12Resource *shadingRateImage); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList6, DispatchMesh) void ( STDMETHODCALLTYPE *DispatchMesh )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, _In_ UINT ThreadGroupCountX, _In_ UINT ThreadGroupCountY, _In_ UINT ThreadGroupCountZ); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList7, Barrier) void ( STDMETHODCALLTYPE *Barrier )( - ID3D12GraphicsCommandList7 * This, + ID3D12GraphicsCommandList8 * This, UINT32 NumBarrierGroups, _In_reads_(NumBarrierGroups) const D3D12_BARRIER_GROUP *pBarrierGroups); + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList8, OMSetFrontAndBackStencilRef) + void ( STDMETHODCALLTYPE *OMSetFrontAndBackStencilRef )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT FrontStencilRef, + _In_ UINT BackStencilRef); + END_INTERFACE - } ID3D12GraphicsCommandList7Vtbl; + } ID3D12GraphicsCommandList8Vtbl; - interface ID3D12GraphicsCommandList7 + interface ID3D12GraphicsCommandList8 { - CONST_VTBL struct ID3D12GraphicsCommandList7Vtbl *lpVtbl; + CONST_VTBL struct ID3D12GraphicsCommandList8Vtbl *lpVtbl; }; @@ -29801,260 +32639,264 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; #ifdef COBJMACROS -#define ID3D12GraphicsCommandList7_QueryInterface(This,riid,ppvObject) \ +#define ID3D12GraphicsCommandList8_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) -#define ID3D12GraphicsCommandList7_AddRef(This) \ +#define ID3D12GraphicsCommandList8_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) -#define ID3D12GraphicsCommandList7_Release(This) \ +#define ID3D12GraphicsCommandList8_Release(This) \ ( (This)->lpVtbl -> Release(This) ) -#define ID3D12GraphicsCommandList7_GetPrivateData(This,guid,pDataSize,pData) \ +#define ID3D12GraphicsCommandList8_GetPrivateData(This,guid,pDataSize,pData) \ ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) -#define ID3D12GraphicsCommandList7_SetPrivateData(This,guid,DataSize,pData) \ +#define ID3D12GraphicsCommandList8_SetPrivateData(This,guid,DataSize,pData) \ ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) -#define ID3D12GraphicsCommandList7_SetPrivateDataInterface(This,guid,pData) \ +#define ID3D12GraphicsCommandList8_SetPrivateDataInterface(This,guid,pData) \ ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) -#define ID3D12GraphicsCommandList7_SetName(This,Name) \ +#define ID3D12GraphicsCommandList8_SetName(This,Name) \ ( (This)->lpVtbl -> SetName(This,Name) ) -#define ID3D12GraphicsCommandList7_GetDevice(This,riid,ppvDevice) \ +#define ID3D12GraphicsCommandList8_GetDevice(This,riid,ppvDevice) \ ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) -#define ID3D12GraphicsCommandList7_GetType(This) \ +#define ID3D12GraphicsCommandList8_GetType(This) \ ( (This)->lpVtbl -> GetType(This) ) -#define ID3D12GraphicsCommandList7_Close(This) \ +#define ID3D12GraphicsCommandList8_Close(This) \ ( (This)->lpVtbl -> Close(This) ) -#define ID3D12GraphicsCommandList7_Reset(This,pAllocator,pInitialState) \ +#define ID3D12GraphicsCommandList8_Reset(This,pAllocator,pInitialState) \ ( (This)->lpVtbl -> Reset(This,pAllocator,pInitialState) ) -#define ID3D12GraphicsCommandList7_ClearState(This,pPipelineState) \ +#define ID3D12GraphicsCommandList8_ClearState(This,pPipelineState) \ ( (This)->lpVtbl -> ClearState(This,pPipelineState) ) -#define ID3D12GraphicsCommandList7_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ +#define ID3D12GraphicsCommandList8_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ ( (This)->lpVtbl -> DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) -#define ID3D12GraphicsCommandList7_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ +#define ID3D12GraphicsCommandList8_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ ( (This)->lpVtbl -> DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) -#define ID3D12GraphicsCommandList7_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ +#define ID3D12GraphicsCommandList8_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ ( (This)->lpVtbl -> Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) -#define ID3D12GraphicsCommandList7_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ +#define ID3D12GraphicsCommandList8_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ ( (This)->lpVtbl -> CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) -#define ID3D12GraphicsCommandList7_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ +#define ID3D12GraphicsCommandList8_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ ( (This)->lpVtbl -> CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) -#define ID3D12GraphicsCommandList7_CopyResource(This,pDstResource,pSrcResource) \ +#define ID3D12GraphicsCommandList8_CopyResource(This,pDstResource,pSrcResource) \ ( (This)->lpVtbl -> CopyResource(This,pDstResource,pSrcResource) ) -#define ID3D12GraphicsCommandList7_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ +#define ID3D12GraphicsCommandList8_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ ( (This)->lpVtbl -> CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) -#define ID3D12GraphicsCommandList7_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ +#define ID3D12GraphicsCommandList8_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ ( (This)->lpVtbl -> ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) -#define ID3D12GraphicsCommandList7_IASetPrimitiveTopology(This,PrimitiveTopology) \ +#define ID3D12GraphicsCommandList8_IASetPrimitiveTopology(This,PrimitiveTopology) \ ( (This)->lpVtbl -> IASetPrimitiveTopology(This,PrimitiveTopology) ) -#define ID3D12GraphicsCommandList7_RSSetViewports(This,NumViewports,pViewports) \ +#define ID3D12GraphicsCommandList8_RSSetViewports(This,NumViewports,pViewports) \ ( (This)->lpVtbl -> RSSetViewports(This,NumViewports,pViewports) ) -#define ID3D12GraphicsCommandList7_RSSetScissorRects(This,NumRects,pRects) \ +#define ID3D12GraphicsCommandList8_RSSetScissorRects(This,NumRects,pRects) \ ( (This)->lpVtbl -> RSSetScissorRects(This,NumRects,pRects) ) -#define ID3D12GraphicsCommandList7_OMSetBlendFactor(This,BlendFactor) \ +#define ID3D12GraphicsCommandList8_OMSetBlendFactor(This,BlendFactor) \ ( (This)->lpVtbl -> OMSetBlendFactor(This,BlendFactor) ) -#define ID3D12GraphicsCommandList7_OMSetStencilRef(This,StencilRef) \ +#define ID3D12GraphicsCommandList8_OMSetStencilRef(This,StencilRef) \ ( (This)->lpVtbl -> OMSetStencilRef(This,StencilRef) ) -#define ID3D12GraphicsCommandList7_SetPipelineState(This,pPipelineState) \ +#define ID3D12GraphicsCommandList8_SetPipelineState(This,pPipelineState) \ ( (This)->lpVtbl -> SetPipelineState(This,pPipelineState) ) -#define ID3D12GraphicsCommandList7_ResourceBarrier(This,NumBarriers,pBarriers) \ +#define ID3D12GraphicsCommandList8_ResourceBarrier(This,NumBarriers,pBarriers) \ ( (This)->lpVtbl -> ResourceBarrier(This,NumBarriers,pBarriers) ) -#define ID3D12GraphicsCommandList7_ExecuteBundle(This,pCommandList) \ +#define ID3D12GraphicsCommandList8_ExecuteBundle(This,pCommandList) \ ( (This)->lpVtbl -> ExecuteBundle(This,pCommandList) ) -#define ID3D12GraphicsCommandList7_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ +#define ID3D12GraphicsCommandList8_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ ( (This)->lpVtbl -> SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) ) -#define ID3D12GraphicsCommandList7_SetComputeRootSignature(This,pRootSignature) \ +#define ID3D12GraphicsCommandList8_SetComputeRootSignature(This,pRootSignature) \ ( (This)->lpVtbl -> SetComputeRootSignature(This,pRootSignature) ) -#define ID3D12GraphicsCommandList7_SetGraphicsRootSignature(This,pRootSignature) \ +#define ID3D12GraphicsCommandList8_SetGraphicsRootSignature(This,pRootSignature) \ ( (This)->lpVtbl -> SetGraphicsRootSignature(This,pRootSignature) ) -#define ID3D12GraphicsCommandList7_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ +#define ID3D12GraphicsCommandList8_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ ( (This)->lpVtbl -> SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) -#define ID3D12GraphicsCommandList7_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ +#define ID3D12GraphicsCommandList8_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ ( (This)->lpVtbl -> SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) -#define ID3D12GraphicsCommandList7_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ +#define ID3D12GraphicsCommandList8_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ ( (This)->lpVtbl -> SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) -#define ID3D12GraphicsCommandList7_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ +#define ID3D12GraphicsCommandList8_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ ( (This)->lpVtbl -> SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) -#define ID3D12GraphicsCommandList7_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ +#define ID3D12GraphicsCommandList8_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ ( (This)->lpVtbl -> SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) -#define ID3D12GraphicsCommandList7_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ +#define ID3D12GraphicsCommandList8_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ ( (This)->lpVtbl -> SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) -#define ID3D12GraphicsCommandList7_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList8_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList7_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList8_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList7_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList8_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList7_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList8_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList7_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList8_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList7_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList8_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList7_IASetIndexBuffer(This,pView) \ +#define ID3D12GraphicsCommandList8_IASetIndexBuffer(This,pView) \ ( (This)->lpVtbl -> IASetIndexBuffer(This,pView) ) -#define ID3D12GraphicsCommandList7_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ +#define ID3D12GraphicsCommandList8_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ ( (This)->lpVtbl -> IASetVertexBuffers(This,StartSlot,NumViews,pViews) ) -#define ID3D12GraphicsCommandList7_SOSetTargets(This,StartSlot,NumViews,pViews) \ +#define ID3D12GraphicsCommandList8_SOSetTargets(This,StartSlot,NumViews,pViews) \ ( (This)->lpVtbl -> SOSetTargets(This,StartSlot,NumViews,pViews) ) -#define ID3D12GraphicsCommandList7_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ +#define ID3D12GraphicsCommandList8_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ ( (This)->lpVtbl -> OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) -#define ID3D12GraphicsCommandList7_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ +#define ID3D12GraphicsCommandList8_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ ( (This)->lpVtbl -> ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) -#define ID3D12GraphicsCommandList7_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ +#define ID3D12GraphicsCommandList8_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ ( (This)->lpVtbl -> ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) ) -#define ID3D12GraphicsCommandList7_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ +#define ID3D12GraphicsCommandList8_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ ( (This)->lpVtbl -> ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) -#define ID3D12GraphicsCommandList7_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ +#define ID3D12GraphicsCommandList8_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ ( (This)->lpVtbl -> ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) -#define ID3D12GraphicsCommandList7_DiscardResource(This,pResource,pRegion) \ +#define ID3D12GraphicsCommandList8_DiscardResource(This,pResource,pRegion) \ ( (This)->lpVtbl -> DiscardResource(This,pResource,pRegion) ) -#define ID3D12GraphicsCommandList7_BeginQuery(This,pQueryHeap,Type,Index) \ +#define ID3D12GraphicsCommandList8_BeginQuery(This,pQueryHeap,Type,Index) \ ( (This)->lpVtbl -> BeginQuery(This,pQueryHeap,Type,Index) ) -#define ID3D12GraphicsCommandList7_EndQuery(This,pQueryHeap,Type,Index) \ +#define ID3D12GraphicsCommandList8_EndQuery(This,pQueryHeap,Type,Index) \ ( (This)->lpVtbl -> EndQuery(This,pQueryHeap,Type,Index) ) -#define ID3D12GraphicsCommandList7_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ +#define ID3D12GraphicsCommandList8_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ ( (This)->lpVtbl -> ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) -#define ID3D12GraphicsCommandList7_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ +#define ID3D12GraphicsCommandList8_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ ( (This)->lpVtbl -> SetPredication(This,pBuffer,AlignedBufferOffset,Operation) ) -#define ID3D12GraphicsCommandList7_SetMarker(This,Metadata,pData,Size) \ +#define ID3D12GraphicsCommandList8_SetMarker(This,Metadata,pData,Size) \ ( (This)->lpVtbl -> SetMarker(This,Metadata,pData,Size) ) -#define ID3D12GraphicsCommandList7_BeginEvent(This,Metadata,pData,Size) \ +#define ID3D12GraphicsCommandList8_BeginEvent(This,Metadata,pData,Size) \ ( (This)->lpVtbl -> BeginEvent(This,Metadata,pData,Size) ) -#define ID3D12GraphicsCommandList7_EndEvent(This) \ +#define ID3D12GraphicsCommandList8_EndEvent(This) \ ( (This)->lpVtbl -> EndEvent(This) ) -#define ID3D12GraphicsCommandList7_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ +#define ID3D12GraphicsCommandList8_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ ( (This)->lpVtbl -> ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) -#define ID3D12GraphicsCommandList7_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ +#define ID3D12GraphicsCommandList8_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ ( (This)->lpVtbl -> AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) -#define ID3D12GraphicsCommandList7_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ +#define ID3D12GraphicsCommandList8_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ ( (This)->lpVtbl -> AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) -#define ID3D12GraphicsCommandList7_OMSetDepthBounds(This,Min,Max) \ +#define ID3D12GraphicsCommandList8_OMSetDepthBounds(This,Min,Max) \ ( (This)->lpVtbl -> OMSetDepthBounds(This,Min,Max) ) -#define ID3D12GraphicsCommandList7_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ +#define ID3D12GraphicsCommandList8_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ ( (This)->lpVtbl -> SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) ) -#define ID3D12GraphicsCommandList7_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ +#define ID3D12GraphicsCommandList8_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ ( (This)->lpVtbl -> ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) -#define ID3D12GraphicsCommandList7_SetViewInstanceMask(This,Mask) \ +#define ID3D12GraphicsCommandList8_SetViewInstanceMask(This,Mask) \ ( (This)->lpVtbl -> SetViewInstanceMask(This,Mask) ) -#define ID3D12GraphicsCommandList7_WriteBufferImmediate(This,Count,pParams,pModes) \ +#define ID3D12GraphicsCommandList8_WriteBufferImmediate(This,Count,pParams,pModes) \ ( (This)->lpVtbl -> WriteBufferImmediate(This,Count,pParams,pModes) ) -#define ID3D12GraphicsCommandList7_SetProtectedResourceSession(This,pProtectedResourceSession) \ +#define ID3D12GraphicsCommandList8_SetProtectedResourceSession(This,pProtectedResourceSession) \ ( (This)->lpVtbl -> SetProtectedResourceSession(This,pProtectedResourceSession) ) -#define ID3D12GraphicsCommandList7_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ +#define ID3D12GraphicsCommandList8_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ ( (This)->lpVtbl -> BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) ) -#define ID3D12GraphicsCommandList7_EndRenderPass(This) \ +#define ID3D12GraphicsCommandList8_EndRenderPass(This) \ ( (This)->lpVtbl -> EndRenderPass(This) ) -#define ID3D12GraphicsCommandList7_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ +#define ID3D12GraphicsCommandList8_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ ( (This)->lpVtbl -> InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) ) -#define ID3D12GraphicsCommandList7_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ +#define ID3D12GraphicsCommandList8_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ ( (This)->lpVtbl -> ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) ) -#define ID3D12GraphicsCommandList7_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ +#define ID3D12GraphicsCommandList8_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ ( (This)->lpVtbl -> BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) ) -#define ID3D12GraphicsCommandList7_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ +#define ID3D12GraphicsCommandList8_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ ( (This)->lpVtbl -> EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) ) -#define ID3D12GraphicsCommandList7_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ +#define ID3D12GraphicsCommandList8_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ ( (This)->lpVtbl -> CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) ) -#define ID3D12GraphicsCommandList7_SetPipelineState1(This,pStateObject) \ +#define ID3D12GraphicsCommandList8_SetPipelineState1(This,pStateObject) \ ( (This)->lpVtbl -> SetPipelineState1(This,pStateObject) ) -#define ID3D12GraphicsCommandList7_DispatchRays(This,pDesc) \ +#define ID3D12GraphicsCommandList8_DispatchRays(This,pDesc) \ ( (This)->lpVtbl -> DispatchRays(This,pDesc) ) -#define ID3D12GraphicsCommandList7_RSSetShadingRate(This,baseShadingRate,combiners) \ +#define ID3D12GraphicsCommandList8_RSSetShadingRate(This,baseShadingRate,combiners) \ ( (This)->lpVtbl -> RSSetShadingRate(This,baseShadingRate,combiners) ) -#define ID3D12GraphicsCommandList7_RSSetShadingRateImage(This,shadingRateImage) \ +#define ID3D12GraphicsCommandList8_RSSetShadingRateImage(This,shadingRateImage) \ ( (This)->lpVtbl -> RSSetShadingRateImage(This,shadingRateImage) ) -#define ID3D12GraphicsCommandList7_DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ +#define ID3D12GraphicsCommandList8_DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ ( (This)->lpVtbl -> DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) -#define ID3D12GraphicsCommandList7_Barrier(This,NumBarrierGroups,pBarrierGroups) \ +#define ID3D12GraphicsCommandList8_Barrier(This,NumBarrierGroups,pBarrierGroups) \ ( (This)->lpVtbl -> Barrier(This,NumBarrierGroups,pBarrierGroups) ) + +#define ID3D12GraphicsCommandList8_OMSetFrontAndBackStencilRef(This,FrontStencilRef,BackStencilRef) \ + ( (This)->lpVtbl -> OMSetFrontAndBackStencilRef(This,FrontStencilRef,BackStencilRef) ) + #endif /* COBJMACROS */ @@ -30063,104 +32905,108 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList7; -#endif /* __ID3D12GraphicsCommandList7_INTERFACE_DEFINED__ */ +#endif /* __ID3D12GraphicsCommandList8_INTERFACE_DEFINED__ */ -#ifndef __ID3D12GraphicsCommandList8_INTERFACE_DEFINED__ -#define __ID3D12GraphicsCommandList8_INTERFACE_DEFINED__ +#ifndef __ID3D12GraphicsCommandList9_INTERFACE_DEFINED__ +#define __ID3D12GraphicsCommandList9_INTERFACE_DEFINED__ -/* interface ID3D12GraphicsCommandList8 */ +/* interface ID3D12GraphicsCommandList9 */ /* [unique][local][object][uuid] */ -EXTERN_C const IID IID_ID3D12GraphicsCommandList8; +EXTERN_C const IID IID_ID3D12GraphicsCommandList9; #if defined(__cplusplus) && !defined(CINTERFACE) - MIDL_INTERFACE("ee936ef9-599d-4d28-938e-23c4ad05ce51") - ID3D12GraphicsCommandList8 : public ID3D12GraphicsCommandList7 + MIDL_INTERFACE("34ed2808-ffe6-4c2b-b11a-cabd2b0c59e1") + ID3D12GraphicsCommandList9 : public ID3D12GraphicsCommandList8 { public: - virtual void STDMETHODCALLTYPE OMSetFrontAndBackStencilRef( - _In_ UINT FrontStencilRef, - _In_ UINT BackStencilRef) = 0; + virtual void STDMETHODCALLTYPE RSSetDepthBias( + _In_ FLOAT DepthBias, + _In_ FLOAT DepthBiasClamp, + _In_ FLOAT SlopeScaledDepthBias) = 0; + + virtual void STDMETHODCALLTYPE IASetIndexBufferStripCutValue( + _In_ D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue) = 0; }; #else /* C style interface */ - typedef struct ID3D12GraphicsCommandList8Vtbl + typedef struct ID3D12GraphicsCommandList9Vtbl { BEGIN_INTERFACE DECLSPEC_XFGVIRT(IUnknown, QueryInterface) HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, REFIID riid, _COM_Outptr_ void **ppvObject); DECLSPEC_XFGVIRT(IUnknown, AddRef) ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D12GraphicsCommandList8 * This); + ID3D12GraphicsCommandList9 * This); DECLSPEC_XFGVIRT(IUnknown, Release) ULONG ( STDMETHODCALLTYPE *Release )( - ID3D12GraphicsCommandList8 * This); + ID3D12GraphicsCommandList9 * This); DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ REFGUID guid, _Inout_ UINT *pDataSize, _Out_writes_bytes_opt_( *pDataSize ) void *pData); DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ REFGUID guid, _In_ UINT DataSize, _In_reads_bytes_opt_( DataSize ) const void *pData); DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ REFGUID guid, _In_opt_ const IUnknown *pData); DECLSPEC_XFGVIRT(ID3D12Object, SetName) HRESULT ( STDMETHODCALLTYPE *SetName )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_z_ LPCWSTR Name); DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) HRESULT ( STDMETHODCALLTYPE *GetDevice )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, REFIID riid, _COM_Outptr_opt_ void **ppvDevice); DECLSPEC_XFGVIRT(ID3D12CommandList, GetType) D3D12_COMMAND_LIST_TYPE ( STDMETHODCALLTYPE *GetType )( - ID3D12GraphicsCommandList8 * This); + ID3D12GraphicsCommandList9 * This); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Close) HRESULT ( STDMETHODCALLTYPE *Close )( - ID3D12GraphicsCommandList8 * This); + ID3D12GraphicsCommandList9 * This); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Reset) HRESULT ( STDMETHODCALLTYPE *Reset )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ ID3D12CommandAllocator *pAllocator, _In_opt_ ID3D12PipelineState *pInitialState); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearState) void ( STDMETHODCALLTYPE *ClearState )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_opt_ ID3D12PipelineState *pPipelineState); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawInstanced) void ( STDMETHODCALLTYPE *DrawInstanced )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT VertexCountPerInstance, _In_ UINT InstanceCount, _In_ UINT StartVertexLocation, @@ -30168,7 +33014,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawIndexedInstanced) void ( STDMETHODCALLTYPE *DrawIndexedInstanced )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT IndexCountPerInstance, _In_ UINT InstanceCount, _In_ UINT StartIndexLocation, @@ -30177,14 +33023,14 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Dispatch) void ( STDMETHODCALLTYPE *Dispatch )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT ThreadGroupCountX, _In_ UINT ThreadGroupCountY, _In_ UINT ThreadGroupCountZ); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyBufferRegion) void ( STDMETHODCALLTYPE *CopyBufferRegion )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ ID3D12Resource *pDstBuffer, UINT64 DstOffset, _In_ ID3D12Resource *pSrcBuffer, @@ -30193,7 +33039,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTextureRegion) void ( STDMETHODCALLTYPE *CopyTextureRegion )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ const D3D12_TEXTURE_COPY_LOCATION *pDst, UINT DstX, UINT DstY, @@ -30203,13 +33049,13 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyResource) void ( STDMETHODCALLTYPE *CopyResource )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ ID3D12Resource *pDstResource, _In_ ID3D12Resource *pSrcResource); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTiles) void ( STDMETHODCALLTYPE *CopyTiles )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ ID3D12Resource *pTiledResource, _In_ const D3D12_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate, _In_ const D3D12_TILE_REGION_SIZE *pTileRegionSize, @@ -30219,7 +33065,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveSubresource) void ( STDMETHODCALLTYPE *ResolveSubresource )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ ID3D12Resource *pDstResource, _In_ UINT DstSubresource, _In_ ID3D12Resource *pSrcResource, @@ -30228,92 +33074,92 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetPrimitiveTopology) void ( STDMETHODCALLTYPE *IASetPrimitiveTopology )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetViewports) void ( STDMETHODCALLTYPE *RSSetViewports )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports, _In_reads_( NumViewports) const D3D12_VIEWPORT *pViewports); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetScissorRects) void ( STDMETHODCALLTYPE *RSSetScissorRects )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects, _In_reads_( NumRects) const D3D12_RECT *pRects); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetBlendFactor) void ( STDMETHODCALLTYPE *OMSetBlendFactor )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_reads_opt_(4) const FLOAT BlendFactor[ 4 ]); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetStencilRef) void ( STDMETHODCALLTYPE *OMSetStencilRef )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT StencilRef); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPipelineState) void ( STDMETHODCALLTYPE *SetPipelineState )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ ID3D12PipelineState *pPipelineState); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResourceBarrier) void ( STDMETHODCALLTYPE *ResourceBarrier )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT NumBarriers, _In_reads_(NumBarriers) const D3D12_RESOURCE_BARRIER *pBarriers); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteBundle) void ( STDMETHODCALLTYPE *ExecuteBundle )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ ID3D12GraphicsCommandList *pCommandList); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetDescriptorHeaps) void ( STDMETHODCALLTYPE *SetDescriptorHeaps )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT NumDescriptorHeaps, _In_reads_(NumDescriptorHeaps) ID3D12DescriptorHeap *const *ppDescriptorHeaps); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootSignature) void ( STDMETHODCALLTYPE *SetComputeRootSignature )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_opt_ ID3D12RootSignature *pRootSignature); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootSignature) void ( STDMETHODCALLTYPE *SetGraphicsRootSignature )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_opt_ ID3D12RootSignature *pRootSignature); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootDescriptorTable) void ( STDMETHODCALLTYPE *SetComputeRootDescriptorTable )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootDescriptorTable) void ( STDMETHODCALLTYPE *SetGraphicsRootDescriptorTable )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstant) void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstant )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT RootParameterIndex, _In_ UINT SrcData, _In_ UINT DestOffsetIn32BitValues); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstant) void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstant )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT RootParameterIndex, _In_ UINT SrcData, _In_ UINT DestOffsetIn32BitValues); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstants) void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstants )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT RootParameterIndex, _In_ UINT Num32BitValuesToSet, _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, @@ -30321,7 +33167,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstants) void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstants )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT RootParameterIndex, _In_ UINT Num32BitValuesToSet, _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, @@ -30329,62 +33175,62 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootConstantBufferView) void ( STDMETHODCALLTYPE *SetComputeRootConstantBufferView )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootConstantBufferView) void ( STDMETHODCALLTYPE *SetGraphicsRootConstantBufferView )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootShaderResourceView) void ( STDMETHODCALLTYPE *SetComputeRootShaderResourceView )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootShaderResourceView) void ( STDMETHODCALLTYPE *SetGraphicsRootShaderResourceView )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootUnorderedAccessView) void ( STDMETHODCALLTYPE *SetComputeRootUnorderedAccessView )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootUnorderedAccessView) void ( STDMETHODCALLTYPE *SetGraphicsRootUnorderedAccessView )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetIndexBuffer) void ( STDMETHODCALLTYPE *IASetIndexBuffer )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_opt_ const D3D12_INDEX_BUFFER_VIEW *pView); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetVertexBuffers) void ( STDMETHODCALLTYPE *IASetVertexBuffers )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT StartSlot, _In_ UINT NumViews, _In_reads_opt_(NumViews) const D3D12_VERTEX_BUFFER_VIEW *pViews); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SOSetTargets) void ( STDMETHODCALLTYPE *SOSetTargets )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT StartSlot, _In_ UINT NumViews, _In_reads_opt_(NumViews) const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetRenderTargets) void ( STDMETHODCALLTYPE *OMSetRenderTargets )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT NumRenderTargetDescriptors, _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors, _In_ BOOL RTsSingleHandleToDescriptorRange, @@ -30392,7 +33238,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearDepthStencilView) void ( STDMETHODCALLTYPE *ClearDepthStencilView )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, _In_ D3D12_CLEAR_FLAGS ClearFlags, _In_ FLOAT Depth, @@ -30402,7 +33248,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearRenderTargetView) void ( STDMETHODCALLTYPE *ClearRenderTargetView )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, _In_ const FLOAT ColorRGBA[ 4 ], _In_ UINT NumRects, @@ -30410,7 +33256,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewUint) void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewUint )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, _In_ ID3D12Resource *pResource, @@ -30420,7 +33266,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewFloat) void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewFloat )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, _In_ ID3D12Resource *pResource, @@ -30430,27 +33276,27 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DiscardResource) void ( STDMETHODCALLTYPE *DiscardResource )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ ID3D12Resource *pResource, _In_opt_ const D3D12_DISCARD_REGION *pRegion); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginQuery) void ( STDMETHODCALLTYPE *BeginQuery )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ ID3D12QueryHeap *pQueryHeap, _In_ D3D12_QUERY_TYPE Type, _In_ UINT Index); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndQuery) void ( STDMETHODCALLTYPE *EndQuery )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ ID3D12QueryHeap *pQueryHeap, _In_ D3D12_QUERY_TYPE Type, _In_ UINT Index); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveQueryData) void ( STDMETHODCALLTYPE *ResolveQueryData )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ ID3D12QueryHeap *pQueryHeap, _In_ D3D12_QUERY_TYPE Type, _In_ UINT StartIndex, @@ -30460,32 +33306,32 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPredication) void ( STDMETHODCALLTYPE *SetPredication )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_opt_ ID3D12Resource *pBuffer, _In_ UINT64 AlignedBufferOffset, _In_ D3D12_PREDICATION_OP Operation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetMarker) void ( STDMETHODCALLTYPE *SetMarker )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, UINT Metadata, _In_reads_bytes_opt_(Size) const void *pData, UINT Size); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginEvent) void ( STDMETHODCALLTYPE *BeginEvent )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, UINT Metadata, _In_reads_bytes_opt_(Size) const void *pData, UINT Size); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndEvent) void ( STDMETHODCALLTYPE *EndEvent )( - ID3D12GraphicsCommandList8 * This); + ID3D12GraphicsCommandList9 * This); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteIndirect) void ( STDMETHODCALLTYPE *ExecuteIndirect )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ ID3D12CommandSignature *pCommandSignature, _In_ UINT MaxCommandCount, _In_ ID3D12Resource *pArgumentBuffer, @@ -30495,7 +33341,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT) void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ ID3D12Resource *pDstBuffer, UINT64 DstOffset, _In_ ID3D12Resource *pSrcBuffer, @@ -30506,7 +33352,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT64) void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT64 )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ ID3D12Resource *pDstBuffer, UINT64 DstOffset, _In_ ID3D12Resource *pSrcBuffer, @@ -30517,20 +33363,20 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, OMSetDepthBounds) void ( STDMETHODCALLTYPE *OMSetDepthBounds )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ FLOAT Min, _In_ FLOAT Max); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetSamplePositions) void ( STDMETHODCALLTYPE *SetSamplePositions )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT NumSamplesPerPixel, _In_ UINT NumPixels, _In_reads_(NumSamplesPerPixel*NumPixels) D3D12_SAMPLE_POSITION *pSamplePositions); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, ResolveSubresourceRegion) void ( STDMETHODCALLTYPE *ResolveSubresourceRegion )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ ID3D12Resource *pDstResource, _In_ UINT DstSubresource, _In_ UINT DstX, @@ -30543,24 +33389,24 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetViewInstanceMask) void ( STDMETHODCALLTYPE *SetViewInstanceMask )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT Mask); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList2, WriteBufferImmediate) void ( STDMETHODCALLTYPE *WriteBufferImmediate )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, UINT Count, _In_reads_(Count) const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER *pParams, _In_reads_opt_(Count) const D3D12_WRITEBUFFERIMMEDIATE_MODE *pModes); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList3, SetProtectedResourceSession) void ( STDMETHODCALLTYPE *SetProtectedResourceSession )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_opt_ ID3D12ProtectedResourceSession *pProtectedResourceSession); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BeginRenderPass) void ( STDMETHODCALLTYPE *BeginRenderPass )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT NumRenderTargets, _In_reads_opt_(NumRenderTargets) const D3D12_RENDER_PASS_RENDER_TARGET_DESC *pRenderTargets, _In_opt_ const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *pDepthStencil, @@ -30568,89 +33414,101 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EndRenderPass) void ( STDMETHODCALLTYPE *EndRenderPass )( - ID3D12GraphicsCommandList8 * This); + ID3D12GraphicsCommandList9 * This); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, InitializeMetaCommand) void ( STDMETHODCALLTYPE *InitializeMetaCommand )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ ID3D12MetaCommand *pMetaCommand, _In_reads_bytes_opt_(InitializationParametersDataSizeInBytes) const void *pInitializationParametersData, _In_ SIZE_T InitializationParametersDataSizeInBytes); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, ExecuteMetaCommand) void ( STDMETHODCALLTYPE *ExecuteMetaCommand )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ ID3D12MetaCommand *pMetaCommand, _In_reads_bytes_opt_(ExecutionParametersDataSizeInBytes) const void *pExecutionParametersData, _In_ SIZE_T ExecutionParametersDataSizeInBytes); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BuildRaytracingAccelerationStructure) void ( STDMETHODCALLTYPE *BuildRaytracingAccelerationStructure )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC *pDesc, _In_ UINT NumPostbuildInfoDescs, _In_reads_opt_(NumPostbuildInfoDescs) const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pPostbuildInfoDescs); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EmitRaytracingAccelerationStructurePostbuildInfo) void ( STDMETHODCALLTYPE *EmitRaytracingAccelerationStructurePostbuildInfo )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pDesc, _In_ UINT NumSourceAccelerationStructures, _In_reads_( NumSourceAccelerationStructures ) const D3D12_GPU_VIRTUAL_ADDRESS *pSourceAccelerationStructureData); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, CopyRaytracingAccelerationStructure) void ( STDMETHODCALLTYPE *CopyRaytracingAccelerationStructure )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ D3D12_GPU_VIRTUAL_ADDRESS DestAccelerationStructureData, _In_ D3D12_GPU_VIRTUAL_ADDRESS SourceAccelerationStructureData, _In_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE Mode); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, SetPipelineState1) void ( STDMETHODCALLTYPE *SetPipelineState1 )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ ID3D12StateObject *pStateObject); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, DispatchRays) void ( STDMETHODCALLTYPE *DispatchRays )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ const D3D12_DISPATCH_RAYS_DESC *pDesc); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRate) void ( STDMETHODCALLTYPE *RSSetShadingRate )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ D3D12_SHADING_RATE baseShadingRate, _In_reads_opt_(D3D12_RS_SET_SHADING_RATE_COMBINER_COUNT) const D3D12_SHADING_RATE_COMBINER *combiners); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRateImage) void ( STDMETHODCALLTYPE *RSSetShadingRateImage )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_opt_ ID3D12Resource *shadingRateImage); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList6, DispatchMesh) void ( STDMETHODCALLTYPE *DispatchMesh )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT ThreadGroupCountX, _In_ UINT ThreadGroupCountY, _In_ UINT ThreadGroupCountZ); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList7, Barrier) void ( STDMETHODCALLTYPE *Barrier )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, UINT32 NumBarrierGroups, _In_reads_(NumBarrierGroups) const D3D12_BARRIER_GROUP *pBarrierGroups); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList8, OMSetFrontAndBackStencilRef) void ( STDMETHODCALLTYPE *OMSetFrontAndBackStencilRef )( - ID3D12GraphicsCommandList8 * This, + ID3D12GraphicsCommandList9 * This, _In_ UINT FrontStencilRef, _In_ UINT BackStencilRef); + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList9, RSSetDepthBias) + void ( STDMETHODCALLTYPE *RSSetDepthBias )( + ID3D12GraphicsCommandList9 * This, + _In_ FLOAT DepthBias, + _In_ FLOAT DepthBiasClamp, + _In_ FLOAT SlopeScaledDepthBias); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList9, IASetIndexBufferStripCutValue) + void ( STDMETHODCALLTYPE *IASetIndexBufferStripCutValue )( + ID3D12GraphicsCommandList9 * This, + _In_ D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue); + END_INTERFACE - } ID3D12GraphicsCommandList8Vtbl; + } ID3D12GraphicsCommandList9Vtbl; - interface ID3D12GraphicsCommandList8 + interface ID3D12GraphicsCommandList9 { - CONST_VTBL struct ID3D12GraphicsCommandList8Vtbl *lpVtbl; + CONST_VTBL struct ID3D12GraphicsCommandList9Vtbl *lpVtbl; }; @@ -30658,264 +33516,271 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; #ifdef COBJMACROS -#define ID3D12GraphicsCommandList8_QueryInterface(This,riid,ppvObject) \ +#define ID3D12GraphicsCommandList9_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) -#define ID3D12GraphicsCommandList8_AddRef(This) \ +#define ID3D12GraphicsCommandList9_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) -#define ID3D12GraphicsCommandList8_Release(This) \ +#define ID3D12GraphicsCommandList9_Release(This) \ ( (This)->lpVtbl -> Release(This) ) -#define ID3D12GraphicsCommandList8_GetPrivateData(This,guid,pDataSize,pData) \ +#define ID3D12GraphicsCommandList9_GetPrivateData(This,guid,pDataSize,pData) \ ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) -#define ID3D12GraphicsCommandList8_SetPrivateData(This,guid,DataSize,pData) \ +#define ID3D12GraphicsCommandList9_SetPrivateData(This,guid,DataSize,pData) \ ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) -#define ID3D12GraphicsCommandList8_SetPrivateDataInterface(This,guid,pData) \ +#define ID3D12GraphicsCommandList9_SetPrivateDataInterface(This,guid,pData) \ ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) -#define ID3D12GraphicsCommandList8_SetName(This,Name) \ +#define ID3D12GraphicsCommandList9_SetName(This,Name) \ ( (This)->lpVtbl -> SetName(This,Name) ) -#define ID3D12GraphicsCommandList8_GetDevice(This,riid,ppvDevice) \ +#define ID3D12GraphicsCommandList9_GetDevice(This,riid,ppvDevice) \ ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) -#define ID3D12GraphicsCommandList8_GetType(This) \ +#define ID3D12GraphicsCommandList9_GetType(This) \ ( (This)->lpVtbl -> GetType(This) ) -#define ID3D12GraphicsCommandList8_Close(This) \ +#define ID3D12GraphicsCommandList9_Close(This) \ ( (This)->lpVtbl -> Close(This) ) -#define ID3D12GraphicsCommandList8_Reset(This,pAllocator,pInitialState) \ +#define ID3D12GraphicsCommandList9_Reset(This,pAllocator,pInitialState) \ ( (This)->lpVtbl -> Reset(This,pAllocator,pInitialState) ) -#define ID3D12GraphicsCommandList8_ClearState(This,pPipelineState) \ +#define ID3D12GraphicsCommandList9_ClearState(This,pPipelineState) \ ( (This)->lpVtbl -> ClearState(This,pPipelineState) ) -#define ID3D12GraphicsCommandList8_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ +#define ID3D12GraphicsCommandList9_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ ( (This)->lpVtbl -> DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) -#define ID3D12GraphicsCommandList8_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ +#define ID3D12GraphicsCommandList9_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ ( (This)->lpVtbl -> DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) -#define ID3D12GraphicsCommandList8_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ +#define ID3D12GraphicsCommandList9_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ ( (This)->lpVtbl -> Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) -#define ID3D12GraphicsCommandList8_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ +#define ID3D12GraphicsCommandList9_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ ( (This)->lpVtbl -> CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) -#define ID3D12GraphicsCommandList8_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ +#define ID3D12GraphicsCommandList9_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ ( (This)->lpVtbl -> CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) -#define ID3D12GraphicsCommandList8_CopyResource(This,pDstResource,pSrcResource) \ +#define ID3D12GraphicsCommandList9_CopyResource(This,pDstResource,pSrcResource) \ ( (This)->lpVtbl -> CopyResource(This,pDstResource,pSrcResource) ) -#define ID3D12GraphicsCommandList8_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ +#define ID3D12GraphicsCommandList9_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ ( (This)->lpVtbl -> CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) -#define ID3D12GraphicsCommandList8_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ +#define ID3D12GraphicsCommandList9_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ ( (This)->lpVtbl -> ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) -#define ID3D12GraphicsCommandList8_IASetPrimitiveTopology(This,PrimitiveTopology) \ +#define ID3D12GraphicsCommandList9_IASetPrimitiveTopology(This,PrimitiveTopology) \ ( (This)->lpVtbl -> IASetPrimitiveTopology(This,PrimitiveTopology) ) -#define ID3D12GraphicsCommandList8_RSSetViewports(This,NumViewports,pViewports) \ +#define ID3D12GraphicsCommandList9_RSSetViewports(This,NumViewports,pViewports) \ ( (This)->lpVtbl -> RSSetViewports(This,NumViewports,pViewports) ) -#define ID3D12GraphicsCommandList8_RSSetScissorRects(This,NumRects,pRects) \ +#define ID3D12GraphicsCommandList9_RSSetScissorRects(This,NumRects,pRects) \ ( (This)->lpVtbl -> RSSetScissorRects(This,NumRects,pRects) ) -#define ID3D12GraphicsCommandList8_OMSetBlendFactor(This,BlendFactor) \ +#define ID3D12GraphicsCommandList9_OMSetBlendFactor(This,BlendFactor) \ ( (This)->lpVtbl -> OMSetBlendFactor(This,BlendFactor) ) -#define ID3D12GraphicsCommandList8_OMSetStencilRef(This,StencilRef) \ +#define ID3D12GraphicsCommandList9_OMSetStencilRef(This,StencilRef) \ ( (This)->lpVtbl -> OMSetStencilRef(This,StencilRef) ) -#define ID3D12GraphicsCommandList8_SetPipelineState(This,pPipelineState) \ +#define ID3D12GraphicsCommandList9_SetPipelineState(This,pPipelineState) \ ( (This)->lpVtbl -> SetPipelineState(This,pPipelineState) ) -#define ID3D12GraphicsCommandList8_ResourceBarrier(This,NumBarriers,pBarriers) \ +#define ID3D12GraphicsCommandList9_ResourceBarrier(This,NumBarriers,pBarriers) \ ( (This)->lpVtbl -> ResourceBarrier(This,NumBarriers,pBarriers) ) -#define ID3D12GraphicsCommandList8_ExecuteBundle(This,pCommandList) \ +#define ID3D12GraphicsCommandList9_ExecuteBundle(This,pCommandList) \ ( (This)->lpVtbl -> ExecuteBundle(This,pCommandList) ) -#define ID3D12GraphicsCommandList8_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ +#define ID3D12GraphicsCommandList9_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ ( (This)->lpVtbl -> SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) ) -#define ID3D12GraphicsCommandList8_SetComputeRootSignature(This,pRootSignature) \ +#define ID3D12GraphicsCommandList9_SetComputeRootSignature(This,pRootSignature) \ ( (This)->lpVtbl -> SetComputeRootSignature(This,pRootSignature) ) -#define ID3D12GraphicsCommandList8_SetGraphicsRootSignature(This,pRootSignature) \ +#define ID3D12GraphicsCommandList9_SetGraphicsRootSignature(This,pRootSignature) \ ( (This)->lpVtbl -> SetGraphicsRootSignature(This,pRootSignature) ) -#define ID3D12GraphicsCommandList8_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ +#define ID3D12GraphicsCommandList9_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ ( (This)->lpVtbl -> SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) -#define ID3D12GraphicsCommandList8_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ +#define ID3D12GraphicsCommandList9_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ ( (This)->lpVtbl -> SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) -#define ID3D12GraphicsCommandList8_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ +#define ID3D12GraphicsCommandList9_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ ( (This)->lpVtbl -> SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) -#define ID3D12GraphicsCommandList8_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ +#define ID3D12GraphicsCommandList9_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ ( (This)->lpVtbl -> SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) -#define ID3D12GraphicsCommandList8_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ +#define ID3D12GraphicsCommandList9_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ ( (This)->lpVtbl -> SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) -#define ID3D12GraphicsCommandList8_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ +#define ID3D12GraphicsCommandList9_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ ( (This)->lpVtbl -> SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) -#define ID3D12GraphicsCommandList8_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList9_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList8_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList9_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList8_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList9_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList8_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList9_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList8_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList9_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList8_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList9_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList8_IASetIndexBuffer(This,pView) \ +#define ID3D12GraphicsCommandList9_IASetIndexBuffer(This,pView) \ ( (This)->lpVtbl -> IASetIndexBuffer(This,pView) ) -#define ID3D12GraphicsCommandList8_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ +#define ID3D12GraphicsCommandList9_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ ( (This)->lpVtbl -> IASetVertexBuffers(This,StartSlot,NumViews,pViews) ) -#define ID3D12GraphicsCommandList8_SOSetTargets(This,StartSlot,NumViews,pViews) \ +#define ID3D12GraphicsCommandList9_SOSetTargets(This,StartSlot,NumViews,pViews) \ ( (This)->lpVtbl -> SOSetTargets(This,StartSlot,NumViews,pViews) ) -#define ID3D12GraphicsCommandList8_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ +#define ID3D12GraphicsCommandList9_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ ( (This)->lpVtbl -> OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) -#define ID3D12GraphicsCommandList8_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ +#define ID3D12GraphicsCommandList9_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ ( (This)->lpVtbl -> ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) -#define ID3D12GraphicsCommandList8_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ +#define ID3D12GraphicsCommandList9_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ ( (This)->lpVtbl -> ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) ) -#define ID3D12GraphicsCommandList8_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ +#define ID3D12GraphicsCommandList9_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ ( (This)->lpVtbl -> ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) -#define ID3D12GraphicsCommandList8_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ +#define ID3D12GraphicsCommandList9_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ ( (This)->lpVtbl -> ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) -#define ID3D12GraphicsCommandList8_DiscardResource(This,pResource,pRegion) \ +#define ID3D12GraphicsCommandList9_DiscardResource(This,pResource,pRegion) \ ( (This)->lpVtbl -> DiscardResource(This,pResource,pRegion) ) -#define ID3D12GraphicsCommandList8_BeginQuery(This,pQueryHeap,Type,Index) \ +#define ID3D12GraphicsCommandList9_BeginQuery(This,pQueryHeap,Type,Index) \ ( (This)->lpVtbl -> BeginQuery(This,pQueryHeap,Type,Index) ) -#define ID3D12GraphicsCommandList8_EndQuery(This,pQueryHeap,Type,Index) \ +#define ID3D12GraphicsCommandList9_EndQuery(This,pQueryHeap,Type,Index) \ ( (This)->lpVtbl -> EndQuery(This,pQueryHeap,Type,Index) ) -#define ID3D12GraphicsCommandList8_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ +#define ID3D12GraphicsCommandList9_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ ( (This)->lpVtbl -> ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) -#define ID3D12GraphicsCommandList8_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ +#define ID3D12GraphicsCommandList9_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ ( (This)->lpVtbl -> SetPredication(This,pBuffer,AlignedBufferOffset,Operation) ) -#define ID3D12GraphicsCommandList8_SetMarker(This,Metadata,pData,Size) \ +#define ID3D12GraphicsCommandList9_SetMarker(This,Metadata,pData,Size) \ ( (This)->lpVtbl -> SetMarker(This,Metadata,pData,Size) ) -#define ID3D12GraphicsCommandList8_BeginEvent(This,Metadata,pData,Size) \ +#define ID3D12GraphicsCommandList9_BeginEvent(This,Metadata,pData,Size) \ ( (This)->lpVtbl -> BeginEvent(This,Metadata,pData,Size) ) -#define ID3D12GraphicsCommandList8_EndEvent(This) \ +#define ID3D12GraphicsCommandList9_EndEvent(This) \ ( (This)->lpVtbl -> EndEvent(This) ) -#define ID3D12GraphicsCommandList8_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ +#define ID3D12GraphicsCommandList9_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ ( (This)->lpVtbl -> ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) -#define ID3D12GraphicsCommandList8_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ +#define ID3D12GraphicsCommandList9_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ ( (This)->lpVtbl -> AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) -#define ID3D12GraphicsCommandList8_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ +#define ID3D12GraphicsCommandList9_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ ( (This)->lpVtbl -> AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) -#define ID3D12GraphicsCommandList8_OMSetDepthBounds(This,Min,Max) \ +#define ID3D12GraphicsCommandList9_OMSetDepthBounds(This,Min,Max) \ ( (This)->lpVtbl -> OMSetDepthBounds(This,Min,Max) ) -#define ID3D12GraphicsCommandList8_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ +#define ID3D12GraphicsCommandList9_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ ( (This)->lpVtbl -> SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) ) -#define ID3D12GraphicsCommandList8_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ +#define ID3D12GraphicsCommandList9_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ ( (This)->lpVtbl -> ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) -#define ID3D12GraphicsCommandList8_SetViewInstanceMask(This,Mask) \ +#define ID3D12GraphicsCommandList9_SetViewInstanceMask(This,Mask) \ ( (This)->lpVtbl -> SetViewInstanceMask(This,Mask) ) -#define ID3D12GraphicsCommandList8_WriteBufferImmediate(This,Count,pParams,pModes) \ +#define ID3D12GraphicsCommandList9_WriteBufferImmediate(This,Count,pParams,pModes) \ ( (This)->lpVtbl -> WriteBufferImmediate(This,Count,pParams,pModes) ) -#define ID3D12GraphicsCommandList8_SetProtectedResourceSession(This,pProtectedResourceSession) \ +#define ID3D12GraphicsCommandList9_SetProtectedResourceSession(This,pProtectedResourceSession) \ ( (This)->lpVtbl -> SetProtectedResourceSession(This,pProtectedResourceSession) ) -#define ID3D12GraphicsCommandList8_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ +#define ID3D12GraphicsCommandList9_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ ( (This)->lpVtbl -> BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) ) -#define ID3D12GraphicsCommandList8_EndRenderPass(This) \ +#define ID3D12GraphicsCommandList9_EndRenderPass(This) \ ( (This)->lpVtbl -> EndRenderPass(This) ) -#define ID3D12GraphicsCommandList8_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ +#define ID3D12GraphicsCommandList9_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ ( (This)->lpVtbl -> InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) ) -#define ID3D12GraphicsCommandList8_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ +#define ID3D12GraphicsCommandList9_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ ( (This)->lpVtbl -> ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) ) -#define ID3D12GraphicsCommandList8_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ +#define ID3D12GraphicsCommandList9_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ ( (This)->lpVtbl -> BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) ) -#define ID3D12GraphicsCommandList8_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ +#define ID3D12GraphicsCommandList9_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ ( (This)->lpVtbl -> EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) ) -#define ID3D12GraphicsCommandList8_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ +#define ID3D12GraphicsCommandList9_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ ( (This)->lpVtbl -> CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) ) -#define ID3D12GraphicsCommandList8_SetPipelineState1(This,pStateObject) \ +#define ID3D12GraphicsCommandList9_SetPipelineState1(This,pStateObject) \ ( (This)->lpVtbl -> SetPipelineState1(This,pStateObject) ) -#define ID3D12GraphicsCommandList8_DispatchRays(This,pDesc) \ +#define ID3D12GraphicsCommandList9_DispatchRays(This,pDesc) \ ( (This)->lpVtbl -> DispatchRays(This,pDesc) ) -#define ID3D12GraphicsCommandList8_RSSetShadingRate(This,baseShadingRate,combiners) \ +#define ID3D12GraphicsCommandList9_RSSetShadingRate(This,baseShadingRate,combiners) \ ( (This)->lpVtbl -> RSSetShadingRate(This,baseShadingRate,combiners) ) -#define ID3D12GraphicsCommandList8_RSSetShadingRateImage(This,shadingRateImage) \ +#define ID3D12GraphicsCommandList9_RSSetShadingRateImage(This,shadingRateImage) \ ( (This)->lpVtbl -> RSSetShadingRateImage(This,shadingRateImage) ) -#define ID3D12GraphicsCommandList8_DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ +#define ID3D12GraphicsCommandList9_DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ ( (This)->lpVtbl -> DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) -#define ID3D12GraphicsCommandList8_Barrier(This,NumBarrierGroups,pBarrierGroups) \ +#define ID3D12GraphicsCommandList9_Barrier(This,NumBarrierGroups,pBarrierGroups) \ ( (This)->lpVtbl -> Barrier(This,NumBarrierGroups,pBarrierGroups) ) -#define ID3D12GraphicsCommandList8_OMSetFrontAndBackStencilRef(This,FrontStencilRef,BackStencilRef) \ +#define ID3D12GraphicsCommandList9_OMSetFrontAndBackStencilRef(This,FrontStencilRef,BackStencilRef) \ ( (This)->lpVtbl -> OMSetFrontAndBackStencilRef(This,FrontStencilRef,BackStencilRef) ) + +#define ID3D12GraphicsCommandList9_RSSetDepthBias(This,DepthBias,DepthBiasClamp,SlopeScaledDepthBias) \ + ( (This)->lpVtbl -> RSSetDepthBias(This,DepthBias,DepthBiasClamp,SlopeScaledDepthBias) ) + +#define ID3D12GraphicsCommandList9_IASetIndexBufferStripCutValue(This,IBStripCutValue) \ + ( (This)->lpVtbl -> IASetIndexBufferStripCutValue(This,IBStripCutValue) ) + #endif /* COBJMACROS */ @@ -30924,108 +33789,106 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList8; -#endif /* __ID3D12GraphicsCommandList8_INTERFACE_DEFINED__ */ +#endif /* __ID3D12GraphicsCommandList9_INTERFACE_DEFINED__ */ -#ifndef __ID3D12GraphicsCommandList9_INTERFACE_DEFINED__ -#define __ID3D12GraphicsCommandList9_INTERFACE_DEFINED__ +#ifndef __ID3D12GraphicsCommandList10_INTERFACE_DEFINED__ +#define __ID3D12GraphicsCommandList10_INTERFACE_DEFINED__ -/* interface ID3D12GraphicsCommandList9 */ +/* interface ID3D12GraphicsCommandList10 */ /* [unique][local][object][uuid] */ -EXTERN_C const IID IID_ID3D12GraphicsCommandList9; +EXTERN_C const IID IID_ID3D12GraphicsCommandList10; #if defined(__cplusplus) && !defined(CINTERFACE) - MIDL_INTERFACE("34ed2808-ffe6-4c2b-b11a-cabd2b0c59e1") - ID3D12GraphicsCommandList9 : public ID3D12GraphicsCommandList8 + MIDL_INTERFACE("7013c015-d161-4b63-a08c-238552dd8acc") + ID3D12GraphicsCommandList10 : public ID3D12GraphicsCommandList9 { public: - virtual void STDMETHODCALLTYPE RSSetDepthBias( - _In_ FLOAT DepthBias, - _In_ FLOAT DepthBiasClamp, - _In_ FLOAT SlopeScaledDepthBias) = 0; + virtual void STDMETHODCALLTYPE SetProgram( + _In_ const D3D12_SET_PROGRAM_DESC *pDesc) = 0; - virtual void STDMETHODCALLTYPE IASetIndexBufferStripCutValue( - _In_ D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue) = 0; + virtual void STDMETHODCALLTYPE DispatchGraph( + _In_ const D3D12_DISPATCH_GRAPH_DESC *pDesc) = 0; }; #else /* C style interface */ - typedef struct ID3D12GraphicsCommandList9Vtbl + typedef struct ID3D12GraphicsCommandList10Vtbl { BEGIN_INTERFACE DECLSPEC_XFGVIRT(IUnknown, QueryInterface) HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, REFIID riid, _COM_Outptr_ void **ppvObject); DECLSPEC_XFGVIRT(IUnknown, AddRef) ULONG ( STDMETHODCALLTYPE *AddRef )( - ID3D12GraphicsCommandList9 * This); + ID3D12GraphicsCommandList10 * This); DECLSPEC_XFGVIRT(IUnknown, Release) ULONG ( STDMETHODCALLTYPE *Release )( - ID3D12GraphicsCommandList9 * This); + ID3D12GraphicsCommandList10 * This); DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ REFGUID guid, _Inout_ UINT *pDataSize, _Out_writes_bytes_opt_( *pDataSize ) void *pData); DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ REFGUID guid, _In_ UINT DataSize, _In_reads_bytes_opt_( DataSize ) const void *pData); DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ REFGUID guid, _In_opt_ const IUnknown *pData); DECLSPEC_XFGVIRT(ID3D12Object, SetName) HRESULT ( STDMETHODCALLTYPE *SetName )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_z_ LPCWSTR Name); DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) HRESULT ( STDMETHODCALLTYPE *GetDevice )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, REFIID riid, _COM_Outptr_opt_ void **ppvDevice); DECLSPEC_XFGVIRT(ID3D12CommandList, GetType) D3D12_COMMAND_LIST_TYPE ( STDMETHODCALLTYPE *GetType )( - ID3D12GraphicsCommandList9 * This); + ID3D12GraphicsCommandList10 * This); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Close) HRESULT ( STDMETHODCALLTYPE *Close )( - ID3D12GraphicsCommandList9 * This); + ID3D12GraphicsCommandList10 * This); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Reset) HRESULT ( STDMETHODCALLTYPE *Reset )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ ID3D12CommandAllocator *pAllocator, _In_opt_ ID3D12PipelineState *pInitialState); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearState) void ( STDMETHODCALLTYPE *ClearState )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_opt_ ID3D12PipelineState *pPipelineState); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawInstanced) void ( STDMETHODCALLTYPE *DrawInstanced )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT VertexCountPerInstance, _In_ UINT InstanceCount, _In_ UINT StartVertexLocation, @@ -31033,7 +33896,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawIndexedInstanced) void ( STDMETHODCALLTYPE *DrawIndexedInstanced )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT IndexCountPerInstance, _In_ UINT InstanceCount, _In_ UINT StartIndexLocation, @@ -31042,14 +33905,14 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Dispatch) void ( STDMETHODCALLTYPE *Dispatch )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT ThreadGroupCountX, _In_ UINT ThreadGroupCountY, _In_ UINT ThreadGroupCountZ); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyBufferRegion) void ( STDMETHODCALLTYPE *CopyBufferRegion )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ ID3D12Resource *pDstBuffer, UINT64 DstOffset, _In_ ID3D12Resource *pSrcBuffer, @@ -31058,7 +33921,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTextureRegion) void ( STDMETHODCALLTYPE *CopyTextureRegion )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ const D3D12_TEXTURE_COPY_LOCATION *pDst, UINT DstX, UINT DstY, @@ -31068,13 +33931,13 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyResource) void ( STDMETHODCALLTYPE *CopyResource )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ ID3D12Resource *pDstResource, _In_ ID3D12Resource *pSrcResource); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTiles) void ( STDMETHODCALLTYPE *CopyTiles )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ ID3D12Resource *pTiledResource, _In_ const D3D12_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate, _In_ const D3D12_TILE_REGION_SIZE *pTileRegionSize, @@ -31084,7 +33947,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveSubresource) void ( STDMETHODCALLTYPE *ResolveSubresource )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ ID3D12Resource *pDstResource, _In_ UINT DstSubresource, _In_ ID3D12Resource *pSrcResource, @@ -31093,92 +33956,92 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetPrimitiveTopology) void ( STDMETHODCALLTYPE *IASetPrimitiveTopology )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetViewports) void ( STDMETHODCALLTYPE *RSSetViewports )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports, _In_reads_( NumViewports) const D3D12_VIEWPORT *pViewports); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetScissorRects) void ( STDMETHODCALLTYPE *RSSetScissorRects )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects, _In_reads_( NumRects) const D3D12_RECT *pRects); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetBlendFactor) void ( STDMETHODCALLTYPE *OMSetBlendFactor )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_reads_opt_(4) const FLOAT BlendFactor[ 4 ]); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetStencilRef) void ( STDMETHODCALLTYPE *OMSetStencilRef )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT StencilRef); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPipelineState) void ( STDMETHODCALLTYPE *SetPipelineState )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ ID3D12PipelineState *pPipelineState); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResourceBarrier) void ( STDMETHODCALLTYPE *ResourceBarrier )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT NumBarriers, _In_reads_(NumBarriers) const D3D12_RESOURCE_BARRIER *pBarriers); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteBundle) void ( STDMETHODCALLTYPE *ExecuteBundle )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ ID3D12GraphicsCommandList *pCommandList); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetDescriptorHeaps) void ( STDMETHODCALLTYPE *SetDescriptorHeaps )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT NumDescriptorHeaps, _In_reads_(NumDescriptorHeaps) ID3D12DescriptorHeap *const *ppDescriptorHeaps); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootSignature) void ( STDMETHODCALLTYPE *SetComputeRootSignature )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_opt_ ID3D12RootSignature *pRootSignature); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootSignature) void ( STDMETHODCALLTYPE *SetGraphicsRootSignature )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_opt_ ID3D12RootSignature *pRootSignature); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootDescriptorTable) void ( STDMETHODCALLTYPE *SetComputeRootDescriptorTable )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootDescriptorTable) void ( STDMETHODCALLTYPE *SetGraphicsRootDescriptorTable )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstant) void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstant )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT RootParameterIndex, _In_ UINT SrcData, _In_ UINT DestOffsetIn32BitValues); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstant) void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstant )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT RootParameterIndex, _In_ UINT SrcData, _In_ UINT DestOffsetIn32BitValues); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstants) void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstants )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT RootParameterIndex, _In_ UINT Num32BitValuesToSet, _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, @@ -31186,7 +34049,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstants) void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstants )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT RootParameterIndex, _In_ UINT Num32BitValuesToSet, _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, @@ -31194,62 +34057,62 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootConstantBufferView) void ( STDMETHODCALLTYPE *SetComputeRootConstantBufferView )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootConstantBufferView) void ( STDMETHODCALLTYPE *SetGraphicsRootConstantBufferView )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootShaderResourceView) void ( STDMETHODCALLTYPE *SetComputeRootShaderResourceView )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootShaderResourceView) void ( STDMETHODCALLTYPE *SetGraphicsRootShaderResourceView )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootUnorderedAccessView) void ( STDMETHODCALLTYPE *SetComputeRootUnorderedAccessView )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootUnorderedAccessView) void ( STDMETHODCALLTYPE *SetGraphicsRootUnorderedAccessView )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT RootParameterIndex, _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetIndexBuffer) void ( STDMETHODCALLTYPE *IASetIndexBuffer )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_opt_ const D3D12_INDEX_BUFFER_VIEW *pView); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetVertexBuffers) void ( STDMETHODCALLTYPE *IASetVertexBuffers )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT StartSlot, _In_ UINT NumViews, _In_reads_opt_(NumViews) const D3D12_VERTEX_BUFFER_VIEW *pViews); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SOSetTargets) void ( STDMETHODCALLTYPE *SOSetTargets )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT StartSlot, _In_ UINT NumViews, _In_reads_opt_(NumViews) const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetRenderTargets) void ( STDMETHODCALLTYPE *OMSetRenderTargets )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT NumRenderTargetDescriptors, _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors, _In_ BOOL RTsSingleHandleToDescriptorRange, @@ -31257,7 +34120,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearDepthStencilView) void ( STDMETHODCALLTYPE *ClearDepthStencilView )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, _In_ D3D12_CLEAR_FLAGS ClearFlags, _In_ FLOAT Depth, @@ -31267,7 +34130,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearRenderTargetView) void ( STDMETHODCALLTYPE *ClearRenderTargetView )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, _In_ const FLOAT ColorRGBA[ 4 ], _In_ UINT NumRects, @@ -31275,7 +34138,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewUint) void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewUint )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, _In_ ID3D12Resource *pResource, @@ -31285,7 +34148,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewFloat) void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewFloat )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, _In_ ID3D12Resource *pResource, @@ -31295,27 +34158,27 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DiscardResource) void ( STDMETHODCALLTYPE *DiscardResource )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ ID3D12Resource *pResource, _In_opt_ const D3D12_DISCARD_REGION *pRegion); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginQuery) void ( STDMETHODCALLTYPE *BeginQuery )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ ID3D12QueryHeap *pQueryHeap, _In_ D3D12_QUERY_TYPE Type, _In_ UINT Index); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndQuery) void ( STDMETHODCALLTYPE *EndQuery )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ ID3D12QueryHeap *pQueryHeap, _In_ D3D12_QUERY_TYPE Type, _In_ UINT Index); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveQueryData) void ( STDMETHODCALLTYPE *ResolveQueryData )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ ID3D12QueryHeap *pQueryHeap, _In_ D3D12_QUERY_TYPE Type, _In_ UINT StartIndex, @@ -31325,32 +34188,32 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPredication) void ( STDMETHODCALLTYPE *SetPredication )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_opt_ ID3D12Resource *pBuffer, _In_ UINT64 AlignedBufferOffset, _In_ D3D12_PREDICATION_OP Operation); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetMarker) void ( STDMETHODCALLTYPE *SetMarker )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, UINT Metadata, _In_reads_bytes_opt_(Size) const void *pData, UINT Size); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginEvent) void ( STDMETHODCALLTYPE *BeginEvent )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, UINT Metadata, _In_reads_bytes_opt_(Size) const void *pData, UINT Size); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndEvent) void ( STDMETHODCALLTYPE *EndEvent )( - ID3D12GraphicsCommandList9 * This); + ID3D12GraphicsCommandList10 * This); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteIndirect) void ( STDMETHODCALLTYPE *ExecuteIndirect )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ ID3D12CommandSignature *pCommandSignature, _In_ UINT MaxCommandCount, _In_ ID3D12Resource *pArgumentBuffer, @@ -31360,7 +34223,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT) void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ ID3D12Resource *pDstBuffer, UINT64 DstOffset, _In_ ID3D12Resource *pSrcBuffer, @@ -31371,7 +34234,7 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT64) void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT64 )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ ID3D12Resource *pDstBuffer, UINT64 DstOffset, _In_ ID3D12Resource *pSrcBuffer, @@ -31382,20 +34245,20 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, OMSetDepthBounds) void ( STDMETHODCALLTYPE *OMSetDepthBounds )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ FLOAT Min, _In_ FLOAT Max); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetSamplePositions) void ( STDMETHODCALLTYPE *SetSamplePositions )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT NumSamplesPerPixel, _In_ UINT NumPixels, _In_reads_(NumSamplesPerPixel*NumPixels) D3D12_SAMPLE_POSITION *pSamplePositions); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, ResolveSubresourceRegion) void ( STDMETHODCALLTYPE *ResolveSubresourceRegion )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ ID3D12Resource *pDstResource, _In_ UINT DstSubresource, _In_ UINT DstX, @@ -31408,24 +34271,24 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetViewInstanceMask) void ( STDMETHODCALLTYPE *SetViewInstanceMask )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT Mask); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList2, WriteBufferImmediate) void ( STDMETHODCALLTYPE *WriteBufferImmediate )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, UINT Count, _In_reads_(Count) const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER *pParams, _In_reads_opt_(Count) const D3D12_WRITEBUFFERIMMEDIATE_MODE *pModes); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList3, SetProtectedResourceSession) void ( STDMETHODCALLTYPE *SetProtectedResourceSession )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_opt_ ID3D12ProtectedResourceSession *pProtectedResourceSession); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BeginRenderPass) void ( STDMETHODCALLTYPE *BeginRenderPass )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT NumRenderTargets, _In_reads_opt_(NumRenderTargets) const D3D12_RENDER_PASS_RENDER_TARGET_DESC *pRenderTargets, _In_opt_ const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *pDepthStencil, @@ -31433,101 +34296,111 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EndRenderPass) void ( STDMETHODCALLTYPE *EndRenderPass )( - ID3D12GraphicsCommandList9 * This); + ID3D12GraphicsCommandList10 * This); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, InitializeMetaCommand) void ( STDMETHODCALLTYPE *InitializeMetaCommand )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ ID3D12MetaCommand *pMetaCommand, _In_reads_bytes_opt_(InitializationParametersDataSizeInBytes) const void *pInitializationParametersData, _In_ SIZE_T InitializationParametersDataSizeInBytes); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, ExecuteMetaCommand) void ( STDMETHODCALLTYPE *ExecuteMetaCommand )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ ID3D12MetaCommand *pMetaCommand, _In_reads_bytes_opt_(ExecutionParametersDataSizeInBytes) const void *pExecutionParametersData, _In_ SIZE_T ExecutionParametersDataSizeInBytes); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BuildRaytracingAccelerationStructure) void ( STDMETHODCALLTYPE *BuildRaytracingAccelerationStructure )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC *pDesc, _In_ UINT NumPostbuildInfoDescs, _In_reads_opt_(NumPostbuildInfoDescs) const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pPostbuildInfoDescs); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EmitRaytracingAccelerationStructurePostbuildInfo) void ( STDMETHODCALLTYPE *EmitRaytracingAccelerationStructurePostbuildInfo )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pDesc, _In_ UINT NumSourceAccelerationStructures, _In_reads_( NumSourceAccelerationStructures ) const D3D12_GPU_VIRTUAL_ADDRESS *pSourceAccelerationStructureData); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, CopyRaytracingAccelerationStructure) void ( STDMETHODCALLTYPE *CopyRaytracingAccelerationStructure )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ D3D12_GPU_VIRTUAL_ADDRESS DestAccelerationStructureData, _In_ D3D12_GPU_VIRTUAL_ADDRESS SourceAccelerationStructureData, _In_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE Mode); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, SetPipelineState1) void ( STDMETHODCALLTYPE *SetPipelineState1 )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ ID3D12StateObject *pStateObject); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, DispatchRays) void ( STDMETHODCALLTYPE *DispatchRays )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ const D3D12_DISPATCH_RAYS_DESC *pDesc); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRate) void ( STDMETHODCALLTYPE *RSSetShadingRate )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ D3D12_SHADING_RATE baseShadingRate, _In_reads_opt_(D3D12_RS_SET_SHADING_RATE_COMBINER_COUNT) const D3D12_SHADING_RATE_COMBINER *combiners); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRateImage) void ( STDMETHODCALLTYPE *RSSetShadingRateImage )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_opt_ ID3D12Resource *shadingRateImage); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList6, DispatchMesh) void ( STDMETHODCALLTYPE *DispatchMesh )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT ThreadGroupCountX, _In_ UINT ThreadGroupCountY, _In_ UINT ThreadGroupCountZ); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList7, Barrier) void ( STDMETHODCALLTYPE *Barrier )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, UINT32 NumBarrierGroups, _In_reads_(NumBarrierGroups) const D3D12_BARRIER_GROUP *pBarrierGroups); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList8, OMSetFrontAndBackStencilRef) void ( STDMETHODCALLTYPE *OMSetFrontAndBackStencilRef )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ UINT FrontStencilRef, _In_ UINT BackStencilRef); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList9, RSSetDepthBias) void ( STDMETHODCALLTYPE *RSSetDepthBias )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ FLOAT DepthBias, _In_ FLOAT DepthBiasClamp, _In_ FLOAT SlopeScaledDepthBias); DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList9, IASetIndexBufferStripCutValue) void ( STDMETHODCALLTYPE *IASetIndexBufferStripCutValue )( - ID3D12GraphicsCommandList9 * This, + ID3D12GraphicsCommandList10 * This, _In_ D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue); + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList10, SetProgram) + void ( STDMETHODCALLTYPE *SetProgram )( + ID3D12GraphicsCommandList10 * This, + _In_ const D3D12_SET_PROGRAM_DESC *pDesc); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList10, DispatchGraph) + void ( STDMETHODCALLTYPE *DispatchGraph )( + ID3D12GraphicsCommandList10 * This, + _In_ const D3D12_DISPATCH_GRAPH_DESC *pDesc); + END_INTERFACE - } ID3D12GraphicsCommandList9Vtbl; + } ID3D12GraphicsCommandList10Vtbl; - interface ID3D12GraphicsCommandList9 + interface ID3D12GraphicsCommandList10 { - CONST_VTBL struct ID3D12GraphicsCommandList9Vtbl *lpVtbl; + CONST_VTBL struct ID3D12GraphicsCommandList10Vtbl *lpVtbl; }; @@ -31535,271 +34408,278 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; #ifdef COBJMACROS -#define ID3D12GraphicsCommandList9_QueryInterface(This,riid,ppvObject) \ +#define ID3D12GraphicsCommandList10_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) -#define ID3D12GraphicsCommandList9_AddRef(This) \ +#define ID3D12GraphicsCommandList10_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) -#define ID3D12GraphicsCommandList9_Release(This) \ +#define ID3D12GraphicsCommandList10_Release(This) \ ( (This)->lpVtbl -> Release(This) ) -#define ID3D12GraphicsCommandList9_GetPrivateData(This,guid,pDataSize,pData) \ +#define ID3D12GraphicsCommandList10_GetPrivateData(This,guid,pDataSize,pData) \ ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) -#define ID3D12GraphicsCommandList9_SetPrivateData(This,guid,DataSize,pData) \ +#define ID3D12GraphicsCommandList10_SetPrivateData(This,guid,DataSize,pData) \ ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) -#define ID3D12GraphicsCommandList9_SetPrivateDataInterface(This,guid,pData) \ +#define ID3D12GraphicsCommandList10_SetPrivateDataInterface(This,guid,pData) \ ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) -#define ID3D12GraphicsCommandList9_SetName(This,Name) \ +#define ID3D12GraphicsCommandList10_SetName(This,Name) \ ( (This)->lpVtbl -> SetName(This,Name) ) -#define ID3D12GraphicsCommandList9_GetDevice(This,riid,ppvDevice) \ +#define ID3D12GraphicsCommandList10_GetDevice(This,riid,ppvDevice) \ ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) -#define ID3D12GraphicsCommandList9_GetType(This) \ +#define ID3D12GraphicsCommandList10_GetType(This) \ ( (This)->lpVtbl -> GetType(This) ) -#define ID3D12GraphicsCommandList9_Close(This) \ +#define ID3D12GraphicsCommandList10_Close(This) \ ( (This)->lpVtbl -> Close(This) ) -#define ID3D12GraphicsCommandList9_Reset(This,pAllocator,pInitialState) \ +#define ID3D12GraphicsCommandList10_Reset(This,pAllocator,pInitialState) \ ( (This)->lpVtbl -> Reset(This,pAllocator,pInitialState) ) -#define ID3D12GraphicsCommandList9_ClearState(This,pPipelineState) \ +#define ID3D12GraphicsCommandList10_ClearState(This,pPipelineState) \ ( (This)->lpVtbl -> ClearState(This,pPipelineState) ) -#define ID3D12GraphicsCommandList9_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ +#define ID3D12GraphicsCommandList10_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ ( (This)->lpVtbl -> DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) -#define ID3D12GraphicsCommandList9_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ +#define ID3D12GraphicsCommandList10_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ ( (This)->lpVtbl -> DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) -#define ID3D12GraphicsCommandList9_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ +#define ID3D12GraphicsCommandList10_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ ( (This)->lpVtbl -> Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) -#define ID3D12GraphicsCommandList9_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ +#define ID3D12GraphicsCommandList10_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ ( (This)->lpVtbl -> CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) -#define ID3D12GraphicsCommandList9_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ +#define ID3D12GraphicsCommandList10_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ ( (This)->lpVtbl -> CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) -#define ID3D12GraphicsCommandList9_CopyResource(This,pDstResource,pSrcResource) \ +#define ID3D12GraphicsCommandList10_CopyResource(This,pDstResource,pSrcResource) \ ( (This)->lpVtbl -> CopyResource(This,pDstResource,pSrcResource) ) -#define ID3D12GraphicsCommandList9_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ +#define ID3D12GraphicsCommandList10_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ ( (This)->lpVtbl -> CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) -#define ID3D12GraphicsCommandList9_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ +#define ID3D12GraphicsCommandList10_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ ( (This)->lpVtbl -> ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) -#define ID3D12GraphicsCommandList9_IASetPrimitiveTopology(This,PrimitiveTopology) \ +#define ID3D12GraphicsCommandList10_IASetPrimitiveTopology(This,PrimitiveTopology) \ ( (This)->lpVtbl -> IASetPrimitiveTopology(This,PrimitiveTopology) ) -#define ID3D12GraphicsCommandList9_RSSetViewports(This,NumViewports,pViewports) \ +#define ID3D12GraphicsCommandList10_RSSetViewports(This,NumViewports,pViewports) \ ( (This)->lpVtbl -> RSSetViewports(This,NumViewports,pViewports) ) -#define ID3D12GraphicsCommandList9_RSSetScissorRects(This,NumRects,pRects) \ +#define ID3D12GraphicsCommandList10_RSSetScissorRects(This,NumRects,pRects) \ ( (This)->lpVtbl -> RSSetScissorRects(This,NumRects,pRects) ) -#define ID3D12GraphicsCommandList9_OMSetBlendFactor(This,BlendFactor) \ +#define ID3D12GraphicsCommandList10_OMSetBlendFactor(This,BlendFactor) \ ( (This)->lpVtbl -> OMSetBlendFactor(This,BlendFactor) ) -#define ID3D12GraphicsCommandList9_OMSetStencilRef(This,StencilRef) \ +#define ID3D12GraphicsCommandList10_OMSetStencilRef(This,StencilRef) \ ( (This)->lpVtbl -> OMSetStencilRef(This,StencilRef) ) -#define ID3D12GraphicsCommandList9_SetPipelineState(This,pPipelineState) \ +#define ID3D12GraphicsCommandList10_SetPipelineState(This,pPipelineState) \ ( (This)->lpVtbl -> SetPipelineState(This,pPipelineState) ) -#define ID3D12GraphicsCommandList9_ResourceBarrier(This,NumBarriers,pBarriers) \ +#define ID3D12GraphicsCommandList10_ResourceBarrier(This,NumBarriers,pBarriers) \ ( (This)->lpVtbl -> ResourceBarrier(This,NumBarriers,pBarriers) ) -#define ID3D12GraphicsCommandList9_ExecuteBundle(This,pCommandList) \ +#define ID3D12GraphicsCommandList10_ExecuteBundle(This,pCommandList) \ ( (This)->lpVtbl -> ExecuteBundle(This,pCommandList) ) -#define ID3D12GraphicsCommandList9_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ +#define ID3D12GraphicsCommandList10_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ ( (This)->lpVtbl -> SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) ) -#define ID3D12GraphicsCommandList9_SetComputeRootSignature(This,pRootSignature) \ +#define ID3D12GraphicsCommandList10_SetComputeRootSignature(This,pRootSignature) \ ( (This)->lpVtbl -> SetComputeRootSignature(This,pRootSignature) ) -#define ID3D12GraphicsCommandList9_SetGraphicsRootSignature(This,pRootSignature) \ +#define ID3D12GraphicsCommandList10_SetGraphicsRootSignature(This,pRootSignature) \ ( (This)->lpVtbl -> SetGraphicsRootSignature(This,pRootSignature) ) -#define ID3D12GraphicsCommandList9_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ +#define ID3D12GraphicsCommandList10_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ ( (This)->lpVtbl -> SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) -#define ID3D12GraphicsCommandList9_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ +#define ID3D12GraphicsCommandList10_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ ( (This)->lpVtbl -> SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) -#define ID3D12GraphicsCommandList9_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ +#define ID3D12GraphicsCommandList10_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ ( (This)->lpVtbl -> SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) -#define ID3D12GraphicsCommandList9_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ +#define ID3D12GraphicsCommandList10_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ ( (This)->lpVtbl -> SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) -#define ID3D12GraphicsCommandList9_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ +#define ID3D12GraphicsCommandList10_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ ( (This)->lpVtbl -> SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) -#define ID3D12GraphicsCommandList9_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ +#define ID3D12GraphicsCommandList10_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ ( (This)->lpVtbl -> SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) -#define ID3D12GraphicsCommandList9_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList10_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList9_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList10_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList9_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList10_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList9_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList10_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList9_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList10_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList9_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ +#define ID3D12GraphicsCommandList10_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ ( (This)->lpVtbl -> SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) -#define ID3D12GraphicsCommandList9_IASetIndexBuffer(This,pView) \ +#define ID3D12GraphicsCommandList10_IASetIndexBuffer(This,pView) \ ( (This)->lpVtbl -> IASetIndexBuffer(This,pView) ) -#define ID3D12GraphicsCommandList9_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ +#define ID3D12GraphicsCommandList10_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ ( (This)->lpVtbl -> IASetVertexBuffers(This,StartSlot,NumViews,pViews) ) -#define ID3D12GraphicsCommandList9_SOSetTargets(This,StartSlot,NumViews,pViews) \ +#define ID3D12GraphicsCommandList10_SOSetTargets(This,StartSlot,NumViews,pViews) \ ( (This)->lpVtbl -> SOSetTargets(This,StartSlot,NumViews,pViews) ) -#define ID3D12GraphicsCommandList9_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ +#define ID3D12GraphicsCommandList10_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ ( (This)->lpVtbl -> OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) -#define ID3D12GraphicsCommandList9_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ +#define ID3D12GraphicsCommandList10_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ ( (This)->lpVtbl -> ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) -#define ID3D12GraphicsCommandList9_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ +#define ID3D12GraphicsCommandList10_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ ( (This)->lpVtbl -> ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) ) -#define ID3D12GraphicsCommandList9_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ +#define ID3D12GraphicsCommandList10_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ ( (This)->lpVtbl -> ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) -#define ID3D12GraphicsCommandList9_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ +#define ID3D12GraphicsCommandList10_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ ( (This)->lpVtbl -> ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) -#define ID3D12GraphicsCommandList9_DiscardResource(This,pResource,pRegion) \ +#define ID3D12GraphicsCommandList10_DiscardResource(This,pResource,pRegion) \ ( (This)->lpVtbl -> DiscardResource(This,pResource,pRegion) ) -#define ID3D12GraphicsCommandList9_BeginQuery(This,pQueryHeap,Type,Index) \ +#define ID3D12GraphicsCommandList10_BeginQuery(This,pQueryHeap,Type,Index) \ ( (This)->lpVtbl -> BeginQuery(This,pQueryHeap,Type,Index) ) -#define ID3D12GraphicsCommandList9_EndQuery(This,pQueryHeap,Type,Index) \ +#define ID3D12GraphicsCommandList10_EndQuery(This,pQueryHeap,Type,Index) \ ( (This)->lpVtbl -> EndQuery(This,pQueryHeap,Type,Index) ) -#define ID3D12GraphicsCommandList9_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ +#define ID3D12GraphicsCommandList10_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ ( (This)->lpVtbl -> ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) -#define ID3D12GraphicsCommandList9_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ +#define ID3D12GraphicsCommandList10_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ ( (This)->lpVtbl -> SetPredication(This,pBuffer,AlignedBufferOffset,Operation) ) -#define ID3D12GraphicsCommandList9_SetMarker(This,Metadata,pData,Size) \ +#define ID3D12GraphicsCommandList10_SetMarker(This,Metadata,pData,Size) \ ( (This)->lpVtbl -> SetMarker(This,Metadata,pData,Size) ) -#define ID3D12GraphicsCommandList9_BeginEvent(This,Metadata,pData,Size) \ +#define ID3D12GraphicsCommandList10_BeginEvent(This,Metadata,pData,Size) \ ( (This)->lpVtbl -> BeginEvent(This,Metadata,pData,Size) ) -#define ID3D12GraphicsCommandList9_EndEvent(This) \ +#define ID3D12GraphicsCommandList10_EndEvent(This) \ ( (This)->lpVtbl -> EndEvent(This) ) -#define ID3D12GraphicsCommandList9_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ +#define ID3D12GraphicsCommandList10_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ ( (This)->lpVtbl -> ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) -#define ID3D12GraphicsCommandList9_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ +#define ID3D12GraphicsCommandList10_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ ( (This)->lpVtbl -> AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) -#define ID3D12GraphicsCommandList9_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ +#define ID3D12GraphicsCommandList10_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ ( (This)->lpVtbl -> AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) -#define ID3D12GraphicsCommandList9_OMSetDepthBounds(This,Min,Max) \ +#define ID3D12GraphicsCommandList10_OMSetDepthBounds(This,Min,Max) \ ( (This)->lpVtbl -> OMSetDepthBounds(This,Min,Max) ) -#define ID3D12GraphicsCommandList9_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ +#define ID3D12GraphicsCommandList10_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ ( (This)->lpVtbl -> SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) ) -#define ID3D12GraphicsCommandList9_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ +#define ID3D12GraphicsCommandList10_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ ( (This)->lpVtbl -> ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) -#define ID3D12GraphicsCommandList9_SetViewInstanceMask(This,Mask) \ +#define ID3D12GraphicsCommandList10_SetViewInstanceMask(This,Mask) \ ( (This)->lpVtbl -> SetViewInstanceMask(This,Mask) ) -#define ID3D12GraphicsCommandList9_WriteBufferImmediate(This,Count,pParams,pModes) \ +#define ID3D12GraphicsCommandList10_WriteBufferImmediate(This,Count,pParams,pModes) \ ( (This)->lpVtbl -> WriteBufferImmediate(This,Count,pParams,pModes) ) -#define ID3D12GraphicsCommandList9_SetProtectedResourceSession(This,pProtectedResourceSession) \ +#define ID3D12GraphicsCommandList10_SetProtectedResourceSession(This,pProtectedResourceSession) \ ( (This)->lpVtbl -> SetProtectedResourceSession(This,pProtectedResourceSession) ) -#define ID3D12GraphicsCommandList9_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ +#define ID3D12GraphicsCommandList10_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ ( (This)->lpVtbl -> BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) ) -#define ID3D12GraphicsCommandList9_EndRenderPass(This) \ +#define ID3D12GraphicsCommandList10_EndRenderPass(This) \ ( (This)->lpVtbl -> EndRenderPass(This) ) -#define ID3D12GraphicsCommandList9_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ +#define ID3D12GraphicsCommandList10_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ ( (This)->lpVtbl -> InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) ) -#define ID3D12GraphicsCommandList9_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ +#define ID3D12GraphicsCommandList10_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ ( (This)->lpVtbl -> ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) ) -#define ID3D12GraphicsCommandList9_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ +#define ID3D12GraphicsCommandList10_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ ( (This)->lpVtbl -> BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) ) -#define ID3D12GraphicsCommandList9_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ +#define ID3D12GraphicsCommandList10_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ ( (This)->lpVtbl -> EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) ) -#define ID3D12GraphicsCommandList9_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ +#define ID3D12GraphicsCommandList10_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ ( (This)->lpVtbl -> CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) ) -#define ID3D12GraphicsCommandList9_SetPipelineState1(This,pStateObject) \ +#define ID3D12GraphicsCommandList10_SetPipelineState1(This,pStateObject) \ ( (This)->lpVtbl -> SetPipelineState1(This,pStateObject) ) -#define ID3D12GraphicsCommandList9_DispatchRays(This,pDesc) \ +#define ID3D12GraphicsCommandList10_DispatchRays(This,pDesc) \ ( (This)->lpVtbl -> DispatchRays(This,pDesc) ) -#define ID3D12GraphicsCommandList9_RSSetShadingRate(This,baseShadingRate,combiners) \ +#define ID3D12GraphicsCommandList10_RSSetShadingRate(This,baseShadingRate,combiners) \ ( (This)->lpVtbl -> RSSetShadingRate(This,baseShadingRate,combiners) ) -#define ID3D12GraphicsCommandList9_RSSetShadingRateImage(This,shadingRateImage) \ +#define ID3D12GraphicsCommandList10_RSSetShadingRateImage(This,shadingRateImage) \ ( (This)->lpVtbl -> RSSetShadingRateImage(This,shadingRateImage) ) -#define ID3D12GraphicsCommandList9_DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ +#define ID3D12GraphicsCommandList10_DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ ( (This)->lpVtbl -> DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) -#define ID3D12GraphicsCommandList9_Barrier(This,NumBarrierGroups,pBarrierGroups) \ +#define ID3D12GraphicsCommandList10_Barrier(This,NumBarrierGroups,pBarrierGroups) \ ( (This)->lpVtbl -> Barrier(This,NumBarrierGroups,pBarrierGroups) ) -#define ID3D12GraphicsCommandList9_OMSetFrontAndBackStencilRef(This,FrontStencilRef,BackStencilRef) \ +#define ID3D12GraphicsCommandList10_OMSetFrontAndBackStencilRef(This,FrontStencilRef,BackStencilRef) \ ( (This)->lpVtbl -> OMSetFrontAndBackStencilRef(This,FrontStencilRef,BackStencilRef) ) -#define ID3D12GraphicsCommandList9_RSSetDepthBias(This,DepthBias,DepthBiasClamp,SlopeScaledDepthBias) \ +#define ID3D12GraphicsCommandList10_RSSetDepthBias(This,DepthBias,DepthBiasClamp,SlopeScaledDepthBias) \ ( (This)->lpVtbl -> RSSetDepthBias(This,DepthBias,DepthBiasClamp,SlopeScaledDepthBias) ) -#define ID3D12GraphicsCommandList9_IASetIndexBufferStripCutValue(This,IBStripCutValue) \ +#define ID3D12GraphicsCommandList10_IASetIndexBufferStripCutValue(This,IBStripCutValue) \ ( (This)->lpVtbl -> IASetIndexBufferStripCutValue(This,IBStripCutValue) ) + +#define ID3D12GraphicsCommandList10_SetProgram(This,pDesc) \ + ( (This)->lpVtbl -> SetProgram(This,pDesc) ) + +#define ID3D12GraphicsCommandList10_DispatchGraph(This,pDesc) \ + ( (This)->lpVtbl -> DispatchGraph(This,pDesc) ) + #endif /* COBJMACROS */ @@ -31808,10 +34688,160 @@ EXTERN_C const IID IID_ID3D12GraphicsCommandList9; -#endif /* __ID3D12GraphicsCommandList9_INTERFACE_DEFINED__ */ +#endif /* __ID3D12GraphicsCommandList10_INTERFACE_DEFINED__ */ -/* interface __MIDL_itf_d3d12_0000_0068 */ +#ifndef __ID3D12GBVDiagnostics_INTERFACE_DEFINED__ +#define __ID3D12GBVDiagnostics_INTERFACE_DEFINED__ + +/* interface ID3D12GBVDiagnostics */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12GBVDiagnostics; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("597985ab-9b75-4dbb-be23-0761195bebee") + ID3D12GBVDiagnostics : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE GetGBVEntireSubresourceStatesData( + _In_ ID3D12Resource *pResource, + _Out_writes_bytes_(DataSize) int *pData, + UINT DataSize) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetGBVSubresourceState( + _In_ ID3D12Resource *pResource, + UINT Subresource, + _Out_ int *pData) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetGBVResourceUniformState( + _In_ ID3D12Resource *pResource, + _Out_ int *pData) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetGBVResourceInfo( + _In_ ID3D12Resource *pResource, + _In_opt_ D3D12_RESOURCE_DESC *pResourceDesc, + _In_opt_ UINT32 *pResourceHash, + _In_opt_ UINT32 *pSubresourceStatesByteOffset) = 0; + + virtual void STDMETHODCALLTYPE GBVReserved0( void) = 0; + + virtual void STDMETHODCALLTYPE GBVReserved1( void) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12GBVDiagnosticsVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12GBVDiagnostics * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12GBVDiagnostics * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12GBVDiagnostics * This); + + DECLSPEC_XFGVIRT(ID3D12GBVDiagnostics, GetGBVEntireSubresourceStatesData) + HRESULT ( STDMETHODCALLTYPE *GetGBVEntireSubresourceStatesData )( + ID3D12GBVDiagnostics * This, + _In_ ID3D12Resource *pResource, + _Out_writes_bytes_(DataSize) int *pData, + UINT DataSize); + + DECLSPEC_XFGVIRT(ID3D12GBVDiagnostics, GetGBVSubresourceState) + HRESULT ( STDMETHODCALLTYPE *GetGBVSubresourceState )( + ID3D12GBVDiagnostics * This, + _In_ ID3D12Resource *pResource, + UINT Subresource, + _Out_ int *pData); + + DECLSPEC_XFGVIRT(ID3D12GBVDiagnostics, GetGBVResourceUniformState) + HRESULT ( STDMETHODCALLTYPE *GetGBVResourceUniformState )( + ID3D12GBVDiagnostics * This, + _In_ ID3D12Resource *pResource, + _Out_ int *pData); + + DECLSPEC_XFGVIRT(ID3D12GBVDiagnostics, GetGBVResourceInfo) + HRESULT ( STDMETHODCALLTYPE *GetGBVResourceInfo )( + ID3D12GBVDiagnostics * This, + _In_ ID3D12Resource *pResource, + _In_opt_ D3D12_RESOURCE_DESC *pResourceDesc, + _In_opt_ UINT32 *pResourceHash, + _In_opt_ UINT32 *pSubresourceStatesByteOffset); + + DECLSPEC_XFGVIRT(ID3D12GBVDiagnostics, GBVReserved0) + void ( STDMETHODCALLTYPE *GBVReserved0 )( + ID3D12GBVDiagnostics * This); + + DECLSPEC_XFGVIRT(ID3D12GBVDiagnostics, GBVReserved1) + void ( STDMETHODCALLTYPE *GBVReserved1 )( + ID3D12GBVDiagnostics * This); + + END_INTERFACE + } ID3D12GBVDiagnosticsVtbl; + + interface ID3D12GBVDiagnostics + { + CONST_VTBL struct ID3D12GBVDiagnosticsVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12GBVDiagnostics_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12GBVDiagnostics_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12GBVDiagnostics_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12GBVDiagnostics_GetGBVEntireSubresourceStatesData(This,pResource,pData,DataSize) \ + ( (This)->lpVtbl -> GetGBVEntireSubresourceStatesData(This,pResource,pData,DataSize) ) + +#define ID3D12GBVDiagnostics_GetGBVSubresourceState(This,pResource,Subresource,pData) \ + ( (This)->lpVtbl -> GetGBVSubresourceState(This,pResource,Subresource,pData) ) + +#define ID3D12GBVDiagnostics_GetGBVResourceUniformState(This,pResource,pData) \ + ( (This)->lpVtbl -> GetGBVResourceUniformState(This,pResource,pData) ) + +#define ID3D12GBVDiagnostics_GetGBVResourceInfo(This,pResource,pResourceDesc,pResourceHash,pSubresourceStatesByteOffset) \ + ( (This)->lpVtbl -> GetGBVResourceInfo(This,pResource,pResourceDesc,pResourceHash,pSubresourceStatesByteOffset) ) + +#define ID3D12GBVDiagnostics_GBVReserved0(This) \ + ( (This)->lpVtbl -> GBVReserved0(This) ) + +#define ID3D12GBVDiagnostics_GBVReserved1(This) \ + ( (This)->lpVtbl -> GBVReserved1(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12GBVDiagnostics_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0074 */ /* [local] */ #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_GAMES) */ @@ -31850,6 +34880,8 @@ DEFINE_GUID(IID_ID3D12SwapChainAssistant,0xf1df64b6,0x57fd,0x49cd,0x88,0x07,0xc0 DEFINE_GUID(IID_ID3D12LifetimeTracker,0x3fd03d36,0x4eb1,0x424a,0xa5,0x82,0x49,0x4e,0xcb,0x8b,0xa8,0x13); DEFINE_GUID(IID_ID3D12StateObject,0x47016943,0xfca8,0x4594,0x93,0xea,0xaf,0x25,0x8b,0x55,0x34,0x6d); DEFINE_GUID(IID_ID3D12StateObjectProperties,0xde5fa827,0x9bf9,0x4f26,0x89,0xff,0xd7,0xf5,0x6f,0xde,0x38,0x60); +DEFINE_GUID(IID_ID3D12StateObjectProperties1,0x460caac7,0x1d24,0x446a,0xa1,0x84,0xca,0x67,0xdb,0x49,0x41,0x38); +DEFINE_GUID(IID_ID3D12WorkGraphProperties,0x065acf71,0xf863,0x4b89,0x82,0xf4,0x02,0xe4,0xd5,0x88,0x67,0x57); DEFINE_GUID(IID_ID3D12Device5,0x8b4f173b,0x2fea,0x4b80,0x8f,0x58,0x43,0x07,0x19,0x1a,0xb9,0x5d); DEFINE_GUID(IID_ID3D12DeviceRemovedExtendedDataSettings,0x82BC481C,0x6B9B,0x4030,0xAE,0xDB,0x7E,0xE3,0xD1,0xDF,0x1E,0x63); DEFINE_GUID(IID_ID3D12DeviceRemovedExtendedDataSettings1,0xDBD5AE51,0x3317,0x4F0A,0xAD,0xF9,0x1D,0x7C,0xED,0xCA,0xAE,0x0B); @@ -31873,21 +34905,25 @@ DEFINE_GUID(IID_ID3D12Device10,0x517f8718,0xaa66,0x49f9,0xb0,0x2b,0xa7,0xab,0x89 DEFINE_GUID(IID_ID3D12Device11,0x5405c344,0xd457,0x444e,0xb4,0xdd,0x23,0x66,0xe4,0x5a,0xee,0x39); DEFINE_GUID(IID_ID3D12Device12,0x5af5c532,0x4c91,0x4cd0,0xb5,0x41,0x15,0xa4,0x05,0x39,0x5f,0xc5); DEFINE_GUID(IID_ID3D12Device13,0x14eecffc,0x4df8,0x40f7,0xa1,0x18,0x5c,0x81,0x6f,0x45,0x69,0x5e); +DEFINE_GUID(IID_ID3D12Device14,0x5f6e592d,0xd895,0x44c2,0x8e,0x4a,0x88,0xad,0x49,0x26,0xd3,0x23); DEFINE_GUID(IID_ID3D12VirtualizationGuestDevice,0xbc66d368,0x7373,0x4943,0x87,0x57,0xfc,0x87,0xdc,0x79,0xe4,0x76); DEFINE_GUID(IID_ID3D12Tools,0x7071e1f0,0xe84b,0x4b33,0x97,0x4f,0x12,0xfa,0x49,0xde,0x65,0xc5); DEFINE_GUID(IID_ID3D12SDKConfiguration,0xe9eb5314,0x33aa,0x42b2,0xa7,0x18,0xd7,0x7f,0x58,0xb1,0xf1,0xc7); DEFINE_GUID(IID_ID3D12SDKConfiguration1,0x8aaf9303,0xad25,0x48b9,0x9a,0x57,0xd9,0xc3,0x7e,0x00,0x9d,0x9f); DEFINE_GUID(IID_ID3D12DeviceFactory,0x61f307d3,0xd34e,0x4e7c,0x83,0x74,0x3b,0xa4,0xde,0x23,0xcc,0xcb); DEFINE_GUID(IID_ID3D12DeviceConfiguration,0x78dbf87b,0xf766,0x422b,0xa6,0x1c,0xc8,0xc4,0x46,0xbd,0xb9,0xad); +DEFINE_GUID(IID_ID3D12DeviceConfiguration1,0xed342442,0x6343,0x4e16,0xbb,0x82,0xa3,0xa5,0x77,0x87,0x4e,0x56); DEFINE_GUID(IID_ID3D12GraphicsCommandList5,0x55050859,0x4024,0x474c,0x87,0xf5,0x64,0x72,0xea,0xee,0x44,0xea); DEFINE_GUID(IID_ID3D12GraphicsCommandList6,0xc3827890,0xe548,0x4cfa,0x96,0xcf,0x56,0x89,0xa9,0x37,0x0f,0x80); DEFINE_GUID(IID_ID3D12GraphicsCommandList7,0xdd171223,0x8b61,0x4769,0x90,0xe3,0x16,0x0c,0xcd,0xe4,0xe2,0xc1); DEFINE_GUID(IID_ID3D12GraphicsCommandList8,0xee936ef9,0x599d,0x4d28,0x93,0x8e,0x23,0xc4,0xad,0x05,0xce,0x51); DEFINE_GUID(IID_ID3D12GraphicsCommandList9,0x34ed2808,0xffe6,0x4c2b,0xb1,0x1a,0xca,0xbd,0x2b,0x0c,0x59,0xe1); +DEFINE_GUID(IID_ID3D12GraphicsCommandList10,0x7013c015,0xd161,0x4b63,0xa0,0x8c,0x23,0x85,0x52,0xdd,0x8a,0xcc); +DEFINE_GUID(IID_ID3D12GBVDiagnostics,0x597985ab,0x9b75,0x4dbb,0xbe,0x23,0x07,0x61,0x19,0x5b,0xeb,0xee); -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0068_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0068_v0_0_s_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0074_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0074_v0_0_s_ifspec; /* Additional Prototypes for ALL interfaces */ diff --git a/WickedEngine/Utility/dx12/d3d12compatibility.h b/WickedEngine/Utility/dx12/d3d12compatibility.h index 1a9430e5c92..f61c590c6a2 100644 --- a/WickedEngine/Utility/dx12/d3d12compatibility.h +++ b/WickedEngine/Utility/dx12/d3d12compatibility.h @@ -87,6 +87,13 @@ typedef interface OpenCLOn12CreatorID OpenCLOn12CreatorID; #endif /* __OpenCLOn12CreatorID_FWD_DEFINED__ */ +#ifndef __VulkanOn12CreatorID_FWD_DEFINED__ +#define __VulkanOn12CreatorID_FWD_DEFINED__ +typedef interface VulkanOn12CreatorID VulkanOn12CreatorID; + +#endif /* __VulkanOn12CreatorID_FWD_DEFINED__ */ + + #ifndef __DirectMLTensorFlowCreatorID_FWD_DEFINED__ #define __DirectMLTensorFlowCreatorID_FWD_DEFINED__ typedef interface DirectMLTensorFlowCreatorID DirectMLTensorFlowCreatorID; @@ -565,6 +572,78 @@ EXTERN_C const IID IID_OpenCLOn12CreatorID; #endif /* __OpenCLOn12CreatorID_INTERFACE_DEFINED__ */ +#ifndef __VulkanOn12CreatorID_INTERFACE_DEFINED__ +#define __VulkanOn12CreatorID_INTERFACE_DEFINED__ + +/* interface VulkanOn12CreatorID */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_VulkanOn12CreatorID; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("bc806e01-3052-406c-a3e8-9fc07f048f98") + VulkanOn12CreatorID : public IUnknown + { + public: + }; + + +#else /* C style interface */ + + typedef struct VulkanOn12CreatorIDVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + VulkanOn12CreatorID * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + VulkanOn12CreatorID * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + VulkanOn12CreatorID * This); + + END_INTERFACE + } VulkanOn12CreatorIDVtbl; + + interface VulkanOn12CreatorID + { + CONST_VTBL struct VulkanOn12CreatorIDVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define VulkanOn12CreatorID_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define VulkanOn12CreatorID_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define VulkanOn12CreatorID_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __VulkanOn12CreatorID_INTERFACE_DEFINED__ */ + + #ifndef __DirectMLTensorFlowCreatorID_INTERFACE_DEFINED__ #define __DirectMLTensorFlowCreatorID_INTERFACE_DEFINED__ @@ -709,7 +788,7 @@ EXTERN_C const IID IID_DirectMLPyTorchCreatorID; #endif /* __DirectMLPyTorchCreatorID_INTERFACE_DEFINED__ */ -/* interface __MIDL_itf_d3d12compatibility_0000_0007 */ +/* interface __MIDL_itf_d3d12compatibility_0000_0008 */ /* [local] */ #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_GAMES) */ @@ -719,12 +798,13 @@ DEFINE_GUID(IID_D3D11On12CreatorID,0xedbf5678,0x2960,0x4e81,0x84,0x29,0x99,0xd4, DEFINE_GUID(IID_D3D9On12CreatorID,0xfffcbb7f,0x15d3,0x42a2,0x84,0x1e,0x9d,0x8d,0x32,0xf3,0x7d,0xdd); DEFINE_GUID(IID_OpenGLOn12CreatorID,0x6bb3cd34,0x0d19,0x45ab,0x97,0xed,0xd7,0x20,0xba,0x3d,0xfc,0x80); DEFINE_GUID(IID_OpenCLOn12CreatorID,0x3f76bb74,0x91b5,0x4a88,0xb1,0x26,0x20,0xca,0x03,0x31,0xcd,0x60); +DEFINE_GUID(IID_VulkanOn12CreatorID,0xbc806e01,0x3052,0x406c,0xa3,0xe8,0x9f,0xc0,0x7f,0x04,0x8f,0x98); DEFINE_GUID(IID_DirectMLTensorFlowCreatorID,0xcb7490ac,0x8a0f,0x44ec,0x9b,0x7b,0x6f,0x4c,0xaf,0xe8,0xe9,0xab); DEFINE_GUID(IID_DirectMLPyTorchCreatorID,0xaf029192,0xfba1,0x4b05,0x91,0x16,0x23,0x5e,0x06,0x56,0x03,0x54); -extern RPC_IF_HANDLE __MIDL_itf_d3d12compatibility_0000_0007_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_d3d12compatibility_0000_0007_v0_0_s_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12compatibility_0000_0008_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12compatibility_0000_0008_v0_0_s_ifspec; /* Additional Prototypes for ALL interfaces */ diff --git a/WickedEngine/Utility/dx12/d3d12sdklayers.h b/WickedEngine/Utility/dx12/d3d12sdklayers.h index 06aa091b558..7951a9eecb5 100644 --- a/WickedEngine/Utility/dx12/d3d12sdklayers.h +++ b/WickedEngine/Utility/dx12/d3d12sdklayers.h @@ -3312,7 +3312,10 @@ enum D3D12_MESSAGE_ID D3D12_MESSAGE_ID_PIX_EVENT_UNDERFLOW = 1384, D3D12_MESSAGE_ID_RECREATEAT_INVALID_TARGET = 1385, D3D12_MESSAGE_ID_RECREATEAT_INSUFFICIENT_SUPPORT = 1386, - D3D12_MESSAGE_ID_D3D12_MESSAGES_END = ( D3D12_MESSAGE_ID_RECREATEAT_INSUFFICIENT_SUPPORT + 1 ) + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_STRUCTURED_BUFFER_STRIDE_MISMATCH = 1387, + D3D12_MESSAGE_ID_DISPATCH_GRAPH_INVALID = 1388, + D3D12_MESSAGE_ID_CREATE_STATE_OBJECT_WARNING = 1414, + D3D12_MESSAGE_ID_D3D12_MESSAGES_END = ( D3D12_MESSAGE_ID_CREATE_STATE_OBJECT_WARNING + 1 ) } D3D12_MESSAGE_ID; typedef struct D3D12_MESSAGE diff --git a/WickedEngine/Utility/dx12/d3d12shader.h b/WickedEngine/Utility/dx12/d3d12shader.h index 0acf584e324..224ae511009 100644 --- a/WickedEngine/Utility/dx12/d3d12shader.h +++ b/WickedEngine/Utility/dx12/d3d12shader.h @@ -37,6 +37,8 @@ typedef enum D3D12_SHADER_VERSION_TYPE D3D12_SHVER_MESH_SHADER = 13, D3D12_SHVER_AMPLIFICATION_SHADER = 14, + D3D12_SHVER_NODE_SHADER = 15, + D3D12_SHVER_RESERVED0 = 0xFFF0, } D3D12_SHADER_VERSION_TYPE; @@ -201,8 +203,10 @@ typedef struct _D3D12_SHADER_INPUT_BIND_DESC #define D3D_SHADER_REQUIRES_SAMPLER_DESCRIPTOR_HEAP_INDEXING 0x04000000 #define D3D_SHADER_REQUIRES_WAVE_MMA 0x08000000 #define D3D_SHADER_REQUIRES_ATOMIC_INT64_ON_DESCRIPTOR_HEAP_RESOURCE 0x10000000 -#define D3D_SHADER_FEATURE_ADVANCED_TEXTURE_OPS 0x20000000 -#define D3D_SHADER_FEATURE_WRITEABLE_MSAA_TEXTURES 0x40000000 +#define D3D_SHADER_REQUIRES_ADVANCED_TEXTURE_OPS 0x20000000 +#define D3D_SHADER_REQUIRES_WRITEABLE_MSAA_TEXTURES 0x40000000 +#define D3D_SHADER_REQUIRES_SAMPLE_CMP_GRADIENT_OR_BIAS 0x80000000 +#define D3D_SHADER_REQUIRES_EXTENDED_COMMAND_INFO 0x100000000ull typedef struct _D3D12_LIBRARY_DESC diff --git a/WickedEngine/Utility/dx12/d3d12video.h b/WickedEngine/Utility/dx12/d3d12video.h index fe9a17377c9..32f4da0f36b 100644 --- a/WickedEngine/Utility/dx12/d3d12video.h +++ b/WickedEngine/Utility/dx12/d3d12video.h @@ -959,7 +959,7 @@ enum D3D12_VIDEO_DECODE_ARGUMENT_TYPE D3D12_VIDEO_DECODE_ARGUMENT_TYPE_PICTURE_PARAMETERS = 0, D3D12_VIDEO_DECODE_ARGUMENT_TYPE_INVERSE_QUANTIZATION_MATRIX = 1, D3D12_VIDEO_DECODE_ARGUMENT_TYPE_SLICE_CONTROL = 2, - D3D12_VIDEO_DECODE_ARGUMENT_TYPE_MAX_VALID = 3 + D3D12_VIDEO_DECODE_ARGUMENT_TYPE_HUFFMAN_TABLE = 3 } D3D12_VIDEO_DECODE_ARGUMENT_TYPE; typedef struct D3D12_FEATURE_DATA_VIDEO_DECODE_SUPPORT @@ -6331,6 +6331,13 @@ DEFINE_GUID(D3D12_VIDEO_DECODE_PROFILE_AV1_PROFILE1, 0x6936ff0f, 0x45b1, 0x4163, DEFINE_GUID(D3D12_VIDEO_DECODE_PROFILE_AV1_PROFILE2, 0x0c5f2aa1, 0xe541, 0x4089, 0xbb, 0x7b, 0x98, 0x11, 0x0a, 0x19, 0xd7, 0xc8); DEFINE_GUID(D3D12_VIDEO_DECODE_PROFILE_AV1_12BIT_PROFILE2, 0x17127009, 0xa00f, 0x4ce1, 0x99, 0x4e, 0xbf, 0x40, 0x81, 0xf6, 0xf3, 0xf0); DEFINE_GUID(D3D12_VIDEO_DECODE_PROFILE_AV1_12BIT_PROFILE2_420, 0x2d80bed6, 0x9cac, 0x4835, 0x9e, 0x91, 0x32, 0x7b, 0xbc, 0x4f, 0x9e, 0xe8); +DEFINE_GUID(D3D12_VIDEO_DECODE_PROFILE_MJPEG_VLD_420, 0x725cb506, 0xc29, 0x43c4, 0x94, 0x40, 0x8e, 0x93, 0x97, 0x90, 0x3a, 0x4); +DEFINE_GUID(D3D12_VIDEO_DECODE_PROFILE_MJPEG_VLD_422, 0x5b77b9cd, 0x1a35, 0x4c30, 0x9f, 0xd8, 0xef, 0x4b, 0x60, 0xc0, 0x35, 0xdd); +DEFINE_GUID(D3D12_VIDEO_DECODE_PROFILE_MJPEG_VLD_444, 0xd95161f9, 0xd44, 0x47e6, 0xbc, 0xf5, 0x1b, 0xfb, 0xfb, 0x26, 0x8f, 0x97); +DEFINE_GUID(D3D12_VIDEO_DECODE_PROFILE_MJPEG_VLD_4444, 0xc91748d5, 0xfd18, 0x4aca, 0x9d, 0xb3, 0x3a, 0x66, 0x34, 0xab, 0x54, 0x7d); +DEFINE_GUID(D3D12_VIDEO_DECODE_PROFILE_JPEG_VLD_420, 0xcf782c83, 0xbef5, 0x4a2c, 0x87, 0xcb, 0x60, 0x19, 0xe7, 0xb1, 0x75, 0xac); +DEFINE_GUID(D3D12_VIDEO_DECODE_PROFILE_JPEG_VLD_422, 0xf04df417, 0xeee2, 0x4067, 0xa7, 0x78, 0xf3, 0x5c, 0x15, 0xab, 0x97, 0x21); +DEFINE_GUID(D3D12_VIDEO_DECODE_PROFILE_JPEG_VLD_444, 0x4cd00e17, 0x89ba, 0x48ef, 0xb9, 0xf9, 0xed, 0xcb, 0x82, 0x71, 0x3f, 0x65); typedef enum D3D12_VIDEO_ENCODER_AV1_PROFILE { @@ -6958,7 +6965,14 @@ typedef enum D3D12_VIDEO_ENCODER_PROFILE_HEVC { D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN = 0, - D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN10 = 1 + D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN10 = 1, + D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN12 = 2, + D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN10_422 = 3, + D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN12_422 = 4, + D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN_444 = 5, + D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN10_444 = 6, + D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN12_444 = 7, + D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN16_444 = 8 } D3D12_VIDEO_ENCODER_PROFILE_HEVC; typedef struct D3D12_VIDEO_ENCODER_PROFILE_DESC @@ -7225,7 +7239,8 @@ enum D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_H264_FLAGS D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_H264_FLAG_ADAPTIVE_8x8_TRANSFORM_ENCODING_SUPPORT = 0x8, D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_H264_FLAG_DIRECT_SPATIAL_ENCODING_SUPPORT = 0x10, D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_H264_FLAG_DIRECT_TEMPORAL_ENCODING_SUPPORT = 0x20, - D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_H264_FLAG_CONSTRAINED_INTRAPREDICTION_SUPPORT = 0x40 + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_H264_FLAG_CONSTRAINED_INTRAPREDICTION_SUPPORT = 0x40, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_H264_FLAG_NUM_REF_IDX_ACTIVE_OVERRIDE_FLAG_SLICE_SUPPORT = 0x80 } D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_H264_FLAGS; DEFINE_ENUM_FLAG_OPERATORS(D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_H264_FLAGS); @@ -7273,7 +7288,30 @@ enum D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAGS D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_ASYMETRIC_MOTION_PARTITION_REQUIRED = 0x20, D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_TRANSFORM_SKIP_SUPPORT = 0x40, D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_DISABLING_LOOP_FILTER_ACROSS_SLICES_SUPPORT = 0x80, - D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_P_FRAMES_IMPLEMENTED_AS_LOW_DELAY_B_FRAMES = 0x100 + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_P_FRAMES_IMPLEMENTED_AS_LOW_DELAY_B_FRAMES = 0x100, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_NUM_REF_IDX_ACTIVE_OVERRIDE_FLAG_SLICE_SUPPORT = 0x200, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_TRANSFORM_SKIP_ROTATION_ENABLED_SUPPORT = 0x400, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_TRANSFORM_SKIP_ROTATION_ENABLED_REQUIRED = 0x800, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_TRANSFORM_SKIP_CONTEXT_ENABLED_SUPPORT = 0x1000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_TRANSFORM_SKIP_CONTEXT_ENABLED_REQUIRED = 0x2000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_IMPLICIT_RDPCM_ENABLED_SUPPORT = 0x4000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_IMPLICIT_RDPCM_ENABLED_REQUIRED = 0x8000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_EXPLICIT_RDPCM_ENABLED_SUPPORT = 0x10000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_EXPLICIT_RDPCM_ENABLED_REQUIRED = 0x20000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_EXTENDED_PRECISION_PROCESSING_SUPPORT = 0x40000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_EXTENDED_PRECISION_PROCESSING_REQUIRED = 0x80000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_INTRA_SMOOTHING_DISABLED_SUPPORT = 0x100000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_INTRA_SMOOTHING_DISABLED_REQUIRED = 0x200000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_HIGH_PRECISION_OFFSETS_ENABLED_SUPPORT = 0x400000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_HIGH_PRECISION_OFFSETS_ENABLED_REQUIRED = 0x800000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_PERSISTENT_RICE_ADAPTATION_ENABLED_SUPPORT = 0x1000000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_PERSISTENT_RICE_ADAPTATION_ENABLED_REQUIRED = 0x2000000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_CABAC_BYPASS_ALIGNMENT_ENABLED_SUPPORT = 0x4000000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_CABAC_BYPASS_ALIGNMENT_ENABLED_REQUIRED = 0x8000000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_CROSS_COMPONENT_PREDICTION_ENABLED_FLAG_SUPPORT = 0x10000000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_CROSS_COMPONENT_PREDICTION_ENABLED_FLAG_REQUIRED = 0x20000000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_CHROMA_QP_OFFSET_LIST_ENABLED_FLAG_SUPPORT = 0x40000000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_CHROMA_QP_OFFSET_LIST_ENABLED_FLAG_REQUIRED = 0x80000000 } D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAGS; DEFINE_ENUM_FLAG_OPERATORS(D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAGS); @@ -7306,6 +7344,34 @@ typedef struct D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC UCHAR max_transform_hierarchy_depth_intra; } D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC; +typedef +enum D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAGS1 + { + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG1_NONE = 0, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG1_SEPARATE_COLOUR_PLANE_SUPPORT = 0x1, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG1_SEPARATE_COLOUR_PLANE_REQUIRED = 0x2 + } D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAGS1; + +DEFINE_ENUM_FLAG_OPERATORS(D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAGS1); +typedef struct D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC1 + { + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAGS SupportFlags; + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE MinLumaCodingUnitSize; + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE MaxLumaCodingUnitSize; + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE MinLumaTransformUnitSize; + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE MaxLumaTransformUnitSize; + UCHAR max_transform_hierarchy_depth_inter; + UCHAR max_transform_hierarchy_depth_intra; + UINT allowed_diff_cu_chroma_qp_offset_depth_values; + UINT allowed_log2_sao_offset_scale_luma_values; + UINT allowed_log2_sao_offset_scale_chroma_values; + UINT allowed_log2_max_transform_skip_block_size_minus2_values; + UINT allowed_chroma_qp_offset_list_len_minus1_values; + UINT allowed_cb_qp_offset_list_values[ 6 ]; + UINT allowed_cr_qp_offset_list_values[ 6 ]; + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAGS1 SupportFlags1; + } D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC1; + typedef struct D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT { UINT DataSize; @@ -7313,6 +7379,7 @@ typedef struct D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT { D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_H264 *pH264Support; D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC *pHEVCSupport; + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC1 *pHEVCSupport1; D3D12_VIDEO_ENCODER_AV1_CODEC_CONFIGURATION_SUPPORT *pAV1Support; } ; } D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT; @@ -7422,7 +7489,17 @@ enum D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAGS D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_ENABLE_LONG_TERM_REFERENCES = 0x8, D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_USE_ASYMETRIC_MOTION_PARTITION = 0x10, D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_ENABLE_TRANSFORM_SKIPPING = 0x20, - D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_USE_CONSTRAINED_INTRAPREDICTION = 0x40 + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_USE_CONSTRAINED_INTRAPREDICTION = 0x40, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_TRANSFORM_SKIP_ROTATION = 0x80, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_TRANSFORM_SKIP_CONTEXT = 0x100, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_IMPLICIT_RDPCM = 0x200, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_EXPLICIT_RDPCM = 0x400, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_EXTENDED_PRECISION_PROCESSING = 0x800, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_INTRA_SMOOTHING_DISABLED = 0x1000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_HIGH_PRECISION_OFFSETS = 0x2000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_PERSISTENT_RICE_ADAPTATION = 0x4000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_CABAC_BYPASS_ALIGNMENT = 0x8000, + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_SEPARATE_COLOUR_PLANE = 0x10000 } D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAGS; DEFINE_ENUM_FLAG_OPERATORS(D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAGS); @@ -8253,7 +8330,8 @@ typedef enum D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_H264_FLAGS { D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_H264_FLAG_NONE = 0, - D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_H264_FLAG_REQUEST_INTRA_CONSTRAINED_SLICES = 0x1 + D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_H264_FLAG_REQUEST_INTRA_CONSTRAINED_SLICES = 0x1, + D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_H264_FLAG_REQUEST_NUM_REF_IDX_ACTIVE_OVERRIDE_FLAG_SLICE = 0x2 } D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_H264_FLAGS; DEFINE_ENUM_FLAG_OPERATORS(D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_H264_FLAGS); @@ -8321,7 +8399,10 @@ typedef enum D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_HEVC_FLAGS { D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_HEVC_FLAG_NONE = 0, - D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_HEVC_FLAG_REQUEST_INTRA_CONSTRAINED_SLICES = 0x1 + D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_HEVC_FLAG_REQUEST_INTRA_CONSTRAINED_SLICES = 0x1, + D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_HEVC_FLAG_REQUEST_NUM_REF_IDX_ACTIVE_OVERRIDE_FLAG_SLICE = 0x2, + D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_HEVC_FLAG_CROSS_COMPONENT_PREDICTION = 0x4, + D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_HEVC_FLAG_CHROMA_QP_OFFSET_LIST = 0x8 } D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_HEVC_FLAGS; DEFINE_ENUM_FLAG_OPERATORS(D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_HEVC_FLAGS); @@ -8346,6 +8427,34 @@ typedef struct D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_HEVC _Field_size_full_(QPMapValuesCount) INT8 *pRateControlQPMap; } D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_HEVC; +typedef struct D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_HEVC1 + { + D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_HEVC_FLAGS Flags; + D3D12_VIDEO_ENCODER_FRAME_TYPE_HEVC FrameType; + UINT slice_pic_parameter_set_id; + UINT PictureOrderCountNumber; + UINT TemporalLayerIndex; + UINT List0ReferenceFramesCount; + _Field_size_full_(List0ReferenceFramesCount) UINT *pList0ReferenceFrames; + UINT List1ReferenceFramesCount; + _Field_size_full_(List1ReferenceFramesCount) UINT *pList1ReferenceFrames; + UINT ReferenceFramesReconPictureDescriptorsCount; + _Field_size_full_(ReferenceFramesReconPictureDescriptorsCount) D3D12_VIDEO_ENCODER_REFERENCE_PICTURE_DESCRIPTOR_HEVC *pReferenceFramesReconPictureDescriptors; + UINT List0RefPicModificationsCount; + _Field_size_full_(List0RefPicModificationsCount) UINT *pList0RefPicModifications; + UINT List1RefPicModificationsCount; + _Field_size_full_(List1RefPicModificationsCount) UINT *pList1RefPicModifications; + UINT QPMapValuesCount; + _Field_size_full_(QPMapValuesCount) INT8 *pRateControlQPMap; + UCHAR diff_cu_chroma_qp_offset_depth; + UCHAR log2_sao_offset_scale_luma; + UCHAR log2_sao_offset_scale_chroma; + UCHAR log2_max_transform_skip_block_size_minus2; + UCHAR chroma_qp_offset_list_len_minus1; + CHAR cb_qp_offset_list[ 6 ]; + CHAR cr_qp_offset_list[ 6 ]; + } D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_HEVC1; + typedef struct D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA { UINT DataSize; @@ -8353,6 +8462,7 @@ typedef struct D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA { D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_H264 *pH264PicData; D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_HEVC *pHEVCPicData; + D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_HEVC1 *pHEVCPicData1; D3D12_VIDEO_ENCODER_AV1_PICTURE_CONTROL_CODEC_DATA *pAV1PicData; } ; } D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA; diff --git a/WickedEngine/Utility/dx12/d3dcommon.h b/WickedEngine/Utility/dx12/d3dcommon.h index 974f205a604..2e2418dc166 100644 --- a/WickedEngine/Utility/dx12/d3dcommon.h +++ b/WickedEngine/Utility/dx12/d3dcommon.h @@ -390,6 +390,10 @@ enum D3D_SRV_DIMENSION #define D3D_SHADER_FEATURE_ATOMIC_INT64_ON_DESCRIPTOR_HEAP_RESOURCE 0x10000000 #define D3D_SHADER_FEATURE_ADVANCED_TEXTURE_OPS 0x20000000 #define D3D_SHADER_FEATURE_WRITEABLE_MSAA_TEXTURES 0x40000000 +#define D3D_SHADER_FEATURE_SAMPLE_CMP_GRADIENT_OR_BIAS 0x80000000 +#define D3D_SHADER_FEATURE_EXTENDED_COMMAND_INFO 0x100000000ull +#define D3D_OPT_SHADER_FEATURE_USES_DERIVATIVES 0x0000010000000000ull +#define D3D_OPT_SHADER_FEATURE_REQUIRES_GROUP 0x0000020000000000ull typedef struct _D3D_SHADER_MACRO { LPCSTR Name; @@ -961,10 +965,22 @@ enum D3D_REGISTER_COMPONENT_TYPE D3D_REGISTER_COMPONENT_UINT32 = 1, D3D_REGISTER_COMPONENT_SINT32 = 2, D3D_REGISTER_COMPONENT_FLOAT32 = 3, + D3D_REGISTER_COMPONENT_UINT16 = 4, + D3D_REGISTER_COMPONENT_SINT16 = 5, + D3D_REGISTER_COMPONENT_FLOAT16 = 6, + D3D_REGISTER_COMPONENT_UINT64 = 7, + D3D_REGISTER_COMPONENT_SINT64 = 8, + D3D_REGISTER_COMPONENT_FLOAT64 = 9, D3D10_REGISTER_COMPONENT_UNKNOWN = D3D_REGISTER_COMPONENT_UNKNOWN, D3D10_REGISTER_COMPONENT_UINT32 = D3D_REGISTER_COMPONENT_UINT32, D3D10_REGISTER_COMPONENT_SINT32 = D3D_REGISTER_COMPONENT_SINT32, - D3D10_REGISTER_COMPONENT_FLOAT32 = D3D_REGISTER_COMPONENT_FLOAT32 + D3D10_REGISTER_COMPONENT_FLOAT32 = D3D_REGISTER_COMPONENT_FLOAT32, + D3D10_REGISTER_COMPONENT_UINT16 = D3D_REGISTER_COMPONENT_UINT16, + D3D10_REGISTER_COMPONENT_SINT16 = D3D_REGISTER_COMPONENT_SINT16, + D3D10_REGISTER_COMPONENT_FLOAT16 = D3D_REGISTER_COMPONENT_FLOAT16, + D3D10_REGISTER_COMPONENT_UINT64 = D3D_REGISTER_COMPONENT_UINT64, + D3D10_REGISTER_COMPONENT_SINT64 = D3D_REGISTER_COMPONENT_SINT64, + D3D10_REGISTER_COMPONENT_FLOAT64 = D3D_REGISTER_COMPONENT_FLOAT64 } D3D_REGISTER_COMPONENT_TYPE; typedef diff --git a/WickedEngine/Utility/dx12/d3dx12_check_feature_support.h b/WickedEngine/Utility/dx12/d3dx12_check_feature_support.h index 653a422d03b..d6dd5c8ea87 100644 --- a/WickedEngine/Utility/dx12/d3dx12_check_feature_support.h +++ b/WickedEngine/Utility/dx12/d3dx12_check_feature_support.h @@ -231,6 +231,11 @@ class CD3DX12FeatureSupport BOOL ComputeOnlyWriteWatchSupported() const noexcept; #endif +#if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) + D3D12_EXECUTE_INDIRECT_TIER ExecuteIndirectTier() const noexcept; + D3D12_WORK_GRAPHS_TIER WorkGraphsTier() const noexcept; +#endif + private: // Private structs and helpers declaration struct ProtectedResourceSessionTypesLocal : D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_TYPES { @@ -317,6 +322,9 @@ class CD3DX12FeatureSupport #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 611) D3D12_FEATURE_DATA_D3D12_OPTIONS20 m_dOptions20; #endif +#if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) + D3D12_FEATURE_DATA_D3D12_OPTIONS21 m_dOptions21; +#endif }; // Implementations for CD3DX12FeatureSupport functions @@ -408,6 +416,9 @@ inline CD3DX12FeatureSupport::CD3DX12FeatureSupport() noexcept #if defined (D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 611) , m_dOptions20{} #endif +#if defined (D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) +, m_dOptions21{} +#endif {} inline HRESULT CD3DX12FeatureSupport::Init(ID3D12Device* pDevice) @@ -576,6 +587,13 @@ inline HRESULT CD3DX12FeatureSupport::Init(ID3D12Device* pDevice) } #endif +#if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) + if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS21, &m_dOptions21, sizeof(m_dOptions21)))) + { + m_dOptions21 = {}; + } +#endif + // Initialize per-node feature support data structures const UINT uNodeCount = m_pDevice->GetNodeCount(); m_dProtectedResourceSessionSupport.resize(uNodeCount); @@ -948,6 +966,12 @@ FEATURE_SUPPORT_GET(UINT, m_dOptions19, MaxViewDescriptorHeapSize); FEATURE_SUPPORT_GET(BOOL, m_dOptions20, ComputeOnlyWriteWatchSupported); #endif +#if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) +// 50: Options21 +FEATURE_SUPPORT_GET(D3D12_EXECUTE_INDIRECT_TIER, m_dOptions21, ExecuteIndirectTier); +FEATURE_SUPPORT_GET(D3D12_WORK_GRAPHS_TIER, m_dOptions21, WorkGraphsTier); +#endif + // Helper function to decide the highest shader model supported by the system // Stores the result in m_dShaderModel // Must be updated whenever a new shader model is added to the d3d12.h header @@ -958,6 +982,9 @@ inline HRESULT CD3DX12FeatureSupport::QueryHighestShaderModel() const D3D_SHADER_MODEL allModelVersions[] = { +#if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) + D3D_SHADER_MODEL_6_9, +#endif #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606) D3D_SHADER_MODEL_6_8, #endif @@ -1054,8 +1081,12 @@ inline HRESULT CD3DX12FeatureSupport::QueryHighestFeatureLevel() D3D_FEATURE_LEVEL_9_3, D3D_FEATURE_LEVEL_9_2, D3D_FEATURE_LEVEL_9_1, +#if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 5) D3D_FEATURE_LEVEL_1_0_CORE, +#endif +#if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 611) D3D_FEATURE_LEVEL_1_0_GENERIC +#endif }; D3D12_FEATURE_DATA_FEATURE_LEVELS dFeatureLevel; diff --git a/WickedEngine/Utility/dx12/d3dx12_core.h b/WickedEngine/Utility/dx12/d3dx12_core.h index 593f7637a32..a93ff5b5ce4 100644 --- a/WickedEngine/Utility/dx12/d3dx12_core.h +++ b/WickedEngine/Utility/dx12/d3dx12_core.h @@ -721,7 +721,7 @@ struct CD3DX12_RASTERIZER_DESC2 : public D3D12_RASTERIZER_DESC2 } operator D3D12_RASTERIZER_DESC() const noexcept { - return (D3D12_RASTERIZER_DESC)CD3DX12_RASTERIZER_DESC1((D3D12_RASTERIZER_DESC1)*this); + return static_cast(CD3DX12_RASTERIZER_DESC1(static_cast(*this))); } }; #endif // D3D12_SDK_VERSION >= 610 diff --git a/WickedEngine/Utility/dx12/d3dx12_pipeline_state_stream.h b/WickedEngine/Utility/dx12/d3dx12_pipeline_state_stream.h index f061e795962..5591a93294f 100644 --- a/WickedEngine/Utility/dx12/d3dx12_pipeline_state_stream.h +++ b/WickedEngine/Utility/dx12/d3dx12_pipeline_state_stream.h @@ -25,8 +25,10 @@ struct DefaultSampleMask { operator UINT() noexcept { return UINT_MAX; } }; struct DefaultSampleDesc { operator DXGI_SAMPLE_DESC() noexcept { return DXGI_SAMPLE_DESC{1, 0}; } }; +#ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4324) +#endif template class alignas(void*) CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT { @@ -42,7 +44,9 @@ class alignas(void*) CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT InnerStructType* operator&() noexcept { return &pssInner; } InnerStructType const* operator&() const noexcept { return &pssInner; } }; +#ifdef _MSC_VER #pragma warning(pop) +#endif typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_PIPELINE_STATE_FLAGS, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_FLAGS> CD3DX12_PIPELINE_STATE_STREAM_FLAGS; typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< UINT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK> CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK; typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< ID3D12RootSignature*, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE> CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE; @@ -123,6 +127,9 @@ struct ID3DX12PipelineParserCallbacks virtual void ErrorBadInputParameter(UINT /*ParameterIndex*/) {} virtual void ErrorDuplicateSubobject(D3D12_PIPELINE_STATE_SUBOBJECT_TYPE /*DuplicateType*/) {} virtual void ErrorUnknownSubobject(UINT /*UnknownTypeValue*/) {} +#if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 613) + virtual void FinalizeCb() {} +#endif virtual ~ID3DX12PipelineParserCallbacks() = default; }; @@ -760,6 +767,7 @@ struct CD3DX12_PIPELINE_MESH_STATE_STREAM : Flags(Desc.Flags) , NodeMask(Desc.NodeMask) , pRootSignature(Desc.pRootSignature) + , PrimitiveTopologyType(Desc.PrimitiveTopologyType) , PS(Desc.PS) , AS(Desc.AS) , MS(Desc.MS) @@ -776,6 +784,7 @@ struct CD3DX12_PIPELINE_MESH_STATE_STREAM CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; + CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY PrimitiveTopologyType; CD3DX12_PIPELINE_STATE_STREAM_PS PS; CD3DX12_PIPELINE_STATE_STREAM_AS AS; CD3DX12_PIPELINE_STATE_STREAM_MS MS; @@ -791,21 +800,22 @@ struct CD3DX12_PIPELINE_MESH_STATE_STREAM D3DX12_MESH_SHADER_PIPELINE_STATE_DESC MeshShaderDescV0() const noexcept { D3DX12_MESH_SHADER_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.PS = this->PS; - D.AS = this->AS; - D.MS = this->MS; - D.BlendState = this->BlendState; - D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState)); - D.DSVFormat = this->DSVFormat; - D.RasterizerState = this->RasterizerState; - D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; + D.Flags = this->Flags; + D.NodeMask = this->NodeMask; + D.pRootSignature = this->pRootSignature; + D.PrimitiveTopologyType = this->PrimitiveTopologyType; + D.PS = this->PS; + D.AS = this->AS; + D.MS = this->MS; + D.BlendState = this->BlendState; + D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState)); + D.DSVFormat = this->DSVFormat; + D.RasterizerState = this->RasterizerState; + D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); - D.SampleDesc = this->SampleDesc; - D.SampleMask = this->SampleMask; - D.CachedPSO = this->CachedPSO; + D.SampleDesc = this->SampleDesc; + D.SampleMask = this->SampleMask; + D.CachedPSO = this->CachedPSO; return D; } }; @@ -1098,7 +1108,87 @@ struct CD3DX12_PIPELINE_STATE_STREAM4_PARSE_HELPER : public ID3DX12PipelineParse }; #endif // D3D12_SDK_VERSION >= 608 -#if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610) +#if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 613) +// This SDK 613 version has better primitive topology default handling than the v610 equivalent below. +struct CD3DX12_PIPELINE_STATE_STREAM5_PARSE_HELPER : public ID3DX12PipelineParserCallbacks +{ + CD3DX12_PIPELINE_STATE_STREAM5 PipelineStream; + CD3DX12_PIPELINE_STATE_STREAM5_PARSE_HELPER() noexcept + : SeenDSS(false), + SeenMS(false), + SeenTopology(false) + { + // Adjust defaults to account for absent members. + PipelineStream.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; + + // Depth disabled if no DSV format specified. + static_cast(PipelineStream.DepthStencilState).DepthEnable = false; + } + + // ID3DX12PipelineParserCallbacks + void FlagsCb(D3D12_PIPELINE_STATE_FLAGS Flags) override { PipelineStream.Flags = Flags; } + void NodeMaskCb(UINT NodeMask) override { PipelineStream.NodeMask = NodeMask; } + void RootSignatureCb(ID3D12RootSignature* pRootSignature) override { PipelineStream.pRootSignature = pRootSignature; } + void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC& InputLayout) override { PipelineStream.InputLayout = InputLayout; } + void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue) override { PipelineStream.IBStripCutValue = IBStripCutValue; } + void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType) override + { + PipelineStream.PrimitiveTopologyType = PrimitiveTopologyType; + SeenTopology = true; + } + void VSCb(const D3D12_SHADER_BYTECODE& VS) override { PipelineStream.VS = VS; } + void GSCb(const D3D12_SHADER_BYTECODE& GS) override { PipelineStream.GS = GS; } + void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC& StreamOutput) override { PipelineStream.StreamOutput = StreamOutput; } + void HSCb(const D3D12_SHADER_BYTECODE& HS) override { PipelineStream.HS = HS; } + void DSCb(const D3D12_SHADER_BYTECODE& DS) override { PipelineStream.DS = DS; } + void PSCb(const D3D12_SHADER_BYTECODE& PS) override { PipelineStream.PS = PS; } + void CSCb(const D3D12_SHADER_BYTECODE& CS) override { PipelineStream.CS = CS; } + void ASCb(const D3D12_SHADER_BYTECODE& AS) override { PipelineStream.AS = AS; } + void MSCb(const D3D12_SHADER_BYTECODE& MS) override { PipelineStream.MS = MS; SeenMS = true; } + void BlendStateCb(const D3D12_BLEND_DESC& BlendState) override { PipelineStream.BlendState = CD3DX12_BLEND_DESC(BlendState); } + void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC& DepthStencilState) override + { + PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(DepthStencilState); + SeenDSS = true; + } + void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1& DepthStencilState) override + { + PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(DepthStencilState); + SeenDSS = true; + } + void DepthStencilState2Cb(const D3D12_DEPTH_STENCIL_DESC2& DepthStencilState) override + { + PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(DepthStencilState); + SeenDSS = true; + } + void DSVFormatCb(DXGI_FORMAT DSVFormat) override {PipelineStream.DSVFormat = DSVFormat;} + void RasterizerStateCb(const D3D12_RASTERIZER_DESC& RasterizerState) override { PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC2(RasterizerState); } + void RasterizerState1Cb(const D3D12_RASTERIZER_DESC1& RasterizerState) override { PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC2(RasterizerState); } + void RasterizerState2Cb(const D3D12_RASTERIZER_DESC2& RasterizerState) override { PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC2(RasterizerState); } + void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY& RTVFormats) override { PipelineStream.RTVFormats = RTVFormats; } + void SampleDescCb(const DXGI_SAMPLE_DESC& SampleDesc) override { PipelineStream.SampleDesc = SampleDesc; } + void SampleMaskCb(UINT SampleMask) override { PipelineStream.SampleMask = SampleMask; } + void ViewInstancingCb(const D3D12_VIEW_INSTANCING_DESC& ViewInstancingDesc) override { PipelineStream.ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC(ViewInstancingDesc); } + void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE& CachedPSO) override { PipelineStream.CachedPSO = CachedPSO; } + void FinalizeCb() override + { + if (!SeenDSS && PipelineStream.DSVFormat != DXGI_FORMAT_UNKNOWN) + { + // Re-enable depth for the default state. + static_cast(PipelineStream.DepthStencilState).DepthEnable = true; + } + if (!SeenTopology && SeenMS) + { + PipelineStream.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED; + } + } + +private: + bool SeenDSS; + bool SeenMS; + bool SeenTopology; +}; +#elif defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610) struct CD3DX12_PIPELINE_STATE_STREAM5_PARSE_HELPER : public ID3DX12PipelineParserCallbacks { CD3DX12_PIPELINE_STATE_STREAM5 PipelineStream; @@ -1398,6 +1488,9 @@ inline HRESULT D3DX12ParsePipelineStream(const D3D12_PIPELINE_STATE_STREAM_DESC& return E_INVALIDARG; } } +#if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 613) + pCallbacks->FinalizeCb(); +#endif return S_OK; } diff --git a/WickedEngine/Utility/dx12/d3dx12_root_signature.h b/WickedEngine/Utility/dx12/d3dx12_root_signature.h index 572efed8524..e194d30a3f4 100644 --- a/WickedEngine/Utility/dx12/d3dx12_root_signature.h +++ b/WickedEngine/Utility/dx12/d3dx12_root_signature.h @@ -995,6 +995,11 @@ struct CD3DX12_GPU_DESCRIPTOR_HANDLE : public D3D12_GPU_DESCRIPTOR_HANDLE // To help enable root signature 1.1 features when they are available and not require maintaining // two code paths for building root signatures, this helper method reconstructs a 1.0 signature when // 1.1 is not supported. +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcovered-switch-default" +#endif + inline HRESULT D3DX12SerializeVersionedRootSignature( _In_ const D3D12_VERSIONED_ROOT_SIGNATURE_DESC* pRootSignatureDesc, D3D_ROOT_SIGNATURE_VERSION MaxVersion, @@ -1054,32 +1059,38 @@ inline HRESULT D3DX12SerializeVersionedRootSignature( break; case D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE: - const D3D12_ROOT_DESCRIPTOR_TABLE1& table_1_1 = desc_1_1.pParameters[n].DescriptorTable; - - const SIZE_T DescriptorRangesSize = sizeof(D3D12_DESCRIPTOR_RANGE) * table_1_1.NumDescriptorRanges; - void* pDescriptorRanges = (DescriptorRangesSize > 0 && SUCCEEDED(hr)) ? HeapAlloc(GetProcessHeap(), 0, DescriptorRangesSize) : nullptr; - if (DescriptorRangesSize > 0 && pDescriptorRanges == nullptr) { - hr = E_OUTOFMEMORY; - } - auto pDescriptorRanges_1_0 = static_cast(pDescriptorRanges); + const D3D12_ROOT_DESCRIPTOR_TABLE1& table_1_1 = desc_1_1.pParameters[n].DescriptorTable; - if (SUCCEEDED(hr)) - { - for (UINT x = 0; x < table_1_1.NumDescriptorRanges; x++) + const SIZE_T DescriptorRangesSize = sizeof(D3D12_DESCRIPTOR_RANGE) * table_1_1.NumDescriptorRanges; + void* pDescriptorRanges = (DescriptorRangesSize > 0 && SUCCEEDED(hr)) ? HeapAlloc(GetProcessHeap(), 0, DescriptorRangesSize) : nullptr; + if (DescriptorRangesSize > 0 && pDescriptorRanges == nullptr) + { + hr = E_OUTOFMEMORY; + } + auto pDescriptorRanges_1_0 = static_cast(pDescriptorRanges); + + if (SUCCEEDED(hr)) { - __analysis_assume(DescriptorRangesSize == sizeof(D3D12_DESCRIPTOR_RANGE) * table_1_1.NumDescriptorRanges); - pDescriptorRanges_1_0[x].BaseShaderRegister = table_1_1.pDescriptorRanges[x].BaseShaderRegister; - pDescriptorRanges_1_0[x].NumDescriptors = table_1_1.pDescriptorRanges[x].NumDescriptors; - pDescriptorRanges_1_0[x].OffsetInDescriptorsFromTableStart = table_1_1.pDescriptorRanges[x].OffsetInDescriptorsFromTableStart; - pDescriptorRanges_1_0[x].RangeType = table_1_1.pDescriptorRanges[x].RangeType; - pDescriptorRanges_1_0[x].RegisterSpace = table_1_1.pDescriptorRanges[x].RegisterSpace; + for (UINT x = 0; x < table_1_1.NumDescriptorRanges; x++) + { + __analysis_assume(DescriptorRangesSize == sizeof(D3D12_DESCRIPTOR_RANGE) * table_1_1.NumDescriptorRanges); + pDescriptorRanges_1_0[x].BaseShaderRegister = table_1_1.pDescriptorRanges[x].BaseShaderRegister; + pDescriptorRanges_1_0[x].NumDescriptors = table_1_1.pDescriptorRanges[x].NumDescriptors; + pDescriptorRanges_1_0[x].OffsetInDescriptorsFromTableStart = table_1_1.pDescriptorRanges[x].OffsetInDescriptorsFromTableStart; + pDescriptorRanges_1_0[x].RangeType = table_1_1.pDescriptorRanges[x].RangeType; + pDescriptorRanges_1_0[x].RegisterSpace = table_1_1.pDescriptorRanges[x].RegisterSpace; + } } + + D3D12_ROOT_DESCRIPTOR_TABLE& table_1_0 = pParameters_1_0[n].DescriptorTable; + table_1_0.NumDescriptorRanges = table_1_1.NumDescriptorRanges; + table_1_0.pDescriptorRanges = pDescriptorRanges_1_0; } + break; - D3D12_ROOT_DESCRIPTOR_TABLE& table_1_0 = pParameters_1_0[n].DescriptorTable; - table_1_0.NumDescriptorRanges = table_1_1.NumDescriptorRanges; - table_1_0.pDescriptorRanges = pDescriptorRanges_1_0; + default: + break; } } } @@ -1137,6 +1148,9 @@ inline HRESULT D3DX12SerializeVersionedRootSignature( return hr; } + + default: + break; } break; @@ -1193,12 +1207,21 @@ inline HRESULT D3DX12SerializeVersionedRootSignature( } #endif + default: + break; } + break; + #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609) case D3D_ROOT_SIGNATURE_VERSION_1_2: #endif + default: return D3D12SerializeVersionedRootSignature(pRootSignatureDesc, ppBlob, ppErrorBlob); } return E_INVALIDARG; } + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif diff --git a/WickedEngine/Utility/dx12/d3dx12_state_object.h b/WickedEngine/Utility/dx12/d3dx12_state_object.h index 74dc6ca2d9f..f74d2577324 100644 --- a/WickedEngine/Utility/dx12/d3dx12_state_object.h +++ b/WickedEngine/Utility/dx12/d3dx12_state_object.h @@ -12,6 +12,8 @@ #endif #include "d3d12.h" +#include "d3dx12_default.h" +#include "d3dx12_core.h" //================================================================================================ // D3DX12 State Object Creation Helpers @@ -27,6 +29,8 @@ // //================================================================================================ #include +#include +#include #include #include #include @@ -55,9 +59,20 @@ class CD3DX12_STATE_OBJECT_DESC Init(Type); } void SetStateObjectType(D3D12_STATE_OBJECT_TYPE Type) noexcept { m_Desc.Type = Type; } - operator const D3D12_STATE_OBJECT_DESC&() + CD3DX12_STATE_OBJECT_DESC(const CD3DX12_STATE_OBJECT_DESC& other) = delete; + CD3DX12_STATE_OBJECT_DESC& operator=(const CD3DX12_STATE_OBJECT_DESC& other) = delete; + CD3DX12_STATE_OBJECT_DESC(CD3DX12_STATE_OBJECT_DESC&& other) = default; + CD3DX12_STATE_OBJECT_DESC& operator=(CD3DX12_STATE_OBJECT_DESC&& other) = default; + operator const D3D12_STATE_OBJECT_DESC& () { // Do final preparation work + for (auto& ownedSubobject : m_OwnedSubobjectHelpers) + { + ownedSubobject->Finalize(); + } + + m_RepointedSubobjectVectors.clear(); + m_RepointedPrograms.clear(); m_RepointedAssociations.clear(); m_SubobjectArray.clear(); m_SubobjectArray.reserve(m_Desc.NumSubobjects); @@ -85,12 +100,34 @@ class CD3DX12_STATE_OBJECT_DESC m_RepointedAssociations.push_back(Repointed); m_SubobjectArray[i].pDesc = &m_RepointedAssociations.back(); } + else if (m_SubobjectArray[i].Type == D3D12_STATE_SUBOBJECT_TYPE_GENERIC_PROGRAM) + { + auto originalGenericProgramDesc = + static_cast(m_SubobjectArray[i].pDesc); + D3D12_GENERIC_PROGRAM_DESC Repointed = *originalGenericProgramDesc; + if (originalGenericProgramDesc->NumSubobjects > 0) + { + m_RepointedSubobjectVectors.emplace_back(std::vector()); + std::vector& repointedGenericProgramSubobjects = m_RepointedSubobjectVectors.back(); + repointedGenericProgramSubobjects.resize(originalGenericProgramDesc->NumSubobjects); + for (UINT s = 0; s < originalGenericProgramDesc->NumSubobjects; s++) + { + auto pWrapper = + static_cast(originalGenericProgramDesc->ppSubobjects[s]); + repointedGenericProgramSubobjects[s] = pWrapper->pSubobjectArrayLocation; + } + // Below: using ugly way to get pointer in case .data() is not defined + Repointed.ppSubobjects = &repointedGenericProgramSubobjects[0]; + } + m_RepointedPrograms.push_back(Repointed); + m_SubobjectArray[i].pDesc = &m_RepointedPrograms.back(); + } } // Below: using ugly way to get pointer in case .data() is not defined m_Desc.pSubobjects = m_Desc.NumSubobjects ? &m_SubobjectArray[0] : nullptr; return m_Desc; } - operator const D3D12_STATE_OBJECT_DESC*() + operator const D3D12_STATE_OBJECT_DESC* () { // Cast calls the above final preparation work return &static_cast(*this); @@ -148,6 +185,8 @@ class CD3DX12_STATE_OBJECT_DESC m_SubobjectList.clear(); m_SubobjectArray.clear(); m_RepointedAssociations.clear(); + m_RepointedSubobjectVectors.clear(); + m_RepointedPrograms.clear(); } typedef struct SUBOBJECT_WRAPPER : public D3D12_STATE_SUBOBJECT { @@ -160,13 +199,19 @@ class CD3DX12_STATE_OBJECT_DESC std::vector m_SubobjectArray; // Built at the end, copying list contents std::list - m_RepointedAssociations; // subobject type that contains pointers to other subobjects, - // repointed to flattened array + m_RepointedAssociations; // subobject type that contains pointers to other subobjects, + // repointed to flattened array + std::list> + m_RepointedSubobjectVectors; + std::list + m_RepointedPrograms; + + template class StringContainer { public: - LPCWSTR LocalCopy(LPCWSTR string, bool bSingleString = false) + CStr LocalCopy(CStr string, bool bSingleString = false) { if (string) { @@ -188,38 +233,34 @@ class CD3DX12_STATE_OBJECT_DESC } void clear() noexcept { m_Strings.clear(); } private: - std::list m_Strings; + std::list m_Strings; }; +public: class SUBOBJECT_HELPER_BASE { public: SUBOBJECT_HELPER_BASE() noexcept { Init(); } virtual ~SUBOBJECT_HELPER_BASE() = default; virtual D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept = 0; + SUBOBJECT_HELPER_BASE(const SUBOBJECT_HELPER_BASE& other) = delete; + SUBOBJECT_HELPER_BASE& operator=(const SUBOBJECT_HELPER_BASE& other) = delete; + SUBOBJECT_HELPER_BASE(SUBOBJECT_HELPER_BASE&& other) = default; + SUBOBJECT_HELPER_BASE& operator=(SUBOBJECT_HELPER_BASE&& other) = default; void AddToStateObject(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) { m_pSubobject = ContainingStateObject.TrackSubobject(Type(), Data()); } + virtual void Finalize() {}; + operator const D3D12_STATE_SUBOBJECT& () const noexcept { return *m_pSubobject; } protected: virtual void* Data() noexcept = 0; void Init() noexcept { m_pSubobject = nullptr; } D3D12_STATE_SUBOBJECT* m_pSubobject; }; -#if(__cplusplus >= 201103L) - std::list> m_OwnedSubobjectHelpers; -#else - class OWNED_HELPER - { - public: - OWNED_HELPER(const SUBOBJECT_HELPER_BASE* pHelper) noexcept { m_pHelper = pHelper; } - ~OWNED_HELPER() { delete m_pHelper; } - const SUBOBJECT_HELPER_BASE* m_pHelper; - }; - - std::list m_OwnedSubobjectHelpers; -#endif +private: + std::list> m_OwnedSubobjectHelpers; friend class CD3DX12_DXIL_LIBRARY_SUBOBJECT; friend class CD3DX12_EXISTING_COLLECTION_SUBOBJECT; @@ -233,6 +274,33 @@ class CD3DX12_STATE_OBJECT_DESC friend class CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT; friend class CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT; friend class CD3DX12_NODE_MASK_SUBOBJECT; + //TODO: SDK Version check should include all the newly added subobject type for the public release. + // The SDK version check will be changed based on when we release state objects. +#if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) + friend class CD3DX12_GENERIC_PROGRAM_SUBOBJECT; + friend class CD3DX12_WORK_GRAPH_SUBOBJECT; + friend class CD3DX12_STREAM_OUTPUT_SUBOBJECT; + friend class CD3DX12_BLEND_SUBOBJECT; + friend class CD3DX12_RASTERIZER_SUBOBJECT; + friend class CD3DX12_DEPTH_STENCIL2_SUBOBJECT; + friend class CD3DX12_INPUT_LAYOUT_SUBOBJECT; + friend class CD3DX12_IB_STRIP_CUT_VALUE_SUBOBJECT; + friend class CD3DX12_PRIMITIVE_TOPOLOGY_SUBOBJECT; + friend class CD3DX12_RENDER_TARGET_FORMATS_SUBOBJECT; + friend class CD3DX12_DEPTH_STENCIL_FORMAT_SUBOBJECT; + friend class CD3DX12_SAMPLE_DESC_SUBOBJECT; + friend class CD3DX12_FLAGS_SUBOBJECT; + friend class CD3DX12_VIEW_INSTANCING_SUBOBJECT; + friend class CD3DX12_DEPTH_STENCIL_SUBOBJECT; + friend class CD3DX12_DEPTH_STENCIL1_SUBOBJECT; + friend class CD3DX12_SAMPLE_MASK_SUBOBJECT; + friend class CD3DX12_NODE_OUTPUT_OVERRIDES; + friend class CD3DX12_SHADER_NODE; + friend class CD3DX12_BROADCASTING_LAUNCH_NODE_OVERRIDES; + friend class CD3DX12_COALESCING_LAUNCH_NODE_OVERRIDES; + friend class CD3DX12_THREAD_LAUNCH_NODE_OVERRIDES; + friend class CD3DX12_COMMON_COMPUTE_NODE_OVERRIDES; +#endif // D3D12_SDK_VERSION >= 612 }; //------------------------------------------------------------------------------------------------ @@ -286,7 +354,6 @@ class CD3DX12_DXIL_LIBRARY_SUBOBJECT { return D3D12_STATE_SUBOBJECT_TYPE_DXIL_LIBRARY; } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } operator const D3D12_DXIL_LIBRARY_DESC&() const noexcept { return m_Desc; } private: void Init() noexcept @@ -298,7 +365,7 @@ class CD3DX12_DXIL_LIBRARY_SUBOBJECT } void* Data() noexcept override { return &m_Desc; } D3D12_DXIL_LIBRARY_DESC m_Desc; - CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; + CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; std::vector m_Exports; }; @@ -353,7 +420,6 @@ class CD3DX12_EXISTING_COLLECTION_SUBOBJECT { return D3D12_STATE_SUBOBJECT_TYPE_EXISTING_COLLECTION; } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } operator const D3D12_EXISTING_COLLECTION_DESC&() const noexcept { return m_Desc; } private: void Init() noexcept @@ -367,7 +433,7 @@ class CD3DX12_EXISTING_COLLECTION_SUBOBJECT void* Data() noexcept override { return &m_Desc; } D3D12_EXISTING_COLLECTION_DESC m_Desc; D3DX12_COM_PTR m_CollectionRef; - CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; + CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; std::vector m_Exports; }; @@ -414,7 +480,6 @@ class CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT { return D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION; } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } operator const D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION&() const noexcept { return m_Desc; } private: void Init() noexcept @@ -426,7 +491,7 @@ class CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT } void* Data() noexcept override { return &m_Desc; } D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION m_Desc; - CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; + CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; std::vector m_Exports; }; @@ -473,7 +538,6 @@ class CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION { return D3D12_STATE_SUBOBJECT_TYPE_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION; } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } operator const D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION&() const noexcept { return m_Desc; } private: void Init() noexcept @@ -486,8 +550,8 @@ class CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION } void* Data() noexcept override { return &m_Desc; } D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION m_Desc; - CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; - CD3DX12_STATE_OBJECT_DESC::StringContainer m_SubobjectName; + CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; + CD3DX12_STATE_OBJECT_DESC::StringContainer m_SubobjectName; std::vector m_Exports; }; @@ -526,7 +590,6 @@ class CD3DX12_HIT_GROUP_SUBOBJECT { return D3D12_STATE_SUBOBJECT_TYPE_HIT_GROUP; } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } operator const D3D12_HIT_GROUP_DESC&() const noexcept { return m_Desc; } private: void Init() noexcept @@ -541,7 +604,7 @@ class CD3DX12_HIT_GROUP_SUBOBJECT void* Data() noexcept override { return &m_Desc; } D3D12_HIT_GROUP_DESC m_Desc; static constexpr UINT m_NumStrings = 4; - CD3DX12_STATE_OBJECT_DESC::StringContainer + CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings[m_NumStrings]; // one string for every entrypoint name }; @@ -568,7 +631,6 @@ class CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT { return D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_SHADER_CONFIG; } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } operator const D3D12_RAYTRACING_SHADER_CONFIG&() const noexcept { return m_Desc; } private: void Init() noexcept @@ -602,7 +664,6 @@ class CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT { return D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG; } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } operator const D3D12_RAYTRACING_PIPELINE_CONFIG&() const noexcept { return m_Desc; } private: void Init() noexcept @@ -637,7 +698,6 @@ class CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT { return D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG1; } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } operator const D3D12_RAYTRACING_PIPELINE_CONFIG1&() const noexcept { return m_Desc; } private: void Init() noexcept @@ -671,7 +731,6 @@ class CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT { return D3D12_STATE_SUBOBJECT_TYPE_GLOBAL_ROOT_SIGNATURE; } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } operator ID3D12RootSignature*() const noexcept { return D3DX12_COM_PTR_GET(m_pRootSig); } private: void Init() noexcept @@ -705,7 +764,6 @@ class CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT { return D3D12_STATE_SUBOBJECT_TYPE_LOCAL_ROOT_SIGNATURE; } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } operator ID3D12RootSignature*() const noexcept { return D3DX12_COM_PTR_GET(m_pRootSig); } private: void Init() noexcept @@ -739,7 +797,6 @@ class CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT { return D3D12_STATE_SUBOBJECT_TYPE_STATE_OBJECT_CONFIG; } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } operator const D3D12_STATE_OBJECT_CONFIG&() const noexcept { return m_Desc; } private: void Init() noexcept @@ -773,7 +830,6 @@ class CD3DX12_NODE_MASK_SUBOBJECT { return D3D12_STATE_SUBOBJECT_TYPE_NODE_MASK; } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } operator const D3D12_NODE_MASK&() const noexcept { return m_Desc; } private: void Init() noexcept @@ -785,6 +841,1313 @@ class CD3DX12_NODE_MASK_SUBOBJECT D3D12_NODE_MASK m_Desc; }; +#if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) +//------------------------------------------------------------------------------------------------ +class CD3DX12_STREAM_OUTPUT_SUBOBJECT + : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE +{ +public: + CD3DX12_STREAM_OUTPUT_SUBOBJECT() + { + Init(); + } + CD3DX12_STREAM_OUTPUT_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) + { + Init(); + AddToStateObject(ContainingStateObject); + } + void SetSODeclEntries(const D3D12_SO_DECLARATION_ENTRY* soDeclEntries, UINT numEntries) + { + m_soDecalEntries.resize(numEntries); + for (UINT i = 0; i < numEntries; i++) + { + m_soDecalEntries[i] = D3D12_SO_DECLARATION_ENTRY{ + soDeclEntries[i].Stream, + m_Strings.LocalCopy(soDeclEntries[i].SemanticName), + soDeclEntries[i].SemanticIndex, + soDeclEntries[i].StartComponent, + soDeclEntries[i].ComponentCount, + soDeclEntries[i].OutputSlot + }; + } + // Below: using ugly way to get pointer in case .data() is not defined + m_Desc.pSODeclaration = &m_soDecalEntries[0]; + m_Desc.NumEntries = numEntries; + } + void SetBufferStrides(const UINT* bufferStrides, UINT numStrides) + { + m_Desc.pBufferStrides = bufferStrides; + m_Desc.NumStrides = numStrides; + } + void SetRasterizedStream(UINT rasterizedStream) + { + m_Desc.RasterizedStream = rasterizedStream; + } + D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override + { + return D3D12_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT; + } + operator const D3D12_STREAM_OUTPUT_DESC& () const noexcept { return m_Desc; } + +private: + void Init() + { + SUBOBJECT_HELPER_BASE::Init(); + m_Desc = {}; + } + void* Data() noexcept override { return &m_Desc; } + D3D12_STREAM_OUTPUT_DESC m_Desc; + CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; + std::vector m_soDecalEntries; +}; + +//------------------------------------------------------------------------------------------------ +class CD3DX12_BLEND_SUBOBJECT + : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE +{ +public: + CD3DX12_BLEND_SUBOBJECT() + { + Init(); + } + CD3DX12_BLEND_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) + { + Init(); + AddToStateObject(ContainingStateObject); + } + void SetAlphaToCoverageEnable(bool alphaToCoverageEnable) + { + m_Desc.AlphaToCoverageEnable = alphaToCoverageEnable; + } + void SetIndependentBlendEnable(bool independentBlendEnable) + { + m_Desc.IndependentBlendEnable = independentBlendEnable; + } + void SetRenderTarget(UINT renderTargetIndex, const D3D12_RENDER_TARGET_BLEND_DESC& renderTargetBlendDesc) + { + m_Desc.RenderTarget[renderTargetIndex].BlendEnable = renderTargetBlendDesc.BlendEnable; + m_Desc.RenderTarget[renderTargetIndex].BlendOp = renderTargetBlendDesc.BlendOp; + m_Desc.RenderTarget[renderTargetIndex].BlendOpAlpha = renderTargetBlendDesc.BlendOpAlpha; + m_Desc.RenderTarget[renderTargetIndex].DestBlend = renderTargetBlendDesc.DestBlend; + m_Desc.RenderTarget[renderTargetIndex].DestBlendAlpha = renderTargetBlendDesc.DestBlendAlpha; + m_Desc.RenderTarget[renderTargetIndex].LogicOp = renderTargetBlendDesc.LogicOp; + m_Desc.RenderTarget[renderTargetIndex].LogicOpEnable = renderTargetBlendDesc.LogicOpEnable; + m_Desc.RenderTarget[renderTargetIndex].RenderTargetWriteMask = renderTargetBlendDesc.RenderTargetWriteMask; + m_Desc.RenderTarget[renderTargetIndex].SrcBlend = renderTargetBlendDesc.SrcBlend; + m_Desc.RenderTarget[renderTargetIndex].SrcBlendAlpha = renderTargetBlendDesc.SrcBlendAlpha; + } + D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override + { + return D3D12_STATE_SUBOBJECT_TYPE_BLEND; + } + operator const D3D12_BLEND_DESC& () const noexcept { return m_Desc; } +private: + void Init() noexcept + { + SUBOBJECT_HELPER_BASE::Init(); + m_Desc = CD3DX12_BLEND_DESC(D3D12_DEFAULT); + } + void* Data() noexcept override { return &m_Desc; } + CD3DX12_BLEND_DESC m_Desc; +}; + +//------------------------------------------------------------------------------------------------ +class CD3DX12_RASTERIZER_SUBOBJECT + : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE +{ +public: + CD3DX12_RASTERIZER_SUBOBJECT() + { + Init(); + } + CD3DX12_RASTERIZER_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) + { + Init(); + AddToStateObject(ContainingStateObject); + } + void SetFillMode(D3D12_FILL_MODE fillMode) + { + m_Desc.FillMode = fillMode; + } + void SetCullMode(D3D12_CULL_MODE cullMode) + { + m_Desc.CullMode = cullMode; + } + void SetFrontCounterClockwise(BOOL frontCounterClockwise) + { + m_Desc.FrontCounterClockwise = frontCounterClockwise; + } + void SetDepthBias(FLOAT depthBias) + { + m_Desc.DepthBias = depthBias; + } + void SetDepthBiasClamp(FLOAT depthBiasClamp) + { + m_Desc.DepthBiasClamp = depthBiasClamp; + } + void SetSlopeScaledDepthBias(FLOAT slopeScaledDepthBias) + { + m_Desc.SlopeScaledDepthBias = slopeScaledDepthBias; + } + void SetDepthClipEnable(BOOL depthClipEnable) + { + m_Desc.DepthClipEnable = depthClipEnable; + } + void SetLineRasterizationMode(D3D12_LINE_RASTERIZATION_MODE lineRasterizationMode) + { + m_Desc.LineRasterizationMode = lineRasterizationMode; + } + void SetForcedSampleCount(UINT forcedSampleCount) + { + m_Desc.ForcedSampleCount = forcedSampleCount; + } + void SetConservativeRaster(D3D12_CONSERVATIVE_RASTERIZATION_MODE conservativeRaster) + { + m_Desc.ConservativeRaster = conservativeRaster; + } + D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override + { + return D3D12_STATE_SUBOBJECT_TYPE_RASTERIZER; + } + operator const D3D12_RASTERIZER_DESC2& () const noexcept { return m_Desc; } +private: + void Init() noexcept + { + SUBOBJECT_HELPER_BASE::Init(); + m_Desc = CD3DX12_RASTERIZER_DESC2(D3D12_DEFAULT); + } + void* Data() noexcept override { return &m_Desc; } + CD3DX12_RASTERIZER_DESC2 m_Desc; +}; + +//------------------------------------------------------------------------------------------------ +class CD3DX12_DEPTH_STENCIL2_SUBOBJECT + : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE +{ +public: + CD3DX12_DEPTH_STENCIL2_SUBOBJECT() + { + Init(); + } + CD3DX12_DEPTH_STENCIL2_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) + { + Init(); + AddToStateObject(ContainingStateObject); + } + void SetDepthEnable(BOOL depthEnable) + { + m_Desc.DepthEnable = depthEnable; + } + void SetDepthWriteMask(D3D12_DEPTH_WRITE_MASK depthWriteMask) + { + m_Desc.DepthWriteMask = depthWriteMask; + } + void SetDepthFunc(D3D12_COMPARISON_FUNC depthFunc) + { + m_Desc.DepthFunc = depthFunc; + } + void SetStencilEnable(BOOL stencilEnable) + { + m_Desc.StencilEnable = stencilEnable; + } + void SetFrontFace(D3D12_DEPTH_STENCILOP_DESC1 frontFace) + { + m_Desc.FrontFace = { + frontFace.StencilFailOp, + frontFace.StencilDepthFailOp, + frontFace.StencilPassOp, + frontFace.StencilFunc, + frontFace.StencilReadMask, + frontFace.StencilWriteMask + }; + } + void SetBackFace(D3D12_DEPTH_STENCILOP_DESC1 backFace) + { + m_Desc.BackFace = { + backFace.StencilFailOp, + backFace.StencilDepthFailOp, + backFace.StencilPassOp, + backFace.StencilFunc, + backFace.StencilReadMask, + backFace.StencilWriteMask + }; + } + void SetDepthBoundsTestEnable(BOOL depthBoundsTestEnable) + { + m_Desc.DepthBoundsTestEnable = depthBoundsTestEnable; + } + D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override + { + return D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL2; + } + operator const D3D12_DEPTH_STENCIL_DESC2& () const noexcept { return m_Desc; } +private: + void Init() noexcept + { + SUBOBJECT_HELPER_BASE::Init(); + m_Desc = CD3DX12_DEPTH_STENCIL_DESC2(D3D12_DEFAULT); + } + void* Data() noexcept override { return &m_Desc; } + CD3DX12_DEPTH_STENCIL_DESC2 m_Desc; +}; + +//------------------------------------------------------------------------------------------------ +class CD3DX12_INPUT_LAYOUT_SUBOBJECT + : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE +{ +public: + CD3DX12_INPUT_LAYOUT_SUBOBJECT() + { + Init(); + } + CD3DX12_INPUT_LAYOUT_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) + { + Init(); + AddToStateObject(ContainingStateObject); + } + void AddInputLayoutElementDesc(D3D12_INPUT_ELEMENT_DESC inputLayoutElementDesc) + { + m_inputLayoutElements.emplace_back( + D3D12_INPUT_ELEMENT_DESC{ + m_Strings.LocalCopy(inputLayoutElementDesc.SemanticName), + inputLayoutElementDesc.SemanticIndex, + inputLayoutElementDesc.Format, + inputLayoutElementDesc.InputSlot, + inputLayoutElementDesc.AlignedByteOffset, + inputLayoutElementDesc.InputSlotClass, + inputLayoutElementDesc.InstanceDataStepRate + }); + ++m_numElements; + } + D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override + { + return D3D12_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT; + } + operator const D3D12_INPUT_LAYOUT_DESC& () const noexcept { return m_Desc; } + virtual void Finalize() override + { + if (m_numElements > 0) + { + std::list::iterator inputLayoutIt = m_inputLayoutElements.begin(); + m_inputLayoutElementsVector.resize(m_numElements); + for (UINT i = 0; inputLayoutIt != m_inputLayoutElements.end(); i++, inputLayoutIt++) + { + m_inputLayoutElementsVector[i] = *inputLayoutIt; + } + // Below: using ugly way to get pointer in case .data() is not defined + m_Desc.pInputElementDescs = &m_inputLayoutElementsVector[0]; + } + m_Desc.NumElements = m_numElements; + } +private: + void Init() noexcept + { + SUBOBJECT_HELPER_BASE::Init(); + m_Desc = {}; + m_Desc.pInputElementDescs = nullptr; + m_numElements = 0; + m_inputLayoutElements.clear(); + m_inputLayoutElementsVector.clear(); + } + void* Data() noexcept override { return &m_Desc; } + D3D12_INPUT_LAYOUT_DESC m_Desc; + std::list m_inputLayoutElements; + std::vector m_inputLayoutElementsVector; + UINT m_numElements; + CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; +}; + +//------------------------------------------------------------------------------------------------ +class CD3DX12_IB_STRIP_CUT_VALUE_SUBOBJECT + : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE +{ +public: + CD3DX12_IB_STRIP_CUT_VALUE_SUBOBJECT() + { + Init(); + } + CD3DX12_IB_STRIP_CUT_VALUE_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) + { + Init(); + AddToStateObject(ContainingStateObject); + } + void SetIBStripCutValue(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE ibStripCutValue) + { + m_Desc = ibStripCutValue; + } + D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override + { + return D3D12_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE; + } + operator const D3D12_INDEX_BUFFER_STRIP_CUT_VALUE& () const noexcept { return m_Desc; } +private: + void Init() noexcept + { + SUBOBJECT_HELPER_BASE::Init(); + } + void* Data() noexcept override { return &m_Desc; } + D3D12_INDEX_BUFFER_STRIP_CUT_VALUE m_Desc; +}; + +//------------------------------------------------------------------------------------------------ +class CD3DX12_PRIMITIVE_TOPOLOGY_SUBOBJECT + : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE +{ +public: + CD3DX12_PRIMITIVE_TOPOLOGY_SUBOBJECT() + { + Init(); + } + CD3DX12_PRIMITIVE_TOPOLOGY_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) + { + Init(); + AddToStateObject(ContainingStateObject); + } + void SetPrimitiveTopologyType(D3D12_PRIMITIVE_TOPOLOGY_TYPE primitiveTopologytype) + { + m_Desc = primitiveTopologytype; + } + D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override + { + return D3D12_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY; + } + operator const D3D12_PRIMITIVE_TOPOLOGY_TYPE& () const noexcept { return m_Desc; } +private: + void Init() noexcept + { + SUBOBJECT_HELPER_BASE::Init(); + } + void* Data() noexcept override { return &m_Desc; } + D3D12_PRIMITIVE_TOPOLOGY_TYPE m_Desc; +}; + +//------------------------------------------------------------------------------------------------ +class CD3DX12_RENDER_TARGET_FORMATS_SUBOBJECT + : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE +{ +public: + CD3DX12_RENDER_TARGET_FORMATS_SUBOBJECT() + { + Init(); + } + CD3DX12_RENDER_TARGET_FORMATS_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) + { + Init(); + AddToStateObject(ContainingStateObject); + } + void SetNumRenderTargets(UINT numRenderTargets) + { + m_Desc.NumRenderTargets = numRenderTargets; + } + void SetRenderTargetFormat(UINT renderTarget, DXGI_FORMAT renderTargetFormat) + { + m_Desc.RTFormats[renderTarget] = renderTargetFormat; + } + D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override + { + return D3D12_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS; + } + operator const D3D12_RT_FORMAT_ARRAY& () const noexcept { return m_Desc; } +private: + void Init() noexcept + { + SUBOBJECT_HELPER_BASE::Init(); + m_Desc = {}; + } + void* Data() noexcept override { return &m_Desc; } + D3D12_RT_FORMAT_ARRAY m_Desc; +}; + +//------------------------------------------------------------------------------------------------ +class CD3DX12_DEPTH_STENCIL_FORMAT_SUBOBJECT + : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE +{ +public: + CD3DX12_DEPTH_STENCIL_FORMAT_SUBOBJECT() + { + Init(); + } + CD3DX12_DEPTH_STENCIL_FORMAT_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) + { + Init(); + AddToStateObject(ContainingStateObject); + } + void SetDepthStencilFormat(DXGI_FORMAT depthStencilFormat) + { + m_Desc = depthStencilFormat; + } + D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override + { + return D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT; + } + operator const DXGI_FORMAT& () const noexcept { return m_Desc; } +private: + void Init() noexcept + { + SUBOBJECT_HELPER_BASE::Init(); + } + void* Data() noexcept override { return &m_Desc; } + DXGI_FORMAT m_Desc; +}; + +//------------------------------------------------------------------------------------------------ +class CD3DX12_SAMPLE_DESC_SUBOBJECT + : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE +{ +public: + CD3DX12_SAMPLE_DESC_SUBOBJECT() + { + Init(); + } + CD3DX12_SAMPLE_DESC_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) + { + Init(); + AddToStateObject(ContainingStateObject); + } + void SetCount(UINT count) + { + m_Desc.Count = count; + } + void SetQuality(UINT quality) + { + m_Desc.Quality = quality; + } + D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override + { + return D3D12_STATE_SUBOBJECT_TYPE_SAMPLE_DESC; + } + operator const DXGI_SAMPLE_DESC& () const noexcept { return m_Desc; } +private: + void Init() noexcept + { + SUBOBJECT_HELPER_BASE::Init(); + m_Desc = {}; + } + void* Data() noexcept override { return &m_Desc; } + DXGI_SAMPLE_DESC m_Desc; +}; + +//------------------------------------------------------------------------------------------------ +class CD3DX12_FLAGS_SUBOBJECT + : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE +{ +public: + CD3DX12_FLAGS_SUBOBJECT() + { + Init(); + } + CD3DX12_FLAGS_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) + { + Init(); + AddToStateObject(ContainingStateObject); + } + void SetFlags(D3D12_PIPELINE_STATE_FLAGS flags) + { + m_Desc = flags; + } + D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override + { + return D3D12_STATE_SUBOBJECT_TYPE_FLAGS; + } + operator const D3D12_PIPELINE_STATE_FLAGS& () const noexcept { return m_Desc; } +private: + void Init() noexcept + { + SUBOBJECT_HELPER_BASE::Init(); + m_Desc = {}; + } + void* Data() noexcept override { return &m_Desc; } + D3D12_PIPELINE_STATE_FLAGS m_Desc; +}; + +//------------------------------------------------------------------------------------------------ +class CD3DX12_VIEW_INSTANCING_SUBOBJECT + : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE +{ +public: + CD3DX12_VIEW_INSTANCING_SUBOBJECT() + { + Init(); + } + CD3DX12_VIEW_INSTANCING_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) + { + Init(); + AddToStateObject(ContainingStateObject); + } + void AddViewInstanceLocation(D3D12_VIEW_INSTANCE_LOCATION viewInstanceLocation) + { + m_viewInstanceCount++; + m_viewInstanceLocations.emplace_back( + D3D12_VIEW_INSTANCE_LOCATION + { + viewInstanceLocation.ViewportArrayIndex, + viewInstanceLocation.RenderTargetArrayIndex + } + ); + } + void SetFlags(D3D12_VIEW_INSTANCING_FLAGS flags) + { + m_Desc.Flags = flags; + } + D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override + { + return D3D12_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING; + } + operator const D3D12_VIEW_INSTANCING_DESC& () const noexcept { return m_Desc; } + virtual void Finalize() override + { + if (m_viewInstanceCount > 0) + { + m_viewInstanceLocationsVector.resize(m_viewInstanceCount); + std::list::iterator viewInstancingLocationIt = m_viewInstanceLocations.begin(); + for (UINT i = 0; viewInstancingLocationIt != m_viewInstanceLocations.end(); i++, viewInstancingLocationIt++) + { + m_viewInstanceLocationsVector[i] = *viewInstancingLocationIt; + } + // Below: using ugly way to get pointer in case .data() is not defined + m_Desc.pViewInstanceLocations = &m_viewInstanceLocationsVector[0]; + } + m_Desc.ViewInstanceCount = m_viewInstanceCount; + } +private: + void Init() noexcept + { + SUBOBJECT_HELPER_BASE::Init(); + m_Desc = CD3DX12_VIEW_INSTANCING_DESC(D3D12_DEFAULT); + m_viewInstanceCount = 0; + m_viewInstanceLocations.clear(); + m_viewInstanceLocationsVector.clear(); + } + void* Data() noexcept override { return &m_Desc; } + CD3DX12_VIEW_INSTANCING_DESC m_Desc; + UINT m_viewInstanceCount; + std::list m_viewInstanceLocations; + std::vector m_viewInstanceLocationsVector; +}; + +//------------------------------------------------------------------------------------------------ +class CD3DX12_DEPTH_STENCIL_SUBOBJECT + : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE +{ +public: + CD3DX12_DEPTH_STENCIL_SUBOBJECT() + { + Init(); + } + CD3DX12_DEPTH_STENCIL_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) + { + Init(); + AddToStateObject(ContainingStateObject); + } + void SetDepthEnable(BOOL depthEnable) + { + m_Desc.DepthEnable = depthEnable; + } + void SetDepthWriteMask(D3D12_DEPTH_WRITE_MASK depthWriteMask) + { + m_Desc.DepthWriteMask = depthWriteMask; + } + void SetDepthFunc(D3D12_COMPARISON_FUNC depthFunc) + { + m_Desc.DepthFunc = depthFunc; + } + void SetStencilEnable(BOOL stencilEnable) + { + m_Desc.StencilEnable = stencilEnable; + } + void SetStencilReadMask(UINT8 stencilReadMask) + { + m_Desc.StencilReadMask = stencilReadMask; + } + void SetStencilWriteMask(UINT8 stencilWriteMask) + { + m_Desc.StencilWriteMask = stencilWriteMask; + } + void SetFrontFace(D3D12_DEPTH_STENCILOP_DESC frontFace) + { + m_Desc.FrontFace = { + frontFace.StencilFailOp, + frontFace.StencilDepthFailOp, + frontFace.StencilPassOp, + frontFace.StencilFunc + }; + } + void SetBackFace(D3D12_DEPTH_STENCILOP_DESC backFace) + { + m_Desc.BackFace = { + backFace.StencilFailOp, + backFace.StencilDepthFailOp, + backFace.StencilPassOp, + backFace.StencilFunc + }; + } + D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override + { + return D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL; + } + operator const D3D12_DEPTH_STENCIL_DESC& () const noexcept { return m_Desc; } +private: + void Init() noexcept + { + SUBOBJECT_HELPER_BASE::Init(); + m_Desc = CD3DX12_DEPTH_STENCIL_DESC(D3D12_DEFAULT); + } + void* Data() noexcept override { return &m_Desc; } + CD3DX12_DEPTH_STENCIL_DESC m_Desc; +}; + +//------------------------------------------------------------------------------------------------ +class CD3DX12_DEPTH_STENCIL1_SUBOBJECT + : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE +{ +public: + CD3DX12_DEPTH_STENCIL1_SUBOBJECT() + { + Init(); + } + CD3DX12_DEPTH_STENCIL1_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) + { + Init(); + AddToStateObject(ContainingStateObject); + } + void SetDepthEnable(BOOL depthEnable) + { + m_Desc.DepthEnable = depthEnable; + } + void SetDepthWriteMask(D3D12_DEPTH_WRITE_MASK depthWriteMask) + { + m_Desc.DepthWriteMask = depthWriteMask; + } + void SetDepthFunc(D3D12_COMPARISON_FUNC depthFunc) + { + m_Desc.DepthFunc = depthFunc; + } + void SetStencilEnable(BOOL stencilEnable) + { + m_Desc.StencilEnable = stencilEnable; + } + void SetStencilReadMask(UINT8 stencilReadMask) + { + m_Desc.StencilReadMask = stencilReadMask; + } + void SetStencilWriteMask(UINT8 stencilWriteMask) + { + m_Desc.StencilWriteMask = stencilWriteMask; + } + void SetFrontFace(D3D12_DEPTH_STENCILOP_DESC frontFace) + { + m_Desc.FrontFace = { + frontFace.StencilFailOp, + frontFace.StencilDepthFailOp, + frontFace.StencilPassOp, + frontFace.StencilFunc + }; + } + void SetBackFace(D3D12_DEPTH_STENCILOP_DESC backFace) + { + m_Desc.BackFace = { + backFace.StencilFailOp, + backFace.StencilDepthFailOp, + backFace.StencilPassOp, + backFace.StencilFunc + }; + } + void SetDepthBoundsTestEnable(BOOL depthBoundsTestEnable) + { + m_Desc.DepthBoundsTestEnable = depthBoundsTestEnable; + } + D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override + { + return D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1; + } + operator const D3D12_DEPTH_STENCIL_DESC1& () const noexcept { return m_Desc; } +private: + void Init() noexcept + { + SUBOBJECT_HELPER_BASE::Init(); + m_Desc = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEFAULT); + } + void* Data() noexcept override { return &m_Desc; } + CD3DX12_DEPTH_STENCIL_DESC1 m_Desc; +}; + +//------------------------------------------------------------------------------------------------ +class CD3DX12_SAMPLE_MASK_SUBOBJECT + : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE +{ +public: + CD3DX12_SAMPLE_MASK_SUBOBJECT() + { + Init(); + } + CD3DX12_SAMPLE_MASK_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) + { + Init(); + AddToStateObject(ContainingStateObject); + } + void SetSampleMask(UINT sampleMask) + { + m_Desc = sampleMask; + } + D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override + { + return D3D12_STATE_SUBOBJECT_TYPE_SAMPLE_MASK; + } + operator const UINT& () const noexcept { return m_Desc; } +private: + void Init() noexcept + { + SUBOBJECT_HELPER_BASE::Init(); + } + void* Data() noexcept override { return &m_Desc; } + UINT m_Desc; +}; + +//------------------------------------------------------------------------------------------------ +class CD3DX12_GENERIC_PROGRAM_SUBOBJECT + : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE +{ +public: + CD3DX12_GENERIC_PROGRAM_SUBOBJECT() + { + Init(); + } + CD3DX12_GENERIC_PROGRAM_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) + { + Init(); + AddToStateObject(ContainingStateObject); + } + void SetProgramName(LPCWSTR ProgramName) + { + m_Desc.ProgramName = m_Strings.LocalCopy(ProgramName); + } + void AddExport(LPCWSTR exportName) + { + m_Exports.emplace_back(m_Strings.LocalCopy(exportName)); + m_numExports++; + } + void AddSubobject(const D3D12_STATE_SUBOBJECT& subobject) + { + m_Subobjects.emplace_back(&subobject); + m_numSubobjects++; + } + D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override + { + return D3D12_STATE_SUBOBJECT_TYPE_GENERIC_PROGRAM; + } + operator const D3D12_GENERIC_PROGRAM_DESC& () const noexcept { return m_Desc; } + virtual void Finalize() override + { + // Set exports + if (m_numExports > 0) + { + m_ExportsVector.resize(m_numExports); + std::list::iterator exportIt = m_Exports.begin(); + for (UINT i = 0; exportIt != m_Exports.end(); i++, exportIt++) + { + m_ExportsVector[i] = *exportIt; + } + // Below: using ugly way to get pointer in case .data() is not defined + m_Desc.pExports = &m_ExportsVector[0]; + } + else + { + m_Desc.pExports = nullptr; + } + m_Desc.NumExports = m_numExports; + + // Set subobjects + if (m_numSubobjects > 0) + { + m_SubobjectsVector.resize(m_numSubobjects); + std::list::iterator subobjectIt = m_Subobjects.begin(); + for (UINT i = 0; subobjectIt != m_Subobjects.end(); i++, subobjectIt++) + { + m_SubobjectsVector[i] = *subobjectIt; + } + // Below: using ugly way to get pointer in case .data() is not defined + m_Desc.ppSubobjects = &m_SubobjectsVector[0]; + } + else + { + m_Desc.ppSubobjects = nullptr; + } + m_Desc.NumSubobjects = m_numSubobjects; + } +private: + void Init() noexcept + { + SUBOBJECT_HELPER_BASE::Init(); + m_Desc = {}; + m_numExports = 0; + m_numSubobjects = 0; + } + void* Data() noexcept override { return &m_Desc; } + D3D12_GENERIC_PROGRAM_DESC m_Desc; + std::list m_Exports; + std::vector m_ExportsVector; + UINT m_numExports; + std::list m_Subobjects; + std::vector m_SubobjectsVector; + UINT m_numSubobjects; + CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; +}; + +//------------------------------------------------------------------------------------------------ +class CD3DX12_NODE_OUTPUT_OVERRIDES +{ +public: + CD3DX12_NODE_OUTPUT_OVERRIDES(const D3D12_NODE_OUTPUT_OVERRIDES** ppOwner, UINT* pNumOutputOverrides) noexcept + { + m_Desc.clear(); + m_ppOwner = ppOwner; + *m_ppOwner = nullptr; + m_pNumOutputOverrides = pNumOutputOverrides; + *m_pNumOutputOverrides = 0; + } + void NewOutputOverride() + { + m_Desc.emplace_back(D3D12_NODE_OUTPUT_OVERRIDES{}); + *m_ppOwner = m_Desc.data(); + (*m_pNumOutputOverrides)++; + } + void OutputIndex(UINT index) + { + m_Desc.back().OutputIndex = index; + } + void NewName(LPCWSTR Name, UINT ArrayIndex = 0) + { + m_NodeIDs.emplace_front(D3D12_NODE_ID{ m_Strings.LocalCopy(Name),ArrayIndex }); + m_Desc.back().pNewName = &m_NodeIDs.front(); + } + void AllowSparseNodes(BOOL bAllow) + { + m_UINTs.emplace_front((UINT)bAllow); + m_Desc.back().pAllowSparseNodes = (BOOL*)&m_UINTs.front(); + } + void MaxOutputRecords(UINT maxOutputRecords) noexcept + { + m_UINTs.emplace_front(maxOutputRecords); + m_Desc.back().pMaxRecords = &m_UINTs.front(); + } + void MaxOutputRecordsSharedWith(UINT outputIndex) noexcept + { + m_UINTs.emplace_front(outputIndex); + m_Desc.back().pMaxRecordsSharedWithOutputIndex = &m_UINTs.front(); + } +private: + std::vector m_Desc; + // Cached parameters + CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; + std::forward_list m_UINTs; + std::forward_list m_NodeIDs; + const D3D12_NODE_OUTPUT_OVERRIDES** m_ppOwner; + UINT* m_pNumOutputOverrides; +}; + +//------------------------------------------------------------------------------------------------ +class CD3DX12_NODE_HELPER_BASE +{ +public: + virtual ~CD3DX12_NODE_HELPER_BASE() = default; +}; + +//------------------------------------------------------------------------------------------------ +class CD3DX12_SHADER_NODE // Not specifying launch mode. + // Don't need to distinguish if no parameter overriding is happening + : public CD3DX12_NODE_HELPER_BASE +{ +public: + CD3DX12_SHADER_NODE( + D3D12_NODE* pNode, + LPCWSTR _Shader = nullptr) + { + m_pDesc = pNode; + m_pDesc->NodeType = D3D12_NODE_TYPE_SHADER; + Shader(_Shader); + } + void Shader(LPCWSTR _Shader) + { + m_pDesc->Shader.Shader = m_Strings.LocalCopy(_Shader); + } + D3D12_NODE* m_pDesc; +private: + CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; +}; + +//------------------------------------------------------------------------------------------------ +// Use this class when defining a broadcasting launch node where configuration parameters +// need to be overridden. If overrides are not needed, just use CD3DX12_COMPUTE_SHADER_NODE +class CD3DX12_BROADCASTING_LAUNCH_NODE_OVERRIDES + : public CD3DX12_NODE_HELPER_BASE +{ +public: + CD3DX12_BROADCASTING_LAUNCH_NODE_OVERRIDES( + D3D12_NODE* pNode, + LPCWSTR _Shader = nullptr) : + m_NodeOutputOverrides(&Overrides.pOutputOverrides, &Overrides.NumOutputOverrides) + { + Overrides = {}; + m_pDesc = pNode; + m_pDesc->NodeType = D3D12_NODE_TYPE_SHADER; + m_pDesc->Shader.OverridesType = D3D12_NODE_OVERRIDES_TYPE_BROADCASTING_LAUNCH; + m_pDesc->Shader.pBroadcastingLaunchOverrides = &Overrides; + Shader(_Shader); + } + void Shader(LPCWSTR _Shader) + { + m_pDesc->Shader.Shader = m_Strings.LocalCopy(_Shader); + } + void LocalRootArgumentsTableIndex(UINT index) + { + m_UINTs.emplace_front(index); + Overrides.pLocalRootArgumentsTableIndex = &m_UINTs.front(); + } + void ProgramEntry(BOOL bIsProgramEntry) + { + m_UINTs.emplace_front(bIsProgramEntry); + Overrides.pProgramEntry = (BOOL*)&m_UINTs.front(); + } + void NewName(D3D12_NODE_ID NodeID) + { + m_NodeIDs.emplace_front(D3D12_NODE_ID{ m_Strings.LocalCopy(NodeID.Name),NodeID.ArrayIndex }); + Overrides.pNewName = &m_NodeIDs.front(); + } + void ShareInputOf(D3D12_NODE_ID NodeID) + { + m_NodeIDs.emplace_front(D3D12_NODE_ID{ m_Strings.LocalCopy(NodeID.Name),NodeID.ArrayIndex }); + Overrides.pShareInputOf = &m_NodeIDs.front(); + } + void DispatchGrid(UINT x, UINT y, UINT z) + { + m_UINT3s.emplace_front(UINT3{ x,y,z }); + Overrides.pDispatchGrid = (UINT*)&m_UINT3s.front(); + } + void MaxDispatchGrid(UINT x, UINT y, UINT z) + { + m_UINT3s.emplace_front(UINT3{x,y,z}); + Overrides.pMaxDispatchGrid = (UINT*)&m_UINT3s.front(); + } + CD3DX12_NODE_OUTPUT_OVERRIDES& NodeOutputOverrides() + { + return m_NodeOutputOverrides; + } + D3D12_BROADCASTING_LAUNCH_OVERRIDES Overrides; + D3D12_NODE* m_pDesc; +private: + // Cached parameters + CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; + std::forward_list m_UINTs; + struct UINT3 + { + UINT x; + UINT y; + UINT z; + }; + std::forward_list m_UINT3s; + std::forward_list m_NodeIDs; + CD3DX12_NODE_OUTPUT_OVERRIDES m_NodeOutputOverrides; +}; + +//------------------------------------------------------------------------------------------------ +// Use this class when defining a coalescing launch node where configuration parameters +// need to be overridden. If overrides are not needed, just use CD3DX12_COMPUTE_SHADER_NODE +class CD3DX12_COALESCING_LAUNCH_NODE_OVERRIDES + : public CD3DX12_NODE_HELPER_BASE +{ +public: + CD3DX12_COALESCING_LAUNCH_NODE_OVERRIDES( + D3D12_NODE* pNode, + LPCWSTR _Shader = nullptr) : + m_NodeOutputOverrides(&Overrides.pOutputOverrides, &Overrides.NumOutputOverrides) + { + Overrides = {}; + m_pDesc = pNode; + m_pDesc->NodeType = D3D12_NODE_TYPE_SHADER; + m_pDesc->Shader.OverridesType = D3D12_NODE_OVERRIDES_TYPE_COALESCING_LAUNCH; + m_pDesc->Shader.pCoalescingLaunchOverrides = &Overrides; + Shader(_Shader); + } + void Shader(LPCWSTR _Shader) + { + m_pDesc->Shader.Shader = m_Strings.LocalCopy(_Shader); + } + void LocalRootArgumentsTableIndex(UINT index) + { + m_UINTs.emplace_front(index); + Overrides.pLocalRootArgumentsTableIndex = &m_UINTs.front(); + } + void ProgramEntry(BOOL bIsProgramEntry) + { + m_UINTs.emplace_front(bIsProgramEntry); + Overrides.pProgramEntry = (BOOL*)&m_UINTs.front(); + } + void NewName(D3D12_NODE_ID NodeID) + { + m_NodeIDs.emplace_front(D3D12_NODE_ID{ m_Strings.LocalCopy(NodeID.Name),NodeID.ArrayIndex }); + Overrides.pNewName = &m_NodeIDs.front(); + } + void ShareInputOf(D3D12_NODE_ID NodeID) + { + m_NodeIDs.emplace_front(D3D12_NODE_ID{ m_Strings.LocalCopy(NodeID.Name),NodeID.ArrayIndex }); + Overrides.pShareInputOf = &m_NodeIDs.front(); + } + CD3DX12_NODE_OUTPUT_OVERRIDES& NodeOutputOverrides() + { + return m_NodeOutputOverrides; + } + D3D12_COALESCING_LAUNCH_OVERRIDES Overrides; + D3D12_NODE* m_pDesc; +private: + // Cached parameters + CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; + std::forward_list m_UINTs; + struct UINT3 + { + UINT x; + UINT y; + UINT z; + }; + std::forward_list m_UINT3s; + std::forward_list m_NodeIDs; + CD3DX12_NODE_OUTPUT_OVERRIDES m_NodeOutputOverrides; +}; + +//------------------------------------------------------------------------------------------------ +// Use this class when defining a thread launch node where configuration parameters +// need to be overridden. If overrides are not needed, just use CD3DX12_COMPUTE_SHADER_NODE +class CD3DX12_THREAD_LAUNCH_NODE_OVERRIDES + : public CD3DX12_NODE_HELPER_BASE +{ +public: + CD3DX12_THREAD_LAUNCH_NODE_OVERRIDES( + D3D12_NODE* pNode, + LPCWSTR _Shader = nullptr) : + m_NodeOutputOverrides(&Overrides.pOutputOverrides, &Overrides.NumOutputOverrides) + { + Overrides = {}; + m_pDesc = pNode; + m_pDesc->NodeType = D3D12_NODE_TYPE_SHADER; + m_pDesc->Shader.OverridesType = D3D12_NODE_OVERRIDES_TYPE_THREAD_LAUNCH; + m_pDesc->Shader.pThreadLaunchOverrides = &Overrides; + Shader(_Shader); + } + void Shader(LPCWSTR _Shader) + { + m_pDesc->Shader.Shader = m_Strings.LocalCopy(_Shader); + } + void LocalRootArgumentsTableIndex(UINT index) + { + m_UINTs.emplace_front(index); + Overrides.pLocalRootArgumentsTableIndex = &m_UINTs.front(); + } + void ProgramEntry(BOOL bIsProgramEntry) + { + m_UINTs.emplace_front(bIsProgramEntry); + Overrides.pProgramEntry = (BOOL*)&m_UINTs.front(); + } + void NewName(D3D12_NODE_ID NodeID) + { + m_NodeIDs.emplace_front(D3D12_NODE_ID{ m_Strings.LocalCopy(NodeID.Name),NodeID.ArrayIndex }); + Overrides.pNewName = &m_NodeIDs.front(); + } + void ShareInputOf(D3D12_NODE_ID NodeID) + { + m_NodeIDs.emplace_front(D3D12_NODE_ID{ m_Strings.LocalCopy(NodeID.Name),NodeID.ArrayIndex }); + Overrides.pShareInputOf = &m_NodeIDs.front(); + } + CD3DX12_NODE_OUTPUT_OVERRIDES& NodeOutputOverrides() + { + return m_NodeOutputOverrides; + } + D3D12_THREAD_LAUNCH_OVERRIDES Overrides; + D3D12_NODE* m_pDesc; +private: + // Cached parameters + CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; + std::forward_list m_UINTs; + std::forward_list m_NodeIDs; + CD3DX12_NODE_OUTPUT_OVERRIDES m_NodeOutputOverrides; +}; + +//------------------------------------------------------------------------------------------------ +// Use this class when defining a node where configuration parameters +// need to be overridden for parameters that are common to all launch node types. +// This option is a convenience if you don't want to determine what the launch mode is +// and just want to override a setting that isn't specific to launch mode. +// If overrides are not needed, just use CD3DX12_COMPUTE_SHADER_NODE +class CD3DX12_COMMON_COMPUTE_NODE_OVERRIDES + : public CD3DX12_NODE_HELPER_BASE +{ +public: + CD3DX12_COMMON_COMPUTE_NODE_OVERRIDES( + D3D12_NODE* pNode, + LPCWSTR _Shader = nullptr) : + m_NodeOutputOverrides(&Overrides.pOutputOverrides, &Overrides.NumOutputOverrides) + { + Overrides = {}; + m_pDesc = pNode; + m_pDesc->NodeType = D3D12_NODE_TYPE_SHADER; + m_pDesc->Shader.OverridesType = D3D12_NODE_OVERRIDES_TYPE_COMMON_COMPUTE; + m_pDesc->Shader.pThreadLaunchOverrides = &Overrides; + Shader(_Shader); + } + void Shader(LPCWSTR _Shader) + { + m_pDesc->Shader.Shader = m_Strings.LocalCopy(_Shader); + } + void LocalRootArgumentsTableIndex(UINT index) + { + m_UINTs.emplace_front(index); + Overrides.pLocalRootArgumentsTableIndex = &m_UINTs.front(); + } + void ProgramEntry(BOOL bIsProgramEntry) + { + m_UINTs.emplace_front(bIsProgramEntry); + Overrides.pProgramEntry = (BOOL*)&m_UINTs.front(); + } + void NewName(D3D12_NODE_ID NodeID) + { + m_NodeIDs.emplace_front(D3D12_NODE_ID{ m_Strings.LocalCopy(NodeID.Name),NodeID.ArrayIndex }); + Overrides.pNewName = &m_NodeIDs.front(); + } + void ShareInputOf(D3D12_NODE_ID NodeID) + { + m_NodeIDs.emplace_front(D3D12_NODE_ID{ m_Strings.LocalCopy(NodeID.Name),NodeID.ArrayIndex }); + Overrides.pShareInputOf = &m_NodeIDs.front(); + } + CD3DX12_NODE_OUTPUT_OVERRIDES& NodeOutputOverrides() + { + return m_NodeOutputOverrides; + } + D3D12_THREAD_LAUNCH_OVERRIDES Overrides; + D3D12_NODE* m_pDesc; +private: + // Cached parameters + CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; + std::forward_list m_UINTs; + std::forward_list m_NodeIDs; + CD3DX12_NODE_OUTPUT_OVERRIDES m_NodeOutputOverrides; +}; + +//------------------------------------------------------------------------------------------------ +class CD3DX12_WORK_GRAPH_SUBOBJECT + : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE +{ +public: + CD3DX12_WORK_GRAPH_SUBOBJECT() noexcept + { + Init(); + } + CD3DX12_WORK_GRAPH_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) + { + Init(); + AddToStateObject(ContainingStateObject); + } + D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override + { + return D3D12_STATE_SUBOBJECT_TYPE_WORK_GRAPH; + } + void IncludeAllAvailableNodes() + { + m_Desc.Flags |= D3D12_WORK_GRAPH_FLAG_INCLUDE_ALL_AVAILABLE_NODES; + } + void SetProgramName(LPCWSTR ProgramName) + { + m_Desc.ProgramName = m_Strings.LocalCopy(ProgramName); + } + void AddEntrypoint(D3D12_NODE_ID Entrypoint) + { + m_Entrypoints.emplace_back(D3D12_NODE_ID{ m_Strings.LocalCopy(Entrypoint.Name),Entrypoint.ArrayIndex }); + m_NumEntrypoints++; + } + + template + T* CreateNode() + { + m_NodeDescs.push_back({}); + m_NumNodes++; + T* pNodeHelper = new T(&m_NodeDescs.back()); + m_OwnedNodeHelpers.emplace_back(pNodeHelper); + return pNodeHelper; + } + CD3DX12_SHADER_NODE* CreateShaderNode(LPCWSTR Shader = nullptr) + { + auto pNode = CreateNode(); + pNode->Shader(Shader); + return pNode; + } + CD3DX12_BROADCASTING_LAUNCH_NODE_OVERRIDES* CreateBroadcastingLaunchNodeOverrides(LPCWSTR Shader = nullptr) + { + auto pNode = CreateNode(); + pNode->Shader(Shader); + return pNode; + } + CD3DX12_COALESCING_LAUNCH_NODE_OVERRIDES* CreateCoalescingLaunchNodeOverrides(LPCWSTR Shader = nullptr) + { + auto pNode = CreateNode(); + pNode->Shader(Shader); + return pNode; + } + CD3DX12_THREAD_LAUNCH_NODE_OVERRIDES* CreateThreadLaunchNodeOverrides(LPCWSTR Shader = nullptr) + { + auto pNode = CreateNode(); + pNode->Shader(Shader); + return pNode; + } + CD3DX12_COMMON_COMPUTE_NODE_OVERRIDES* CreateCommonComputeNodeOverrides(LPCWSTR Shader = nullptr) + { + auto pNode = CreateNode(); + pNode->Shader(Shader); + return pNode; + } + operator const D3D12_WORK_GRAPH_DESC& () noexcept + { + return m_Desc; + } + virtual void Finalize() override + { + m_EntrypointsVector.resize(m_NumEntrypoints); + std::list::iterator entryIt = m_Entrypoints.begin(); + for (UINT n = 0; n < m_NumEntrypoints; n++, entryIt++) + { + m_EntrypointsVector[n] = *entryIt; + } + m_Desc.NumEntrypoints = m_NumEntrypoints; + m_Desc.pEntrypoints = m_EntrypointsVector.data(); + + m_NodeDescsVector.resize(m_NumNodes); + std::list::iterator nodeIt = m_NodeDescs.begin(); + for (UINT n = 0; n < m_NumNodes; n++, nodeIt++) + { + m_NodeDescsVector[n] = *nodeIt; + } + m_Desc.NumExplicitlyDefinedNodes = m_NumNodes; + m_Desc.pExplicitlyDefinedNodes = m_NodeDescsVector.data(); + } +private: + void Init() noexcept + { + SUBOBJECT_HELPER_BASE::Init(); + m_Desc = {}; + m_NodeDescs.clear(); + m_NodeDescsVector.clear(); + m_NumNodes = 0; + m_NumEntrypoints = 0; + } + void* Data() noexcept override { return &m_Desc; } + D3D12_WORK_GRAPH_DESC m_Desc; + std::list m_Entrypoints; + UINT m_NumEntrypoints; + std::vector m_EntrypointsVector; + std::list m_NodeDescs; + UINT m_NumNodes; + std::vector m_NodeDescsVector; + CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; + std::list> m_OwnedNodeHelpers; +}; +#endif // D3D12_SDK_VERSION >= 612 + #undef D3DX12_COM_PTR #undef D3DX12_COM_PTR_GET #undef D3DX12_COM_PTR_ADDRESSOF diff --git a/WickedEngine/Utility/dx12/dxcore_interface.h b/WickedEngine/Utility/dx12/dxcore_interface.h index b487fe13fb6..c3cc962f835 100644 --- a/WickedEngine/Utility/dx12/dxcore_interface.h +++ b/WickedEngine/Utility/dx12/dxcore_interface.h @@ -35,13 +35,25 @@ enum class DXCoreAdapterProperty : uint32_t IsHardware = 11, IsIntegrated = 12, IsDetachable = 13, - HardwareIDParts = 14 + HardwareIDParts = 14, + PhysicalAdapterCount = 15, + AdapterEngineCount = 16, + AdapterEngineName = 17, }; enum class DXCoreAdapterState : uint32_t { IsDriverUpdateInProgress = 0, - AdapterMemoryBudget = 1 + AdapterMemoryBudget = 1, + AdapterMemoryUsageBytes = 2, + AdapterMemoryUsageByProcessBytes = 3, + AdapterEngineRunningTimeMicroseconds = 4, + AdapterEngineRunningTimeByProcessMicroseconds = 5, + AdapterTemperatureCelsius = 6, + AdapterInUseProcessCount = 7, + AdapterInUseProcessSet = 8, + AdapterEngineFrequencyHertz = 9, + AdapterMemoryFrequencyHertz = 10 }; enum class DXCoreSegmentGroup : uint32_t @@ -65,6 +77,34 @@ enum class DXCoreAdapterPreference : uint32_t HighPerformance = 2 }; +enum class DXCoreWorkload : uint32_t +{ + Graphics = 0, + Compute = 1, + Media = 2, + MachineLearning = 3, +}; + +enum class DXCoreRuntimeFilterFlags : uint32_t +{ + None = 0x0, + D3D11 = 0x1, + D3D12 = 0x2 +}; + +DEFINE_ENUM_FLAG_OPERATORS(DXCoreRuntimeFilterFlags); + +enum class DXCoreHardwareTypeFilterFlags : uint32_t +{ + None = 0x0, + GPU = 0x1, + ComputeAccelerator = 0x2, + NPU = 0x4, + MediaAccelerator = 0x8 +}; + +DEFINE_ENUM_FLAG_OPERATORS(DXCoreHardwareTypeFilterFlags); + struct DXCoreHardwareID { uint32_t vendorID; @@ -96,6 +136,86 @@ struct DXCoreAdapterMemoryBudget uint64_t currentReservation; }; +struct DXCoreAdapterEngineIndex +{ + uint32_t physicalAdapterIndex; + uint32_t engineIndex; +}; + +struct DXCoreEngineQueryInput +{ + DXCoreAdapterEngineIndex adapterEngineIndex; + uint32_t processId; +}; + +struct DXCoreEngineQueryOutput +{ + uint64_t runningTime; + bool processQuerySucceeded; +}; + +enum class DXCoreMemoryType : uint32_t +{ + Dedicated = 0, + Shared = 1 +}; + +struct DXCoreMemoryUsage +{ + uint64_t committed; + uint64_t resident; +}; + +struct DXCoreMemoryQueryInput +{ + uint32_t physicalAdapterIndex; + DXCoreMemoryType memoryType; +}; + +struct DXCoreProcessMemoryQueryInput +{ + uint32_t physicalAdapterIndex; + DXCoreMemoryType memoryType; + uint32_t processId; +}; + +struct DXCoreProcessMemoryQueryOutput +{ + DXCoreMemoryUsage memoryUsage; + bool processQuerySucceeded; +}; + +struct DXCoreAdapterProcessSetQueryInput +{ + uint32_t arraySize; + _Field_size_(arraySize) uint32_t* processIds; +}; + +struct DXCoreAdapterProcessSetQueryOutput +{ + uint32_t processesWritten; + uint32_t processesTotal; +}; + +struct DXCoreEngineNamePropertyInput +{ + DXCoreAdapterEngineIndex adapterEngineIndex; + uint32_t engineNameLength; + _Field_size_(engineNameLength) wchar_t *engineName; +}; + +struct DXCoreEngineNamePropertyOutput +{ + uint32_t engineNameLength; +}; + +struct DXCoreFrequencyQueryOutput +{ + uint64_t frequency; + uint64_t maxFrequency; + uint64_t maxOverclockedFrequency; +}; + typedef void (STDMETHODCALLTYPE *PFN_DXCORE_NOTIFICATION_CALLBACK)( DXCoreNotificationType notificationType, _In_ IUnknown *object, @@ -104,11 +224,21 @@ typedef void (STDMETHODCALLTYPE *PFN_DXCORE_NOTIFICATION_CALLBACK)( static_assert(sizeof(bool) == 1, "bool assumed as one byte"); DEFINE_GUID(IID_IDXCoreAdapterFactory, 0x78ee5945, 0xc36e, 0x4b13, 0xa6, 0x69, 0x00, 0x5d, 0xd1, 0x1c, 0x0f, 0x06); +DEFINE_GUID(IID_IDXCoreAdapterFactory1, 0xd5682e19, 0x6d21, 0x401c, 0x82, 0x7a, 0x9a, 0x51, 0xa4, 0xea, 0x35, 0xd7); DEFINE_GUID(IID_IDXCoreAdapterList, 0x526c7776, 0x40e9, 0x459b, 0xb7, 0x11, 0xf3, 0x2a, 0xd7, 0x6d, 0xfc, 0x28); DEFINE_GUID(IID_IDXCoreAdapter, 0xf0db4c7f, 0xfe5a, 0x42a2, 0xbd, 0x62, 0xf2, 0xa6, 0xcf, 0x6f, 0xc8, 0x3e); +DEFINE_GUID(IID_IDXCoreAdapter1, 0xa0783366, 0xcfa3, 0x43be, 0x9d, 0x79, 0x55, 0xb2, 0xda, 0x97, 0xc6, 0x3c); + DEFINE_GUID(DXCORE_ADAPTER_ATTRIBUTE_D3D11_GRAPHICS, 0x8c47866b, 0x7583, 0x450d, 0xf0, 0xf0, 0x6b, 0xad, 0xa8, 0x95, 0xaf, 0x4b); DEFINE_GUID(DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, 0x0c9ece4d, 0x2f6e, 0x4f01, 0x8c, 0x96, 0xe8, 0x9e, 0x33, 0x1b, 0x47, 0xb1); DEFINE_GUID(DXCORE_ADAPTER_ATTRIBUTE_D3D12_CORE_COMPUTE, 0x248e2800, 0xa793, 0x4724, 0xab, 0xaa, 0x23, 0xa6, 0xde, 0x1b, 0xe0, 0x90); +DEFINE_GUID(DXCORE_ADAPTER_ATTRIBUTE_D3D12_GENERIC_ML, 0xb71b0d41, 0x1088, 0x422f, 0xa2, 0x7c, 0x2, 0x50, 0xb7, 0xd3, 0xa9, 0x88); +DEFINE_GUID(DXCORE_ADAPTER_ATTRIBUTE_D3D12_GENERIC_MEDIA, 0x8eb2c848, 0x82f6, 0x4b49, 0xaa, 0x87, 0xae, 0xcf, 0xcf, 0x1, 0x74, 0xc6); + +DEFINE_GUID(DXCORE_HARDWARE_TYPE_ATTRIBUTE_GPU, 0xb69eb219, 0x3ded, 0x4464, 0x97, 0x9f, 0xa0, 0xb, 0xd4, 0x68, 0x70, 0x6); +DEFINE_GUID(DXCORE_HARDWARE_TYPE_ATTRIBUTE_COMPUTE_ACCELERATOR, 0xe0b195da, 0x58ef, 0x4a22, 0x90, 0xf1, 0x1f, 0x28, 0x16, 0x9c, 0xab, 0x8d); +DEFINE_GUID(DXCORE_HARDWARE_TYPE_ATTRIBUTE_NPU, 0xd46140c4, 0xadd7, 0x451b, 0x9e, 0x56, 0x6, 0xfe, 0x8c, 0x3b, 0x58, 0xed); +DEFINE_GUID(DXCORE_HARDWARE_TYPE_ATTRIBUTE_MEDIA_ACCELERATOR, 0x66bdb96a, 0x50b, 0x44c7, 0xa4, 0xfd, 0xd1, 0x44, 0xce, 0xa, 0xb4, 0x43); /* interface IDXCoreAdapter */ MIDL_INTERFACE("f0db4c7f-fe5a-42a2-bd62-f2a6cf6fc83e") @@ -214,6 +344,32 @@ IDXCoreAdapter : public IUnknown } }; +/* interface IDXCoreAdapter1 */ +MIDL_INTERFACE("a0783366-cfa3-43be-9d79-55b2da97c63c") +IDXCoreAdapter1 : public IDXCoreAdapter +{ +public: + virtual HRESULT STDMETHODCALLTYPE GetPropertyWithInput( + DXCoreAdapterProperty property, + size_t inputPropertyDetailsSize, + _In_reads_bytes_opt_(inputPropertyDetailsSize) const void *inputPropertyDetails, + size_t outputBufferSize, + _Out_writes_bytes_(outputBufferSize) void *outputBuffer) = 0; + + template + HRESULT GetPropertyWithInput( + DXCoreAdapterProperty property, + _In_reads_bytes_opt_(sizeof(T1)) const T1 *inputPropertyDetails, + _Out_writes_bytes_(sizeof(T2)) T2 *outputBuffer) + { + return GetPropertyWithInput(property, + sizeof(T1), + (const void*)inputPropertyDetails, + sizeof(T2), + (void*)outputBuffer); + } +}; + /* interface IDXCoreAdapterList */ MIDL_INTERFACE("526c7776-40e9-459b-b711-f32ad76dfc28") IDXCoreAdapterList : public IUnknown @@ -309,8 +465,33 @@ IDXCoreAdapterFactory : public IUnknown uint32_t eventCookie) = 0; }; +/* interface IDXCoreAdapterFactory1 */ +MIDL_INTERFACE("d5682e19-6d21-401c-827a-9a51a4ea35d7") +IDXCoreAdapterFactory1 : public IDXCoreAdapterFactory +{ +public: + virtual HRESULT STDMETHODCALLTYPE CreateAdapterListByWorkload( + DXCoreWorkload workload, + DXCoreRuntimeFilterFlags runtimeFilter, + DXCoreHardwareTypeFilterFlags hardwareTypeFilter, + REFIID riid, + _COM_Outptr_ void **ppvAdapterList) = 0; + + template + HRESULT STDMETHODCALLTYPE CreateAdapterListByWorkload( + DXCoreWorkload workload, + DXCoreRuntimeFilterFlags runtimeFilter, + DXCoreHardwareTypeFilterFlags hardwareTypeFilter, + _COM_Outptr_ T **ppvAdapterList) + { + return CreateAdapterListByWorkload(workload, + runtimeFilter, + hardwareTypeFilter, + IID_PPV_ARGS(ppvAdapterList)); + } +}; + #endif // __cplusplus #endif // __dxcore_interface_h__ - diff --git a/WickedEngine/Utility/dxcapi.h b/WickedEngine/Utility/dxcapi.h index b226cf9dfce..752041b7c7f 100644 --- a/WickedEngine/Utility/dxcapi.h +++ b/WickedEngine/Utility/dxcapi.h @@ -19,7 +19,7 @@ #endif #else #ifndef DXC_API_IMPORT -#define DXC_API_IMPORT __attribute__ ((visibility ("default"))) +#define DXC_API_IMPORT __attribute__((visibility("default"))) #endif #endif @@ -33,59 +33,56 @@ #else +#include "WinAdapter.h" #include -#include "dxc/Support/WinAdapter.h" #endif struct IMalloc; struct IDxcIncludeHandler; -typedef HRESULT (__stdcall *DxcCreateInstanceProc)( - _In_ REFCLSID rclsid, - _In_ REFIID riid, - _Out_ LPVOID* ppv -); - -typedef HRESULT(__stdcall *DxcCreateInstance2Proc)( - _In_ IMalloc *pMalloc, - _In_ REFCLSID rclsid, - _In_ REFIID riid, - _Out_ LPVOID* ppv - ); - -/// -/// Creates a single uninitialized object of the class associated with a specified CLSID. -/// -/// -/// The CLSID associated with the data and code that will be used to create the object. -/// -/// -/// A reference to the identifier of the interface to be used to communicate -/// with the object. -/// -/// -/// Address of pointer variable that receives the interface pointer requested -/// in riid. Upon successful return, *ppv contains the requested interface -/// pointer. Upon failure, *ppv contains NULL. -/// -/// While this function is similar to CoCreateInstance, there is no COM involvement. -/// - -extern "C" -DXC_API_IMPORT HRESULT __stdcall DxcCreateInstance( - _In_ REFCLSID rclsid, - _In_ REFIID riid, - _Out_ LPVOID* ppv - ); - -extern "C" -DXC_API_IMPORT HRESULT __stdcall DxcCreateInstance2( - _In_ IMalloc *pMalloc, - _In_ REFCLSID rclsid, - _In_ REFIID riid, - _Out_ LPVOID* ppv -); +/// \brief Typedef for DxcCreateInstance function pointer. +/// +/// This can be used with GetProcAddress to get the DxcCreateInstance function. +typedef HRESULT(__stdcall *DxcCreateInstanceProc)(_In_ REFCLSID rclsid, + _In_ REFIID riid, + _Out_ LPVOID *ppv); + +/// \brief Typedef for DxcCreateInstance2 function pointer. +/// +/// This can be used with GetProcAddress to get the DxcCreateInstance2 function. +typedef HRESULT(__stdcall *DxcCreateInstance2Proc)(_In_ IMalloc *pMalloc, + _In_ REFCLSID rclsid, + _In_ REFIID riid, + _Out_ LPVOID *ppv); + +/// \brief Creates a single uninitialized object of the class associated with a +/// specified CLSID. +/// +/// \param rclsid The CLSID associated with the data and code that will be used +/// to create the object. +/// +/// \param riid A reference to the identifier of the interface to be used to +/// communicate with the object. +/// +/// \param ppv Address of pointer variable that receives the interface pointer +/// requested in riid. Upon successful return, *ppv contains the requested +/// interface pointer. Upon failure, *ppv contains NULL. +/// +/// While this function is similar to CoCreateInstance, there is no COM +/// involvement. +extern "C" DXC_API_IMPORT + HRESULT __stdcall DxcCreateInstance(_In_ REFCLSID rclsid, _In_ REFIID riid, + _Out_ LPVOID *ppv); + +/// \brief Version of DxcCreateInstance that takes an IMalloc interface. +/// +/// This can be used to create an instance of the compiler with a custom memory +/// allocator. +extern "C" DXC_API_IMPORT + HRESULT __stdcall DxcCreateInstance2(_In_ IMalloc *pMalloc, + _In_ REFCLSID rclsid, _In_ REFIID riid, + _Out_ LPVOID *ppv); // For convenience, equivalent definitions to CP_UTF8 and CP_UTF16. #define DXC_CP_UTF8 65001 @@ -94,37 +91,39 @@ DXC_API_IMPORT HRESULT __stdcall DxcCreateInstance2( // Use DXC_CP_ACP for: Binary; ANSI Text; Autodetect UTF with BOM #define DXC_CP_ACP 0 +/// Codepage for "wide" characters - UTF16 on Windows, UTF32 on other platforms. #ifdef _WIN32 #define DXC_CP_WIDE DXC_CP_UTF16 #else #define DXC_CP_WIDE DXC_CP_UTF32 #endif -// This flag indicates that the shader hash was computed taking into account source information (-Zss) -#define DXC_HASHFLAG_INCLUDES_SOURCE 1 +/// Indicates that the shader hash was computed taking into account source +/// information (-Zss). +#define DXC_HASHFLAG_INCLUDES_SOURCE 1 -// Hash digest type for ShaderHash +/// Hash digest type for ShaderHash. typedef struct DxcShaderHash { - UINT32 Flags; // DXC_HASHFLAG_* - BYTE HashDigest[16]; + UINT32 Flags; ///< DXC_HASHFLAG_* + BYTE HashDigest[16]; ///< The hash digest } DxcShaderHash; -#define DXC_FOURCC(ch0, ch1, ch2, ch3) ( \ - (UINT32)(UINT8)(ch0) | (UINT32)(UINT8)(ch1) << 8 | \ - (UINT32)(UINT8)(ch2) << 16 | (UINT32)(UINT8)(ch3) << 24 \ - ) -#define DXC_PART_PDB DXC_FOURCC('I', 'L', 'D', 'B') -#define DXC_PART_PDB_NAME DXC_FOURCC('I', 'L', 'D', 'N') -#define DXC_PART_PRIVATE_DATA DXC_FOURCC('P', 'R', 'I', 'V') -#define DXC_PART_ROOT_SIGNATURE DXC_FOURCC('R', 'T', 'S', '0') -#define DXC_PART_DXIL DXC_FOURCC('D', 'X', 'I', 'L') -#define DXC_PART_REFLECTION_DATA DXC_FOURCC('S', 'T', 'A', 'T') -#define DXC_PART_SHADER_HASH DXC_FOURCC('H', 'A', 'S', 'H') -#define DXC_PART_INPUT_SIGNATURE DXC_FOURCC('I', 'S', 'G', '1') -#define DXC_PART_OUTPUT_SIGNATURE DXC_FOURCC('O', 'S', 'G', '1') +#define DXC_FOURCC(ch0, ch1, ch2, ch3) \ + ((UINT32)(UINT8)(ch0) | (UINT32)(UINT8)(ch1) << 8 | \ + (UINT32)(UINT8)(ch2) << 16 | (UINT32)(UINT8)(ch3) << 24) +#define DXC_PART_PDB DXC_FOURCC('I', 'L', 'D', 'B') +#define DXC_PART_PDB_NAME DXC_FOURCC('I', 'L', 'D', 'N') +#define DXC_PART_PRIVATE_DATA DXC_FOURCC('P', 'R', 'I', 'V') +#define DXC_PART_ROOT_SIGNATURE DXC_FOURCC('R', 'T', 'S', '0') +#define DXC_PART_DXIL DXC_FOURCC('D', 'X', 'I', 'L') +#define DXC_PART_REFLECTION_DATA DXC_FOURCC('S', 'T', 'A', 'T') +#define DXC_PART_SHADER_HASH DXC_FOURCC('H', 'A', 'S', 'H') +#define DXC_PART_INPUT_SIGNATURE DXC_FOURCC('I', 'S', 'G', '1') +#define DXC_PART_OUTPUT_SIGNATURE DXC_FOURCC('O', 'S', 'G', '1') #define DXC_PART_PATCH_CONSTANT_SIGNATURE DXC_FOURCC('P', 'S', 'G', '1') -// Some option arguments are defined here for continuity with D3DCompile interface +// Some option arguments are defined here for continuity with D3DCompile +// interface. #define DXC_ARG_DEBUG L"-Zi" #define DXC_ARG_SKIP_VALIDATION L"-Vd" #define DXC_ARG_SKIP_OPTIMIZATIONS L"-Od" @@ -145,341 +144,606 @@ typedef struct DxcShaderHash { #define DXC_ARG_DEBUG_NAME_FOR_SOURCE L"-Zss" #define DXC_ARG_DEBUG_NAME_FOR_BINARY L"-Zsb" -// IDxcBlob is an alias of ID3D10Blob and ID3DBlob CROSS_PLATFORM_UUIDOF(IDxcBlob, "8BA5FB08-5195-40e2-AC58-0D989C3A0102") +/// \brief A sized buffer that can be passed in and out of DXC APIs. +/// +/// This is an alias of ID3D10Blob and ID3DBlob. struct IDxcBlob : public IUnknown { public: + /// \brief Retrieves a pointer to the blob's data. virtual LPVOID STDMETHODCALLTYPE GetBufferPointer(void) = 0; + + /// \brief Retrieves the size, in bytes, of the blob's data. virtual SIZE_T STDMETHODCALLTYPE GetBufferSize(void) = 0; }; CROSS_PLATFORM_UUIDOF(IDxcBlobEncoding, "7241d424-2646-4191-97c0-98e96e42fc68") +/// \brief A blob that might have a known encoding. struct IDxcBlobEncoding : public IDxcBlob { public: + /// \brief Retrieve the encoding for this blob. + /// + /// \param pKnown Pointer to a variable that will be set to TRUE if the + /// encoding is known. + /// + /// \param pCodePage Pointer to variable that will be set to the encoding used + /// for this blog. + /// + /// If the encoding is not known then pCodePage will be set to CP_ACP. virtual HRESULT STDMETHODCALLTYPE GetEncoding(_Out_ BOOL *pKnown, _Out_ UINT32 *pCodePage) = 0; }; -// Notes on IDxcBlobWide and IDxcBlobUtf8 -// These guarantee null-terminated text and eithre utf8 or the native wide char encoding. -// GetBufferSize() will return the size in bytes, including null-terminator -// GetStringLength() will return the length in characters, excluding the null-terminator -// Name strings will use IDxcBlobWide, while other string output blobs, -// such as errors/warnings, preprocessed HLSL, or other text will be based -// on the -encoding option. - -// The API will use this interface for output name strings CROSS_PLATFORM_UUIDOF(IDxcBlobWide, "A3F84EAB-0FAA-497E-A39C-EE6ED60B2D84") +/// \brief A blob containing a null-terminated wide string. +/// +/// This uses the native wide character encoding (utf16 on Windows, utf32 on +/// Linux). +/// +/// The value returned by GetBufferSize() is the size of the buffer, in bytes, +/// including the null-terminator. +/// +/// This interface is used to return output name strings DXC. Other string +/// output blobs, such as errors/warnings, preprocessed HLSL, or other text are +/// returned using encodings based on the -encoding option passed to the +/// compiler. struct IDxcBlobWide : public IDxcBlobEncoding { public: + /// \brief Retrieves a pointer to the string stored in this blob. virtual LPCWSTR STDMETHODCALLTYPE GetStringPointer(void) = 0; + + /// \brief Retrieves the length of the string stored in this blob, in + /// characters, excluding the null-terminator. virtual SIZE_T STDMETHODCALLTYPE GetStringLength(void) = 0; }; + CROSS_PLATFORM_UUIDOF(IDxcBlobUtf8, "3DA636C9-BA71-4024-A301-30CBF125305B") +/// \brief A blob containing a UTF-8 encoded string. +/// +/// The value returned by GetBufferSize() is the size of the buffer, in bytes, +/// including the null-terminator. +/// +/// Depending on the -encoding option passed to the compiler, this interface is +/// used to return string output blobs, such as errors/warnings, preprocessed +/// HLSL, or other text. Output name strings always use IDxcBlobWide. struct IDxcBlobUtf8 : public IDxcBlobEncoding { public: + /// \brief Retrieves a pointer to the string stored in this blob. virtual LPCSTR STDMETHODCALLTYPE GetStringPointer(void) = 0; + + /// \brief Retrieves the length of the string stored in this blob, in + /// characters, excluding the null-terminator. virtual SIZE_T STDMETHODCALLTYPE GetStringLength(void) = 0; }; -// Define legacy name IDxcBlobUtf16 as IDxcBlobWide for Win32 #ifdef _WIN32 +/// IDxcBlobUtf16 is a legacy alias for IDxcBlobWide on Win32. typedef IDxcBlobWide IDxcBlobUtf16; #endif -CROSS_PLATFORM_UUIDOF(IDxcIncludeHandler, "7f61fc7d-950d-467f-b3e3-3c02fb49187c") +CROSS_PLATFORM_UUIDOF(IDxcIncludeHandler, + "7f61fc7d-950d-467f-b3e3-3c02fb49187c") +/// \brief Interface for handling include directives. +/// +/// This interface can be implemented to customize handling of include +/// directives. +/// +/// Use IDxcUtils::CreateDefaultIncludeHandler to create a default +/// implementation that reads include files from the filesystem. +/// struct IDxcIncludeHandler : public IUnknown { - virtual HRESULT STDMETHODCALLTYPE LoadSource( - _In_z_ LPCWSTR pFilename, // Candidate filename. - _COM_Outptr_result_maybenull_ IDxcBlob **ppIncludeSource // Resultant source object for included file, nullptr if not found. - ) = 0; + /// \brief Load a source file to be included by the compiler. + /// + /// \param pFilename Candidate filename. + /// + /// \param ppIncludeSource Resultant source object for included file, nullptr + /// if not found. + virtual HRESULT STDMETHODCALLTYPE + LoadSource(_In_z_ LPCWSTR pFilename, + _COM_Outptr_result_maybenull_ IDxcBlob **ppIncludeSource) = 0; }; -// Structure for supplying bytes or text input to Dxc APIs. -// Use Encoding = 0 for non-text bytes, ANSI text, or unknown with BOM. +/// \brief Structure for supplying bytes or text input to Dxc APIs. typedef struct DxcBuffer { + /// \brief Pointer to the start of the buffer. LPCVOID Ptr; + + /// \brief Size of the buffer in bytes. SIZE_T Size; + + /// \brief Encoding of the buffer. + /// + /// Use Encoding = 0 for non-text bytes, ANSI text, or unknown with BOM. UINT Encoding; } DxcText; +/// \brief Structure for supplying defines to Dxc APIs. struct DxcDefine { - LPCWSTR Name; - _Maybenull_ LPCWSTR Value; + LPCWSTR Name; ///< The define name. + _Maybenull_ LPCWSTR Value; ///< Optional value for the define. }; CROSS_PLATFORM_UUIDOF(IDxcCompilerArgs, "73EFFE2A-70DC-45F8-9690-EFF64C02429D") +/// \brief Interface for managing arguments passed to DXC. +/// +/// Use IDxcUtils::BuildArguments to create an instance of this interface. struct IDxcCompilerArgs : public IUnknown { - // Pass GetArguments() and GetCount() to Compile - virtual LPCWSTR* STDMETHODCALLTYPE GetArguments() = 0; + /// \brief Retrieve the array of arguments. + /// + /// This can be passed directly to the pArguments parameter of the Compile() + /// method. + virtual LPCWSTR *STDMETHODCALLTYPE GetArguments() = 0; + + /// \brief Retrieve the number of arguments. + /// + /// This can be passed directly to the argCount parameter of the Compile() + /// method. virtual UINT32 STDMETHODCALLTYPE GetCount() = 0; - // Add additional arguments or defines here, if desired. + /// \brief Add additional arguments to this list of compiler arguments. virtual HRESULT STDMETHODCALLTYPE AddArguments( - _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments to add - _In_ UINT32 argCount // Number of arguments to add - ) = 0; + _In_opt_count_(argCount) + LPCWSTR *pArguments, ///< Array of pointers to arguments to add. + _In_ UINT32 argCount ///< Number of arguments to add. + ) = 0; + + /// \brief Add additional UTF-8 encoded arguments to this list of compiler + /// arguments. virtual HRESULT STDMETHODCALLTYPE AddArgumentsUTF8( - _In_opt_count_(argCount)LPCSTR *pArguments, // Array of pointers to UTF-8 arguments to add - _In_ UINT32 argCount // Number of arguments to add - ) = 0; + _In_opt_count_(argCount) + LPCSTR *pArguments, ///< Array of pointers to UTF-8 arguments to add. + _In_ UINT32 argCount ///< Number of arguments to add. + ) = 0; + + /// \brief Add additional defines to this list of compiler arguments. virtual HRESULT STDMETHODCALLTYPE AddDefines( - _In_count_(defineCount) const DxcDefine *pDefines, // Array of defines - _In_ UINT32 defineCount // Number of defines - ) = 0; + _In_count_(defineCount) const DxcDefine *pDefines, ///< Array of defines. + _In_ UINT32 defineCount ///< Number of defines. + ) = 0; }; ////////////////////////// // Legacy Interfaces ///////////////////////// -// NOTE: IDxcUtils replaces IDxcLibrary CROSS_PLATFORM_UUIDOF(IDxcLibrary, "e5204dc7-d18c-4c3c-bdfb-851673980fe7") +/// \deprecated IDxcUtils replaces IDxcLibrary; please use IDxcUtils insted. struct IDxcLibrary : public IUnknown { + /// \deprecated virtual HRESULT STDMETHODCALLTYPE SetMalloc(_In_opt_ IMalloc *pMalloc) = 0; - virtual HRESULT STDMETHODCALLTYPE CreateBlobFromBlob( - _In_ IDxcBlob *pBlob, UINT32 offset, UINT32 length, _COM_Outptr_ IDxcBlob **ppResult) = 0; - virtual HRESULT STDMETHODCALLTYPE CreateBlobFromFile( - _In_z_ LPCWSTR pFileName, _In_opt_ UINT32* codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; + + /// \deprecated + virtual HRESULT STDMETHODCALLTYPE + CreateBlobFromBlob(_In_ IDxcBlob *pBlob, UINT32 offset, UINT32 length, + _COM_Outptr_ IDxcBlob **ppResult) = 0; + + /// \deprecated + virtual HRESULT STDMETHODCALLTYPE + CreateBlobFromFile(_In_z_ LPCWSTR pFileName, _In_opt_ UINT32 *codePage, + _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; + + /// \deprecated virtual HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingFromPinned( - _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; + _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage, + _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; + + /// \deprecated virtual HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingOnHeapCopy( - _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; + _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage, + _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; + + /// \deprecated virtual HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingOnMalloc( - _In_bytecount_(size) LPCVOID pText, IMalloc *pIMalloc, UINT32 size, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; - virtual HRESULT STDMETHODCALLTYPE CreateIncludeHandler( - _COM_Outptr_ IDxcIncludeHandler **ppResult) = 0; + _In_bytecount_(size) LPCVOID pText, IMalloc *pIMalloc, UINT32 size, + UINT32 codePage, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; + + /// \deprecated + virtual HRESULT STDMETHODCALLTYPE + CreateIncludeHandler(_COM_Outptr_ IDxcIncludeHandler **ppResult) = 0; + + /// \deprecated virtual HRESULT STDMETHODCALLTYPE CreateStreamFromBlobReadOnly( - _In_ IDxcBlob *pBlob, _COM_Outptr_ IStream **ppStream) = 0; + _In_ IDxcBlob *pBlob, _COM_Outptr_ IStream **ppStream) = 0; + + /// \deprecated virtual HRESULT STDMETHODCALLTYPE GetBlobAsUtf8( - _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; + _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; // Renamed from GetBlobAsUtf16 to GetBlobAsWide + /// \deprecated virtual HRESULT STDMETHODCALLTYPE GetBlobAsWide( - _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; + _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; #ifdef _WIN32 // Alias to GetBlobAsWide on Win32 - inline HRESULT GetBlobAsUtf16( - _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) { + /// \deprecated + inline HRESULT GetBlobAsUtf16(_In_ IDxcBlob *pBlob, + _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) { return this->GetBlobAsWide(pBlob, pBlobEncoding); } #endif }; -// NOTE: IDxcResult replaces IDxcOperationResult -CROSS_PLATFORM_UUIDOF(IDxcOperationResult, "CEDB484A-D4E9-445A-B991-CA21CA157DC2") +CROSS_PLATFORM_UUIDOF(IDxcOperationResult, + "CEDB484A-D4E9-445A-B991-CA21CA157DC2") +/// \brief The results of a DXC operation. +/// +/// Note: IDxcResult replaces IDxcOperationResult and should be used wherever +/// possible. struct IDxcOperationResult : public IUnknown { + /// \brief Retrieve the overall status of the operation. virtual HRESULT STDMETHODCALLTYPE GetStatus(_Out_ HRESULT *pStatus) = 0; - // GetResult returns the main result of the operation. - // This corresponds to: - // DXC_OUT_OBJECT - Compile() with shader or library target - // DXC_OUT_DISASSEMBLY - Disassemble() - // DXC_OUT_HLSL - Compile() with -P - // DXC_OUT_ROOT_SIGNATURE - Compile() with rootsig_* target - virtual HRESULT STDMETHODCALLTYPE GetResult(_COM_Outptr_result_maybenull_ IDxcBlob **ppResult) = 0; - - // GetErrorBuffer Corresponds to DXC_OUT_ERRORS. - virtual HRESULT STDMETHODCALLTYPE GetErrorBuffer(_COM_Outptr_result_maybenull_ IDxcBlobEncoding **ppErrors) = 0; + /// \brief Retrieve the primary output of the operation. + /// + /// This corresponds to: + /// * DXC_OUT_OBJECT - Compile() with shader or library target + /// * DXC_OUT_DISASSEMBLY - Disassemble() + /// * DXC_OUT_HLSL - Compile() with -P + /// * DXC_OUT_ROOT_SIGNATURE - Compile() with rootsig_* target + virtual HRESULT STDMETHODCALLTYPE + GetResult(_COM_Outptr_result_maybenull_ IDxcBlob **ppResult) = 0; + + /// \brief Retrieves the error buffer from the operation, if there is one. + /// + // This corresponds to calling IDxcResult::GetOutput() with DXC_OUT_ERRORS. + virtual HRESULT STDMETHODCALLTYPE + GetErrorBuffer(_COM_Outptr_result_maybenull_ IDxcBlobEncoding **ppErrors) = 0; }; -// NOTE: IDxcCompiler3 replaces IDxcCompiler and IDxcCompiler2 CROSS_PLATFORM_UUIDOF(IDxcCompiler, "8c210bf3-011f-4422-8d70-6f9acb8db617") +/// \deprecated Please use IDxcCompiler3 instead. struct IDxcCompiler : public IUnknown { - // Compile a single entry point to the target shader model + /// \brief Compile a single entry point to the target shader model. + /// + /// \deprecated Please use IDxcCompiler3::Compile() instead. virtual HRESULT STDMETHODCALLTYPE Compile( - _In_ IDxcBlob *pSource, // Source text to compile - _In_opt_z_ LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and include handlers. - _In_opt_z_ LPCWSTR pEntryPoint, // entry point name - _In_z_ LPCWSTR pTargetProfile, // shader profile to compile - _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments - _In_ UINT32 argCount, // Number of arguments - _In_count_(defineCount) - const DxcDefine *pDefines, // Array of defines - _In_ UINT32 defineCount, // Number of defines - _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional) - _COM_Outptr_ IDxcOperationResult **ppResult // Compiler output status, buffer, and errors - ) = 0; - - // Preprocess source text + _In_ IDxcBlob *pSource, // Source text to compile. + _In_opt_z_ LPCWSTR pSourceName, // Optional file name for pSource. Used in + // errors and include handlers. + _In_opt_z_ LPCWSTR pEntryPoint, // Entry point name. + _In_z_ LPCWSTR pTargetProfile, // Shader profile to compile. + _In_opt_count_(argCount) + LPCWSTR *pArguments, // Array of pointers to arguments. + _In_ UINT32 argCount, // Number of arguments. + _In_count_(defineCount) const DxcDefine *pDefines, // Array of defines. + _In_ UINT32 defineCount, // Number of defines. + _In_opt_ IDxcIncludeHandler + *pIncludeHandler, // User-provided interface to handle #include + // directives (optional). + _COM_Outptr_ IDxcOperationResult * + *ppResult // Compiler output status, buffer, and errors. + ) = 0; + + /// \brief Preprocess source text. + /// + /// \deprecated Please use IDxcCompiler3::Compile() with the "-P" argument + /// instead. virtual HRESULT STDMETHODCALLTYPE Preprocess( - _In_ IDxcBlob *pSource, // Source text to preprocess - _In_opt_z_ LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and include handlers. - _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments - _In_ UINT32 argCount, // Number of arguments - _In_count_(defineCount) - const DxcDefine *pDefines, // Array of defines - _In_ UINT32 defineCount, // Number of defines - _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional) - _COM_Outptr_ IDxcOperationResult **ppResult // Preprocessor output status, buffer, and errors - ) = 0; - - // Disassemble a program. + _In_ IDxcBlob *pSource, // Source text to preprocess. + _In_opt_z_ LPCWSTR pSourceName, // Optional file name for pSource. Used in + // errors and include handlers. + _In_opt_count_(argCount) + LPCWSTR *pArguments, // Array of pointers to arguments. + _In_ UINT32 argCount, // Number of arguments. + _In_count_(defineCount) const DxcDefine *pDefines, // Array of defines. + _In_ UINT32 defineCount, // Number of defines. + _In_opt_ IDxcIncludeHandler + *pIncludeHandler, // user-provided interface to handle #include + // directives (optional). + _COM_Outptr_ IDxcOperationResult * + *ppResult // Preprocessor output status, buffer, and errors. + ) = 0; + + /// \brief Disassemble a program. + /// + /// \deprecated Please use IDxcCompiler3::Disassemble() instead. virtual HRESULT STDMETHODCALLTYPE Disassemble( - _In_ IDxcBlob *pSource, // Program to disassemble. - _COM_Outptr_ IDxcBlobEncoding **ppDisassembly // Disassembly text. - ) = 0; + _In_ IDxcBlob *pSource, // Program to disassemble. + _COM_Outptr_ IDxcBlobEncoding **ppDisassembly // Disassembly text. + ) = 0; }; -// NOTE: IDxcCompiler3 replaces IDxcCompiler and IDxcCompiler2 CROSS_PLATFORM_UUIDOF(IDxcCompiler2, "A005A9D9-B8BB-4594-B5C9-0E633BEC4D37") +/// \deprecated Please use IDxcCompiler3 instead. struct IDxcCompiler2 : public IDxcCompiler { - // Compile a single entry point to the target shader model with debug information. + /// \brief Compile a single entry point to the target shader model with debug + /// information. + /// + /// \deprecated Please use IDxcCompiler3::Compile() instead. virtual HRESULT STDMETHODCALLTYPE CompileWithDebug( - _In_ IDxcBlob *pSource, // Source text to compile - _In_opt_z_ LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and include handlers. - _In_opt_z_ LPCWSTR pEntryPoint, // Entry point name - _In_z_ LPCWSTR pTargetProfile, // Shader profile to compile - _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments - _In_ UINT32 argCount, // Number of arguments - _In_count_(defineCount) - const DxcDefine *pDefines, // Array of defines - _In_ UINT32 defineCount, // Number of defines - _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional) - _COM_Outptr_ IDxcOperationResult **ppResult, // Compiler output status, buffer, and errors - _Outptr_opt_result_z_ LPWSTR *ppDebugBlobName,// Suggested file name for debug blob. (Must be CoTaskMemFree()'d!) - _COM_Outptr_opt_ IDxcBlob **ppDebugBlob // Debug blob - ) = 0; + _In_ IDxcBlob *pSource, // Source text to compile. + _In_opt_z_ LPCWSTR pSourceName, // Optional file name for pSource. Used in + // errors and include handlers. + _In_opt_z_ LPCWSTR pEntryPoint, // Entry point name. + _In_z_ LPCWSTR pTargetProfile, // Shader profile to compile. + _In_opt_count_(argCount) + LPCWSTR *pArguments, // Array of pointers to arguments. + _In_ UINT32 argCount, // Number of arguments. + _In_count_(defineCount) const DxcDefine *pDefines, // Array of defines. + _In_ UINT32 defineCount, // Number of defines. + _In_opt_ IDxcIncludeHandler + *pIncludeHandler, // user-provided interface to handle #include + // directives (optional). + _COM_Outptr_ IDxcOperationResult * + *ppResult, // Compiler output status, buffer, and errors. + _Outptr_opt_result_z_ LPWSTR + *ppDebugBlobName, // Suggested file name for debug blob. Must be + // CoTaskMemFree()'d. + _COM_Outptr_opt_ IDxcBlob **ppDebugBlob // Debug blob. + ) = 0; }; CROSS_PLATFORM_UUIDOF(IDxcLinker, "F1B5BE2A-62DD-4327-A1C2-42AC1E1E78E6") +/// \brief DXC linker interface. +/// +/// Use DxcCreateInstance with CLSID_DxcLinker to obtain an instance of this +/// interface. struct IDxcLinker : public IUnknown { public: - // Register a library with name to ref it later. - virtual HRESULT RegisterLibrary( - _In_opt_ LPCWSTR pLibName, // Name of the library. - _In_ IDxcBlob *pLib // Library blob. - ) = 0; - - // Links the shader and produces a shader blob that the Direct3D runtime can - // use. + /// \brief Register a library with name to reference it later. + virtual HRESULT + RegisterLibrary(_In_opt_ LPCWSTR pLibName, ///< Name of the library. + _In_ IDxcBlob *pLib ///< Library blob. + ) = 0; + + /// \brief Links the shader and produces a shader blob that the Direct3D + /// runtime can use. virtual HRESULT STDMETHODCALLTYPE Link( - _In_opt_ LPCWSTR pEntryName, // Entry point name - _In_ LPCWSTR pTargetProfile, // shader profile to link - _In_count_(libCount) - const LPCWSTR *pLibNames, // Array of library names to link - _In_ UINT32 libCount, // Number of libraries to link - _In_opt_count_(argCount) const LPCWSTR *pArguments, // Array of pointers to arguments - _In_ UINT32 argCount, // Number of arguments - _COM_Outptr_ - IDxcOperationResult **ppResult // Linker output status, buffer, and errors - ) = 0; + _In_opt_ LPCWSTR pEntryName, ///< Entry point name. + _In_ LPCWSTR pTargetProfile, ///< shader profile to link. + _In_count_(libCount) + const LPCWSTR *pLibNames, ///< Array of library names to link. + _In_ UINT32 libCount, ///< Number of libraries to link. + _In_opt_count_(argCount) + const LPCWSTR *pArguments, ///< Array of pointers to arguments. + _In_ UINT32 argCount, ///< Number of arguments. + _COM_Outptr_ IDxcOperationResult * + *ppResult ///< Linker output status, buffer, and errors. + ) = 0; }; ///////////////////////// -// Latest interfaces. Please use these +// Latest interfaces. Please use these. //////////////////////// -// NOTE: IDxcUtils replaces IDxcLibrary CROSS_PLATFORM_UUIDOF(IDxcUtils, "4605C4CB-2019-492A-ADA4-65F20BB7D67F") +/// \brief Various utility functions for DXC. +/// +/// Use DxcCreateInstance with CLSID_DxcUtils to obtain an instance of this +/// interface. +/// +/// IDxcUtils replaces IDxcLibrary. struct IDxcUtils : public IUnknown { - // Create a sub-blob that holds a reference to the outer blob and points to its memory. - virtual HRESULT STDMETHODCALLTYPE CreateBlobFromBlob( - _In_ IDxcBlob *pBlob, UINT32 offset, UINT32 length, _COM_Outptr_ IDxcBlob **ppResult) = 0; - - // For codePage, use 0 (or DXC_CP_ACP) for raw binary or ANSI code page - - // Creates a blob referencing existing memory, with no copy. - // User must manage the memory lifetime separately. - // (was: CreateBlobWithEncodingFromPinned) + /// \brief Create a sub-blob that holds a reference to the outer blob and + /// points to its memory. + /// + /// \param pBlob The outer blob. + /// + /// \param offset The offset inside the outer blob. + /// + /// \param length The size, in bytes, of the buffer to reference from the + /// output blob. + /// + /// \param ppResult Address of the pointer that receives a pointer to the + /// newly created blob. + virtual HRESULT STDMETHODCALLTYPE + CreateBlobFromBlob(_In_ IDxcBlob *pBlob, UINT32 offset, UINT32 length, + _COM_Outptr_ IDxcBlob **ppResult) = 0; + + // For codePage, use 0 (or DXC_CP_ACP) for raw binary or ANSI code page. + + /// \brief Create a blob referencing existing memory, with no copy. + /// + /// \param pData Pointer to buffer containing the contents of the new blob. + /// + /// \param size The size of the pData buffer, in bytes. + /// + /// \param codePage The code page to use if the blob contains text. Use + /// DXC_CP_ACP for binary or ANSI code page. + /// + /// \param ppBlobEncoding Address of the pointer that receives a pointer to + /// the newly created blob. + /// + /// The user must manage the memory lifetime separately. + /// + /// This replaces IDxcLibrary::CreateBlobWithEncodingFromPinned. virtual HRESULT STDMETHODCALLTYPE CreateBlobFromPinned( - _In_bytecount_(size) LPCVOID pData, UINT32 size, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; - - // Create blob, taking ownership of memory allocated with supplied allocator. - // (was: CreateBlobWithEncodingOnMalloc) + _In_bytecount_(size) LPCVOID pData, UINT32 size, UINT32 codePage, + _COM_Outptr_ IDxcBlobEncoding **ppBlobEncoding) = 0; + + /// \brief Create a blob, taking ownership of memory allocated with the + /// supplied allocator. + /// + /// \param pData Pointer to buffer containing the contents of the new blob. + /// + /// \param pIMalloc The memory allocator to use. + /// + /// \param size The size of thee pData buffer, in bytes. + /// + /// \param codePage The code page to use if the blob contains text. Use + /// DXC_CP_ACP for binary or ANSI code page. + /// + /// \param ppBlobEncoding Address of the pointer that receives a pointer to + /// the newly created blob. + /// + /// This replaces IDxcLibrary::CreateBlobWithEncodingOnMalloc. virtual HRESULT STDMETHODCALLTYPE MoveToBlob( - _In_bytecount_(size) LPCVOID pData, IMalloc *pIMalloc, UINT32 size, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; - - //// - // New blobs and copied contents are allocated with the current allocator - - // Copy blob contents to memory owned by the new blob. - // (was: CreateBlobWithEncodingOnHeapCopy) - virtual HRESULT STDMETHODCALLTYPE CreateBlob( - _In_bytecount_(size) LPCVOID pData, UINT32 size, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; - - // (was: CreateBlobFromFile) - virtual HRESULT STDMETHODCALLTYPE LoadFile( - _In_z_ LPCWSTR pFileName, _In_opt_ UINT32* pCodePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; - + _In_bytecount_(size) LPCVOID pData, IMalloc *pIMalloc, UINT32 size, + UINT32 codePage, _COM_Outptr_ IDxcBlobEncoding **ppBlobEncoding) = 0; + + /// \brief Create a blob containing a copy of the existing data. + /// + /// \param pData Pointer to buffer containing the contents of the new blob. + /// + /// \param size The size of thee pData buffer, in bytes. + /// + /// \param codePage The code page to use if the blob contains text. Use + /// DXC_CP_ACP for binary or ANSI code page. + /// + /// \param ppBlobEncoding Address of the pointer that receives a pointer to + /// the newly created blob. + /// + /// The new blob and its contents are allocated with the current allocator. + /// This replaces IDxcLibrary::CreateBlobWithEncodingOnHeapCopy. + virtual HRESULT STDMETHODCALLTYPE + CreateBlob(_In_bytecount_(size) LPCVOID pData, UINT32 size, UINT32 codePage, + _COM_Outptr_ IDxcBlobEncoding **ppBlobEncoding) = 0; + + /// \brief Create a blob with data loaded from a file. + /// + /// \param pFileName The name of the file to load from. + /// + /// \param pCodePage Optional code page to use if the blob contains text. Pass + /// NULL for binary data. + /// + /// \param ppBlobEncoding Address of the pointer that receives a pointer to + /// the newly created blob. + /// + /// The new blob and its contents are allocated with the current allocator. + /// This replaces IDxcLibrary::CreateBlobFromFile. + virtual HRESULT STDMETHODCALLTYPE + LoadFile(_In_z_ LPCWSTR pFileName, _In_opt_ UINT32 *pCodePage, + _COM_Outptr_ IDxcBlobEncoding **ppBlobEncoding) = 0; + + /// \brief Create a stream that reads data from a blob. + /// + /// \param pBlob The blob to read from. + /// + /// \param ppStream Address of the pointer that receives a pointer to the + /// newly created stream. virtual HRESULT STDMETHODCALLTYPE CreateReadOnlyStreamFromBlob( - _In_ IDxcBlob *pBlob, _COM_Outptr_ IStream **ppStream) = 0; - - // Create default file-based include handler - virtual HRESULT STDMETHODCALLTYPE CreateDefaultIncludeHandler( - _COM_Outptr_ IDxcIncludeHandler **ppResult) = 0; - - // Convert or return matching encoded text blobs + _In_ IDxcBlob *pBlob, _COM_Outptr_ IStream **ppStream) = 0; + + /// \brief Create default file-based include handler. + /// + /// \param ppResult Address of the pointer that receives a pointer to the + /// newly created include handler. + virtual HRESULT STDMETHODCALLTYPE + CreateDefaultIncludeHandler(_COM_Outptr_ IDxcIncludeHandler **ppResult) = 0; + + /// \brief Convert or return matching encoded text blob as UTF-8. + /// + /// \param pBlob The blob to convert. + /// + /// \param ppBlobEncoding Address of the pointer that receives a pointer to + /// the newly created blob. virtual HRESULT STDMETHODCALLTYPE GetBlobAsUtf8( - _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobUtf8 **pBlobEncoding) = 0; - - // Renamed from GetBlobAsUtf16 to GetBlobAsWide + _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobUtf8 **ppBlobEncoding) = 0; + + /// \brief Convert or return matching encoded text blob as UTF-16. + /// + /// \param pBlob The blob to convert. + /// + /// \param ppBlobEncoding Address of the pointer that receives a pointer to + /// the newly created blob. virtual HRESULT STDMETHODCALLTYPE GetBlobAsWide( - _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobWide **pBlobEncoding) = 0; + _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobWide **ppBlobEncoding) = 0; #ifdef _WIN32 - // Alias to GetBlobAsWide on Win32 - inline HRESULT GetBlobAsUtf16( - _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobWide **pBlobEncoding) { - return this->GetBlobAsWide(pBlob, pBlobEncoding); + /// \brief Convert or return matching encoded text blob as UTF-16. + /// + /// \param pBlob The blob to convert. + /// + /// \param ppBlobEncoding Address of the pointer that receives a pointer to + /// the newly created blob. + /// + /// Alias to GetBlobAsWide on Win32. + inline HRESULT GetBlobAsUtf16(_In_ IDxcBlob *pBlob, + _COM_Outptr_ IDxcBlobWide **ppBlobEncoding) { + return this->GetBlobAsWide(pBlob, ppBlobEncoding); } #endif - virtual HRESULT STDMETHODCALLTYPE GetDxilContainerPart( - _In_ const DxcBuffer *pShader, - _In_ UINT32 DxcPart, - _Outptr_result_nullonfailure_ void **ppPartData, - _Out_ UINT32 *pPartSizeInBytes) = 0; - - // Create reflection interface from serialized Dxil container, or DXC_PART_REFLECTION_DATA. - // TBD: Require part header for RDAT? (leaning towards yes) + /// \brief Retrieve a single part from a DXIL container. + /// + /// \param pShader The shader to retrieve the part from. + /// + /// \param DxcPart The part to retrieve (eg DXC_PART_ROOT_SIGNATURE). + /// + /// \param ppPartData Address of the pointer that receives a pointer to the + /// part. + /// + /// \param pPartSizeInBytes Address of the pointer that receives the size of + /// the part. + /// + /// The returned pointer points inside the buffer passed in pShader. + virtual HRESULT STDMETHODCALLTYPE + GetDxilContainerPart(_In_ const DxcBuffer *pShader, _In_ UINT32 DxcPart, + _Outptr_result_nullonfailure_ void **ppPartData, + _Out_ UINT32 *pPartSizeInBytes) = 0; + + /// \brief Create reflection interface from serialized DXIL container or the + /// DXC_OUT_REFLECTION blob contents. + /// + /// \param pData The source data. + /// + /// \param iid The interface ID of the reflection interface to create. + /// + /// \param ppvReflection Address of the pointer that receives a pointer to the + /// newly created reflection interface. + /// + /// Use this with interfaces such as ID3D12ShaderReflection. virtual HRESULT STDMETHODCALLTYPE CreateReflection( - _In_ const DxcBuffer *pData, REFIID iid, void **ppvReflection) = 0; + _In_ const DxcBuffer *pData, REFIID iid, void **ppvReflection) = 0; + /// \brief Build arguments that can be passed to the Compile method. virtual HRESULT STDMETHODCALLTYPE BuildArguments( - _In_opt_z_ LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and include handlers. - _In_opt_z_ LPCWSTR pEntryPoint, // Entry point name. (-E) - _In_z_ LPCWSTR pTargetProfile, // Shader profile to compile. (-T) - _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments - _In_ UINT32 argCount, // Number of arguments - _In_count_(defineCount) - const DxcDefine *pDefines, // Array of defines - _In_ UINT32 defineCount, // Number of defines - _COM_Outptr_ IDxcCompilerArgs **ppArgs // Arguments you can use with Compile() method - ) = 0; - - // Takes the shader PDB and returns the hash and the container inside it - virtual HRESULT STDMETHODCALLTYPE GetPDBContents( - _In_ IDxcBlob *pPDBBlob, _COM_Outptr_ IDxcBlob **ppHash, _COM_Outptr_ IDxcBlob **ppContainer) = 0; + _In_opt_z_ LPCWSTR pSourceName, ///< Optional file name for pSource. Used + ///< in errors and include handlers. + _In_opt_z_ LPCWSTR pEntryPoint, ///< Entry point name (-E). + _In_z_ LPCWSTR pTargetProfile, ///< Shader profile to compile (-T). + _In_opt_count_(argCount) + LPCWSTR *pArguments, ///< Array of pointers to arguments. + _In_ UINT32 argCount, ///< Number of arguments. + _In_count_(defineCount) const DxcDefine *pDefines, ///< Array of defines. + _In_ UINT32 defineCount, ///< Number of defines. + _COM_Outptr_ IDxcCompilerArgs * + *ppArgs ///< Arguments you can use with Compile() method. + ) = 0; + + /// \brief Retrieve the hash and contents of a shader PDB. + /// + /// \param pPDBBlob The blob containing the PDB. + /// + /// \param ppHash Address of the pointer that receives a pointer to the hash + /// blob. + /// + /// \param ppContainer Address of the pointer that receives a pointer to the + /// bloc containing the contents of the PDB. + /// + virtual HRESULT STDMETHODCALLTYPE + GetPDBContents(_In_ IDxcBlob *pPDBBlob, _COM_Outptr_ IDxcBlob **ppHash, + _COM_Outptr_ IDxcBlob **ppContainer) = 0; }; -// For use with IDxcResult::[Has|Get]Output dxcOutKind argument -// Note: text outputs returned from version 2 APIs are UTF-8 or UTF-16 based on -encoding option +/// \brief Specifies the kind of output to retrieve from a IDxcResult. +/// +/// Note: text outputs returned from version 2 APIs are UTF-8 or UTF-16 based on +/// the -encoding option passed to the compiler. typedef enum DXC_OUT_KIND { - DXC_OUT_NONE = 0, - DXC_OUT_OBJECT = 1, // IDxcBlob - Shader or library object - DXC_OUT_ERRORS = 2, // IDxcBlobUtf8 or IDxcBlobWide - DXC_OUT_PDB = 3, // IDxcBlob - DXC_OUT_SHADER_HASH = 4, // IDxcBlob - DxcShaderHash of shader or shader with source info (-Zsb/-Zss) - DXC_OUT_DISASSEMBLY = 5, // IDxcBlobUtf8 or IDxcBlobWide - from Disassemble - DXC_OUT_HLSL = 6, // IDxcBlobUtf8 or IDxcBlobWide - from Preprocessor or Rewriter - DXC_OUT_TEXT = 7, // IDxcBlobUtf8 or IDxcBlobWide - other text, such as -ast-dump or -Odump - DXC_OUT_REFLECTION = 8, // IDxcBlob - RDAT part with reflection data - DXC_OUT_ROOT_SIGNATURE = 9, // IDxcBlob - Serialized root signature output - DXC_OUT_EXTRA_OUTPUTS = 10,// IDxcExtraResults - Extra outputs - DXC_OUT_REMARKS = 11, // IDxcBlobUtf8 or IDxcBlobWide - text directed at stdout - DXC_OUT_TIME_REPORT = 12, // IDxcBlobUtf8 or IDxcBlobWide - text directed at stdout - - DXC_OUT_LAST = DXC_OUT_TIME_REPORT, // Last value for a counter + DXC_OUT_NONE = 0, ///< No output. + DXC_OUT_OBJECT = 1, ///< IDxcBlob - Shader or library object. + DXC_OUT_ERRORS = 2, ///< IDxcBlobUtf8 or IDxcBlobWide. + DXC_OUT_PDB = 3, ///< IDxcBlob. + DXC_OUT_SHADER_HASH = 4, ///< IDxcBlob - DxcShaderHash of shader or shader + ///< with source info (-Zsb/-Zss). + DXC_OUT_DISASSEMBLY = 5, ///< IDxcBlobUtf8 or IDxcBlobWide - from Disassemble. + DXC_OUT_HLSL = + 6, ///< IDxcBlobUtf8 or IDxcBlobWide - from Preprocessor or Rewriter. + DXC_OUT_TEXT = 7, ///< IDxcBlobUtf8 or IDxcBlobWide - other text, such as + ///< -ast-dump or -Odump. + DXC_OUT_REFLECTION = 8, ///< IDxcBlob - RDAT part with reflection data. + DXC_OUT_ROOT_SIGNATURE = 9, ///< IDxcBlob - Serialized root signature output. + DXC_OUT_EXTRA_OUTPUTS = 10, ///< IDxcExtraOutputs - Extra outputs. + DXC_OUT_REMARKS = + 11, ///< IDxcBlobUtf8 or IDxcBlobWide - text directed at stdout. + DXC_OUT_TIME_REPORT = + 12, ///< IDxcBlobUtf8 or IDxcBlobWide - text directed at stdout. + DXC_OUT_TIME_TRACE = + 13, ///< IDxcBlobUtf8 or IDxcBlobWide - text directed at stdout. + + DXC_OUT_LAST = DXC_OUT_TIME_TRACE, ///< Last value for a counter. DXC_OUT_NUM_ENUMS, DXC_OUT_FORCE_DWORD = 0xFFFFFFFF @@ -489,148 +753,347 @@ static_assert(DXC_OUT_NUM_ENUMS == DXC_OUT_LAST + 1, "DXC_OUT_* Enum added and last value not updated."); CROSS_PLATFORM_UUIDOF(IDxcResult, "58346CDA-DDE7-4497-9461-6F87AF5E0659") +/// \brief Result of a DXC operation. +/// +/// DXC operations may have multiple outputs, such as a shader object and +/// errors. This interface provides access to the outputs. struct IDxcResult : public IDxcOperationResult { + /// \brief Determines whether or not this result has the specified output. + /// + /// \param dxcOutKind The kind of output to check for. virtual BOOL STDMETHODCALLTYPE HasOutput(_In_ DXC_OUT_KIND dxcOutKind) = 0; - virtual HRESULT STDMETHODCALLTYPE GetOutput(_In_ DXC_OUT_KIND dxcOutKind, - _In_ REFIID iid, _COM_Outptr_opt_result_maybenull_ void **ppvObject, - _COM_Outptr_ IDxcBlobWide **ppOutputName) = 0; + /// \brief Retrieves the specified output. + /// + /// \param dxcOutKind The kind of output to retrieve. + /// + /// \param iid The interface ID of the output interface. + /// + /// \param ppvObject Address of the pointer that receives a pointer to the + /// output. + /// + /// \param ppOutputName Optional address of a pointer to receive the name + /// blob, if there is one. + virtual HRESULT STDMETHODCALLTYPE + GetOutput(_In_ DXC_OUT_KIND dxcOutKind, _In_ REFIID iid, + _COM_Outptr_opt_result_maybenull_ void **ppvObject, + _COM_Outptr_ IDxcBlobWide **ppOutputName) = 0; + + /// \brief Retrieves the number of outputs available in this result. virtual UINT32 GetNumOutputs() = 0; + + /// \brief Retrieves the output kind at the specified index. virtual DXC_OUT_KIND GetOutputByIndex(UINT32 Index) = 0; + + /// \brief Retrieves the primary output kind for this result. + /// + /// See IDxcOperationResult::GetResult() for more information on the primary + /// output kinds. virtual DXC_OUT_KIND PrimaryOutput() = 0; }; -// Special names for extra output that should get written to specific streams +// Special names for extra output that should get written to specific streams. #define DXC_EXTRA_OUTPUT_NAME_STDOUT L"*stdout*" #define DXC_EXTRA_OUTPUT_NAME_STDERR L"*stderr*" CROSS_PLATFORM_UUIDOF(IDxcExtraOutputs, "319b37a2-a5c2-494a-a5de-4801b2faf989") +/// \brief Additional outputs from a DXC operation. +/// +/// This can be used to obtain outputs that don't have an explicit DXC_OUT_KIND. +/// Use DXC_OUT_EXTRA_OUTPUTS to obtain instances of this. struct IDxcExtraOutputs : public IUnknown { - + /// \brief Retrieves the number of outputs available virtual UINT32 STDMETHODCALLTYPE GetOutputCount() = 0; - virtual HRESULT STDMETHODCALLTYPE GetOutput(_In_ UINT32 uIndex, - _In_ REFIID iid, _COM_Outptr_opt_result_maybenull_ void **ppvObject, - _COM_Outptr_opt_result_maybenull_ IDxcBlobWide **ppOutputType, - _COM_Outptr_opt_result_maybenull_ IDxcBlobWide **ppOutputName) = 0; + + /// \brief Retrieves the specified output. + /// + /// \param uIndex The index of the output to retrieve. + /// + /// \param iid The interface ID of the output interface. + /// + /// \param ppvObject Optional address of the pointer that receives a pointer + /// to the output if there is one. + /// + /// \param ppOutputType Optional address of the pointer that receives the + /// output type name blob if there is one. + /// + /// \param ppOutputName Optional address of the pointer that receives the + /// output name blob if there is one. + virtual HRESULT STDMETHODCALLTYPE + GetOutput(_In_ UINT32 uIndex, _In_ REFIID iid, + _COM_Outptr_opt_result_maybenull_ void **ppvObject, + _COM_Outptr_opt_result_maybenull_ IDxcBlobWide **ppOutputType, + _COM_Outptr_opt_result_maybenull_ IDxcBlobWide **ppOutputName) = 0; }; CROSS_PLATFORM_UUIDOF(IDxcCompiler3, "228B4687-5A6A-4730-900C-9702B2203F54") +/// \brief Interface to the DirectX Shader Compiler. +/// +/// Use DxcCreateInstance with CLSID_DxcCompiler to obtain an instance of this +/// interface. struct IDxcCompiler3 : public IUnknown { - // Compile a single entry point to the target shader model, - // Compile a library to a library target (-T lib_*), - // Compile a root signature (-T rootsig_*), or - // Preprocess HLSL source (-P) + /// \brief Compile a shader. + /// + /// IDxcUtils::BuildArguments can be used to assist building the pArguments + /// and argCount parameters. + /// + /// Depending on the arguments, this method can be used to: + /// + /// * Compile a single entry point to the target shader model, + /// * Compile a library to a library target (-T lib_*) + /// * Compile a root signature (-T rootsig_*), + /// * Preprocess HLSL source (-P). virtual HRESULT STDMETHODCALLTYPE Compile( - _In_ const DxcBuffer *pSource, // Source text to compile - _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments - _In_ UINT32 argCount, // Number of arguments - _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional) - _In_ REFIID riid, _Out_ LPVOID *ppResult // IDxcResult: status, buffer, and errors - ) = 0; - - // Disassemble a program. + _In_ const DxcBuffer *pSource, ///< Source text to compile. + _In_opt_count_(argCount) + LPCWSTR *pArguments, ///< Array of pointers to arguments. + _In_ UINT32 argCount, ///< Number of arguments. + _In_opt_ IDxcIncludeHandler + *pIncludeHandler, ///< user-provided interface to handle include + ///< directives (optional). + _In_ REFIID riid, ///< Interface ID for the result. + _Out_ LPVOID *ppResult ///< IDxcResult: status, buffer, and errors. + ) = 0; + + /// \brief Disassemble a program. virtual HRESULT STDMETHODCALLTYPE Disassemble( - _In_ const DxcBuffer *pObject, // Program to disassemble: dxil container or bitcode. - _In_ REFIID riid, _Out_ LPVOID *ppResult // IDxcResult: status, disassembly text, and errors - ) = 0; + _In_ const DxcBuffer + *pObject, ///< Program to disassemble: dxil container or bitcode. + _In_ REFIID riid, ///< Interface ID for the result. + _Out_ LPVOID + *ppResult ///< IDxcResult: status, disassembly text, and errors. + ) = 0; }; static const UINT32 DxcValidatorFlags_Default = 0; -static const UINT32 DxcValidatorFlags_InPlaceEdit = 1; // Validator is allowed to update shader blob in-place. +static const UINT32 DxcValidatorFlags_InPlaceEdit = + 1; // Validator is allowed to update shader blob in-place. static const UINT32 DxcValidatorFlags_RootSignatureOnly = 2; static const UINT32 DxcValidatorFlags_ModuleOnly = 4; static const UINT32 DxcValidatorFlags_ValidMask = 0x7; CROSS_PLATFORM_UUIDOF(IDxcValidator, "A6E82BD2-1FD7-4826-9811-2857E797F49A") +/// \brief Interface to DXC shader validator. +/// +/// Use DxcCreateInstance with CLSID_DxcValidator to obtain an instance of this. struct IDxcValidator : public IUnknown { - // Validate a shader. + /// \brief Validate a shader. virtual HRESULT STDMETHODCALLTYPE Validate( - _In_ IDxcBlob *pShader, // Shader to validate. - _In_ UINT32 Flags, // Validation flags. - _COM_Outptr_ IDxcOperationResult **ppResult // Validation output status, buffer, and errors - ) = 0; + _In_ IDxcBlob *pShader, ///< Shader to validate. + _In_ UINT32 Flags, ///< Validation flags. + _COM_Outptr_ IDxcOperationResult * + *ppResult ///< Validation output status, buffer, and errors. + ) = 0; }; CROSS_PLATFORM_UUIDOF(IDxcValidator2, "458e1fd1-b1b2-4750-a6e1-9c10f03bed92") +/// \brief Interface to DXC shader validator. +/// +/// Use DxcCreateInstance with CLSID_DxcValidator to obtain an instance of this. struct IDxcValidator2 : public IDxcValidator { - // Validate a shader. + /// \brief Validate a shader with optional debug bitcode. virtual HRESULT STDMETHODCALLTYPE ValidateWithDebug( - _In_ IDxcBlob *pShader, // Shader to validate. - _In_ UINT32 Flags, // Validation flags. - _In_opt_ DxcBuffer *pOptDebugBitcode, // Optional debug module bitcode to provide line numbers - _COM_Outptr_ IDxcOperationResult **ppResult // Validation output status, buffer, and errors - ) = 0; + _In_ IDxcBlob *pShader, ///< Shader to validate. + _In_ UINT32 Flags, ///< Validation flags. + _In_opt_ DxcBuffer *pOptDebugBitcode, ///< Optional debug module bitcode + ///< to provide line numbers. + _COM_Outptr_ IDxcOperationResult * + *ppResult ///< Validation output status, buffer, and errors. + ) = 0; }; -CROSS_PLATFORM_UUIDOF(IDxcContainerBuilder, "334b1f50-2292-4b35-99a1-25588d8c17fe") +CROSS_PLATFORM_UUIDOF(IDxcContainerBuilder, + "334b1f50-2292-4b35-99a1-25588d8c17fe") +/// \brief Interface to DXC container builder. +/// +/// Use DxcCreateInstance with CLSID_DxcContainerBuilder to obtain an instance +/// of this. struct IDxcContainerBuilder : public IUnknown { - virtual HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pDxilContainerHeader) = 0; // Loads DxilContainer to the builder - virtual HRESULT STDMETHODCALLTYPE AddPart(_In_ UINT32 fourCC, _In_ IDxcBlob *pSource) = 0; // Part to add to the container - virtual HRESULT STDMETHODCALLTYPE RemovePart(_In_ UINT32 fourCC) = 0; // Remove the part with fourCC - virtual HRESULT STDMETHODCALLTYPE SerializeContainer(_Out_ IDxcOperationResult **ppResult) = 0; // Builds a container of the given container builder state + /// \brief Load a DxilContainer to the builder. + virtual HRESULT STDMETHODCALLTYPE + Load(_In_ IDxcBlob *pDxilContainerHeader) = 0; + + /// \brief Add a part to the container. + /// + /// \param fourCC The part identifier (eg DXC_PART_PDB). + /// + /// \param pSource The source blob. + virtual HRESULT STDMETHODCALLTYPE AddPart(_In_ UINT32 fourCC, + _In_ IDxcBlob *pSource) = 0; + + /// \brief Remove a part from the container. + /// + /// \param fourCC The part identifier (eg DXC_PART_PDB). + /// + /// \return S_OK on success, DXC_E_MISSING_PART if the part was not found, or + /// other standard HRESULT error code. + virtual HRESULT STDMETHODCALLTYPE RemovePart(_In_ UINT32 fourCC) = 0; + + /// \brief Build the container. + /// + /// \param ppResult Pointer to variable to receive the result. + virtual HRESULT STDMETHODCALLTYPE + SerializeContainer(_Out_ IDxcOperationResult **ppResult) = 0; }; CROSS_PLATFORM_UUIDOF(IDxcAssembler, "091f7a26-1c1f-4948-904b-e6e3a8a771d5") +/// \brief Interface to DxcAssembler. +/// +/// Use DxcCreateInstance with CLSID_DxcAssembler to obtain an instance of this. struct IDxcAssembler : public IUnknown { - // Assemble dxil in ll or llvm bitcode to DXIL container. + /// \brief Assemble DXIL in LL or LLVM bitcode to DXIL container. virtual HRESULT STDMETHODCALLTYPE AssembleToContainer( - _In_ IDxcBlob *pShader, // Shader to assemble. - _COM_Outptr_ IDxcOperationResult **ppResult // Assembly output status, buffer, and errors - ) = 0; + _In_ IDxcBlob *pShader, ///< Shader to assemble. + _COM_Outptr_ IDxcOperationResult * + *ppResult ///< Assembly output status, buffer, and errors. + ) = 0; }; -CROSS_PLATFORM_UUIDOF(IDxcContainerReflection, "d2c21b26-8350-4bdc-976a-331ce6f4c54c") +CROSS_PLATFORM_UUIDOF(IDxcContainerReflection, + "d2c21b26-8350-4bdc-976a-331ce6f4c54c") +/// \brief Interface to DxcContainerReflection. +/// +/// Use DxcCreateInstance with CLSID_DxcContainerReflection to obtain an +/// instance of this. struct IDxcContainerReflection : public IUnknown { - virtual HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pContainer) = 0; // Container to load. + /// \brief Choose the container to perform reflection on + /// + /// \param pContainer The container to load. If null is passed then this + /// instance will release any held resources. + virtual HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pContainer) = 0; + + /// \brief Retrieves the number of parts in the container. + /// + /// \param pResult Pointer to variable to receive the result. + /// + /// \return S_OK on success, E_NOT_VALID_STATE if a container has not been + /// loaded using Load(), or other standard HRESULT error codes. virtual HRESULT STDMETHODCALLTYPE GetPartCount(_Out_ UINT32 *pResult) = 0; - virtual HRESULT STDMETHODCALLTYPE GetPartKind(UINT32 idx, _Out_ UINT32 *pResult) = 0; - virtual HRESULT STDMETHODCALLTYPE GetPartContent(UINT32 idx, _COM_Outptr_ IDxcBlob **ppResult) = 0; - virtual HRESULT STDMETHODCALLTYPE FindFirstPartKind(UINT32 kind, _Out_ UINT32 *pResult) = 0; - virtual HRESULT STDMETHODCALLTYPE GetPartReflection(UINT32 idx, REFIID iid, void **ppvObject) = 0; + + /// \brief Retrieve the kind of a specified part. + /// + /// \param idx The index of the part to retrieve the kind of. + /// + /// \param pResult Pointer to variable to receive the result. + /// + /// \return S_OK on success, E_NOT_VALID_STATE if a container has not been + /// loaded using Load(), E_BOUND if idx is out of bounds, or other standard + /// HRESULT error codes. + virtual HRESULT STDMETHODCALLTYPE GetPartKind(UINT32 idx, + _Out_ UINT32 *pResult) = 0; + + /// \brief Retrieve the content of a specified part. + /// + /// \param idx The index of the part to retrieve. + /// + /// \param ppResult Pointer to variable to receive the result. + /// + /// \return S_OK on success, E_NOT_VALID_STATE if a container has not been + /// loaded using Load(), E_BOUND if idx is out of bounds, or other standard + /// HRESULT error codes. + virtual HRESULT STDMETHODCALLTYPE + GetPartContent(UINT32 idx, _COM_Outptr_ IDxcBlob **ppResult) = 0; + + /// \brief Retrieve the index of the first part with the specified kind. + /// + /// \param kind The kind to search for. + /// + /// \param pResult Pointer to variable to receive the index of the matching + /// part. + /// + /// \return S_OK on success, E_NOT_VALID_STATE if a container has not been + /// loaded using Load(), HRESULT_FROM_WIN32(ERROR_NOT_FOUND) if there is no + /// part with the specified kind, or other standard HRESULT error codes. + virtual HRESULT STDMETHODCALLTYPE + FindFirstPartKind(UINT32 kind, _Out_ UINT32 *pResult) = 0; + + /// \brief Retrieve the reflection interface for a specified part. + /// + /// \param idx The index of the part to retrieve the reflection interface of. + /// + /// \param iid The IID of the interface to retrieve. + /// + /// \param ppvObject Pointer to variable to receive the result. + /// + /// Use this with interfaces such as ID3D12ShaderReflection. + /// + /// \return S_OK on success, E_NOT_VALID_STATE if a container has not been + /// loaded using Load(), E_BOUND if idx is out of bounds, or other standard + /// HRESULT error codes. + virtual HRESULT STDMETHODCALLTYPE GetPartReflection(UINT32 idx, REFIID iid, + void **ppvObject) = 0; }; CROSS_PLATFORM_UUIDOF(IDxcOptimizerPass, "AE2CD79F-CC22-453F-9B6B-B124E7A5204C") +/// \brief An optimizer pass. +/// +/// Instances of this can be obtained via IDxcOptimizer::GetAvailablePass. struct IDxcOptimizerPass : public IUnknown { - virtual HRESULT STDMETHODCALLTYPE GetOptionName(_COM_Outptr_ LPWSTR *ppResult) = 0; - virtual HRESULT STDMETHODCALLTYPE GetDescription(_COM_Outptr_ LPWSTR *ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetOptionName(_COM_Outptr_ LPWSTR *ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetDescription(_COM_Outptr_ LPWSTR *ppResult) = 0; virtual HRESULT STDMETHODCALLTYPE GetOptionArgCount(_Out_ UINT32 *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetOptionArgName(UINT32 argIndex, _COM_Outptr_ LPWSTR *ppResult) = 0; - virtual HRESULT STDMETHODCALLTYPE GetOptionArgDescription(UINT32 argIndex, _COM_Outptr_ LPWSTR *ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetOptionArgName(UINT32 argIndex, _COM_Outptr_ LPWSTR *ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetOptionArgDescription(UINT32 argIndex, _COM_Outptr_ LPWSTR *ppResult) = 0; }; CROSS_PLATFORM_UUIDOF(IDxcOptimizer, "25740E2E-9CBA-401B-9119-4FB42F39F270") +/// \brief Interface to DxcOptimizer. +/// +/// Use DxcCreateInstance with CLSID_DxcOptimizer to obtain an instance of this. struct IDxcOptimizer : public IUnknown { - virtual HRESULT STDMETHODCALLTYPE GetAvailablePassCount(_Out_ UINT32 *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetAvailablePass(UINT32 index, _COM_Outptr_ IDxcOptimizerPass** ppResult) = 0; - virtual HRESULT STDMETHODCALLTYPE RunOptimizer(IDxcBlob *pBlob, - _In_count_(optionCount) LPCWSTR *ppOptions, UINT32 optionCount, - _COM_Outptr_ IDxcBlob **pOutputModule, - _COM_Outptr_opt_ IDxcBlobEncoding **ppOutputText) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetAvailablePassCount(_Out_ UINT32 *pCount) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetAvailablePass(UINT32 index, _COM_Outptr_ IDxcOptimizerPass **ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + RunOptimizer(IDxcBlob *pBlob, _In_count_(optionCount) LPCWSTR *ppOptions, + UINT32 optionCount, _COM_Outptr_ IDxcBlob **pOutputModule, + _COM_Outptr_opt_ IDxcBlobEncoding **ppOutputText) = 0; }; static const UINT32 DxcVersionInfoFlags_None = 0; static const UINT32 DxcVersionInfoFlags_Debug = 1; // Matches VS_FF_DEBUG -static const UINT32 DxcVersionInfoFlags_Internal = 2; // Internal Validator (non-signing) +static const UINT32 DxcVersionInfoFlags_Internal = + 2; // Internal Validator (non-signing) CROSS_PLATFORM_UUIDOF(IDxcVersionInfo, "b04f5b50-2059-4f12-a8ff-a1e0cde1cc7e") +/// \brief PDB Version information. +/// +/// Use IDxcPdbUtils2::GetVersionInfo to obtain an instance of this. struct IDxcVersionInfo : public IUnknown { - virtual HRESULT STDMETHODCALLTYPE GetVersion(_Out_ UINT32 *pMajor, _Out_ UINT32 *pMinor) = 0; + virtual HRESULT STDMETHODCALLTYPE GetVersion(_Out_ UINT32 *pMajor, + _Out_ UINT32 *pMinor) = 0; virtual HRESULT STDMETHODCALLTYPE GetFlags(_Out_ UINT32 *pFlags) = 0; }; CROSS_PLATFORM_UUIDOF(IDxcVersionInfo2, "fb6904c4-42f0-4b62-9c46-983af7da7c83") +/// \brief PDB Version Information. +/// +/// Use IDxcPdbUtils2::GetVersionInfo to obtain a IDxcVersionInfo interface, and +/// then use QueryInterface to obtain an instance of this interface from it. struct IDxcVersionInfo2 : public IDxcVersionInfo { virtual HRESULT STDMETHODCALLTYPE GetCommitInfo( - _Out_ UINT32 *pCommitCount, // The total number commits. - _Outptr_result_z_ char **pCommitHash // The SHA of the latest commit. (Must be CoTaskMemFree()'d!) - ) = 0; + _Out_ UINT32 *pCommitCount, ///< The total number commits. + _Outptr_result_z_ char **pCommitHash ///< The SHA of the latest commit. + ///< Must be CoTaskMemFree()'d. + ) = 0; }; CROSS_PLATFORM_UUIDOF(IDxcVersionInfo3, "5e13e843-9d25-473c-9ad2-03b2d0b44b1e") +/// \brief PDB Version Information. +/// +/// Use IDxcPdbUtils2::GetVersionInfo to obtain a IDxcVersionInfo interface, and +/// then use QueryInterface to obtain an instance of this interface from it. struct IDxcVersionInfo3 : public IUnknown { virtual HRESULT STDMETHODCALLTYPE GetCustomVersionString( - _Outptr_result_z_ char **pVersionString // Custom version string for compiler. (Must be CoTaskMemFree()'d!) - ) = 0; + _Outptr_result_z_ char * + *pVersionString ///< Custom version string for compiler. Must be + ///< CoTaskMemFree()'d. + ) = 0; }; struct DxcArgPair { @@ -639,86 +1102,126 @@ struct DxcArgPair { }; CROSS_PLATFORM_UUIDOF(IDxcPdbUtils, "E6C9647E-9D6A-4C3B-B94C-524B5A6C343D") +/// \deprecated Please use IDxcPdbUtils2 instead. struct IDxcPdbUtils : public IUnknown { virtual HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pPdbOrDxil) = 0; virtual HRESULT STDMETHODCALLTYPE GetSourceCount(_Out_ UINT32 *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetSource(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobEncoding **ppResult) = 0; - virtual HRESULT STDMETHODCALLTYPE GetSourceName(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetSource(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobEncoding **ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetSourceName(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) = 0; virtual HRESULT STDMETHODCALLTYPE GetFlagCount(_Out_ UINT32 *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetFlag(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetFlag(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) = 0; virtual HRESULT STDMETHODCALLTYPE GetArgCount(_Out_ UINT32 *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetArg(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) = 0; + virtual HRESULT STDMETHODCALLTYPE GetArg(_In_ UINT32 uIndex, + _Outptr_result_z_ BSTR *pResult) = 0; virtual HRESULT STDMETHODCALLTYPE GetArgPairCount(_Out_ UINT32 *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetArgPair(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pName, _Outptr_result_z_ BSTR *pValue) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetArgPair(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pName, + _Outptr_result_z_ BSTR *pValue) = 0; virtual HRESULT STDMETHODCALLTYPE GetDefineCount(_Out_ UINT32 *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetDefine(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetDefine(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) = 0; - virtual HRESULT STDMETHODCALLTYPE GetTargetProfile(_Outptr_result_z_ BSTR *pResult) = 0; - virtual HRESULT STDMETHODCALLTYPE GetEntryPoint(_Outptr_result_z_ BSTR *pResult) = 0; - virtual HRESULT STDMETHODCALLTYPE GetMainFileName(_Outptr_result_z_ BSTR *pResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetTargetProfile(_Outptr_result_z_ BSTR *pResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetEntryPoint(_Outptr_result_z_ BSTR *pResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetMainFileName(_Outptr_result_z_ BSTR *pResult) = 0; - virtual HRESULT STDMETHODCALLTYPE GetHash(_COM_Outptr_ IDxcBlob **ppResult) = 0; - virtual HRESULT STDMETHODCALLTYPE GetName(_Outptr_result_z_ BSTR *pResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetHash(_COM_Outptr_ IDxcBlob **ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetName(_Outptr_result_z_ BSTR *pResult) = 0; virtual BOOL STDMETHODCALLTYPE IsFullPDB() = 0; - virtual HRESULT STDMETHODCALLTYPE GetFullPDB(_COM_Outptr_ IDxcBlob **ppFullPDB) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetVersionInfo(_COM_Outptr_ IDxcVersionInfo **ppVersionInfo) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetCompiler(_In_ IDxcCompiler3 *pCompiler) = 0; - virtual HRESULT STDMETHODCALLTYPE CompileForFullPDB(_COM_Outptr_ IDxcResult **ppResult) = 0; - virtual HRESULT STDMETHODCALLTYPE OverrideArgs(_In_ DxcArgPair *pArgPairs, UINT32 uNumArgPairs) = 0; - virtual HRESULT STDMETHODCALLTYPE OverrideRootSignature(_In_ const WCHAR *pRootSignature) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetFullPDB(_COM_Outptr_ IDxcBlob **ppFullPDB) = 0; + + virtual HRESULT STDMETHODCALLTYPE + GetVersionInfo(_COM_Outptr_ IDxcVersionInfo **ppVersionInfo) = 0; + + virtual HRESULT STDMETHODCALLTYPE + SetCompiler(_In_ IDxcCompiler3 *pCompiler) = 0; + virtual HRESULT STDMETHODCALLTYPE + CompileForFullPDB(_COM_Outptr_ IDxcResult **ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE OverrideArgs(_In_ DxcArgPair *pArgPairs, + UINT32 uNumArgPairs) = 0; + virtual HRESULT STDMETHODCALLTYPE + OverrideRootSignature(_In_ const WCHAR *pRootSignature) = 0; }; CROSS_PLATFORM_UUIDOF(IDxcPdbUtils2, "4315D938-F369-4F93-95A2-252017CC3807") +/// \brief DxcPdbUtils interface. +/// +/// Use DxcCreateInstance with CLSID_DxcPdbUtils to create an instance of this. struct IDxcPdbUtils2 : public IUnknown { virtual HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pPdbOrDxil) = 0; virtual HRESULT STDMETHODCALLTYPE GetSourceCount(_Out_ UINT32 *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetSource(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobEncoding **ppResult) = 0; - virtual HRESULT STDMETHODCALLTYPE GetSourceName(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetSource(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobEncoding **ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetSourceName(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) = 0; virtual HRESULT STDMETHODCALLTYPE GetLibraryPDBCount(UINT32 *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetLibraryPDB(_In_ UINT32 uIndex, _COM_Outptr_ IDxcPdbUtils2 **ppOutPdbUtils, _COM_Outptr_opt_result_maybenull_ IDxcBlobWide **ppLibraryName) = 0; + virtual HRESULT STDMETHODCALLTYPE GetLibraryPDB( + _In_ UINT32 uIndex, _COM_Outptr_ IDxcPdbUtils2 **ppOutPdbUtils, + _COM_Outptr_opt_result_maybenull_ IDxcBlobWide **ppLibraryName) = 0; virtual HRESULT STDMETHODCALLTYPE GetFlagCount(_Out_ UINT32 *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetFlag(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetFlag(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) = 0; virtual HRESULT STDMETHODCALLTYPE GetArgCount(_Out_ UINT32 *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetArg(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetArg(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) = 0; virtual HRESULT STDMETHODCALLTYPE GetArgPairCount(_Out_ UINT32 *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetArgPair(_In_ UINT32 uIndex, _COM_Outptr_result_maybenull_ IDxcBlobWide **ppName, _COM_Outptr_result_maybenull_ IDxcBlobWide **ppValue) = 0; + virtual HRESULT STDMETHODCALLTYPE GetArgPair( + _In_ UINT32 uIndex, _COM_Outptr_result_maybenull_ IDxcBlobWide **ppName, + _COM_Outptr_result_maybenull_ IDxcBlobWide **ppValue) = 0; virtual HRESULT STDMETHODCALLTYPE GetDefineCount(_Out_ UINT32 *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetDefine(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetDefine(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) = 0; - virtual HRESULT STDMETHODCALLTYPE GetTargetProfile(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) = 0; - virtual HRESULT STDMETHODCALLTYPE GetEntryPoint(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) = 0; - virtual HRESULT STDMETHODCALLTYPE GetMainFileName(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetTargetProfile(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetEntryPoint(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetMainFileName(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) = 0; - virtual HRESULT STDMETHODCALLTYPE GetHash(_COM_Outptr_result_maybenull_ IDxcBlob **ppResult) = 0; - virtual HRESULT STDMETHODCALLTYPE GetName(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetHash(_COM_Outptr_result_maybenull_ IDxcBlob **ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetName(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) = 0; - virtual HRESULT STDMETHODCALLTYPE GetVersionInfo(_COM_Outptr_result_maybenull_ IDxcVersionInfo **ppVersionInfo) = 0; + virtual HRESULT STDMETHODCALLTYPE GetVersionInfo( + _COM_Outptr_result_maybenull_ IDxcVersionInfo **ppVersionInfo) = 0; virtual HRESULT STDMETHODCALLTYPE GetCustomToolchainID(_Out_ UINT32 *pID) = 0; - virtual HRESULT STDMETHODCALLTYPE GetCustomToolchainData(_COM_Outptr_result_maybenull_ IDxcBlob **ppBlob) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetCustomToolchainData(_COM_Outptr_result_maybenull_ IDxcBlob **ppBlob) = 0; - virtual HRESULT STDMETHODCALLTYPE GetWholeDxil(_COM_Outptr_result_maybenull_ IDxcBlob **ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetWholeDxil(_COM_Outptr_result_maybenull_ IDxcBlob **ppResult) = 0; virtual BOOL STDMETHODCALLTYPE IsFullPDB() = 0; virtual BOOL STDMETHODCALLTYPE IsPDBRef() = 0; }; // Note: __declspec(selectany) requires 'extern' -// On Linux __declspec(selectany) is removed and using 'extern' results in link error. +// On Linux __declspec(selectany) is removed and using 'extern' results in link +// error. #ifdef _MSC_VER #define CLSID_SCOPE __declspec(selectany) extern #else diff --git a/WickedEngine/Utility/mikktspace.c b/WickedEngine/Utility/mikktspace.c new file mode 100644 index 00000000000..0342ae0146f --- /dev/null +++ b/WickedEngine/Utility/mikktspace.c @@ -0,0 +1,1899 @@ +/** \file mikktspace/mikktspace.c + * \ingroup mikktspace + */ +/** + * Copyright (C) 2011 by Morten S. Mikkelsen + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + */ + +#include +#include +#include +#include +#include +#include + +#include "mikktspace.h" + +#define TFALSE 0 +#define TTRUE 1 + +#ifndef M_PI +#define M_PI 3.1415926535897932384626433832795 +#endif + +#define INTERNAL_RND_SORT_SEED 39871946 + +// internal structure +typedef struct { + float x, y, z; +} SVec3; + +static tbool veq( const SVec3 v1, const SVec3 v2 ) +{ + return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z); +} + +static SVec3 vadd( const SVec3 v1, const SVec3 v2 ) +{ + SVec3 vRes; + + vRes.x = v1.x + v2.x; + vRes.y = v1.y + v2.y; + vRes.z = v1.z + v2.z; + + return vRes; +} + + +static SVec3 vsub( const SVec3 v1, const SVec3 v2 ) +{ + SVec3 vRes; + + vRes.x = v1.x - v2.x; + vRes.y = v1.y - v2.y; + vRes.z = v1.z - v2.z; + + return vRes; +} + +static SVec3 vscale(const float fS, const SVec3 v) +{ + SVec3 vRes; + + vRes.x = fS * v.x; + vRes.y = fS * v.y; + vRes.z = fS * v.z; + + return vRes; +} + +static float LengthSquared( const SVec3 v ) +{ + return v.x*v.x + v.y*v.y + v.z*v.z; +} + +static float Length( const SVec3 v ) +{ + return sqrtf(LengthSquared(v)); +} + +static SVec3 Normalize( const SVec3 v ) +{ + return vscale(1 / Length(v), v); +} + +static float vdot( const SVec3 v1, const SVec3 v2) +{ + return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z; +} + + +static tbool NotZero(const float fX) +{ + // could possibly use FLT_EPSILON instead + return fabsf(fX) > FLT_MIN; +} + +static tbool VNotZero(const SVec3 v) +{ + // might change this to an epsilon based test + return NotZero(v.x) || NotZero(v.y) || NotZero(v.z); +} + + + +typedef struct { + int iNrFaces; + int * pTriMembers; +} SSubGroup; + +typedef struct { + int iNrFaces; + int * pFaceIndices; + int iVertexRepresentitive; + tbool bOrientPreservering; +} SGroup; + +// +#define MARK_DEGENERATE 1 +#define QUAD_ONE_DEGEN_TRI 2 +#define GROUP_WITH_ANY 4 +#define ORIENT_PRESERVING 8 + + + +typedef struct { + int FaceNeighbors[3]; + SGroup * AssignedGroup[3]; + + // normalized first order face derivatives + SVec3 vOs, vOt; + float fMagS, fMagT; // original magnitudes + + // determines if the current and the next triangle are a quad. + int iOrgFaceNumber; + int iFlag, iTSpacesOffs; + unsigned char vert_num[4]; +} STriInfo; + +typedef struct { + SVec3 vOs; + float fMagS; + SVec3 vOt; + float fMagT; + int iCounter; // this is to average back into quads. + tbool bOrient; +} STSpace; + +static int GenerateInitialVerticesIndexList(STriInfo pTriInfos[], int piTriList_out[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn); +static void GenerateSharedVerticesIndexList(int piTriList_in_and_out[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn); +static void InitTriInfo(STriInfo pTriInfos[], const int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn); +static int Build4RuleGroups(STriInfo pTriInfos[], SGroup pGroups[], int piGroupTrianglesBuffer[], const int piTriListIn[], const int iNrTrianglesIn); +static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], const SGroup pGroups[], + const int iNrActiveGroups, const int piTriListIn[], const float fThresCos, + const SMikkTSpaceContext * pContext); + +static int MakeIndex(const int iFace, const int iVert) +{ + assert(iVert>=0 && iVert<4 && iFace>=0); + return (iFace<<2) | (iVert&0x3); +} + +static void IndexToData(int * piFace, int * piVert, const int iIndexIn) +{ + piVert[0] = iIndexIn&0x3; + piFace[0] = iIndexIn>>2; +} + +static STSpace AvgTSpace(const STSpace * pTS0, const STSpace * pTS1) +{ + STSpace ts_res; + + // this if is important. Due to floating point precision + // averaging when ts0==ts1 will cause a slight difference + // which results in tangent space splits later on + if (pTS0->fMagS==pTS1->fMagS && pTS0->fMagT==pTS1->fMagT && + veq(pTS0->vOs,pTS1->vOs) && veq(pTS0->vOt, pTS1->vOt)) + { + ts_res.fMagS = pTS0->fMagS; + ts_res.fMagT = pTS0->fMagT; + ts_res.vOs = pTS0->vOs; + ts_res.vOt = pTS0->vOt; + } + else + { + ts_res.fMagS = 0.5f*(pTS0->fMagS+pTS1->fMagS); + ts_res.fMagT = 0.5f*(pTS0->fMagT+pTS1->fMagT); + ts_res.vOs = vadd(pTS0->vOs,pTS1->vOs); + ts_res.vOt = vadd(pTS0->vOt,pTS1->vOt); + if ( VNotZero(ts_res.vOs) ) ts_res.vOs = Normalize(ts_res.vOs); + if ( VNotZero(ts_res.vOt) ) ts_res.vOt = Normalize(ts_res.vOt); + } + + return ts_res; +} + + + +static SVec3 GetPosition(const SMikkTSpaceContext * pContext, const int index); +static SVec3 GetNormal(const SMikkTSpaceContext * pContext, const int index); +static SVec3 GetTexCoord(const SMikkTSpaceContext * pContext, const int index); + + +// degen triangles +static void DegenPrologue(STriInfo pTriInfos[], int piTriList_out[], const int iNrTrianglesIn, const int iTotTris); +static void DegenEpilogue(STSpace psTspace[], STriInfo pTriInfos[], int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn, const int iTotTris); + + +tbool genTangSpaceDefault(const SMikkTSpaceContext * pContext) +{ + return genTangSpace(pContext, 180.0f); +} + +tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThreshold) +{ + // count nr_triangles + int * piTriListIn = NULL, * piGroupTrianglesBuffer = NULL; + STriInfo * pTriInfos = NULL; + SGroup * pGroups = NULL; + STSpace * psTspace = NULL; + int iNrTrianglesIn = 0, f=0, t=0, i=0; + int iNrTSPaces = 0, iTotTris = 0, iDegenTriangles = 0, iNrMaxGroups = 0; + int iNrActiveGroups = 0, index = 0; + const int iNrFaces = pContext->m_pInterface->m_getNumFaces(pContext); + tbool bRes = TFALSE; + const float fThresCos = (float) cos((fAngularThreshold*(float)M_PI)/180.0f); + + // verify all call-backs have been set + if ( pContext->m_pInterface->m_getNumFaces==NULL || + pContext->m_pInterface->m_getNumVerticesOfFace==NULL || + pContext->m_pInterface->m_getPosition==NULL || + pContext->m_pInterface->m_getNormal==NULL || + pContext->m_pInterface->m_getTexCoord==NULL ) + return TFALSE; + + // count triangles on supported faces + for (f=0; fm_pInterface->m_getNumVerticesOfFace(pContext, f); + if (verts==3) ++iNrTrianglesIn; + else if (verts==4) iNrTrianglesIn += 2; + } + if (iNrTrianglesIn<=0) return TFALSE; + + // allocate memory for an index list + piTriListIn = (int *) malloc(sizeof(int)*3*iNrTrianglesIn); + pTriInfos = (STriInfo *) malloc(sizeof(STriInfo)*iNrTrianglesIn); + if (piTriListIn==NULL || pTriInfos==NULL) + { + if (piTriListIn!=NULL) free(piTriListIn); + if (pTriInfos!=NULL) free(pTriInfos); + return TFALSE; + } + + // make an initial triangle --> face index list + iNrTSPaces = GenerateInitialVerticesIndexList(pTriInfos, piTriListIn, pContext, iNrTrianglesIn); + + // make a welded index list of identical positions and attributes (pos, norm, texc) + //printf("gen welded index list begin\n"); + GenerateSharedVerticesIndexList(piTriListIn, pContext, iNrTrianglesIn); + //printf("gen welded index list end\n"); + + // Mark all degenerate triangles + iTotTris = iNrTrianglesIn; + iDegenTriangles = 0; + for (t=0; tm_pInterface->m_getNumVerticesOfFace(pContext, f); + if (verts!=3 && verts!=4) continue; + + + // I've decided to let degenerate triangles and group-with-anythings + // vary between left/right hand coordinate systems at the vertices. + // All healthy triangles on the other hand are built to always be either or. + + /*// force the coordinate system orientation to be uniform for every face. + // (this is already the case for good triangles but not for + // degenerate ones and those with bGroupWithAnything==true) + bool bOrient = psTspace[index].bOrient; + if (psTspace[index].iCounter == 0) // tspace was not derived from a group + { + // look for a space created in GenerateTSpaces() by iCounter>0 + bool bNotFound = true; + int i=1; + while (i 0) bNotFound=false; + else ++i; + } + if (!bNotFound) bOrient = psTspace[index+i].bOrient; + }*/ + + // set data + for (i=0; ivOs.x, pTSpace->vOs.y, pTSpace->vOs.z}; + float bitang[] = {pTSpace->vOt.x, pTSpace->vOt.y, pTSpace->vOt.z}; + if (pContext->m_pInterface->m_setTSpace!=NULL) + pContext->m_pInterface->m_setTSpace(pContext, tang, bitang, pTSpace->fMagS, pTSpace->fMagT, pTSpace->bOrient, f, i); + if (pContext->m_pInterface->m_setTSpaceBasic!=NULL) + pContext->m_pInterface->m_setTSpaceBasic(pContext, tang, pTSpace->bOrient==TTRUE ? 1.0f : (-1.0f), f, i); + + ++index; + } + } + + free(psTspace); + + + return TTRUE; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct { + float vert[3]; + int index; +} STmpVert; + +static const int g_iCells = 2048; + +#ifdef _MSC_VER +# define NOINLINE __declspec(noinline) +#else +# define NOINLINE __attribute__ ((noinline)) +#endif + +// it is IMPORTANT that this function is called to evaluate the hash since +// inlining could potentially reorder instructions and generate different +// results for the same effective input value fVal. +static NOINLINE int FindGridCell(const float fMin, const float fMax, const float fVal) +{ + const float fIndex = g_iCells * ((fVal-fMin)/(fMax-fMin)); + const int iIndex = (int)fIndex; + return iIndex < g_iCells ? (iIndex >= 0 ? iIndex : 0) : (g_iCells - 1); +} + +static void MergeVertsFast(int piTriList_in_and_out[], STmpVert pTmpVert[], const SMikkTSpaceContext * pContext, const int iL_in, const int iR_in); +static void MergeVertsSlow(int piTriList_in_and_out[], const SMikkTSpaceContext * pContext, const int pTable[], const int iEntries); +static void GenerateSharedVerticesIndexListSlow(int piTriList_in_and_out[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn); + +static void GenerateSharedVerticesIndexList(int piTriList_in_and_out[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn) +{ + + // Generate bounding box + int * piHashTable=NULL, * piHashCount=NULL, * piHashOffsets=NULL, * piHashCount2=NULL; + STmpVert * pTmpVert = NULL; + int i=0, iChannel=0, k=0, e=0; + int iMaxCount=0; + SVec3 vMin = GetPosition(pContext, 0), vMax = vMin, vDim; + float fMin, fMax; + for (i=1; i<(iNrTrianglesIn*3); i++) + { + const int index = piTriList_in_and_out[i]; + + const SVec3 vP = GetPosition(pContext, index); + if (vMin.x > vP.x) vMin.x = vP.x; + else if (vMax.x < vP.x) vMax.x = vP.x; + if (vMin.y > vP.y) vMin.y = vP.y; + else if (vMax.y < vP.y) vMax.y = vP.y; + if (vMin.z > vP.z) vMin.z = vP.z; + else if (vMax.z < vP.z) vMax.z = vP.z; + } + + vDim = vsub(vMax,vMin); + iChannel = 0; + fMin = vMin.x; fMax=vMax.x; + if (vDim.y>vDim.x && vDim.y>vDim.z) + { + iChannel=1; + fMin = vMin.y; + fMax = vMax.y; + } + else if (vDim.z>vDim.x) + { + iChannel=2; + fMin = vMin.z; + fMax = vMax.z; + } + + // make allocations + piHashTable = (int *) malloc(sizeof(int)*iNrTrianglesIn*3); + piHashCount = (int *) malloc(sizeof(int)*g_iCells); + piHashOffsets = (int *) malloc(sizeof(int)*g_iCells); + piHashCount2 = (int *) malloc(sizeof(int)*g_iCells); + + if (piHashTable==NULL || piHashCount==NULL || piHashOffsets==NULL || piHashCount2==NULL) + { + if (piHashTable!=NULL) free(piHashTable); + if (piHashCount!=NULL) free(piHashCount); + if (piHashOffsets!=NULL) free(piHashOffsets); + if (piHashCount2!=NULL) free(piHashCount2); + GenerateSharedVerticesIndexListSlow(piTriList_in_and_out, pContext, iNrTrianglesIn); + return; + } + memset(piHashCount, 0, sizeof(int)*g_iCells); + memset(piHashCount2, 0, sizeof(int)*g_iCells); + + // count amount of elements in each cell unit + for (i=0; i<(iNrTrianglesIn*3); i++) + { + const int index = piTriList_in_and_out[i]; + const SVec3 vP = GetPosition(pContext, index); + const float fVal = iChannel==0 ? vP.x : (iChannel==1 ? vP.y : vP.z); + const int iCell = FindGridCell(fMin, fMax, fVal); + ++piHashCount[iCell]; + } + + // evaluate start index of each cell. + piHashOffsets[0]=0; + for (k=1; kpTmpVert[l].vert[c]) fvMin[c]=pTmpVert[l].vert[c]; + if (fvMax[c]dx && dy>dz) channel=1; + else if (dz>dx) channel=2; + + fSep = 0.5f*(fvMax[channel]+fvMin[channel]); + + // stop if all vertices are NaNs + if (!isfinite(fSep)) + return; + + // terminate recursion when the separation/average value + // is no longer strictly between fMin and fMax values. + if (fSep>=fvMax[channel] || fSep<=fvMin[channel]) + { + // complete the weld + for (l=iL_in; l<=iR_in; l++) + { + int i = pTmpVert[l].index; + const int index = piTriList_in_and_out[i]; + const SVec3 vP = GetPosition(pContext, index); + const SVec3 vN = GetNormal(pContext, index); + const SVec3 vT = GetTexCoord(pContext, index); + + tbool bNotFound = TTRUE; + int l2=iL_in, i2rec=-1; + while (l20); // at least 2 entries + + // separate (by fSep) all points between iL_in and iR_in in pTmpVert[] + while (iL < iR) + { + tbool bReadyLeftSwap = TFALSE, bReadyRightSwap = TFALSE; + while ((!bReadyLeftSwap) && iL=iL_in && iL<=iR_in); + bReadyLeftSwap = !(pTmpVert[iL].vert[channel]=iL_in && iR<=iR_in); + bReadyRightSwap = pTmpVert[iR].vert[channel]m_pInterface->m_getNumFaces(pContext); f++) + { + const int verts = pContext->m_pInterface->m_getNumVerticesOfFace(pContext, f); + if (verts!=3 && verts!=4) continue; + + pTriInfos[iDstTriIndex].iOrgFaceNumber = f; + pTriInfos[iDstTriIndex].iTSpacesOffs = iTSpacesOffs; + + if (verts==3) + { + unsigned char * pVerts = pTriInfos[iDstTriIndex].vert_num; + pVerts[0]=0; pVerts[1]=1; pVerts[2]=2; + piTriList_out[iDstTriIndex*3+0] = MakeIndex(f, 0); + piTriList_out[iDstTriIndex*3+1] = MakeIndex(f, 1); + piTriList_out[iDstTriIndex*3+2] = MakeIndex(f, 2); + ++iDstTriIndex; // next + } + else + { + { + pTriInfos[iDstTriIndex+1].iOrgFaceNumber = f; + pTriInfos[iDstTriIndex+1].iTSpacesOffs = iTSpacesOffs; + } + + { + // need an order independent way to evaluate + // tspace on quads. This is done by splitting + // along the shortest diagonal. + const int i0 = MakeIndex(f, 0); + const int i1 = MakeIndex(f, 1); + const int i2 = MakeIndex(f, 2); + const int i3 = MakeIndex(f, 3); + const SVec3 T0 = GetTexCoord(pContext, i0); + const SVec3 T1 = GetTexCoord(pContext, i1); + const SVec3 T2 = GetTexCoord(pContext, i2); + const SVec3 T3 = GetTexCoord(pContext, i3); + const float distSQ_02 = LengthSquared(vsub(T2,T0)); + const float distSQ_13 = LengthSquared(vsub(T3,T1)); + tbool bQuadDiagIs_02; + if (distSQ_02m_pInterface->m_getPosition(pContext, pos, iF, iI); + res.x=pos[0]; res.y=pos[1]; res.z=pos[2]; + return res; +} + +static SVec3 GetNormal(const SMikkTSpaceContext * pContext, const int index) +{ + int iF, iI; + SVec3 res; float norm[3]; + IndexToData(&iF, &iI, index); + pContext->m_pInterface->m_getNormal(pContext, norm, iF, iI); + res.x=norm[0]; res.y=norm[1]; res.z=norm[2]; + return res; +} + +static SVec3 GetTexCoord(const SMikkTSpaceContext * pContext, const int index) +{ + int iF, iI; + SVec3 res; float texc[2]; + IndexToData(&iF, &iI, index); + pContext->m_pInterface->m_getTexCoord(pContext, texc, iF, iI); + res.x=texc[0]; res.y=texc[1]; res.z=1.0f; + return res; +} + +///////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////// + +typedef union { + struct + { + int i0, i1, f; + }; + int array[3]; +} SEdge; + +static void BuildNeighborsFast(STriInfo pTriInfos[], SEdge * pEdges, const int piTriListIn[], const int iNrTrianglesIn); +static void BuildNeighborsSlow(STriInfo pTriInfos[], const int piTriListIn[], const int iNrTrianglesIn); + +// returns the texture area times 2 +static float CalcTexArea(const SMikkTSpaceContext * pContext, const int indices[]) +{ + const SVec3 t1 = GetTexCoord(pContext, indices[0]); + const SVec3 t2 = GetTexCoord(pContext, indices[1]); + const SVec3 t3 = GetTexCoord(pContext, indices[2]); + + const float t21x = t2.x-t1.x; + const float t21y = t2.y-t1.y; + const float t31x = t3.x-t1.x; + const float t31y = t3.y-t1.y; + + const float fSignedAreaSTx2 = t21x*t31y - t21y*t31x; + + return fSignedAreaSTx2<0 ? (-fSignedAreaSTx2) : fSignedAreaSTx2; +} + +static void InitTriInfo(STriInfo pTriInfos[], const int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn) +{ + int f=0, i=0, t=0; + // pTriInfos[f].iFlag is cleared in GenerateInitialVerticesIndexList() which is called before this function. + + // generate neighbor info list + for (f=0; f0 ? ORIENT_PRESERVING : 0); + + if ( NotZero(fSignedAreaSTx2) ) + { + const float fAbsArea = fabsf(fSignedAreaSTx2); + const float fLenOs = Length(vOs); + const float fLenOt = Length(vOt); + const float fS = (pTriInfos[f].iFlag&ORIENT_PRESERVING)==0 ? (-1.0f) : 1.0f; + if ( NotZero(fLenOs) ) pTriInfos[f].vOs = vscale(fS/fLenOs, vOs); + if ( NotZero(fLenOt) ) pTriInfos[f].vOt = vscale(fS/fLenOt, vOt); + + // evaluate magnitudes prior to normalization of vOs and vOt + pTriInfos[f].fMagS = fLenOs / fAbsArea; + pTriInfos[f].fMagT = fLenOt / fAbsArea; + + // if this is a good triangle + if ( NotZero(pTriInfos[f].fMagS) && NotZero(pTriInfos[f].fMagT)) + pTriInfos[f].iFlag &= (~GROUP_WITH_ANY); + } + } + + // force otherwise healthy quads to a fixed orientation + while (t<(iNrTrianglesIn-1)) + { + const int iFO_a = pTriInfos[t].iOrgFaceNumber; + const int iFO_b = pTriInfos[t+1].iOrgFaceNumber; + if (iFO_a==iFO_b) // this is a quad + { + const tbool bIsDeg_a = (pTriInfos[t].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE; + const tbool bIsDeg_b = (pTriInfos[t+1].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE; + + // bad triangles should already have been removed by + // DegenPrologue(), but just in case check bIsDeg_a and bIsDeg_a are false + if ((bIsDeg_a||bIsDeg_b)==TFALSE) + { + const tbool bOrientA = (pTriInfos[t].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; + const tbool bOrientB = (pTriInfos[t+1].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; + // if this happens the quad has extremely bad mapping!! + if (bOrientA!=bOrientB) + { + //printf("found quad with bad mapping\n"); + tbool bChooseOrientFirstTri = TFALSE; + if ((pTriInfos[t+1].iFlag&GROUP_WITH_ANY)!=0) bChooseOrientFirstTri = TTRUE; + else if ( CalcTexArea(pContext, &piTriListIn[t*3+0]) >= CalcTexArea(pContext, &piTriListIn[(t+1)*3+0]) ) + bChooseOrientFirstTri = TTRUE; + + // force match + { + const int t0 = bChooseOrientFirstTri ? t : (t+1); + const int t1 = bChooseOrientFirstTri ? (t+1) : t; + pTriInfos[t1].iFlag &= (~ORIENT_PRESERVING); // clear first + pTriInfos[t1].iFlag |= (pTriInfos[t0].iFlag&ORIENT_PRESERVING); // copy bit + } + } + } + t += 2; + } + else + ++t; + } + + // match up edge pairs + { + SEdge * pEdges = (SEdge *) malloc(sizeof(SEdge)*iNrTrianglesIn*3); + if (pEdges==NULL) + BuildNeighborsSlow(pTriInfos, piTriListIn, iNrTrianglesIn); + else + { + BuildNeighborsFast(pTriInfos, pEdges, piTriListIn, iNrTrianglesIn); + + free(pEdges); + } + } +} + +///////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////// + +static tbool AssignRecur(const int piTriListIn[], STriInfo psTriInfos[], const int iMyTriIndex, SGroup * pGroup); +static void AddTriToGroup(SGroup * pGroup, const int iTriIndex); + +static int Build4RuleGroups(STriInfo pTriInfos[], SGroup pGroups[], int piGroupTrianglesBuffer[], const int piTriListIn[], const int iNrTrianglesIn) +{ + const int iNrMaxGroups = iNrTrianglesIn*3; + int iNrActiveGroups = 0; + int iOffset = 0, f=0, i=0; + (void)iNrMaxGroups; /* quiet warnings in non debug mode */ + for (f=0; fiVertexRepresentitive = vert_index; + pTriInfos[f].AssignedGroup[i]->bOrientPreservering = (pTriInfos[f].iFlag&ORIENT_PRESERVING)!=0; + pTriInfos[f].AssignedGroup[i]->iNrFaces = 0; + pTriInfos[f].AssignedGroup[i]->pFaceIndices = &piGroupTrianglesBuffer[iOffset]; + ++iNrActiveGroups; + + AddTriToGroup(pTriInfos[f].AssignedGroup[i], f); + bOrPre = (pTriInfos[f].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; + neigh_indexL = pTriInfos[f].FaceNeighbors[i]; + neigh_indexR = pTriInfos[f].FaceNeighbors[i>0?(i-1):2]; + if (neigh_indexL>=0) // neighbor + { + const tbool bAnswer = + AssignRecur(piTriListIn, pTriInfos, neigh_indexL, + pTriInfos[f].AssignedGroup[i] ); + + const tbool bOrPre2 = (pTriInfos[neigh_indexL].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; + const tbool bDiff = bOrPre!=bOrPre2 ? TTRUE : TFALSE; + assert(bAnswer || bDiff); + (void)bAnswer, (void)bDiff; /* quiet warnings in non debug mode */ + } + if (neigh_indexR>=0) // neighbor + { + const tbool bAnswer = + AssignRecur(piTriListIn, pTriInfos, neigh_indexR, + pTriInfos[f].AssignedGroup[i] ); + + const tbool bOrPre2 = (pTriInfos[neigh_indexR].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; + const tbool bDiff = bOrPre!=bOrPre2 ? TTRUE : TFALSE; + assert(bAnswer || bDiff); + (void)bAnswer, (void)bDiff; /* quiet warnings in non debug mode */ + } + + // update offset + iOffset += pTriInfos[f].AssignedGroup[i]->iNrFaces; + // since the groups are disjoint a triangle can never + // belong to more than 3 groups. Subsequently something + // is completely screwed if this assertion ever hits. + assert(iOffset <= iNrMaxGroups); + } + } + } + + return iNrActiveGroups; +} + +static void AddTriToGroup(SGroup * pGroup, const int iTriIndex) +{ + pGroup->pFaceIndices[pGroup->iNrFaces] = iTriIndex; + ++pGroup->iNrFaces; +} + +static tbool AssignRecur(const int piTriListIn[], STriInfo psTriInfos[], + const int iMyTriIndex, SGroup * pGroup) +{ + STriInfo * pMyTriInfo = &psTriInfos[iMyTriIndex]; + + // track down vertex + const int iVertRep = pGroup->iVertexRepresentitive; + const int * pVerts = &piTriListIn[3*iMyTriIndex+0]; + int i=-1; + if (pVerts[0]==iVertRep) i=0; + else if (pVerts[1]==iVertRep) i=1; + else if (pVerts[2]==iVertRep) i=2; + assert(i>=0 && i<3); + + // early out + if (pMyTriInfo->AssignedGroup[i] == pGroup) return TTRUE; + else if (pMyTriInfo->AssignedGroup[i]!=NULL) return TFALSE; + if ((pMyTriInfo->iFlag&GROUP_WITH_ANY)!=0) + { + // first to group with a group-with-anything triangle + // determines it's orientation. + // This is the only existing order dependency in the code!! + if ( pMyTriInfo->AssignedGroup[0] == NULL && + pMyTriInfo->AssignedGroup[1] == NULL && + pMyTriInfo->AssignedGroup[2] == NULL ) + { + pMyTriInfo->iFlag &= (~ORIENT_PRESERVING); + pMyTriInfo->iFlag |= (pGroup->bOrientPreservering ? ORIENT_PRESERVING : 0); + } + } + { + const tbool bOrient = (pMyTriInfo->iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; + if (bOrient != pGroup->bOrientPreservering) return TFALSE; + } + + AddTriToGroup(pGroup, iMyTriIndex); + pMyTriInfo->AssignedGroup[i] = pGroup; + + { + const int neigh_indexL = pMyTriInfo->FaceNeighbors[i]; + const int neigh_indexR = pMyTriInfo->FaceNeighbors[i>0?(i-1):2]; + if (neigh_indexL>=0) + AssignRecur(piTriListIn, psTriInfos, neigh_indexL, pGroup); + if (neigh_indexR>=0) + AssignRecur(piTriListIn, psTriInfos, neigh_indexR, pGroup); + } + + + + return TTRUE; +} + +///////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////// + +static tbool CompareSubGroups(const SSubGroup * pg1, const SSubGroup * pg2); +static void QuickSort(int* pSortBuffer, int iLeft, int iRight, unsigned int uSeed); +static STSpace EvalTspace(int face_indices[], const int iFaces, const int piTriListIn[], const STriInfo pTriInfos[], const SMikkTSpaceContext * pContext, const int iVertexRepresentitive); + +static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], const SGroup pGroups[], + const int iNrActiveGroups, const int piTriListIn[], const float fThresCos, + const SMikkTSpaceContext * pContext) +{ + STSpace * pSubGroupTspace = NULL; + SSubGroup * pUniSubGroups = NULL; + int * pTmpMembers = NULL; + int iMaxNrFaces=0, iUniqueTspaces=0, g=0, i=0; + for (g=0; giNrFaces; i++) // triangles + { + const int f = pGroup->pFaceIndices[i]; // triangle number + int index=-1, iVertIndex=-1, iOF_1=-1, iMembers=0, j=0, l=0; + SSubGroup tmp_group; + tbool bFound; + SVec3 n, vOs, vOt; + if (pTriInfos[f].AssignedGroup[0]==pGroup) index=0; + else if (pTriInfos[f].AssignedGroup[1]==pGroup) index=1; + else if (pTriInfos[f].AssignedGroup[2]==pGroup) index=2; + assert(index>=0 && index<3); + + iVertIndex = piTriListIn[f*3+index]; + assert(iVertIndex==pGroup->iVertexRepresentitive); + + // is normalized already + n = GetNormal(pContext, iVertIndex); + + // project + vOs = vsub(pTriInfos[f].vOs, vscale(vdot(n,pTriInfos[f].vOs), n)); + vOt = vsub(pTriInfos[f].vOt, vscale(vdot(n,pTriInfos[f].vOt), n)); + if ( VNotZero(vOs) ) vOs = Normalize(vOs); + if ( VNotZero(vOt) ) vOt = Normalize(vOt); + + // original face number + iOF_1 = pTriInfos[f].iOrgFaceNumber; + + iMembers = 0; + for (j=0; jiNrFaces; j++) + { + const int t = pGroup->pFaceIndices[j]; // triangle number + const int iOF_2 = pTriInfos[t].iOrgFaceNumber; + + // project + SVec3 vOs2 = vsub(pTriInfos[t].vOs, vscale(vdot(n,pTriInfos[t].vOs), n)); + SVec3 vOt2 = vsub(pTriInfos[t].vOt, vscale(vdot(n,pTriInfos[t].vOt), n)); + if ( VNotZero(vOs2) ) vOs2 = Normalize(vOs2); + if ( VNotZero(vOt2) ) vOt2 = Normalize(vOt2); + + { + const tbool bAny = ( (pTriInfos[f].iFlag | pTriInfos[t].iFlag) & GROUP_WITH_ANY )!=0 ? TTRUE : TFALSE; + // make sure triangles which belong to the same quad are joined. + const tbool bSameOrgFace = iOF_1==iOF_2 ? TTRUE : TFALSE; + + const float fCosS = vdot(vOs,vOs2); + const float fCosT = vdot(vOt,vOt2); + + assert(f!=t || bSameOrgFace); // sanity check + if (bAny || bSameOrgFace || (fCosS>fThresCos && fCosT>fThresCos)) + pTmpMembers[iMembers++] = t; + } + } + + // sort pTmpMembers + tmp_group.iNrFaces = iMembers; + tmp_group.pTriMembers = pTmpMembers; + if (iMembers>1) + { + unsigned int uSeed = INTERNAL_RND_SORT_SEED; // could replace with a random seed? + QuickSort(pTmpMembers, 0, iMembers-1, uSeed); + } + + // look for an existing match + bFound = TFALSE; + l=0; + while (liVertexRepresentitive); + ++iUniqueSubGroups; + } + + // output tspace + { + const int iOffs = pTriInfos[f].iTSpacesOffs; + const int iVert = pTriInfos[f].vert_num[index]; + STSpace * pTS_out = &psTspace[iOffs+iVert]; + assert(pTS_out->iCounter<2); + assert(((pTriInfos[f].iFlag&ORIENT_PRESERVING)!=0) == pGroup->bOrientPreservering); + if (pTS_out->iCounter==1) + { + *pTS_out = AvgTSpace(pTS_out, &pSubGroupTspace[l]); + pTS_out->iCounter = 2; // update counter + pTS_out->bOrient = pGroup->bOrientPreservering; + } + else + { + assert(pTS_out->iCounter==0); + *pTS_out = pSubGroupTspace[l]; + pTS_out->iCounter = 1; // update counter + pTS_out->bOrient = pGroup->bOrientPreservering; + } + } + } + + // clean up and offset iUniqueTspaces + for (s=0; s=0 && i<3); + + // project + index = piTriListIn[3*f+i]; + n = GetNormal(pContext, index); + vOs = vsub(pTriInfos[f].vOs, vscale(vdot(n,pTriInfos[f].vOs), n)); + vOt = vsub(pTriInfos[f].vOt, vscale(vdot(n,pTriInfos[f].vOt), n)); + if ( VNotZero(vOs) ) vOs = Normalize(vOs); + if ( VNotZero(vOt) ) vOt = Normalize(vOt); + + i2 = piTriListIn[3*f + (i<2?(i+1):0)]; + i1 = piTriListIn[3*f + i]; + i0 = piTriListIn[3*f + (i>0?(i-1):2)]; + + p0 = GetPosition(pContext, i0); + p1 = GetPosition(pContext, i1); + p2 = GetPosition(pContext, i2); + v1 = vsub(p0,p1); + v2 = vsub(p2,p1); + + // project + v1 = vsub(v1, vscale(vdot(n,v1),n)); if ( VNotZero(v1) ) v1 = Normalize(v1); + v2 = vsub(v2, vscale(vdot(n,v2),n)); if ( VNotZero(v2) ) v2 = Normalize(v2); + + // weight contribution by the angle + // between the two edge vectors + fCos = vdot(v1,v2); fCos=fCos>1?1:(fCos<(-1) ? (-1) : fCos); + fAngle = (float) acos(fCos); + fMagS = pTriInfos[f].fMagS; + fMagT = pTriInfos[f].fMagT; + + res.vOs=vadd(res.vOs, vscale(fAngle,vOs)); + res.vOt=vadd(res.vOt,vscale(fAngle,vOt)); + res.fMagS+=(fAngle*fMagS); + res.fMagT+=(fAngle*fMagT); + fAngleSum += fAngle; + } + } + + // normalize + if ( VNotZero(res.vOs) ) res.vOs = Normalize(res.vOs); + if ( VNotZero(res.vOt) ) res.vOt = Normalize(res.vOt); + if (fAngleSum>0) + { + res.fMagS /= fAngleSum; + res.fMagT /= fAngleSum; + } + + return res; +} + +static tbool CompareSubGroups(const SSubGroup * pg1, const SSubGroup * pg2) +{ + tbool bStillSame=TTRUE; + int i=0; + if (pg1->iNrFaces!=pg2->iNrFaces) return TFALSE; + while (iiNrFaces && bStillSame) + { + bStillSame = pg1->pTriMembers[i]==pg2->pTriMembers[i] ? TTRUE : TFALSE; + if (bStillSame) ++i; + } + return bStillSame; +} + +static void QuickSort(int* pSortBuffer, int iLeft, int iRight, unsigned int uSeed) +{ + int iL, iR, n, index, iMid, iTmp; + + // Random + unsigned int t=uSeed&31; + t=(uSeed<>(32-t)); + uSeed=uSeed+t+3; + // Random end + + iL=iLeft; iR=iRight; + n = (iR-iL)+1; + assert(n>=0); + index = (int) (uSeed%n); + + iMid=pSortBuffer[index + iL]; + + + do + { + while (pSortBuffer[iL] < iMid) + ++iL; + while (pSortBuffer[iR] > iMid) + --iR; + + if (iL <= iR) + { + iTmp = pSortBuffer[iL]; + pSortBuffer[iL] = pSortBuffer[iR]; + pSortBuffer[iR] = iTmp; + ++iL; --iR; + } + } + while (iL <= iR); + + if (iLeft < iR) + QuickSort(pSortBuffer, iLeft, iR, uSeed); + if (iL < iRight) + QuickSort(pSortBuffer, iL, iRight, uSeed); +} + +///////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////// + +static void QuickSortEdges(SEdge * pSortBuffer, int iLeft, int iRight, const int channel, unsigned int uSeed); +static void GetEdge(int * i0_out, int * i1_out, int * edgenum_out, const int indices[], const int i0_in, const int i1_in); + +static void BuildNeighborsFast(STriInfo pTriInfos[], SEdge * pEdges, const int piTriListIn[], const int iNrTrianglesIn) +{ + // build array of edges + unsigned int uSeed = INTERNAL_RND_SORT_SEED; // could replace with a random seed? + int iEntries=0, iCurStartIndex=-1, f=0, i=0; + for (f=0; f pSortBuffer[iRight].array[channel]) + { + sTmp = pSortBuffer[iLeft]; + pSortBuffer[iLeft] = pSortBuffer[iRight]; + pSortBuffer[iRight] = sTmp; + } + return; + } + + // Random + t=uSeed&31; + t=(uSeed<>(32-t)); + uSeed=uSeed+t+3; + // Random end + + iL = iLeft; + iR = iRight; + n = (iR-iL)+1; + assert(n>=0); + index = (int) (uSeed%n); + + iMid=pSortBuffer[index + iL].array[channel]; + + do + { + while (pSortBuffer[iL].array[channel] < iMid) + ++iL; + while (pSortBuffer[iR].array[channel] > iMid) + --iR; + + if (iL <= iR) + { + sTmp = pSortBuffer[iL]; + pSortBuffer[iL] = pSortBuffer[iR]; + pSortBuffer[iR] = sTmp; + ++iL; --iR; + } + } + while (iL <= iR); + + if (iLeft < iR) + QuickSortEdges(pSortBuffer, iLeft, iR, channel, uSeed); + if (iL < iRight) + QuickSortEdges(pSortBuffer, iL, iRight, channel, uSeed); +} + +// resolve ordering and edge number +static void GetEdge(int * i0_out, int * i1_out, int * edgenum_out, const int indices[], const int i0_in, const int i1_in) +{ + *edgenum_out = -1; + + // test if first index is on the edge + if (indices[0]==i0_in || indices[0]==i1_in) + { + // test if second index is on the edge + if (indices[1]==i0_in || indices[1]==i1_in) + { + edgenum_out[0]=0; // first edge + i0_out[0]=indices[0]; + i1_out[0]=indices[1]; + } + else + { + edgenum_out[0]=2; // third edge + i0_out[0]=indices[2]; + i1_out[0]=indices[0]; + } + } + else + { + // only second and third index is on the edge + edgenum_out[0]=1; // second edge + i0_out[0]=indices[1]; + i1_out[0]=indices[2]; + } +} + + +///////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////// Degenerate triangles //////////////////////////////////// + +static void DegenPrologue(STriInfo pTriInfos[], int piTriList_out[], const int iNrTrianglesIn, const int iTotTris) +{ + int iNextGoodTriangleSearchIndex=-1; + tbool bStillFindingGoodOnes; + + // locate quads with only one good triangle + int t=0; + while (t<(iTotTris-1)) + { + const int iFO_a = pTriInfos[t].iOrgFaceNumber; + const int iFO_b = pTriInfos[t+1].iOrgFaceNumber; + if (iFO_a==iFO_b) // this is a quad + { + const tbool bIsDeg_a = (pTriInfos[t].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE; + const tbool bIsDeg_b = (pTriInfos[t+1].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE; + if ((bIsDeg_a^bIsDeg_b)!=0) + { + pTriInfos[t].iFlag |= QUAD_ONE_DEGEN_TRI; + pTriInfos[t+1].iFlag |= QUAD_ONE_DEGEN_TRI; + } + t += 2; + } + else + ++t; + } + + // reorder list so all degen triangles are moved to the back + // without reordering the good triangles + iNextGoodTriangleSearchIndex = 1; + t=0; + bStillFindingGoodOnes = TTRUE; + while (t (t+1)); + + // swap triangle t0 and t1 + if (!bJustADegenerate) + { + int i=0; + for (i=0; i<3; i++) + { + const int index = piTriList_out[t0*3+i]; + piTriList_out[t0*3+i] = piTriList_out[t1*3+i]; + piTriList_out[t1*3+i] = index; + } + { + const STriInfo tri_info = pTriInfos[t0]; + pTriInfos[t0] = pTriInfos[t1]; + pTriInfos[t1] = tri_info; + } + } + else + bStillFindingGoodOnes = TFALSE; // this is not supposed to happen + } + + if (bStillFindingGoodOnes) ++t; + } + + assert(bStillFindingGoodOnes); // code will still work. + assert(iNrTrianglesIn == t); +} + +static void DegenEpilogue(STSpace psTspace[], STriInfo pTriInfos[], int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn, const int iTotTris) +{ + int t=0, i=0; + // deal with degenerate triangles + // punishment for degenerate triangles is O(N^2) + for (t=iNrTrianglesIn; t http://image.diku.dk/projects/media/morten.mikkelsen.08.pdf + * Note that though the tangent spaces at the vertices are generated in an order-independent way, + * by this implementation, the interpolated tangent space is still affected by which diagonal is + * chosen to split each quad. A sensible solution is to have your tools pipeline always + * split quads by the shortest diagonal. This choice is order-independent and works with mirroring. + * If these have the same length then compare the diagonals defined by the texture coordinates. + * XNormal which is a tool for baking normal maps allows you to write your own tangent space plugin + * and also quad triangulator plugin. + */ + + +typedef int tbool; +typedef struct SMikkTSpaceContext SMikkTSpaceContext; + +typedef struct { + // Returns the number of faces (triangles/quads) on the mesh to be processed. + int (*m_getNumFaces)(const SMikkTSpaceContext * pContext); + + // Returns the number of vertices on face number iFace + // iFace is a number in the range {0, 1, ..., getNumFaces()-1} + int (*m_getNumVerticesOfFace)(const SMikkTSpaceContext * pContext, const int iFace); + + // returns the position/normal/texcoord of the referenced face of vertex number iVert. + // iVert is in the range {0,1,2} for triangles and {0,1,2,3} for quads. + void (*m_getPosition)(const SMikkTSpaceContext * pContext, float fvPosOut[], const int iFace, const int iVert); + void (*m_getNormal)(const SMikkTSpaceContext * pContext, float fvNormOut[], const int iFace, const int iVert); + void (*m_getTexCoord)(const SMikkTSpaceContext * pContext, float fvTexcOut[], const int iFace, const int iVert); + + // either (or both) of the two setTSpace callbacks can be set. + // The call-back m_setTSpaceBasic() is sufficient for basic normal mapping. + + // This function is used to return the tangent and fSign to the application. + // fvTangent is a unit length vector. + // For normal maps it is sufficient to use the following simplified version of the bitangent which is generated at pixel/vertex level. + // bitangent = fSign * cross(vN, tangent); + // Note that the results are returned unindexed. It is possible to generate a new index list + // But averaging/overwriting tangent spaces by using an already existing index list WILL produce INCRORRECT results. + // DO NOT! use an already existing index list. + void (*m_setTSpaceBasic)(const SMikkTSpaceContext * pContext, const float fvTangent[], const float fSign, const int iFace, const int iVert); + + // This function is used to return tangent space results to the application. + // fvTangent and fvBiTangent are unit length vectors and fMagS and fMagT are their + // true magnitudes which can be used for relief mapping effects. + // fvBiTangent is the "real" bitangent and thus may not be perpendicular to fvTangent. + // However, both are perpendicular to the vertex normal. + // For normal maps it is sufficient to use the following simplified version of the bitangent which is generated at pixel/vertex level. + // fSign = bIsOrientationPreserving ? 1.0f : (-1.0f); + // bitangent = fSign * cross(vN, tangent); + // Note that the results are returned unindexed. It is possible to generate a new index list + // But averaging/overwriting tangent spaces by using an already existing index list WILL produce INCRORRECT results. + // DO NOT! use an already existing index list. + void (*m_setTSpace)(const SMikkTSpaceContext * pContext, const float fvTangent[], const float fvBiTangent[], const float fMagS, const float fMagT, + const tbool bIsOrientationPreserving, const int iFace, const int iVert); +} SMikkTSpaceInterface; + +struct SMikkTSpaceContext +{ + SMikkTSpaceInterface * m_pInterface; // initialized with callback functions + void * m_pUserData; // pointer to client side mesh data etc. (passed as the first parameter with every interface call) +}; + +// these are both thread safe! +tbool genTangSpaceDefault(const SMikkTSpaceContext * pContext); // Default (recommended) fAngularThreshold is 180 degrees (which means threshold disabled) +tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThreshold); + + +// To avoid visual errors (distortions/unwanted hard edges in lighting), when using sampled normal maps, the +// normal map sampler must use the exact inverse of the pixel shader transformation. +// The most efficient transformation we can possibly do in the pixel shader is +// achieved by using, directly, the "unnormalized" interpolated tangent, bitangent and vertex normal: vT, vB and vN. +// pixel shader (fast transform out) +// vNout = normalize( vNt.x * vT + vNt.y * vB + vNt.z * vN ); +// where vNt is the tangent space normal. The normal map sampler must likewise use the +// interpolated and "unnormalized" tangent, bitangent and vertex normal to be compliant with the pixel shader. +// sampler does (exact inverse of pixel shader): +// float3 row0 = cross(vB, vN); +// float3 row1 = cross(vN, vT); +// float3 row2 = cross(vT, vB); +// float fSign = dot(vT, row0)<0 ? -1 : 1; +// vNt = normalize( fSign * float3(dot(vNout,row0), dot(vNout,row1), dot(vNout,row2)) ); +// where vNout is the sampled normal in some chosen 3D space. +// +// Should you choose to reconstruct the bitangent in the pixel shader instead +// of the vertex shader, as explained earlier, then be sure to do this in the normal map sampler also. +// Finally, beware of quad triangulations. If the normal map sampler doesn't use the same triangulation of +// quads as your renderer then problems will occur since the interpolated tangent spaces will differ +// eventhough the vertex level tangent spaces match. This can be solved either by triangulating before +// sampling/exporting or by using the order-independent choice of diagonal for splitting quads suggested earlier. +// However, this must be used both by the sampler and your tools/rendering pipeline. + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/WickedEngine/Utility/utility_common.cpp b/WickedEngine/Utility/utility_common.cpp index 0b09407de3c..7533703eb33 100644 --- a/WickedEngine/Utility/utility_common.cpp +++ b/WickedEngine/Utility/utility_common.cpp @@ -27,6 +27,8 @@ #define H264_IMPLEMENTATION #include "h264.h" +#include "mikktspace.c" + // Basis Universal library sources are compiled below for simplicity: diff --git a/WickedEngine/WickedEngine.h b/WickedEngine/WickedEngine.h index b89414a8acc..730893dc5f8 100644 --- a/WickedEngine/WickedEngine.h +++ b/WickedEngine/WickedEngine.h @@ -72,6 +72,9 @@ #include "wiTerrain.h" #include "wiLocalization.h" #include "wiVideo.h" +#include "wiVoxelGrid.h" +#include "wiPathQuery.h" +#include "wiTrailRenderer.h" #ifdef PLATFORM_WINDOWS_DESKTOP #pragma comment(lib,"WickedEngine_Windows.lib") diff --git a/WickedEngine/WickedEngine_SOURCE.vcxitems b/WickedEngine/WickedEngine_SOURCE.vcxitems index ec8f8d8f04d..05ddddd6f15 100644 --- a/WickedEngine/WickedEngine_SOURCE.vcxitems +++ b/WickedEngine/WickedEngine_SOURCE.vcxitems @@ -241,6 +241,8 @@ + + @@ -276,6 +278,8 @@ + + @@ -370,6 +374,8 @@ + + @@ -517,6 +523,8 @@ + + @@ -707,8 +715,12 @@ + + + + diff --git a/WickedEngine/WickedEngine_SOURCE.vcxitems.filters b/WickedEngine/WickedEngine_SOURCE.vcxitems.filters index 693f46f508d..af629b040d2 100644 --- a/WickedEngine/WickedEngine_SOURCE.vcxitems.filters +++ b/WickedEngine/WickedEngine_SOURCE.vcxitems.filters @@ -1125,6 +1125,24 @@ UTILITY + + ENGINE\Helpers + + + ENGINE\Helpers + + + ENGINE\Scripting\LuaBindings + + + ENGINE\Scripting\LuaBindings + + + ENGINE\Graphics + + + ENGINE\Scripting\LuaBindings + @@ -1880,6 +1898,24 @@ UTILITY + + ENGINE\Helpers + + + ENGINE\Helpers + + + ENGINE\Scripting\LuaBindings + + + ENGINE\Scripting\LuaBindings + + + ENGINE\Graphics + + + ENGINE\Scripting\LuaBindings + diff --git a/WickedEngine/dxcompiler.dll b/WickedEngine/dxcompiler.dll index 2f7fef71890..84e93019284 100644 Binary files a/WickedEngine/dxcompiler.dll and b/WickedEngine/dxcompiler.dll differ diff --git a/WickedEngine/dxil.dll b/WickedEngine/dxil.dll index fcfccc5e402..c2c7b96b425 100644 Binary files a/WickedEngine/dxil.dll and b/WickedEngine/dxil.dll differ diff --git a/WickedEngine/libdxcompiler.so b/WickedEngine/libdxcompiler.so index 92b31f55a72..5ec3944adcc 100644 Binary files a/WickedEngine/libdxcompiler.so and b/WickedEngine/libdxcompiler.so differ diff --git a/WickedEngine/libdxil.so b/WickedEngine/libdxil.so new file mode 100644 index 00000000000..f4a9b881375 Binary files /dev/null and b/WickedEngine/libdxil.so differ diff --git a/WickedEngine/offlineshadercompiler.cpp b/WickedEngine/offlineshadercompiler.cpp index 588ea376271..200f1802c7f 100644 --- a/WickedEngine/offlineshadercompiler.cpp +++ b/WickedEngine/offlineshadercompiler.cpp @@ -67,17 +67,20 @@ wi::vector shaders = { {"ffx-fsr2/ffx_fsr2_accumulate_pass", wi::graphics::ShaderStage::CS}, {"ffx-fsr2/ffx_fsr2_rcas_pass", wi::graphics::ShaderStage::CS}, {"ssaoCS", wi::graphics::ShaderStage::CS}, + {"ssgi_deinterleaveCS", wi::graphics::ShaderStage::CS}, + {"ssgiCS", wi::graphics::ShaderStage::CS}, + {"ssgi_upsampleCS", wi::graphics::ShaderStage::CS}, {"rtdiffuseCS", wi::graphics::ShaderStage::CS, wi::graphics::ShaderModel::SM_6_5}, {"rtdiffuse_spatialCS", wi::graphics::ShaderStage::CS}, {"rtdiffuse_temporalCS", wi::graphics::ShaderStage::CS}, - {"rtdiffuse_bilateralCS", wi::graphics::ShaderStage::CS}, + {"rtdiffuse_upsampleCS", wi::graphics::ShaderStage::CS}, {"rtreflectionCS", wi::graphics::ShaderStage::CS, wi::graphics::ShaderModel::SM_6_5}, {"ssr_tileMaxRoughness_horizontalCS", wi::graphics::ShaderStage::CS}, {"ssr_tileMaxRoughness_verticalCS", wi::graphics::ShaderStage::CS}, {"ssr_depthHierarchyCS", wi::graphics::ShaderStage::CS}, {"ssr_resolveCS", wi::graphics::ShaderStage::CS}, {"ssr_temporalCS", wi::graphics::ShaderStage::CS}, - {"ssr_bilateralCS", wi::graphics::ShaderStage::CS}, + {"ssr_upsampleCS", wi::graphics::ShaderStage::CS}, {"ssr_raytraceCS", wi::graphics::ShaderStage::CS}, {"ssr_raytraceCS_cheap", wi::graphics::ShaderStage::CS}, {"ssr_raytraceCS_earlyexit", wi::graphics::ShaderStage::CS}, @@ -188,7 +191,6 @@ wi::vector shaders = { {"skyAtmosphere_skyViewLutCS", wi::graphics::ShaderStage::CS }, {"skyAtmosphere_multiScatteredLuminanceLutCS", wi::graphics::ShaderStage::CS }, {"skyAtmosphere_skyLuminanceLutCS", wi::graphics::ShaderStage::CS }, - {"upsample_bilateral_uint4CS", wi::graphics::ShaderStage::CS }, {"screenspaceshadowCS", wi::graphics::ShaderStage::CS }, {"rtshadowCS", wi::graphics::ShaderStage::CS, wi::graphics::ShaderModel::SM_6_5 }, {"rtshadow_denoise_tileclassificationCS", wi::graphics::ShaderStage::CS }, @@ -280,6 +282,7 @@ wi::vector shaders = { {"ddgi_debugPS", wi::graphics::ShaderStage::PS }, {"copyDepthPS", wi::graphics::ShaderStage::PS }, {"copyStencilBitPS", wi::graphics::ShaderStage::PS }, + {"trailPS", wi::graphics::ShaderStage::PS }, {"hairparticleVS", wi::graphics::ShaderStage::VS }, @@ -335,6 +338,7 @@ wi::vector shaders = { {"shadowVS_transparent", wi::graphics::ShaderStage::VS }, {"shadowVS_transparent_emulation", wi::graphics::ShaderStage::VS }, {"screenVS", wi::graphics::ShaderStage::VS }, + {"trailVS", wi::graphics::ShaderStage::VS }, @@ -482,6 +486,13 @@ int main(int argc, char* argv[]) shaders.back().permutations.emplace_back().defines = x; } + // permutations for ssgiCS: + shaders.push_back({ "ssgiCS", wi::graphics::ShaderStage::CS }); + shaders.back().permutations.emplace_back().defines = { "WIDE" }; + // permutations for ssgi_upsampleCS: + shaders.push_back({ "ssgi_upsampleCS", wi::graphics::ShaderStage::CS }); + shaders.back().permutations.emplace_back().defines = { "WIDE" }; + wi::jobsystem::Initialize(); wi::jobsystem::context ctx; diff --git a/WickedEngine/shaders/ShaderInterop.h b/WickedEngine/shaders/ShaderInterop.h index 726288f7ba8..77574b5cf21 100644 --- a/WickedEngine/shaders/ShaderInterop.h +++ b/WickedEngine/shaders/ShaderInterop.h @@ -112,6 +112,7 @@ static const uint IndirectDispatchArgsAlignment = 4u; #define CBSLOT_OTHER_GPUSORTLIB 4 #define CBSLOT_MSAO 4 #define CBSLOT_FSR 4 +#define CBSLOT_TRAILRENDERER 3 #else // Don't use overlapping slots on PS5: diff --git a/WickedEngine/shaders/ShaderInterop_Postprocess.h b/WickedEngine/shaders/ShaderInterop_Postprocess.h index 78b0ef249da..6ad3825dddc 100644 --- a/WickedEngine/shaders/ShaderInterop_Postprocess.h +++ b/WickedEngine/shaders/ShaderInterop_Postprocess.h @@ -55,6 +55,7 @@ static const uint SSR_TILESIZE = 32; #define rtdiffuse_range ssao_range #define rtdiffuse_frame ssr_frame +#define ssgi_frame ssr_frame #define rtreflection_range ssao_range #define rtreflection_roughness_cutoff ssr_roughness_cutoff diff --git a/WickedEngine/shaders/ShaderInterop_Renderer.h b/WickedEngine/shaders/ShaderInterop_Renderer.h index dbc7de13720..80331c88dec 100644 --- a/WickedEngine/shaders/ShaderInterop_Renderer.h +++ b/WickedEngine/shaders/ShaderInterop_Renderer.h @@ -1047,14 +1047,14 @@ struct ShaderCamera int texture_roughness_index; int buffer_entitytiles_index; - int padding; int texture_reflection_index; int texture_reflection_depth_index; int texture_refraction_index; - int texture_waterriples_index; + int texture_ao_index; int texture_ssr_index; + int texture_ssgi_index; int texture_rtshadow_index; int texture_surfelgi_index; @@ -1120,6 +1120,7 @@ struct ShaderCamera texture_waterriples_index = -1; texture_ao_index = -1; texture_ssr_index = -1; + texture_ssgi_index = -1; texture_rtshadow_index = -1; texture_surfelgi_index = -1; texture_depth_index_prev = -1; @@ -1255,7 +1256,7 @@ struct CopyTextureCB static const uint PAINT_TEXTURE_BLOCKSIZE = 8; -struct PaintTextureCB +struct PaintTexturePushConstants { uint2 xPaintBrushCenter; uint xPaintBrushRadius; @@ -1263,13 +1264,13 @@ struct PaintTextureCB float xPaintBrushSmoothness; uint xPaintBrushColor; - uint xPaintReveal; + uint xPaintRedirectAlpha; float xPaintBrushRotation; uint xPaintBrushShape; - uint padding0; - uint padding1; - uint padding2; + int texture_brush; + int texture_reveal; + int texture_output; }; CBUFFER(PaintRadiusCB, CBSLOT_RENDERER_MISC) @@ -1396,5 +1397,19 @@ struct VirtualTextureTileRequestsPush int padding2; }; +CBUFFER(TrailRendererCB, CBSLOT_TRAILRENDERER) +{ + float4x4 g_xTrailTransform; + float4 g_xTrailColor; + float4 g_xTrailTexMulAdd; + float4 g_xTrailTexMulAdd2; + int g_xTrailTextureIndex1; + int g_xTrailTextureIndex2; + int g_xTrailLinearDepthTextureIndex; + float g_xTrailDepthSoften; + float3 g_xTrailPadding; + float g_xTrailCameraFar; +}; + #endif // WI_SHADERINTEROP_RENDERER_H diff --git a/WickedEngine/shaders/Shaders_SOURCE.vcxitems b/WickedEngine/shaders/Shaders_SOURCE.vcxitems index 0725a21dc2a..6375a3aa09e 100644 --- a/WickedEngine/shaders/Shaders_SOURCE.vcxitems +++ b/WickedEngine/shaders/Shaders_SOURCE.vcxitems @@ -882,7 +882,7 @@ Compute 4.0 - + Compute 4.0 @@ -939,7 +939,19 @@ Compute Compute - + + Compute + 4.0 + + + Compute + 4.0 + + + Compute + 4.0 + + Compute 4.0 @@ -1007,21 +1019,16 @@ Compute 4.0 + + Pixel + + + Vertex + Compute 4.0 - - Compute - 5.0 - Compute - Compute - Compute - Compute - Compute - Compute - Compute - Compute Compute diff --git a/WickedEngine/shaders/Shaders_SOURCE.vcxitems.filters b/WickedEngine/shaders/Shaders_SOURCE.vcxitems.filters index 1cd3aa802f5..2bad342ce6b 100644 --- a/WickedEngine/shaders/Shaders_SOURCE.vcxitems.filters +++ b/WickedEngine/shaders/Shaders_SOURCE.vcxitems.filters @@ -800,9 +800,6 @@ GS - - CS - CS @@ -944,7 +941,7 @@ CS - + CS @@ -1010,7 +1007,7 @@ CS - + CS @@ -1139,6 +1136,21 @@ PS + + VS + + + PS + + + CS + + + CS + + + CS + diff --git a/WickedEngine/shaders/depthoffield_postfilterCS.hlsl b/WickedEngine/shaders/depthoffield_postfilterCS.hlsl index 071dd98c39a..24fcce22ed6 100644 --- a/WickedEngine/shaders/depthoffield_postfilterCS.hlsl +++ b/WickedEngine/shaders/depthoffield_postfilterCS.hlsl @@ -9,66 +9,6 @@ Texture2D texture_alpha : register(t1); RWTexture2D output_postfilter : register(u0); RWTexture2D output_alpha : register(u1); -#ifndef __PSSL__ -float min3(float a, float b, float c) -{ - return min(min(a, b), c); -} -float max3(float a, float b, float c) -{ - return max(max(a, b), c); -} -float2 min3(float2 a, float2 b, float2 c) -{ - return float2(min3(a.x, b.x, c.x), min3(a.y, b.y, c.y)); -} -float3 min3(float3 a, float3 b, float3 c) -{ - return float3(min3(a.x, b.x, c.x), min3(a.y, b.y, c.y), min3(a.z, b.z, c.z)); -} -float4 min3(float4 a, float4 b, float4 c) -{ - return float4(min3(a.x, b.x, c.x), min3(a.y, b.y, c.y), min3(a.z, b.z, c.z), min3(a.w, b.w, c.w)); -} -float2 max3(float2 a, float2 b, float2 c) -{ - return float2(max3(a.x, b.x, c.x), max3(a.y, b.y, c.y)); -} -float3 max3(float3 a, float3 b, float3 c) -{ - return float3(max3(a.x, b.x, c.x), max3(a.y, b.y, c.y), max3(a.z, b.z, c.z)); -} -float4 max3(float4 a, float4 b, float4 c) -{ - return float4(max3(a.x, b.x, c.x), max3(a.y, b.y, c.y), max3(a.z, b.z, c.z), max3(a.w, b.w, c.w)); -} -float min4(float4 values) -{ - return min(min3(values.x, values.y, values.z), values.w); -} -float max4(float4 values) -{ - return max(max3(values.x, values.y, values.z), values.w); -} - -float med3(float a, float b, float c) -{ - return max(min(a, b), min(max(a, b), c)); -} -float2 med3(float2 a, float2 b, float2 c) -{ - return float2(med3(a.x, b.x, c.x), med3(a.y, b.y, c.y)); -} -float3 med3(float3 a, float3 b, float3 c) -{ - return float3(med3(a.x, b.x, c.x), med3(a.y, b.y, c.y), med3(a.z, b.z, c.z)); -} -float4 med3(float4 a, float4 b, float4 c) -{ - return float4(med3(a.x, b.x, c.x), med3(a.y, b.y, c.y), med3(a.z, b.z, c.z), med3(a.w, b.w, c.w)); -} -#endif // __PSSL__ - static const float2 squareOffsets[] = { { -1.0, -1.0 }, diff --git a/WickedEngine/shaders/globals.hlsli b/WickedEngine/shaders/globals.hlsli index d7f768c7973..054e1552536 100644 --- a/WickedEngine/shaders/globals.hlsli +++ b/WickedEngine/shaders/globals.hlsli @@ -375,6 +375,77 @@ static const float SKY_UNIT_TO_M = rcp(M_TO_SKY_UNIT); #define sqr(a) ((a)*(a)) #define pow5(x) pow(x, 5) +template +float max3(T v) +{ + return max(max(v.x, v.y), v.z); +} +template +float min3(T v) +{ + return min(min(v.x, v.y), v.z); +} + +#ifndef __PSSL__ +float min3(float a, float b, float c) +{ + return min(min(a, b), c); +} +float max3(float a, float b, float c) +{ + return max(max(a, b), c); +} +float2 min3(float2 a, float2 b, float2 c) +{ + return float2(min3(a.x, b.x, c.x), min3(a.y, b.y, c.y)); +} +float3 min3(float3 a, float3 b, float3 c) +{ + return float3(min3(a.x, b.x, c.x), min3(a.y, b.y, c.y), min3(a.z, b.z, c.z)); +} +float4 min3(float4 a, float4 b, float4 c) +{ + return float4(min3(a.x, b.x, c.x), min3(a.y, b.y, c.y), min3(a.z, b.z, c.z), min3(a.w, b.w, c.w)); +} +float2 max3(float2 a, float2 b, float2 c) +{ + return float2(max3(a.x, b.x, c.x), max3(a.y, b.y, c.y)); +} +float3 max3(float3 a, float3 b, float3 c) +{ + return float3(max3(a.x, b.x, c.x), max3(a.y, b.y, c.y), max3(a.z, b.z, c.z)); +} +float4 max3(float4 a, float4 b, float4 c) +{ + return float4(max3(a.x, b.x, c.x), max3(a.y, b.y, c.y), max3(a.z, b.z, c.z), max3(a.w, b.w, c.w)); +} +float min4(float4 values) +{ + return min(min3(values.x, values.y, values.z), values.w); +} +float max4(float4 values) +{ + return max(max3(values.x, values.y, values.z), values.w); +} + +float med3(float a, float b, float c) +{ + return max(min(a, b), min(max(a, b), c)); +} +float2 med3(float2 a, float2 b, float2 c) +{ + return float2(med3(a.x, b.x, c.x), med3(a.y, b.y, c.y)); +} +float3 med3(float3 a, float3 b, float3 c) +{ + return float3(med3(a.x, b.x, c.x), med3(a.y, b.y, c.y), med3(a.z, b.z, c.z)); +} +float4 med3(float4 a, float4 b, float4 c) +{ + return float4(med3(a.x, b.x, c.x), med3(a.y, b.y, c.y), med3(a.z, b.z, c.z), med3(a.w, b.w, c.w)); +} +#endif // __PSSL__ + // attribute computation with barycentric interpolation // a0 : attribute at triangle corner 0 // a1 : attribute at triangle corner 1 @@ -398,6 +469,14 @@ inline float4 attribute_at_bary(in float4 a0, in float4 a1, in float4 a2, in flo return mad(a0, 1 - bary.x - bary.y, mad(a1, bary.x, a2 * bary.y)); } +// bilinear interpolation of gathered values based on pixel fraction +inline float bilinear(float4 gather, float2 pixel_frac) +{ + const float top_row = lerp(gather.w, gather.z, pixel_frac.x); + const float bottom_row = lerp(gather.x, gather.y, pixel_frac.x); + return lerp(top_row, bottom_row, pixel_frac.y); +} + inline bool is_saturated(float a) { return a == saturate(a); } inline bool is_saturated(float2 a) { return all(a == saturate(a)); } inline bool is_saturated(float3 a) { return all(a == saturate(a)); } @@ -612,9 +691,9 @@ float noise_gradient_3D(in float3 p) // Based on: https://www.shadertoy.com/view/MslGD8 float2 hash_voronoi(float2 p) { - //p = mod(p, 4.0); // tile + //p = mod(p, 4.0); // tile p = float2(dot(p, float2(127.1, 311.7)), - dot(p, float2(269.5, 183.3))); + dot(p, float2(269.5, 183.3))); return frac(sin(p) * 18.5453); } @@ -1549,43 +1628,60 @@ enum class ColorSpace static const uint NUM_PARALLAX_OCCLUSION_STEPS = 32; +static const float NUM_PARALLAX_OCCLUSION_STEPS_RCP = 1.0 / NUM_PARALLAX_OCCLUSION_STEPS; inline void ParallaxOcclusionMapping_Impl( inout float4 uvsets, // uvsets to modify in float3 V, // view vector (pointing towards camera) in float3x3 TBN, // tangent basis matrix (same that is used for normal mapping) - in ShaderMaterial material, // material parameters + in float strength, // material parameters in Texture2D tex, // displacement map texture in float2 uv, // uv to use for the displacement map in float2 uv_dx, // horizontal derivative of displacement map uv - in float2 uv_dy // vertical derivative of displacement map uv + in float2 uv_dy, // vertical derivative of displacement map uv + in SamplerState sam = sampler_linear_wrap ) { [branch] - if (material.parallaxOcclusionMapping > 0) + if (strength <= 0) + return; + + TBN[0] = normalize(TBN[0]); + TBN[1] = normalize(TBN[1]); + TBN[2] = normalize(TBN[2]); + V = normalize(mul(TBN, V)); + float curLayerHeight = 0; + float2 dtex = strength * V.xy * NUM_PARALLAX_OCCLUSION_STEPS_RCP; + float2 currentTextureCoords = uv; + float heightFromTexture = 1 - tex.SampleGrad(sam, currentTextureCoords, uv_dx, uv_dy).r; + uint iter = 0; + [loop] + while (heightFromTexture > curLayerHeight && iter < NUM_PARALLAX_OCCLUSION_STEPS) { - V = mul(TBN, V); - float layerHeight = 1.0 / NUM_PARALLAX_OCCLUSION_STEPS; - float curLayerHeight = 0; - float2 dtex = material.parallaxOcclusionMapping * V.xy / NUM_PARALLAX_OCCLUSION_STEPS; - float2 currentTextureCoords = uv; - float heightFromTexture = 1 - tex.SampleGrad(sampler_linear_wrap, currentTextureCoords, uv_dx, uv_dy).r; - uint iter = 0; - [loop] - while (heightFromTexture > curLayerHeight && iter < NUM_PARALLAX_OCCLUSION_STEPS) - { - curLayerHeight += layerHeight; - currentTextureCoords -= dtex; - heightFromTexture = 1 - tex.SampleGrad(sampler_linear_wrap, currentTextureCoords, uv_dx, uv_dy).r; - iter++; - } - float2 prevTCoords = currentTextureCoords + dtex; - float nextH = heightFromTexture - curLayerHeight; - float prevH = 1 - tex.SampleGrad(sampler_linear_wrap, prevTCoords, uv_dx, uv_dy).r - curLayerHeight + layerHeight; - float weight = nextH / (nextH - prevH); - float2 finalTextureCoords = mad(prevTCoords, weight, currentTextureCoords * (1.0 - weight)); - float2 difference = finalTextureCoords - uv; - uvsets += difference.xyxy; + curLayerHeight += NUM_PARALLAX_OCCLUSION_STEPS_RCP; + currentTextureCoords -= dtex; + heightFromTexture = 1 - tex.SampleGrad(sam, currentTextureCoords, uv_dx, uv_dy).r; + iter++; } + float2 prevTCoords = currentTextureCoords + dtex; + float nextH = heightFromTexture - curLayerHeight; + float prevH = 1 - tex.SampleGrad(sam, prevTCoords, uv_dx, uv_dy).r - curLayerHeight + NUM_PARALLAX_OCCLUSION_STEPS_RCP; + float weight = nextH / (nextH - prevH); + float2 finalTextureCoords = mad(prevTCoords, weight, currentTextureCoords * (1.0 - weight)); + float2 difference = finalTextureCoords - uv; + uvsets += difference.xyxy; +} + +inline float3 get_forward(float4x4 m) +{ + return float3(m[2][0], m[2][1], m[2][2]); +} +inline float3 get_up(float4x4 m) +{ + return float3(m[1][0], m[1][1], m[1][2]); +} +inline float3 get_right(float4x4 m) +{ + return float3(m[0][0], m[0][1], m[0][2]); } #endif // WI_SHADER_GLOBALS_HF diff --git a/WickedEngine/shaders/hairparticlePS.hlsl b/WickedEngine/shaders/hairparticlePS.hlsl index 379c251659a..f7b2e633585 100644 --- a/WickedEngine/shaders/hairparticlePS.hlsl +++ b/WickedEngine/shaders/hairparticlePS.hlsl @@ -44,6 +44,11 @@ float4 main(VertexToPixel input) : SV_Target { surface.occlusion *= bindless_textures_float[GetCamera().texture_ao_index].SampleLevel(sampler_linear_clamp, ScreenCoord, 0).r; } + [branch] + if (GetCamera().texture_ssgi_index >= 0) + { + surface.ssgi = bindless_textures[GetCamera().texture_ssgi_index].SampleLevel(sampler_linear_clamp, ScreenCoord, 0).rgb; + } #endif // CARTOON #endif // TRANSPARENT #endif // ENVMAPRENDERING diff --git a/WickedEngine/shaders/hbaoCS.hlsl b/WickedEngine/shaders/hbaoCS.hlsl index 68afbeddd5d..5c5dff827c4 100644 --- a/WickedEngine/shaders/hbaoCS.hlsl +++ b/WickedEngine/shaders/hbaoCS.hlsl @@ -10,11 +10,11 @@ RWTexture2D output : register(u0); // Step size in number of pixels #define STEP_SIZE 4 // Number of shared-memory samples per direction -#define NUM_STEPS 8 +#define NUM_STEPS 16 // The last sample has weight = exp(-KERNEL_FALLOFF) -#define KERNEL_FALLOFF 3.0f -#define TAN_ANGLE_BIAS 0 -#define DEPTH_FIX 2.0f +#define KERNEL_FALLOFF 2.0 +#define TAN_ANGLE_BIAS 0.1 +#define DEPTH_FIX 0.4 static const int TILE_BORDER = NUM_STEPS * STEP_SIZE; static const int CACHE_SIZE = TILE_BORDER + POSTPROCESS_HBAO_THREADCOUNT + TILE_BORDER; @@ -47,16 +47,14 @@ void IntegrateDirection(inout float ao, float2 P, float tanT, int threadId, int float tanH = tanT; float sinH = TanToSin(tanH); float sinT = TanToSin(tanT); - - [unroll] + for (int sampleId = 0; sampleId < NUM_STEPS; ++sampleId) { float2 S = cache[threadId + sampleId * deltaX + deltaX]; float2 V = S - P; float tanS = Tangent(V); float d2 = dot(V, V); - - [flatten] + if ((d2 < DEPTH_FIX) && (tanS > tanH)) { // Accumulate AO between the horizon and the sample diff --git a/WickedEngine/shaders/lightingHF.hlsli b/WickedEngine/shaders/lightingHF.hlsli index af0e4e81730..2a6c4d87041 100644 --- a/WickedEngine/shaders/lightingHF.hlsli +++ b/WickedEngine/shaders/lightingHF.hlsli @@ -36,7 +36,7 @@ struct Lighting inline void ApplyLighting(in Surface surface, in Lighting lighting, inout float4 color) { - float3 diffuse = lighting.direct.diffuse / PI + lighting.indirect.diffuse * GetFrame().gi_boost * (1 - surface.F) * surface.occlusion; + float3 diffuse = lighting.direct.diffuse / PI + lighting.indirect.diffuse * GetFrame().gi_boost * (1 - surface.F) * surface.occlusion + surface.ssgi; float3 specular = lighting.direct.specular + lighting.indirect.specular * surface.occlusion; // reminder: cannot apply surface.F for whole indirect specular, because multiple layers have separate fresnels (sheen, clearcoat) color.rgb = lerp(surface.albedo * diffuse, surface.refraction.rgb, surface.refraction.a); color.rgb += specular; diff --git a/WickedEngine/shaders/msao_preparedepthbuffers1CS.hlsl b/WickedEngine/shaders/msao_preparedepthbuffers1CS.hlsl index 585349c31c7..9cead021d1c 100644 --- a/WickedEngine/shaders/msao_preparedepthbuffers1CS.hlsl +++ b/WickedEngine/shaders/msao_preparedepthbuffers1CS.hlsl @@ -3,9 +3,9 @@ #include "globals.hlsli" #include "ShaderInterop_Postprocess.h" -RWTexture2D DS2x : register(u0); +RWTexture2D DS2x : register(u0); RWTexture2DArray DS2xAtlas : register(u1); -RWTexture2D DS4x : register(u2); +RWTexture2D DS4x : register(u2); RWTexture2DArray DS4xAtlas : register(u3); groupshared float g_CacheW[256]; @@ -13,12 +13,15 @@ groupshared float g_CacheW[256]; [numthreads(8, 8, 1)] void main(uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID) { + uint2 dim; + texture_lineardepth.GetDimensions(dim.x, dim.y); + uint2 startST = Gid.xy << 4 | GTid.xy; uint destIdx = GTid.y << 4 | GTid.x; - g_CacheW[destIdx + 0] = texture_lineardepth[startST | uint2(0, 0)]; - g_CacheW[destIdx + 8] = texture_lineardepth[startST | uint2(8, 0)]; - g_CacheW[destIdx + 128] = texture_lineardepth[startST | uint2(0, 8)]; - g_CacheW[destIdx + 136] = texture_lineardepth[startST | uint2(8, 8)]; + g_CacheW[destIdx + 0] = texture_lineardepth[min(startST | uint2(0, 0), dim - 1)]; + g_CacheW[destIdx + 8] = texture_lineardepth[min(startST | uint2(8, 0), dim - 1)]; + g_CacheW[destIdx + 128] = texture_lineardepth[min(startST | uint2(0, 8), dim - 1)]; + g_CacheW[destIdx + 136] = texture_lineardepth[min(startST | uint2(8, 8), dim - 1)]; GroupMemoryBarrierWithGroupSync(); diff --git a/WickedEngine/shaders/msao_preparedepthbuffers2CS.hlsl b/WickedEngine/shaders/msao_preparedepthbuffers2CS.hlsl index 04482c9aa5f..a932f6090c7 100644 --- a/WickedEngine/shaders/msao_preparedepthbuffers2CS.hlsl +++ b/WickedEngine/shaders/msao_preparedepthbuffers2CS.hlsl @@ -13,7 +13,10 @@ RWTexture2DArray DS16xAtlas : register(u3); [numthreads(8, 8, 1)] void main(uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID) { - float m1 = DS4x[DTid.xy << 1]; + uint2 dim; + DS4x.GetDimensions(dim.x, dim.y); + + float m1 = DS4x[min(DTid.xy << 1, dim - 1)]; uint2 st = DTid.xy; uint2 stAtlas = st >> 2; diff --git a/WickedEngine/shaders/objectHF.hlsli b/WickedEngine/shaders/objectHF.hlsli index 33cd3441292..813f8720d37 100644 --- a/WickedEngine/shaders/objectHF.hlsli +++ b/WickedEngine/shaders/objectHF.hlsli @@ -233,13 +233,11 @@ struct VertexSurface } normal = mul((float3x3)input.GetInstance().transformInverseTranspose.GetMatrix(), normal); + normal = any(normal) ? normalize(normal) : 0; tangent = input.GetTangent(); tangent.xyz = mul((min16float3x3)input.GetInstance().transformInverseTranspose.GetMatrix(), tangent.xyz); - - // Note: normalization must happen when normal is exported as half precision for interpolator! - normal = any(normal) ? normalize(normal) : 0; - tangent = any(tangent) ? normalize(tangent) : 0; + tangent.xyz = any(tangent.xyz) ? normalize(tangent.xyz) : 0; uvsets = input.GetUVSets(); @@ -512,9 +510,11 @@ float4 main(PixelInput input, in bool is_frontface : SV_IsFrontFace) : SV_Target input.tan = -input.tan; } surface.T = input.tan; + surface.T.w = surface.T.w < 0 ? -1 : 1; + float3 bitangent = cross(surface.T.xyz, input.nor) * surface.T.w; + float3x3 TBN = float3x3(surface.T.xyz, bitangent, input.nor); // unnormalized TBN! http://www.mikktspace.com/ + surface.T.xyz = normalize(surface.T.xyz); - float3 binormal = normalize(cross(surface.T.xyz, surface.N) * surface.T.w); - float3x3 TBN = float3x3(surface.T.xyz, binormal, surface.N); #endif #ifdef PARALLAXOCCLUSIONMAPPING @@ -530,7 +530,7 @@ float4 main(PixelInput input, in bool is_frontface : SV_IsFrontFace) : SV_Target uvsets, surface.V, TBN, - GetMaterial(), + GetMaterial().parallaxOcclusionMapping, tex, uv, uv_dx, @@ -580,7 +580,7 @@ float4 main(PixelInput input, in bool is_frontface : SV_IsFrontFace) : SV_Target #ifndef WATER #ifdef OBJECTSHADER_USE_TANGENT [branch] - if (GetMaterial().normalMapStrength > 0 && GetMaterial().textures[NORMALMAP].IsValid()) + if (GetMaterial().textures[NORMALMAP].IsValid()) { surface.bumpColor = float3(GetMaterial().textures[NORMALMAP].Sample(sampler_objectshader, uvsets).rg, 1); surface.bumpColor = surface.bumpColor * 2 - 1; @@ -633,7 +633,7 @@ float4 main(PixelInput input, in bool is_frontface : SV_IsFrontFace) : SV_Target [branch] if (any(surface.bumpColor)) { - surface.N = normalize(lerp(surface.N, mul(surface.bumpColor, TBN), length(surface.bumpColor))); + surface.N = normalize(mul(surface.bumpColor, TBN)); } #endif // OBJECTSHADER_USE_TANGENT #endif // WATER @@ -805,7 +805,7 @@ float4 main(PixelInput input, in bool is_frontface : SV_IsFrontFace) : SV_Target } surface.bumpColor = float3(bumpColor0 + bumpColor1 + bumpColor2, 1) * GetMaterial().refraction; surface.N = normalize(lerp(surface.N, mul(normalize(surface.bumpColor), TBN), GetMaterial().normalMapStrength)); - surface.bumpColor *= GetMaterial().normalMapStrength; + surface.bumpColor.rg *= GetMaterial().normalMapStrength; [branch] if (GetCamera().texture_reflection_index >= 0) @@ -892,6 +892,11 @@ float4 main(PixelInput input, in bool is_frontface : SV_IsFrontFace) : SV_Target float4 ssr = bindless_textures[GetCamera().texture_ssr_index].SampleLevel(sampler_linear_clamp, ScreenCoord, 0); lighting.indirect.specular = lerp(lighting.indirect.specular, ssr.rgb * surface.F, ssr.a); } + [branch] + if (GetCamera().texture_ssgi_index >= 0) + { + surface.ssgi = bindless_textures[GetCamera().texture_ssgi_index].SampleLevel(sampler_linear_clamp, ScreenCoord, 0).rgb; + } #endif // CARTOON #endif // TRANSPARENT #endif // ENVMAPRENDERING diff --git a/WickedEngine/shaders/paint_textureCS.hlsl b/WickedEngine/shaders/paint_textureCS.hlsl index e8252e8fb88..f9ff65e4caa 100644 --- a/WickedEngine/shaders/paint_textureCS.hlsl +++ b/WickedEngine/shaders/paint_textureCS.hlsl @@ -1,18 +1,15 @@ #include "globals.hlsli" #include "ShaderInterop_Renderer.h" -PUSHCONSTANT(push, PaintTextureCB); - -Texture2D texture_brush : register(t0); -Texture2D texture_reveal : register(t1); - -RWTexture2D output : register(u0); +PUSHCONSTANT(push, PaintTexturePushConstants); [numthreads(PAINT_TEXTURE_BLOCKSIZE, PAINT_TEXTURE_BLOCKSIZE, 1)] void main( uint3 DTid : SV_DispatchThreadID ) { + RWTexture2D texture_output = bindless_rwtextures[push.texture_output]; + float2 dim; - output.GetDimensions(dim.x, dim.y); + texture_output.GetDimensions(dim.x, dim.y); const uint2 pixelUnwrapped = push.xPaintBrushCenter + DTid.xy - push.xPaintBrushRadius.xx; const uint2 pixel = pixelUnwrapped % dim.xy; @@ -36,32 +33,50 @@ void main( uint3 DTid : SV_DispatchThreadID ) radius /= SQRT2; break; } + + float4 brush_color = 1; - const float2 brush_uv = (diff / radius) * float2(0.5, -0.5) + 0.5; - const float2 brush_uv_quad_x = QuadReadAcrossX(brush_uv); - const float2 brush_uv_quad_y = QuadReadAcrossY(brush_uv); - const float2 brush_uv_dx = brush_uv - brush_uv_quad_x; - const float2 brush_uv_dy = brush_uv - brush_uv_quad_y; - float4 brush_color = texture_brush.SampleGrad(sampler_linear_clamp, brush_uv, brush_uv_dx, brush_uv_dy) * unpack_rgba(push.xPaintBrushColor); + [branch] + if(push.texture_brush >= 0) + { + Texture2D texture_brush = bindless_textures[push.texture_brush]; + const float2 brush_uv = (diff / radius) * float2(0.5, -0.5) + 0.5; + const float2 brush_uv_quad_x = QuadReadAcrossX(brush_uv); + const float2 brush_uv_quad_y = QuadReadAcrossY(brush_uv); + const float2 brush_uv_dx = brush_uv - brush_uv_quad_x; + const float2 brush_uv_dy = brush_uv - brush_uv_quad_y; + brush_color *= texture_brush.SampleGrad(sampler_linear_clamp, brush_uv, brush_uv_dx, brush_uv_dy); + } - const float2 reveal_uv = (pixel + 0.5) / dim; - const float2 reveal_uv_quad_x = QuadReadAcrossX(reveal_uv); - const float2 reveal_uv_quad_y = QuadReadAcrossY(reveal_uv); - const float2 reveal_uv_dx = reveal_uv - reveal_uv_quad_x; - const float2 reveal_uv_dy = reveal_uv - reveal_uv_quad_y; - float4 reveal_color = texture_reveal.SampleGrad(sampler_linear_clamp, reveal_uv, reveal_uv_dx, reveal_uv_dy); + [branch] + if(push.texture_reveal >= 0) + { + Texture2D texture_reveal = bindless_textures[push.texture_reveal]; + const float2 reveal_uv = (pixel + 0.5) / dim; + const float2 reveal_uv_quad_x = QuadReadAcrossX(reveal_uv); + const float2 reveal_uv_quad_y = QuadReadAcrossY(reveal_uv); + const float2 reveal_uv_dx = reveal_uv - reveal_uv_quad_x; + const float2 reveal_uv_dy = reveal_uv - reveal_uv_quad_y; + brush_color *= texture_reveal.SampleGrad(sampler_linear_clamp, reveal_uv, reveal_uv_dx, reveal_uv_dy); + } const float affection = push.xPaintBrushAmount * smoothstep(0, push.xPaintBrushSmoothness, 1 - dist / radius); if (affection > 0 && dist < radius) { - if (push.xPaintReveal) + brush_color.a *= affection; + brush_color *= unpack_rgba(push.xPaintBrushColor); + float4 prevColor = texture_output[pixel]; + float4 color = 0; + if(push.xPaintRedirectAlpha) + { + color.rgb = prevColor.rgb; + color.a = prevColor.a * (1 - brush_color.a) + brush_color.r * brush_color.a; + } + else { - brush_color *= reveal_color; + color.rgb = prevColor.rgb * (1 - brush_color.a) + brush_color.rgb * brush_color.a; + color.a = prevColor.a * (1 - brush_color.a) + brush_color.a; } - output[pixel] = lerp(output[pixel], brush_color, affection); + texture_output[pixel] = color; } - //else - //{ - // output[pixel] = float4(1,0,0,1); - //} } diff --git a/WickedEngine/shaders/rtdiffuse_bilateralCS.hlsl b/WickedEngine/shaders/rtdiffuse_upsampleCS.hlsl similarity index 54% rename from WickedEngine/shaders/rtdiffuse_bilateralCS.hlsl rename to WickedEngine/shaders/rtdiffuse_upsampleCS.hlsl index 8ef7cc5d506..f95efd68e77 100644 --- a/WickedEngine/shaders/rtdiffuse_bilateralCS.hlsl +++ b/WickedEngine/shaders/rtdiffuse_upsampleCS.hlsl @@ -13,7 +13,7 @@ static const float depthThreshold = 10000.0; static const float normalThreshold = 1.0; static const float varianceEstimateThreshold = 0.015; // Larger variance values use stronger blur static const float varianceExitThreshold = 0.0025; // Variance needs to be higher than this value to accept blur -static const uint2 bilateralMinMaxRadius = uint2(4, 8); // Chosen by variance +static const uint2 bilateralMinMaxRadius = uint2(0, 8); // Chosen by variance #define BILATERAL_SIGMA 0.9 @@ -22,8 +22,6 @@ void main(uint3 DTid : SV_DispatchThreadID) { const float depth = texture_depth[DTid.xy]; - float2 direction = postprocess.params0.xy; - const float linearDepth = texture_lineardepth[DTid.xy]; const float3 N = decode_oct(texture_normal[DTid.xy]); @@ -49,37 +47,41 @@ void main(uint3 DTid : SV_DispatchThreadID) float4 result = 0; float weightSum = 0.0f; - for (int r = -effectiveRadius; r <= effectiveRadius; r++) + for(uint d = 0; d < 2; ++d) { - const int2 sampleCoord = DTid.xy + (direction * r); // Left to right diameter directionally - - if (all(and(sampleCoord >= int2(0, 0), sampleCoord < (int2) postprocess.resolution))) + const int2 direction = d < 1 ? int2(1, 0) : int2(0, 1); + for (int r = -effectiveRadius; r <= effectiveRadius; r++) { - const float sampleDepth = texture_depth[sampleCoord]; + const int2 sampleCoord = DTid.xy + (direction * r); // Left to right diameter directionally - float2 sampleUV = (sampleCoord + 0.5) * postprocess.resolution_rcp; - const float4 sampleColor = texture_temporal.SampleLevel(sampler_linear_clamp, sampleUV, 0); + if (all(and(sampleCoord >= int2(0, 0), sampleCoord < (int2) postprocess.resolution))) + { + const float sampleDepth = texture_depth[sampleCoord]; - const float3 sampleN = decode_oct(texture_normal[sampleCoord]); + float2 sampleUV = (sampleCoord + 0.5) * postprocess.resolution_rcp; + const float4 sampleColor = texture_temporal.SampleLevel(sampler_linear_clamp, sampleUV, 0); - float3 sampleP = reconstruct_position(sampleUV, sampleDepth); + const float3 sampleN = decode_oct(texture_normal[sampleCoord]); - { - float3 dq = P - sampleP; - float planeError = max(abs(dot(dq, sampleN)), abs(dot(dq, N))); - float relativeDepthDifference = planeError / (linearDepth * GetCamera().z_far); - float bilateralDepthWeight = exp(-sqr(relativeDepthDifference) * depthThreshold); + float3 sampleP = reconstruct_position(sampleUV, sampleDepth); + + { + float3 dq = P - sampleP; + float planeError = max(abs(dot(dq, sampleN)), abs(dot(dq, N))); + float relativeDepthDifference = planeError / (linearDepth * GetCamera().z_far); + float bilateralDepthWeight = exp(-sqr(relativeDepthDifference) * depthThreshold); - float normalError = pow(saturate(dot(sampleN, N)), 4.0); - float bilateralNormalWeight = saturate(1.0 - (1.0 - normalError) * normalThreshold); + float normalError = pow(saturate(dot(sampleN, N)), 4.0); + float bilateralNormalWeight = saturate(1.0 - (1.0 - normalError) * normalThreshold); - float bilateralWeight = bilateralDepthWeight * bilateralNormalWeight; + float bilateralWeight = bilateralDepthWeight * bilateralNormalWeight; - float gaussian = exp(-sqr(r / sigma)); - float weight = (r == 0) ? 1.0 : gaussian * bilateralWeight; // Skip center gaussian peak + float gaussian = exp(-sqr(r / sigma)); + float weight = (r == 0) ? 1.0 : gaussian * bilateralWeight; // Skip center gaussian peak - result += sampleColor * weight; - weightSum += weight; + result += sampleColor * weight; + weightSum += weight; + } } } } diff --git a/WickedEngine/shaders/shadingHF.hlsli b/WickedEngine/shaders/shadingHF.hlsli index bea418b8890..36dd68155ed 100644 --- a/WickedEngine/shaders/shadingHF.hlsli +++ b/WickedEngine/shaders/shadingHF.hlsli @@ -198,10 +198,10 @@ inline void ForwardDecals(inout Surface surface, inout float4 surfaceMap, Sample continue; float4x4 decalProjection = load_entitymatrix(decal.GetMatrixIndex()); - int decalTexture = asint(decalProjection[3][0]); - int decalNormal = asint(decalProjection[3][1]); - float decalNormalStrength = decalProjection[3][2]; - int decalSurfacemap = asint(decalProjection[3][3]); + const int decalTexture = asint(decalProjection[3][0]); + const int decalNormal = asint(decalProjection[3][1]); + const int decalSurfacemap = asint(decalProjection[3][2]); + const int decalDisplacementmap = asint(decalProjection[3][3]); decalProjection[3] = float4(0, 0, 0, 1); // under here will be VGPR! @@ -223,6 +223,27 @@ inline void ForwardDecals(inout Surface surface, inout float4 surfaceMap, Sample const float slopeBlend = decal.GetConeAngleCos() > 0 ? pow(saturate(dot(surface.N, decal.GetDirection())), decal.GetConeAngleCos()) : 1; decalColor.a *= edgeBlend * slopeBlend; [branch] + if (decalDisplacementmap >= 0) + { + const float3 t = get_right(decalProjection); + const float3 b = -get_up(decalProjection); + const float3 n = surface.N; + const float3x3 tbn = float3x3(t, b, n); + float4 inoutuv = uvw.xyxy; + ParallaxOcclusionMapping_Impl( + inoutuv, + surface.V, + tbn, + decal.GetLength(), + bindless_textures[decalDisplacementmap], + uvw.xy, + decalDX, + decalDY, + sampler_linear_clamp + ); + uvw.xy = saturate(inoutuv.xy); + } + [branch] if (decalTexture >= 0) { decalColor *= bindless_textures[decalTexture].SampleGrad(sam, uvw.xy, decalDX, decalDY); @@ -239,7 +260,7 @@ inline void ForwardDecals(inout Surface surface, inout float4 surfaceMap, Sample { float3 decalBumpColor = float3(bindless_textures[decalNormal].SampleGrad(sam, uvw.xy, decalDX, decalDY).rg, 1); decalBumpColor = decalBumpColor * 2 - 1; - decalBumpColor.rg *= decalNormalStrength; + decalBumpColor.rg *= decal.GetAngleScale(); decalBumpAccumulation.rgb = mad(1 - decalBumpAccumulation.a, decalColor.a * decalBumpColor.rgb, decalBumpAccumulation.rgb); decalBumpAccumulation.a = mad(1 - decalColor.a, decalBumpAccumulation.a, decalColor.a); } @@ -547,10 +568,10 @@ inline void TiledDecals(inout Surface surface, uint flatTileIndex, inout float4 continue; float4x4 decalProjection = load_entitymatrix(decal.GetMatrixIndex()); - int decalTexture = asint(decalProjection[3][0]); - int decalNormal = asint(decalProjection[3][1]); - float decalNormalStrength = decalProjection[3][2]; - int decalSurfacemap = asint(decalProjection[3][3]); + const int decalTexture = asint(decalProjection[3][0]); + const int decalNormal = asint(decalProjection[3][1]); + const int decalSurfacemap = asint(decalProjection[3][2]); + const int decalDisplacementmap = asint(decalProjection[3][3]); decalProjection[3] = float4(0, 0, 0, 1); // under here will be VGPR! @@ -572,6 +593,27 @@ inline void TiledDecals(inout Surface surface, uint flatTileIndex, inout float4 const float slopeBlend = decal.GetConeAngleCos() > 0 ? pow(saturate(dot(surface.N, decal.GetDirection())), decal.GetConeAngleCos()) : 1; decalColor.a *= edgeBlend * slopeBlend; [branch] + if (decalDisplacementmap >= 0) + { + const float3 t = get_right(decalProjection); + const float3 b = -get_up(decalProjection); + const float3 n = surface.N; + const float3x3 tbn = float3x3(t, b, n); + float4 inoutuv = uvw.xyxy; + ParallaxOcclusionMapping_Impl( + inoutuv, + surface.V, + tbn, + decal.GetLength(), + bindless_textures[decalDisplacementmap], + uvw.xy, + decalDX, + decalDY, + sampler_linear_clamp + ); + uvw.xy = saturate(inoutuv.xy); + } + [branch] if (decalTexture >= 0) { decalColor *= bindless_textures[decalTexture].SampleGrad(sam, uvw.xy, decalDX, decalDY); @@ -588,7 +630,7 @@ inline void TiledDecals(inout Surface surface, uint flatTileIndex, inout float4 { float3 decalBumpColor = float3(bindless_textures[decalNormal].SampleGrad(sam, uvw.xy, decalDX, decalDY).rg, 1); decalBumpColor = decalBumpColor * 2 - 1; - decalBumpColor.rg *= decalNormalStrength; + decalBumpColor.rg *= decal.GetAngleScale(); decalBumpAccumulation.rgb = mad(1 - decalBumpAccumulation.a, decalColor.a * decalBumpColor.rgb, decalBumpAccumulation.rgb); decalBumpAccumulation.a = mad(1 - decalColor.a, decalBumpAccumulation.a, decalColor.a); } diff --git a/WickedEngine/shaders/ssgiCS.hlsl b/WickedEngine/shaders/ssgiCS.hlsl new file mode 100644 index 00000000000..d4aaa398c1d --- /dev/null +++ b/WickedEngine/shaders/ssgiCS.hlsl @@ -0,0 +1,191 @@ +#include "globals.hlsli" +#include "stochasticSSRHF.hlsli" +#include "ShaderInterop_Postprocess.h" + +PUSHCONSTANT(postprocess, PostProcess); + +Texture2DArray input_depth : register(t0); +Texture2DArray input_color : register(t1); +Texture2D input_normal : register(t2); + +RWTexture2D output_diffuse : register(u0); + +#ifdef WIDE +static const uint THREADCOUNT = 16; +static const int TILE_BORDER = 16; +#else +static const uint THREADCOUNT = 8; +static const int TILE_BORDER = 4; +#endif // WIDE +static const int TILE_SIZE = TILE_BORDER + THREADCOUNT + TILE_BORDER; +groupshared uint cache_xy[TILE_SIZE * TILE_SIZE]; +groupshared float cache_z[TILE_SIZE * TILE_SIZE]; +groupshared uint cache_rgb[TILE_SIZE * TILE_SIZE]; +groupshared uint group_valid; + +inline uint coord_to_cache(int2 coord) +{ + return flatten2D(clamp(coord, 0, TILE_SIZE - 1), TILE_SIZE); +} + +float3 compute_diffuse( + float3 origin_position, + float3 origin_normal, + int2 originLoc, // coord in cache + int2 sampleLoc // coord in cache +) +{ + const uint t = coord_to_cache(sampleLoc); + uint c = cache_rgb[t]; + if(c == 0) + return 0; // early exit if pixel doesn't have lighting + float3 sample_position; + sample_position.z = cache_z[t]; + sample_position.xy = unpack_half2(cache_xy[t]); + const float3 origin_to_sample = sample_position - origin_position; + float occlusion = saturate(dot(origin_normal, origin_to_sample)); // normal falloff + occlusion *= saturate(1 + origin_to_sample.z * postprocess.params0.w); // depth rejection + + if(occlusion > 0) + { + const float origin_z = origin_position.z; + const float sample_z = sample_position.z; + + // DDA occlusion: + const int2 start = originLoc; + const int2 goal = sampleLoc; + + const int dx = int(goal.x) - int(start.x); + const int dy = int(goal.y) - int(start.y); + + int step = max(abs(dx), abs(dy)); + step = (step + 1) / 2; // reduce steps + const float step_rcp = rcp(step); + + const float x_incr = float(dx) * step_rcp; + const float y_incr = float(dy) * step_rcp; + + float x = float(start.x); + float y = float(start.y); + + for (int i = 0; i < step - 1; i++) + { + x += x_incr; + y += y_incr; + + const int2 loc = int2(x, y); + const uint tt = coord_to_cache(loc); + + const float dt = float(i) / float(step); + const float z = lerp(origin_z, sample_z, dt); + + const float sz = cache_z[tt]; + if(sz < z - 0.1) + { + c = cache_rgb[tt]; + break; + } + } + } + + return occlusion * Unpack_R11G11B10_FLOAT(c); +} + +[numthreads(THREADCOUNT, THREADCOUNT, 1)] +void main(uint3 DTid : SV_DispatchThreadID, uint3 Gid : SV_GroupID, uint2 GTid : SV_GroupThreadID, uint groupIndex : SV_GroupIndex) +{ + const uint layer = DTid.z; + const uint2 interleaved_pixel = DTid.xy << 2 | uint2(DTid.z & 3, DTid.z >> 2); + + if(groupIndex == 0) + { + group_valid = 0; + } + GroupMemoryBarrierWithGroupSync(); + + const int2 tile_upperleft = Gid.xy * THREADCOUNT - TILE_BORDER; + for(uint x = GTid.x * 2; x < TILE_SIZE; x += THREADCOUNT * 2) + for(uint y = GTid.y * 2; y < TILE_SIZE; y += THREADCOUNT * 2) + { + const int2 pixel = tile_upperleft + int2(x, y); + const float3 uvw = float3((pixel + 0.5f) * postprocess.resolution_rcp, layer); + const float4 depths = input_depth.GatherRed(sampler_linear_clamp, uvw); + const float4 reds = input_color.GatherRed(sampler_linear_clamp, uvw); + const float4 greens = input_color.GatherGreen(sampler_linear_clamp, uvw); + const float4 blues = input_color.GatherBlue(sampler_linear_clamp, uvw); + const float2 uv0 = (pixel + 0.5 + int2(0, 0)) * postprocess.resolution_rcp; + const float2 uv1 = (pixel + 0.5 + int2(1, 0)) * postprocess.resolution_rcp; + const float2 uv2 = (pixel + 0.5 + int2(0, 1)) * postprocess.resolution_rcp; + const float2 uv3 = (pixel + 0.5 + int2(1, 1)) * postprocess.resolution_rcp; + const float3 P0 = reconstruct_position(uv0, depths.w, GetCamera().inverse_projection); + const float3 P1 = reconstruct_position(uv1, depths.z, GetCamera().inverse_projection); + const float3 P2 = reconstruct_position(uv2, depths.x, GetCamera().inverse_projection); + const float3 P3 = reconstruct_position(uv3, depths.y, GetCamera().inverse_projection); + const uint C0 = Pack_R11G11B10_FLOAT(float3(reds.w, greens.w, blues.w)); + const uint C1 = Pack_R11G11B10_FLOAT(float3(reds.z, greens.z, blues.z)); + const uint C2 = Pack_R11G11B10_FLOAT(float3(reds.x, greens.x, blues.x)); + const uint C3 = Pack_R11G11B10_FLOAT(float3(reds.y, greens.y, blues.y)); + + const uint t = coord_to_cache(int2(x, y)); + cache_xy[t] = pack_half2(P0.xy); + cache_z[t] = P0.z; + cache_rgb[t] = C0; + + cache_xy[t + 1] = pack_half2(P1.xy); + cache_z[t + 1] = P1.z; + cache_rgb[t + 1] = C1; + + cache_xy[t + TILE_SIZE] = pack_half2(P2.xy); + cache_z[t + TILE_SIZE] = P2.z; + cache_rgb[t + TILE_SIZE] = C2; + + cache_xy[t + TILE_SIZE + 1] = pack_half2(P3.xy); + cache_z[t + TILE_SIZE + 1] = P3.z; + cache_rgb[t + TILE_SIZE + 1] = C3; + + if(C0 || C1 || C2 || C3) + InterlockedOr(group_valid, 1u); + } + GroupMemoryBarrierWithGroupSync(); + + [branch] + if (group_valid == 0) + return; // if no valid color was cached, whole group can exit early + + const int2 originLoc = GTid.xy + TILE_BORDER; + const uint t = coord_to_cache(originLoc); + float3 P; + P.z = cache_z[t]; + + [branch] + if(P.z > GetCamera().z_far - 1) + return; // if pixel depth is not valid, it can exit early + + P.xy = unpack_half2(cache_xy[t]); + + const float3 N = mul((float3x3)GetCamera().view, decode_oct(input_normal[interleaved_pixel].rg)); + + float3 diffuse = 0; + float sum = 0; + const int range = int(postprocess.params0.x); + const float spread = postprocess.params0.y /*+ dither(DTid.xy)*/; + const float rangespread_rcp2 = postprocess.params0.z; + + for(int x = -range; x <= range; ++x) + { + for(int y = -range; y <= range; ++y) + { + const int2 offset = int2(x, y) * spread; + const float weight = saturate(1 - abs(offset.x) * abs(offset.y) * rangespread_rcp2); + diffuse += compute_diffuse(P, N, originLoc, originLoc + offset) * weight; + sum += weight; + } + } + if(sum > 0) + { + diffuse = diffuse / sum; + } + + // interleave result: + output_diffuse[interleaved_pixel] = float4(diffuse, 1); +} diff --git a/WickedEngine/shaders/ssgi_deinterleaveCS.hlsl b/WickedEngine/shaders/ssgi_deinterleaveCS.hlsl new file mode 100644 index 00000000000..70339af0451 --- /dev/null +++ b/WickedEngine/shaders/ssgi_deinterleaveCS.hlsl @@ -0,0 +1,112 @@ +#include "globals.hlsli" +#include "ShaderInterop_Postprocess.h" + +Texture2D texture_input : register(t0); + +RWTexture2DArray atlas2x_depth : register(u0); +RWTexture2DArray atlas4x_depth : register(u1); +RWTexture2DArray atlas8x_depth : register(u2); +RWTexture2DArray atlas16x_depth : register(u3); +RWTexture2DArray atlas2x_color : register(u4); +RWTexture2DArray atlas4x_color : register(u5); +RWTexture2DArray atlas8x_color : register(u6); +RWTexture2DArray atlas16x_color : register(u7); +RWTexture2D regular2x_depth : register(u8); +RWTexture2D regular4x_depth : register(u9); +RWTexture2D regular8x_depth : register(u10); +RWTexture2D regular16x_depth : register(u11); +RWTexture2D regular2x_normal : register(u12); +RWTexture2D regular4x_normal : register(u13); +RWTexture2D regular8x_normal : register(u14); +RWTexture2D regular16x_normal : register(u15); + +groupshared float shared_depths[256]; +groupshared uint shared_normals[256]; +groupshared uint shared_colors[256]; + +[numthreads(8, 8, 1)] +void main(uint3 Gid : SV_GroupID, uint groupIndex : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID) +{ + uint2 dim; + texture_depth.GetDimensions(dim.x, dim.y); + const float2 dim_rcp = rcp(dim); + + uint2 startST = Gid.xy << 4 | GTid.xy; + uint destIdx = GTid.y << 4 | GTid.x; + shared_depths[destIdx + 0] = texture_depth[min(startST | uint2(0, 0), dim - 1)]; + shared_depths[destIdx + 8] = texture_depth[min(startST | uint2(8, 0), dim - 1)]; + shared_depths[destIdx + 128] = texture_depth[min(startST | uint2(0, 8), dim - 1)]; + shared_depths[destIdx + 136] = texture_depth[min(startST | uint2(8, 8), dim - 1)]; + + shared_normals[destIdx + 0] = pack_half2(texture_normal[min(startST | uint2(0, 0), dim - 1)]); + shared_normals[destIdx + 8] = pack_half2(texture_normal[min(startST | uint2(8, 0), dim - 1)]); + shared_normals[destIdx + 128] = pack_half2(texture_normal[min(startST | uint2(0, 8), dim - 1)]); + shared_normals[destIdx + 136] = pack_half2(texture_normal[min(startST | uint2(8, 8), dim - 1)]); + + const float2 uv0 = float2(startST | uint2(0, 0)) * dim_rcp; + const float2 uv1 = float2(startST | uint2(8, 0)) * dim_rcp; + const float2 uv2 = float2(startST | uint2(0, 8)) * dim_rcp; + const float2 uv3 = float2(startST | uint2(8, 8)) * dim_rcp; + const float2 velocity0 = texture_velocity[min(startST | uint2(0, 0), dim - 1)]; + const float2 velocity1 = texture_velocity[min(startST | uint2(8, 0), dim - 1)]; + const float2 velocity2 = texture_velocity[min(startST | uint2(0, 8), dim - 1)]; + const float2 velocity3 = texture_velocity[min(startST | uint2(8, 8), dim - 1)]; + const float2 prevUV0 = uv0 + velocity0; + const float2 prevUV1 = uv1 + velocity1; + const float2 prevUV2 = uv2 + velocity2; + const float2 prevUV3 = uv3 + velocity3; + shared_colors[destIdx + 0] = Pack_R11G11B10_FLOAT(texture_input.SampleLevel(sampler_linear_clamp, prevUV0, 0)); + shared_colors[destIdx + 8] = Pack_R11G11B10_FLOAT(texture_input.SampleLevel(sampler_linear_clamp, prevUV1, 0)); + shared_colors[destIdx + 128] = Pack_R11G11B10_FLOAT(texture_input.SampleLevel(sampler_linear_clamp, prevUV2, 0)); + shared_colors[destIdx + 136] = Pack_R11G11B10_FLOAT(texture_input.SampleLevel(sampler_linear_clamp, prevUV3, 0)); + + GroupMemoryBarrierWithGroupSync(); + + uint ldsIndex = (GTid.x << 1) | (GTid.y << 5); + + float depth = shared_depths[ldsIndex]; + float2 normal = unpack_half2(shared_normals[ldsIndex]); + float3 color = Unpack_R11G11B10_FLOAT(shared_colors[ldsIndex]); + + color = color - 0.2; // cut out pixels that shouldn't act as lights + color *= 0.9; // accumulation energy loss + color = max(0, color); + + uint2 st = DTid.xy; + uint slice = flatten2D(st % 4, 4); + atlas2x_depth[uint3(st >> 2, slice)] = depth; + atlas2x_color[uint3(st >> 2, slice)] = color; + regular2x_depth[st] = depth; + regular2x_normal[st] = normal; + + if (all(GTid.xy % 2) == 0) + { + st = DTid.xy >> 1; + slice = flatten2D(st % 4, 4); + atlas4x_depth[uint3(st >> 2, slice)] = depth; + atlas4x_color[uint3(st >> 2, slice)] = color; + regular4x_depth[st] = depth; + regular4x_normal[st] = normal; + + if (all(GTid.xy % 4) == 0) + { + st = DTid.xy >> 2; + slice = flatten2D(st % 4, 4); + atlas8x_depth[uint3(st >> 2, slice)] = depth; + atlas8x_color[uint3(st >> 2, slice)] = color; + regular8x_depth[st] = depth; + regular8x_normal[st] = normal; + + if (groupIndex == 0) + { + st = DTid.xy >> 3; + slice = flatten2D(st % 4, 4); + atlas16x_depth[uint3(st >> 2, slice)] = depth; + atlas16x_color[uint3(st >> 2, slice)] = color; + regular16x_depth[st] = depth; + regular16x_normal[st] = normal; + } + } + } + +} diff --git a/WickedEngine/shaders/ssgi_upsampleCS.hlsl b/WickedEngine/shaders/ssgi_upsampleCS.hlsl new file mode 100644 index 00000000000..bfb551cc763 --- /dev/null +++ b/WickedEngine/shaders/ssgi_upsampleCS.hlsl @@ -0,0 +1,146 @@ +#include "globals.hlsli" +#include "stochasticSSRHF.hlsli" +#include "ShaderInterop_Postprocess.h" + +PUSHCONSTANT(postprocess, PostProcess); + +Texture2D input_depth_low : register(t0); +Texture2D input_normal_low : register(t1); +Texture2D input_diffuse_low : register(t2); +Texture2D input_depth_high : register(t3); +Texture2D input_normal_high : register(t4); + +RWTexture2D output : register(u0); + +#ifdef WIDE +static const uint THREADCOUNT = POSTPROCESS_BLOCKSIZE; +static const int TILE_BORDER = 6; +#else +static const uint THREADCOUNT = POSTPROCESS_BLOCKSIZE; +static const int TILE_BORDER = 2; +#endif // WIDE +static const int TILE_SIZE = TILE_BORDER + THREADCOUNT + TILE_BORDER; +groupshared float cache_z[TILE_SIZE * TILE_SIZE]; +groupshared uint cache_rgb[TILE_SIZE * TILE_SIZE]; +groupshared uint cache_oct[TILE_SIZE * TILE_SIZE]; + +inline uint coord_to_cache(int2 coord) +{ + return flatten2D(clamp(coord, 0, TILE_SIZE - 1), TILE_SIZE); +} + +static const float depthThreshold = 0.1; +static const float normalThreshold = 64; + +[numthreads(POSTPROCESS_BLOCKSIZE, POSTPROCESS_BLOCKSIZE, 1)] +void main(uint2 Gid : SV_GroupID, uint groupIndex : SV_GroupIndex) +{ + const uint2 GTid = remap_lane_8x8(groupIndex); + + const int2 tile_upperleft = Gid.xy * THREADCOUNT / 2 - TILE_BORDER; + for(uint x = GTid.x * 2; x < TILE_SIZE; x += THREADCOUNT * 2) + for(uint y = GTid.y * 2; y < TILE_SIZE; y += THREADCOUNT * 2) + { + const int2 pixel = tile_upperleft + int2(x, y); + const float2 uv = (pixel + 0.5f) * postprocess.params1.zw; + const float4 depths = input_depth_low.GatherRed(sampler_linear_clamp, uv); + const float4 reds = input_diffuse_low.GatherRed(sampler_linear_clamp, uv); + const float4 greens = input_diffuse_low.GatherGreen(sampler_linear_clamp, uv); + const float4 blues = input_diffuse_low.GatherBlue(sampler_linear_clamp, uv); + const float4 xxxx = input_normal_low.GatherRed(sampler_linear_clamp, uv); + const float4 yyyy = input_normal_low.GatherGreen(sampler_linear_clamp, uv); + const float Z0 = compute_lineardepth(depths.w); + const float Z1 = compute_lineardepth(depths.z); + const float Z2 = compute_lineardepth(depths.x); + const float Z3 = compute_lineardepth(depths.y); + const uint C0 = Pack_R11G11B10_FLOAT(float3(reds.w, greens.w, blues.w)); + const uint C1 = Pack_R11G11B10_FLOAT(float3(reds.z, greens.z, blues.z)); + const uint C2 = Pack_R11G11B10_FLOAT(float3(reds.x, greens.x, blues.x)); + const uint C3 = Pack_R11G11B10_FLOAT(float3(reds.y, greens.y, blues.y)); + const uint OCT0 = pack_half2(float2(xxxx.w, yyyy.w)); + const uint OCT1 = pack_half2(float2(xxxx.z, yyyy.z)); + const uint OCT2 = pack_half2(float2(xxxx.x, yyyy.x)); + const uint OCT3 = pack_half2(float2(xxxx.y, yyyy.y)); + + const uint t = coord_to_cache(int2(x, y)); + cache_z[t] = Z0; + cache_rgb[t] = C0; + cache_oct[t] = OCT0; + + cache_z[t + 1] = Z1; + cache_rgb[t + 1] = C1; + cache_oct[t + 1] = OCT1; + + cache_z[t + TILE_SIZE] = Z2; + cache_rgb[t + TILE_SIZE] = C2; + cache_oct[t + TILE_SIZE] = OCT2; + + cache_z[t + TILE_SIZE + 1] = Z3; + cache_rgb[t + TILE_SIZE + 1] = C3; + cache_oct[t + TILE_SIZE + 1] = OCT3; + } + GroupMemoryBarrierWithGroupSync(); + + uint2 pixel = Gid * POSTPROCESS_BLOCKSIZE + GTid; + const float2 uv = (pixel + 0.5) * postprocess.resolution_rcp; + + const float depth = input_depth_high[pixel]; + const float linearDepth = compute_lineardepth(depth); + const float3 N = decode_oct(input_normal_high[pixel].rg); + +#if 1 + const int range = int(postprocess.params0.x); + int spread = int(postprocess.params0.y); +#else + const int range = 2; + int spread = 2; +#endif + +#if 0 + const float3 P = reconstruct_position(uv, depth); + const float3 ddxP = P - QuadReadAcrossX(P); + const float3 ddyP = P - QuadReadAcrossY(P); + const float curve = saturate(1 - pow(1 - max(dot(ddxP, ddxP), dot(ddyP, ddyP)), 64)); + const float normalPow = lerp(normalThreshold, 1, curve); + //spread *= 1 + curve; +#else + const float normalPow = normalThreshold; +#endif + + const int2 coord_base = GTid.xy / 2 + TILE_BORDER; + + float3 result = 0; + float sum = 0; + for(int x = -range; x <= range; ++x) + { + for(int y = -range; y <= range; ++y) + { + const int2 coord = coord_base + int2(x, y) * spread; + const uint t = coord_to_cache(coord); + + const float3 sampleDiffuse = Unpack_R11G11B10_FLOAT(cache_rgb[t]); + const float sampleLinearDepth = cache_z[t]; + const float3 sampleN = decode_oct(unpack_half2(cache_oct[t])); + + float bilateralDepthWeight = 1 - saturate(abs(sampleLinearDepth - linearDepth) * depthThreshold); + + float bilateralNormalWeight = pow(saturate(dot(sampleN, N)), normalPow) + 0.001; + + float weight = bilateralDepthWeight * bilateralNormalWeight; + + //weight = 1; + result += sampleDiffuse * weight; + sum += weight; + } + } + + if(sum > 0) + { + result /= sum; + } + + result = max(0, result); + + output[pixel] = output[pixel] + float4(result, 1); + //output[pixel] = float4(curve.xxx, 1); +} diff --git a/WickedEngine/shaders/ssr_bilateralCS.hlsl b/WickedEngine/shaders/ssr_bilateralCS.hlsl deleted file mode 100644 index b51100e2b4e..00000000000 --- a/WickedEngine/shaders/ssr_bilateralCS.hlsl +++ /dev/null @@ -1,104 +0,0 @@ -#include "globals.hlsli" -#include "stochasticSSRHF.hlsli" -#include "ShaderInterop_Postprocess.h" - -PUSHCONSTANT(postprocess, PostProcess); - -Texture2D texture_temporal : register(t0); -Texture2D texture_resolve_variance : register(t1); - -RWTexture2D output : register(u0); - -static const float depthThreshold = 10000.0; -static const float normalThreshold = 1.0; -static const float varianceEstimateThreshold = 0.015; // Larger variance values use stronger blur -static const float varianceExitThreshold = 0.005; // Variance needs to be higher than this value to accept blur -static const uint2 bilateralMinMaxRadius = uint2(0, 2); // Chosen by variance - -#define BILATERAL_SIGMA 0.9 - -[numthreads(POSTPROCESS_BLOCKSIZE, POSTPROCESS_BLOCKSIZE, 1)] -void main(uint3 DTid : SV_DispatchThreadID) -{ -#if 0 // Debug - output[DTid.xy] = float4((texture_resolve_variance[DTid.xy] > varianceEstimateThreshold).rrr, 1.0); - return; -#endif - - const float depth = texture_depth[DTid.xy]; - const float roughness = texture_roughness[DTid.xy]; - - if (!NeedReflection(roughness, depth, ssr_roughness_cutoff)) - { - output[DTid.xy] = texture_temporal[DTid.xy]; - return; - } - - float2 direction = postprocess.params0.xy; - - const float linearDepth = texture_lineardepth[DTid.xy]; - const float3 N = decode_oct(texture_normal[DTid.xy]); - - float4 outputColor = texture_temporal[DTid.xy]; - - - float variance = texture_resolve_variance[DTid.xy]; - bool strongBlur = variance > varianceEstimateThreshold; - - float radius = strongBlur ? bilateralMinMaxRadius.y : bilateralMinMaxRadius.x; - radius = lerp(0.0, radius, saturate(roughness * 8.0)); // roughness 0.125 is destination - - float sigma = radius * BILATERAL_SIGMA; - int effectiveRadius = min(sigma * 2.0, radius); - - if (variance > varianceExitThreshold && effectiveRadius > 0) - { - float2 uv = (DTid.xy + 0.5f) * postprocess.resolution_rcp; - float3 P = reconstruct_position(uv, depth); - - float4 result = 0; - float weightSum = 0.0f; - - for (int r = -effectiveRadius; r <= effectiveRadius; r++) - { - const int2 sampleCoord = DTid.xy + (direction * r); // Left to right diameter directionally - - if (all(and(sampleCoord >= int2(0, 0), sampleCoord < (int2) postprocess.resolution))) - { - const float sampleDepth = texture_depth[sampleCoord]; - const float4 sampleColor = texture_temporal[sampleCoord]; - - const float3 sampleN = decode_oct(texture_normal[sampleCoord]); - const float sampleRoughness = texture_roughness[sampleCoord]; - - float2 sampleUV = (sampleCoord + 0.5) * postprocess.resolution_rcp; - float3 sampleP = reconstruct_position(sampleUV, sampleDepth); - - // Don't let invalid roughness samples interfere - if (NeedReflection(sampleRoughness, sampleDepth, ssr_roughness_cutoff)) - { - float3 dq = P - sampleP; - float planeError = max(abs(dot(dq, sampleN)), abs(dot(dq, N))); - float relativeDepthDifference = planeError / (linearDepth * GetCamera().z_far); - float bilateralDepthWeight = exp(-sqr(relativeDepthDifference) * depthThreshold); - - float normalError = pow(saturate(dot(sampleN, N)), 4.0); - float bilateralNormalWeight = saturate(1.0 - (1.0 - normalError) * normalThreshold); - - float bilateralWeight = bilateralDepthWeight * bilateralNormalWeight; - - float gaussian = exp(-sqr(r / sigma)); - float weight = (r == 0) ? 1.0 : gaussian * bilateralWeight; // Skip center gaussian peak - - result += sampleColor * weight; - weightSum += weight; - } - } - } - - result /= weightSum; - outputColor = result; - } - - output[DTid.xy] = outputColor; -} diff --git a/WickedEngine/shaders/ssr_raytraceCS.hlsl b/WickedEngine/shaders/ssr_raytraceCS.hlsl index b01e8b844e8..dad1edb4070 100644 --- a/WickedEngine/shaders/ssr_raytraceCS.hlsl +++ b/WickedEngine/shaders/ssr_raytraceCS.hlsl @@ -368,7 +368,7 @@ void main(uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID) if (validHit) { - const float3 Phit = reconstruct_position(jitterUV, hit.z, GetCamera().inverse_projection); + const float3 Phit = reconstruct_position(jitterUV, hit.z); output_rayLengths[pixel] = distance(P, Phit); } else diff --git a/WickedEngine/shaders/ssr_resolveCS.hlsl b/WickedEngine/shaders/ssr_resolveCS.hlsl index 9c4a88543f3..fec2d54b26a 100644 --- a/WickedEngine/shaders/ssr_resolveCS.hlsl +++ b/WickedEngine/shaders/ssr_resolveCS.hlsl @@ -87,14 +87,13 @@ uint3 hash33(uint3 x) void main(uint3 DTid : SV_DispatchThreadID) { const float2 uv = (DTid.xy + 0.5f) * postprocess.resolution_rcp; - const uint2 tracingCoord = DTid.xy / 2; - const float depth = texture_depth[DTid.xy]; - const float roughness = texture_roughness[DTid.xy]; + const float depth = texture_depth[DTid.xy * 2]; + const float roughness = texture_roughness[DTid.xy * 2]; if (!NeedReflection(roughness, depth, ssr_roughness_cutoff)) { - texture_resolve[DTid.xy] = texture_rayIndirectSpecular[tracingCoord]; + texture_resolve[DTid.xy] = texture_rayIndirectSpecular[DTid.xy]; texture_resolve_variance[DTid.xy] = 0.0; texture_reprojectionDepth[DTid.xy] = 0.0; return; @@ -102,7 +101,7 @@ void main(uint3 DTid : SV_DispatchThreadID) // Everthing in world space: const float3 P = reconstruct_position(uv, depth); - const float3 N = decode_oct(texture_normal[DTid.xy]); + const float3 N = decode_oct(texture_normal[DTid.xy * 2]); const float3 V = normalize(GetCamera().position - P); const float NdotV = saturate(dot(N, V)); @@ -123,16 +122,15 @@ void main(uint3 DTid : SV_DispatchThreadID) for (int i = 0; i < sampleCount; i++) { float2 offset = (hammersley2d_random(i, sampleCount, random) - 0.5) * resolveSpatialSize; - - int2 neighborTracingCoord = tracingCoord + offset; + int2 neighborCoord = DTid.xy + offset; - float neighborDepth = texture_depth[neighborCoord]; + float neighborDepth = texture_depth[neighborCoord * 2]; if (neighborDepth > 0.0) { - float weight = GetWeight(neighborTracingCoord, V, N, roughness, NdotV); + float weight = GetWeight(neighborCoord, V, N, roughness, NdotV); - float4 sampleColor = texture_rayIndirectSpecular[neighborTracingCoord]; + float4 sampleColor = texture_rayIndirectSpecular[neighborCoord]; sampleColor.rgb *= rcp(1 + Luminance(sampleColor.rgb)); result += sampleColor * weight; @@ -142,7 +140,7 @@ void main(uint3 DTid : SV_DispatchThreadID) if (weight > 0.001) { - float neighborRayLength = texture_rayLength[neighborTracingCoord]; + float neighborRayLength = texture_rayLength[neighborCoord]; closestRayLength = max(closestRayLength, neighborRayLength); } } @@ -155,7 +153,7 @@ void main(uint3 DTid : SV_DispatchThreadID) float resolveVariance = S / weightSum; // Convert to post-projection depth so we can construct dual source reprojection buffers later - const float lineardepth = texture_lineardepth[DTid.xy] * GetCamera().z_far; + const float lineardepth = texture_lineardepth[DTid.xy * 2] * GetCamera().z_far; float reprojectionDepth = compute_inverse_lineardepth(lineardepth + closestRayLength, GetCamera().z_near, GetCamera().z_far); texture_resolve[DTid.xy] = max(result, 0.00001f); diff --git a/WickedEngine/shaders/ssr_temporalCS.hlsl b/WickedEngine/shaders/ssr_temporalCS.hlsl index 3da41e2b950..e968e99a5b8 100644 --- a/WickedEngine/shaders/ssr_temporalCS.hlsl +++ b/WickedEngine/shaders/ssr_temporalCS.hlsl @@ -141,8 +141,8 @@ void main(uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV return; } - const float depth = texture_depth[DTid.xy]; - const float roughness = texture_roughness[DTid.xy]; + const float depth = texture_depth[DTid.xy * 2]; + const float roughness = texture_roughness[DTid.xy * 2]; if (!NeedReflection(roughness, depth, ssr_roughness_cutoff)) { @@ -177,7 +177,7 @@ void main(uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV // Secondary reprojection based on ray lengths: // https://www.ea.com/seed/news/seed-dd18-presentation-slides-raytracing (Slide 45) - float2 velocity = texture_velocity[DTid.xy]; + float2 velocity = texture_velocity[DTid.xy * 2]; float reprojectionDepth = texture_reprojectionDepth[DTid.xy]; float2 uv = (DTid.xy + 0.5f) * postprocess.resolution_rcp; diff --git a/WickedEngine/shaders/ssr_upsampleCS.hlsl b/WickedEngine/shaders/ssr_upsampleCS.hlsl new file mode 100644 index 00000000000..addabdd6f4d --- /dev/null +++ b/WickedEngine/shaders/ssr_upsampleCS.hlsl @@ -0,0 +1,101 @@ +#include "globals.hlsli" +#include "stochasticSSRHF.hlsli" +#include "ShaderInterop_Postprocess.h" + +PUSHCONSTANT(postprocess, PostProcess); + +Texture2D texture_temporal : register(t0); +Texture2D texture_resolve_variance : register(t1); + +RWTexture2D output : register(u0); + +static const float depthThreshold = 10000.0; +static const float normalThreshold = 1.0; +static const float varianceEstimateThreshold = 0.015; // Larger variance values use stronger blur +static const float varianceExitThreshold = 0.005; // Variance needs to be higher than this value to accept blur +static const uint2 bilateralMinMaxRadius = uint2(0, 2); // Chosen by variance + +#define BILATERAL_SIGMA 0.9 + +[numthreads(POSTPROCESS_BLOCKSIZE, POSTPROCESS_BLOCKSIZE, 1)] +void main(uint3 DTid : SV_DispatchThreadID) +{ + const float depth = texture_depth[DTid.xy]; + const float roughness = texture_roughness[DTid.xy]; + + if (!NeedReflection(roughness, depth, ssr_roughness_cutoff)) + { + output[DTid.xy] = 0; + return; + } + + const float linearDepth = texture_lineardepth[DTid.xy]; + const float3 N = decode_oct(texture_normal[DTid.xy]); + + const float2 uv = (DTid.xy + 0.5) * postprocess.resolution_rcp; + float4 outputColor = texture_temporal.SampleLevel(sampler_linear_clamp, uv, 0); + + float variance = texture_resolve_variance.SampleLevel(sampler_linear_clamp, uv, 0); + bool strongBlur = variance > varianceEstimateThreshold; + + float radius = strongBlur ? bilateralMinMaxRadius.y : bilateralMinMaxRadius.x; + radius = lerp(0.0, radius, saturate(roughness * 8.0)); // roughness 0.125 is destination + + float sigma = radius * BILATERAL_SIGMA; + int effectiveRadius = min(sigma * 2.0, radius); + + if (variance > varianceExitThreshold && effectiveRadius > 0) + { + float3 P = reconstruct_position(uv, depth); + + float4 result = 0; + float weightSum = 0.0f; + + for(uint d = 0; d < 2; ++d) + { + const int2 direction = d < 1 ? int2(1, 0) : int2(0, 1); + for (int r = -effectiveRadius; r <= effectiveRadius; r++) + { + const int2 sampleCoord = DTid.xy + (direction * r); // Left to right diameter directionally + + if (all(and(sampleCoord >= int2(0, 0), sampleCoord < (int2) postprocess.resolution))) + { + const float sampleDepth = texture_depth[sampleCoord]; + + float2 sampleUV = (sampleCoord + 0.5) * postprocess.resolution_rcp; + const float4 sampleColor = texture_temporal.SampleLevel(sampler_linear_clamp, sampleUV, 0); + + const float3 sampleN = decode_oct(texture_normal[sampleCoord]); + const float sampleRoughness = texture_roughness[sampleCoord]; + + float3 sampleP = reconstruct_position(sampleUV, sampleDepth); + + // Don't let invalid roughness samples interfere + if (NeedReflection(sampleRoughness, sampleDepth, ssr_roughness_cutoff)) + { + float3 dq = P - sampleP; + float planeError = max(abs(dot(dq, sampleN)), abs(dot(dq, N))); + float relativeDepthDifference = planeError / (linearDepth * GetCamera().z_far); + float bilateralDepthWeight = exp(-sqr(relativeDepthDifference) * depthThreshold); + + float normalError = pow(saturate(dot(sampleN, N)), 4.0); + float bilateralNormalWeight = saturate(1.0 - (1.0 - normalError) * normalThreshold); + + float bilateralWeight = bilateralDepthWeight * bilateralNormalWeight; + + float gaussian = exp(-sqr(r / sigma)); + float weight = (r == 0) ? 1.0 : gaussian * bilateralWeight; // Skip center gaussian peak + + result += sampleColor * weight; + weightSum += weight; + } + } + } + } + + result /= weightSum; + outputColor = result; + } + + output[DTid.xy] = outputColor; +} diff --git a/WickedEngine/shaders/surfaceHF.hlsli b/WickedEngine/shaders/surfaceHF.hlsli index 6a2a715d0dd..a84c1888f73 100644 --- a/WickedEngine/shaders/surfaceHF.hlsli +++ b/WickedEngine/shaders/surfaceHF.hlsli @@ -2,8 +2,6 @@ #define WI_SURFACE_HF #include "globals.hlsli" -#define max3(v) max(max(v.x, v.y), v.z) - // hard coded value for surfaces with simplified lighting: // occlusion = 1 // roughness = 1 @@ -100,6 +98,7 @@ struct Surface float hit_depth; float3 gi; float3 bumpColor; + float3 ssgi; // These will be computed when calling Update(): float NdotV; // cos(angle between normal and view vector) @@ -147,6 +146,7 @@ struct Surface flags = 0; gi = 0; bumpColor = 0; + ssgi = 0; uid_validate = 0; hit_depth = 0; @@ -280,10 +280,10 @@ struct Surface clearcoat.R = -reflect(V, clearcoat.N); #endif // CLEARCOAT - B = normalize(cross(T.xyz, N) * T.w); // Compute bitangent again after normal mapping + B = cross(T.xyz, N) * T.w; // Compute bitangent again after normal mapping #ifdef ANISOTROPIC - aniso.B = normalize(cross(N, aniso.T)); + aniso.B = cross(N, aniso.T); aniso.TdotV = dot(aniso.T.xyz, V); aniso.BdotV = dot(aniso.B, V); float roughnessBRDF = sqr(clamp(roughness, 0.045, 1)); @@ -360,23 +360,28 @@ struct Surface const bool is_emittedparticle = geometry.flags & SHADERMESH_FLAG_EMITTEDPARTICLE; const bool simple_lighting = is_hairparticle || is_emittedparticle; const bool is_backface = flags & SURFACE_FLAG_BACKFACE; + + float3 Nunnormalized = 0; [branch] if (geometry.vb_nor >= 0) { Buffer buf = bindless_buffers_float4[NonUniformResourceIndex(geometry.vb_nor)]; - float3 n0 = buf[i0].xyz; - float3 n1 = buf[i1].xyz; - float3 n2 = buf[i2].xyz; + float3 n0 = mul((float3x3)inst.transformInverseTranspose.GetMatrix(), buf[i0].xyz); + float3 n1 = mul((float3x3)inst.transformInverseTranspose.GetMatrix(), buf[i1].xyz); + float3 n2 = mul((float3x3)inst.transformInverseTranspose.GetMatrix(), buf[i2].xyz); + n0 = any(n0) ? normalize(n0) : 0; + n1 = any(n1) ? normalize(n1) : 0; + n2 = any(n2) ? normalize(n2) : 0; N = attribute_at_bary(n0, n1, n2, bary); - N = mul((float3x3)inst.transformInverseTranspose.GetMatrix(), N); - N = normalize(N); } if (is_backface && !is_hairparticle && !is_emittedparticle) { N = -N; } + Nunnormalized = N; // after normalized-interpolated at barycentric, this is unnormalized! + N = normalize(N); facenormal = N; #ifdef SURFACE_LOAD_MIPCONE @@ -422,22 +427,31 @@ struct Surface #endif // SURFACE_LOAD_QUAD_DERIVATIVES } + float3x3 TBN = float3x3(1,0,0, 0,1,0, 0,0,1); + [branch] if (geometry.vb_tan >= 0) { Buffer buf = bindless_buffers_float4[NonUniformResourceIndex(geometry.vb_tan)]; - const float4 t0 = buf[i0]; - const float4 t1 = buf[i1]; - const float4 t2 = buf[i2]; + float4 t0 = buf[i0]; + float4 t1 = buf[i1]; + float4 t2 = buf[i2]; + t0.xyz = mul((float3x3)inst.transformInverseTranspose.GetMatrix(), t0.xyz); + t1.xyz = mul((float3x3)inst.transformInverseTranspose.GetMatrix(), t1.xyz); + t2.xyz = mul((float3x3)inst.transformInverseTranspose.GetMatrix(), t2.xyz); + t0.xyz = any(t0.xyz) ? normalize(t0.xyz) : 0; + t1.xyz = any(t1.xyz) ? normalize(t1.xyz) : 0; + t2.xyz = any(t2.xyz) ? normalize(t2.xyz) : 0; T = attribute_at_bary(t0, t1, t2, bary); - T.xyz = mul((float3x3)inst.transformInverseTranspose.GetMatrix(), T.xyz); if (is_backface) { - T.xyz = -T.xyz; + T = -T; } + T.w = T.w < 0 ? -1 : 1; + float3 bitangent = cross(T.xyz, Nunnormalized) * T.w; + TBN = float3x3(T.xyz, bitangent, Nunnormalized); // unnormalized TBN! http://www.mikktspace.com/ + T.xyz = normalize(T.xyz); - B = normalize(cross(T.xyz, N) * T.w); - const float3x3 TBN = float3x3(T.xyz, B, N); #ifdef PARALLAXOCCLUSIONMAPPING [branch] @@ -451,7 +465,7 @@ struct Surface uvsets, V, TBN, - material, + material.parallaxOcclusionMapping, tex, uv, uv_dx, @@ -462,7 +476,7 @@ struct Surface // Normal mapping: [branch] - if (geometry.vb_tan >= 0 && material.textures[NORMALMAP].IsValid() && material.normalMapStrength > 0) + if (geometry.vb_tan >= 0 && material.textures[NORMALMAP].IsValid()) { #ifdef SURFACE_LOAD_QUAD_DERIVATIVES bumpColor = float3(material.textures[NORMALMAP].SampleGrad(sam, uvsets, uvsets_dx, uvsets_dy).rg, 1); @@ -652,10 +666,10 @@ struct Surface continue; float4x4 decalProjection = load_entitymatrix(decal.GetMatrixIndex()); - int decalTexture = asint(decalProjection[3][0]); - int decalNormal = asint(decalProjection[3][1]); - float decalNormalStrength = decalProjection[3][2]; - int decalSurfacemap = asint(decalProjection[3][3]); + const int decalTexture = asint(decalProjection[3][0]); + const int decalNormal = asint(decalProjection[3][1]); + const int decalSurfacemap = asint(decalProjection[3][2]); + const int decalDisplacementmap = asint(decalProjection[3][3]); decalProjection[3] = float4(0, 0, 0, 1); // under here will be VGPR! @@ -677,6 +691,27 @@ struct Surface const float slopeBlend = decal.GetConeAngleCos() > 0 ? pow(saturate(dot(N, decal.GetDirection())), decal.GetConeAngleCos()) : 1; decalColor.a *= edgeBlend * slopeBlend; [branch] + if (decalDisplacementmap >= 0) + { + const float3 t = get_right(decalProjection); + const float3 b = -get_up(decalProjection); + const float3 n = N; + const float3x3 tbn = float3x3(t, b, n); + float4 inoutuv = uvw.xyxy; + ParallaxOcclusionMapping_Impl( + inoutuv, + V, + tbn, + decal.GetLength(), + bindless_textures[decalDisplacementmap], + uvw.xy, + decalDX, + decalDY, + sampler_linear_clamp + ); + uvw.xy = saturate(inoutuv.xy); + } + [branch] if (decalTexture >= 0) { decalColor *= bindless_textures[decalTexture].SampleGrad(sam, uvw.xy, decalDX, decalDY); @@ -693,7 +728,7 @@ struct Surface { float3 decalBumpColor = float3(bindless_textures[decalNormal].SampleGrad(sam, uvw.xy, decalDX, decalDY).rg, 1); decalBumpColor = decalBumpColor * 2 - 1; - decalBumpColor.rg *= decalNormalStrength; + decalBumpColor.rg *= decal.GetAngleScale(); decalBumpAccumulation.rgb = mad(1 - decalBumpAccumulation.a, decalColor.a * decalBumpColor.rgb, decalBumpAccumulation.rgb); decalBumpAccumulation.a = mad(1 - decalColor.a, decalBumpAccumulation.a, decalColor.a); } @@ -726,8 +761,7 @@ struct Surface if (any(bumpColor)) { - const float3x3 TBN = float3x3(T.xyz, B, N); - N = normalize(lerp(N, mul(bumpColor, TBN), length(bumpColor))); + N = normalize(mul(bumpColor, TBN)); } float4 specularMap = 1; @@ -884,7 +918,6 @@ struct Surface #endif // SURFACE_LOAD_QUAD_DERIVATIVES clearcoatNormalMap = clearcoatNormalMap * 2 - 1; - const float3x3 TBN = float3x3(T.xyz, B, facenormal); clearcoat.N = mul(clearcoatNormalMap, TBN); } diff --git a/WickedEngine/shaders/trailPS.hlsl b/WickedEngine/shaders/trailPS.hlsl new file mode 100644 index 00000000000..7ad02f86684 --- /dev/null +++ b/WickedEngine/shaders/trailPS.hlsl @@ -0,0 +1,18 @@ +#include "globals.hlsli" + +float4 main(float4 pos : SV_Position, float4 uv : TEXCOORD, float4 color : COLOR) : SV_TARGET +{ + color *= bindless_textures[g_xTrailTextureIndex1].Sample(sampler_linear_mirror, uv.xy); + color *= bindless_textures[g_xTrailTextureIndex2].Sample(sampler_linear_mirror, uv.zw); + + [branch] + if (g_xTrailLinearDepthTextureIndex >= 0) + { + Texture2D lineardepthTexture = bindless_textures[g_xTrailLinearDepthTextureIndex]; + float depthScene = lineardepthTexture[pos.xy].r * g_xTrailCameraFar; + float depthFragment = pos.w; + color.a *= saturate(g_xTrailDepthSoften * (depthScene - depthFragment)); // soft depth fade + } + + return color; +} diff --git a/WickedEngine/shaders/trailVS.hlsl b/WickedEngine/shaders/trailVS.hlsl new file mode 100644 index 00000000000..c29b1734de8 --- /dev/null +++ b/WickedEngine/shaders/trailVS.hlsl @@ -0,0 +1,18 @@ +#include "globals.hlsli" + +struct VertexOut +{ + float4 pos : SV_Position; + float4 uv : TEXCOORD; + float4 color : COLOR; +}; + +VertexOut main(float3 pos : POSITION, float2 uv : TEXCOORD, float4 color : COLOR) +{ + VertexOut Out; + Out.pos = mul(g_xTrailTransform, float4(pos, 1)); + Out.uv.xy = mad(uv, g_xTrailTexMulAdd.xy, g_xTrailTexMulAdd.zw); + Out.uv.zw = mad(uv, g_xTrailTexMulAdd2.xy, g_xTrailTexMulAdd2.zw); + Out.color = color * g_xTrailColor; + return Out; +} diff --git a/WickedEngine/shaders/upsample_bilateral_float4CS.hlsl b/WickedEngine/shaders/upsample_bilateral_float4CS.hlsl index e819901726f..e9c1edb44f8 100644 --- a/WickedEngine/shaders/upsample_bilateral_float4CS.hlsl +++ b/WickedEngine/shaders/upsample_bilateral_float4CS.hlsl @@ -8,6 +8,8 @@ PUSHCONSTANT(postprocess, PostProcess); Texture2D input : register(t0); +Texture2D input_lineardepth_high : register(t1); +Texture2D input_lineardepth_low : register(t2); // Note: this post process can be either a pixel shader or compute shader, depending on use case @@ -27,63 +29,58 @@ void main(uint3 DTid : SV_DispatchThreadID) #endif // USE_PIXELSHADER const float threshold = postprocess.params0.x; - const float lowres_depthchain_mip = postprocess.params0.w; + const uint lowres_depthchain_mip = uint(postprocess.params0.w); const float2 lowres_size = postprocess.params1.xy; const float2 lowres_texel_size = postprocess.params1.zw; + + const float lineardepth_highres = input_lineardepth_high[pixel] * GetCamera().z_far; + + UPSAMPLE_FORMAT color = 0; + float sum = 0; - const float2 uv00 = uv - lowres_texel_size * 0.5; - const float2 uv10 = float2(uv00.x + lowres_texel_size.x, uv00.y); - const float2 uv01 = float2(uv00.x, uv00.y + lowres_texel_size.y); - const float2 uv11 = float2(uv00.x + lowres_texel_size.x, uv00.y + lowres_texel_size.y); + int2 lowres_pixel = int2(float2(pixel) * postprocess.params0.w); - const float4 lineardepth_highres = texture_lineardepth[pixel].xxxx; - const float4 lineardepth_lowres = float4( - texture_lineardepth.SampleLevel(sampler_point_clamp, uv00, lowres_depthchain_mip), - texture_lineardepth.SampleLevel(sampler_point_clamp, uv10, lowres_depthchain_mip), - texture_lineardepth.SampleLevel(sampler_point_clamp, uv01, lowres_depthchain_mip), - texture_lineardepth.SampleLevel(sampler_point_clamp, uv11, lowres_depthchain_mip) - ); - - const float4 depth_diff = abs(lineardepth_highres - lineardepth_lowres) * GetCamera().z_far; - const float accum_diff = dot(depth_diff, float4(1, 1, 1, 1)); - - UPSAMPLE_FORMAT color; - -#ifndef UPSAMPLE_DISABLE_FILTERING - [branch] - if (accum_diff < threshold) - { - // small error, take bilinear sample: - color = input.SampleLevel(sampler_linear_clamp, uv, 0); - } - else -#endif // UPSAMPLE_DISABLE_FILTERING + const int range = 1; + for(int x = -range; x <= range; ++x) + for(int y = -range; y <= range; ++y) { - // large error: - - // find nearest sample to current depth: - float min_depth_diff = depth_diff[0]; - float2 uv_nearest = uv00; - - if (depth_diff[1] < min_depth_diff) - { - uv_nearest = uv10; - min_depth_diff = depth_diff[1]; - } - - if (depth_diff[2] < min_depth_diff) +#ifdef UPSAMPLE_DISABLE_FILTERING + const float sample_lineardepth = input_lineardepth_low[lowres_pixel + int2(x, y)] * GetCamera().z_far; + const float weight = 1 - saturate(abs(sample_lineardepth - lineardepth_highres) * threshold); + if(weight > sum) { - uv_nearest = uv01; - min_depth_diff = depth_diff[2]; + sum = weight; + color = input[lowres_pixel + int2(x, y)]; } +#else + const float4 zzzz = input_lineardepth_low.GatherRed(sampler_linear_clamp, uv, int2(x, y)) * GetCamera().z_far; + const float4 wwww = max(0.001, 1 - saturate(abs(zzzz - lineardepth_highres) * threshold)); + const float4 rrrr = input.GatherRed(sampler_linear_clamp, uv, int2(x, y)); + const float4 gggg = input.GatherGreen(sampler_linear_clamp, uv, int2(x, y)); + const float4 bbbb = input.GatherBlue(sampler_linear_clamp, uv, int2(x, y)); + const float4 aaaa = input.GatherAlpha(sampler_linear_clamp, uv, int2(x, y)); + + float2 sam_pixel = uv * lowres_size + int2(x, y) + (-0.5 + 1.0 / 512.0); // (1.0 / 512.0) correction is described here: https://www.reedbeta.com/blog/texture-gathers-and-coordinate-precision/ + float2 sam_pixel_frac = frac(sam_pixel); + + color += (UPSAMPLE_FORMAT)float4( + bilinear(rrrr * wwww, sam_pixel_frac), + bilinear(gggg * wwww, sam_pixel_frac), + bilinear(bbbb * wwww, sam_pixel_frac), + bilinear(aaaa * wwww, sam_pixel_frac) + ); + + float weight = bilinear(wwww, sam_pixel_frac); + sum += weight; +#endif // UPSAMPLE_DISABLE_FILTERING + } - if (depth_diff[3] < min_depth_diff) - { - uv_nearest = uv11; - min_depth_diff = depth_diff[3]; - } - color = input[floor(uv_nearest * lowres_size)]; +#ifndef UPSAMPLE_DISABLE_FILTERING + if(sum > 0) + { + color /= sum; } +#endif // UPSAMPLE_DISABLE_FILTERING #ifdef USE_PIXELSHADER return color; diff --git a/WickedEngine/shaders/upsample_bilateral_uint4CS.hlsl b/WickedEngine/shaders/upsample_bilateral_uint4CS.hlsl deleted file mode 100644 index 61ece841aea..00000000000 --- a/WickedEngine/shaders/upsample_bilateral_uint4CS.hlsl +++ /dev/null @@ -1,3 +0,0 @@ -#define UPSAMPLE_FORMAT uint4 -#define UPSAMPLE_DISABLE_FILTERING -#include "upsample_bilateral_float4CS.hlsl" diff --git a/WickedEngine/shaders/visibility_shadeCS.hlsl b/WickedEngine/shaders/visibility_shadeCS.hlsl index 97e2969927a..c8aa017b566 100644 --- a/WickedEngine/shaders/visibility_shadeCS.hlsl +++ b/WickedEngine/shaders/visibility_shadeCS.hlsl @@ -113,6 +113,11 @@ void main(uint Gid : SV_GroupID, uint groupIndex : SV_GroupIndex) lighting.indirect.specular = lerp(lighting.indirect.specular, ssr.rgb * surface.F, ssr.a); } [branch] + if (GetCamera().texture_ssgi_index >= 0) + { + surface.ssgi = bindless_textures[GetCamera().texture_ssgi_index].SampleLevel(sampler_linear_clamp, surface.screenUV, 0).rgb; + } + [branch] if (GetCamera().texture_ao_index >= 0) { surface.occlusion *= bindless_textures_float[GetCamera().texture_ao_index].SampleLevel(sampler_linear_clamp, surface.screenUV, 0).r; diff --git a/WickedEngine/shaders/volumetricCloud_shadow_filterCS.hlsl b/WickedEngine/shaders/volumetricCloud_shadow_filterCS.hlsl index 20e2d6c5b87..829f4395365 100644 --- a/WickedEngine/shaders/volumetricCloud_shadow_filterCS.hlsl +++ b/WickedEngine/shaders/volumetricCloud_shadow_filterCS.hlsl @@ -30,7 +30,8 @@ void main(uint3 DTid : SV_DispatchThreadID) if (all(and(neighborCoord >= int2(0, 0), neighborCoord < (int2) postprocess.resolution))) { - float3 neighborResult = input[neighborCoord]; + const float2 neighborUV = (neighborCoord + 0.5) * postprocess.resolution_rcp; + float3 neighborResult = input.SampleLevel(sampler_linear_clamp, neighborUV, 0); filteredResult += neighborResult; sum += 1.0; diff --git a/WickedEngine/shaders/volumetricLight_DirectionalPS.hlsl b/WickedEngine/shaders/volumetricLight_DirectionalPS.hlsl index 3b0797468c1..ada0660f96b 100644 --- a/WickedEngine/shaders/volumetricLight_DirectionalPS.hlsl +++ b/WickedEngine/shaders/volumetricLight_DirectionalPS.hlsl @@ -15,7 +15,8 @@ float4 main(VertexToPixel input) : SV_TARGET } float2 ScreenCoord = input.pos2D.xy / input.pos2D.w * float2(0.5f, -0.5f) + 0.5f; - float depth = max(input.pos.z, texture_depth.SampleLevel(sampler_point_clamp, ScreenCoord, 0)); + float4 depths = texture_depth.GatherRed(sampler_point_clamp, ScreenCoord); + float depth = max(depths.x, max(depths.y, max(depths.z, depths.w))); float3 P = reconstruct_position(ScreenCoord, depth); float3 V = GetCamera().position - P; float cameraDistance = length(V); diff --git a/WickedEngine/shaders/volumetricLight_PointPS.hlsl b/WickedEngine/shaders/volumetricLight_PointPS.hlsl index 60bc89ab78c..ce498e5603d 100644 --- a/WickedEngine/shaders/volumetricLight_PointPS.hlsl +++ b/WickedEngine/shaders/volumetricLight_PointPS.hlsl @@ -8,7 +8,8 @@ float4 main(VertexToPixel input) : SV_TARGET ShaderEntity light = load_entity(GetFrame().lightarray_offset + (uint)g_xColor.x); float2 ScreenCoord = input.pos2D.xy / input.pos2D.w * float2(0.5f, -0.5f) + 0.5f; - float depth = max(input.pos.z, texture_depth.SampleLevel(sampler_point_clamp, ScreenCoord, 0)); + float4 depths = texture_depth.GatherRed(sampler_point_clamp, ScreenCoord); + float depth = max(input.pos.z, max(depths.x, max(depths.y, max(depths.z, depths.w)))); float3 P = reconstruct_position(ScreenCoord, depth); float3 V = GetCamera().position - P; float cameraDistance = length(V); @@ -26,7 +27,7 @@ float4 main(VertexToPixel input) : SV_TARGET } const uint sampleCount = 16; - const float stepSize = length(P - rayEnd) / sampleCount; + const float stepSize = distance(rayEnd, P) / sampleCount; // dither ray start to help with undersampling: P = P + V * stepSize * dither(input.pos.xy); diff --git a/WickedEngine/shaders/volumetricLight_SpotPS.hlsl b/WickedEngine/shaders/volumetricLight_SpotPS.hlsl index 797ada68c5d..3564daa0b77 100644 --- a/WickedEngine/shaders/volumetricLight_SpotPS.hlsl +++ b/WickedEngine/shaders/volumetricLight_SpotPS.hlsl @@ -3,12 +3,45 @@ #include "volumetricLightHF.hlsli" #include "fogHF.hlsli" +// https://github.com/dong-zhan/ray-tracer/blob/master/ray%20cone%20intersect.hlsl +//p: ray o +//v: ray dir +//pa: cone apex +//va: cone dir +//sina2: sin(half apex angle) squared +//cosa2 : cos(half apex angle) squared +bool intersectInfiniteCone(float3 p, float3 v, float3 pa, float3 va, float sina2, float cosa2, out float tnear, out float tfar) +{ + tnear = 0; + tfar = 0; + + float3 dp = p - pa; + float vva = dot(v, va); + float dpva = dot(dp, va); + + float3 v_vvava = v - vva * va; + float3 dpvava = dp - dot(dp, va) * va; + + float A = cosa2 * dot(v_vvava, v_vvava) - sina2 * vva * vva; + float B = 2 * cosa2 * dot(v_vvava, dpvava) - 2 * sina2 * vva * dpva; + float C = cosa2 * dot(dpvava, dpvava) - sina2 * dpva * dpva; + + float disc = B*B - 4 * A*C; + if (disc < 0.0001)return false; + + float sqrtDisc = sqrt( disc ); + tnear = (-B - sqrtDisc ) / (2*A); + tfar = (-B + sqrtDisc ) / (2*A); + return true; +} + float4 main(VertexToPixel input) : SV_TARGET { ShaderEntity light = load_entity(GetFrame().lightarray_offset + (uint)g_xColor.x); float2 ScreenCoord = input.pos2D.xy / input.pos2D.w * float2(0.5f, -0.5f) + 0.5f; - float depth = max(input.pos.z, texture_depth.SampleLevel(sampler_point_clamp, ScreenCoord, 0)); + float4 depths = texture_depth.GatherRed(sampler_point_clamp, ScreenCoord); + float depth = max(input.pos.z, max(depths.x, max(depths.y, max(depths.z, depths.w)))); float3 P = reconstruct_position(ScreenCoord, depth); float3 V = GetCamera().position - P; float cameraDistance = length(V); @@ -18,10 +51,21 @@ float4 main(VertexToPixel input) : SV_TARGET float3 accumulation = 0; float3 rayEnd = GetCamera().position; - // todo: rayEnd should be clamped to the closest cone intersection point when camera is outside volume + + if(g_xColor.w > 0) + { + // If camera is outside light volume, do a cone trace to determine closest point on cone: + float tnear = 0; + float tfar = 0; + if(intersectInfiniteCone(GetCamera().position, -V, light.position, light.GetDirection(), g_xColor.y, g_xColor.z, tnear, tfar)) + { + rayEnd = GetCamera().position - V * max(0, tnear); + //return float4(1,0,0,1); + } + } const uint sampleCount = 16; - const float stepSize = length(P - rayEnd) / sampleCount; + const float stepSize = distance(rayEnd, P) / sampleCount; // dither ray start to help with undersampling: P = P + V * stepSize * dither(input.pos.xy); diff --git a/WickedEngine/wiApplication.cpp b/WickedEngine/wiApplication.cpp index 70105507006..15537631961 100644 --- a/WickedEngine/wiApplication.cpp +++ b/WickedEngine/wiApplication.cpp @@ -60,7 +60,6 @@ namespace wi } // Fade manager will activate on fadeout - fadeManager.Clear(); fadeManager.Start(fadeSeconds, fadeColor, [this, component]() { if (GetActivePath() != nullptr) @@ -109,22 +108,6 @@ namespace wi return; } -#if 0 -#ifdef WICKEDENGINE_BUILD_DX12 - static bool startup_workaround = false; - if (!startup_workaround) - { - startup_workaround = true; - if (dynamic_cast(graphicsDevice.get())) - { - CommandList cmd = graphicsDevice->BeginCommandList(); - wi::renderer::Workaround(1, cmd); - graphicsDevice->SubmitCommandLists(); - } - } -#endif // WICKEDENGINE_BUILD_DX12 -#endif - static bool startup_script = false; if (!startup_script) { @@ -620,6 +603,7 @@ namespace wi } wi::graphics::GetDevice() = graphicsDevice.get(); + rendertarget = {}; canvas.init(window); SwapChainDesc desc; diff --git a/WickedEngine/wiApplication.h b/WickedEngine/wiApplication.h index 88f8ae0307c..4ce4da288b3 100644 --- a/WickedEngine/wiApplication.h +++ b/WickedEngine/wiApplication.h @@ -120,6 +120,8 @@ namespace wi // display all-time engine information text InfoDisplayer infoDisplay; + bool IsFaded() const { return fadeManager.IsFaded(); } + }; } diff --git a/WickedEngine/wiApplication_BindLua.cpp b/WickedEngine/wiApplication_BindLua.cpp index 00197b76505..5b60d7b3657 100644 --- a/WickedEngine/wiApplication_BindLua.cpp +++ b/WickedEngine/wiApplication_BindLua.cpp @@ -4,6 +4,7 @@ #include "wiRenderPath2D_BindLua.h" #include "wiLoadingScreen_BindLua.h" #include "wiProfiler.h" +#include "wiPlatform.h" namespace wi::lua { @@ -26,6 +27,8 @@ namespace wi::lua lunamethod(Application_BindLua, SetVRAMUsageDisplay), lunamethod(Application_BindLua, GetCanvas), lunamethod(Application_BindLua, SetCanvas), + lunamethod(Application_BindLua, Exit), + lunamethod(Application_BindLua, IsFaded), { NULL, NULL } }; Luna::PropertyType Application_BindLua::properties[] = { @@ -382,6 +385,22 @@ namespace wi::lua return 1; } + int Application_BindLua::Exit(lua_State* L) + { + wi::platform::Exit(); + return 0; + } + int Application_BindLua::IsFaded(lua_State* L) + { + if (component == nullptr) + { + wi::lua::SError(L, "IsFaded() component is empty!"); + return 0; + } + wi::lua::SSetBool(L, component->IsFaded()); + return 1; + } + int SetProfilerEnabled(lua_State* L) { diff --git a/WickedEngine/wiApplication_BindLua.h b/WickedEngine/wiApplication_BindLua.h index c2b9a6cc0f2..fecc91483e8 100644 --- a/WickedEngine/wiApplication_BindLua.h +++ b/WickedEngine/wiApplication_BindLua.h @@ -31,9 +31,8 @@ namespace wi::lua class Application_BindLua { - private: - Application* component = nullptr; public: + Application* component = nullptr; inline static constexpr char className[] = "Application"; static Luna::FunctionType methods[]; static Luna::PropertyType properties[]; @@ -59,6 +58,9 @@ namespace wi::lua int GetCanvas(lua_State* L); int SetCanvas(lua_State* L); + int Exit(lua_State* L); + int IsFaded(lua_State* L); + static void Bind(); }; diff --git a/WickedEngine/wiAudio.cpp b/WickedEngine/wiAudio.cpp index d89073bb384..bd7879e280a 100644 --- a/WickedEngine/wiAudio.cpp +++ b/WickedEngine/wiAudio.cpp @@ -7,6 +7,12 @@ #define STB_VORBIS_HEADER_ONLY #include "Utility/stb_vorbis.c" +template +static constexpr T AlignTo(T value, T alignment) +{ + return ((value + alignment - T(1)) / alignment) * alignment; +} + #ifdef _WIN32 #include // ComPtr @@ -431,22 +437,22 @@ namespace wi::audio instanceinternal->buffer.AudioBytes = (uint32_t)soundinternal->audioData.size(); if (instance->begin > 0) { - const uint32_t bytes_from_beginning = std::min(instanceinternal->buffer.AudioBytes, uint32_t(instance->begin * bytes_per_second)); + const uint32_t bytes_from_beginning = AlignTo(std::min(instanceinternal->buffer.AudioBytes, uint32_t(instance->begin * bytes_per_second)), 4u); instanceinternal->buffer.pAudioData += bytes_from_beginning; instanceinternal->buffer.AudioBytes -= bytes_from_beginning; } if (instance->length > 0) { - instanceinternal->buffer.AudioBytes = std::min(instanceinternal->buffer.AudioBytes, uint32_t(instance->length * bytes_per_second)); + instanceinternal->buffer.AudioBytes = AlignTo(std::min(instanceinternal->buffer.AudioBytes, uint32_t(instance->length * bytes_per_second)), 4u); } uint32_t num_remaining_samples = instanceinternal->buffer.AudioBytes / (soundinternal->wfx.nChannels * sizeof(short)); if (instance->loop_begin > 0) { - instanceinternal->buffer.LoopBegin = std::min(num_remaining_samples, uint32_t(instance->loop_begin * soundinternal->wfx.nSamplesPerSec)); + instanceinternal->buffer.LoopBegin = AlignTo(std::min(num_remaining_samples, uint32_t(instance->loop_begin * soundinternal->wfx.nSamplesPerSec)), 4u); num_remaining_samples -= instanceinternal->buffer.LoopBegin; } - instanceinternal->buffer.LoopLength = std::min(num_remaining_samples, uint32_t(instance->loop_length * soundinternal->wfx.nSamplesPerSec)); + instanceinternal->buffer.LoopLength = AlignTo(std::min(num_remaining_samples, uint32_t(instance->loop_length * soundinternal->wfx.nSamplesPerSec)), 4u); instanceinternal->buffer.Flags = XAUDIO2_END_OF_STREAM; instanceinternal->buffer.LoopCount = instance->IsLooped() ? XAUDIO2_LOOP_INFINITE : 0; @@ -1011,22 +1017,22 @@ namespace wi::audio instanceinternal->buffer.AudioBytes = (uint32_t)soundinternal->audioData.size(); if (instance->begin > 0) { - const uint32_t bytes_from_beginning = std::min(instanceinternal->buffer.AudioBytes, uint32_t(instance->begin * bytes_per_second)); + const uint32_t bytes_from_beginning = AlignTo(std::min(instanceinternal->buffer.AudioBytes, uint32_t(instance->begin * bytes_per_second)), 4u); instanceinternal->buffer.pAudioData += bytes_from_beginning; instanceinternal->buffer.AudioBytes -= bytes_from_beginning; } if (instance->length > 0) { - instanceinternal->buffer.AudioBytes = std::min(instanceinternal->buffer.AudioBytes, uint32_t(instance->length * bytes_per_second)); + instanceinternal->buffer.AudioBytes = AlignTo(std::min(instanceinternal->buffer.AudioBytes, uint32_t(instance->length * bytes_per_second)), 4u); } uint32_t num_remaining_samples = instanceinternal->buffer.AudioBytes / (soundinternal->wfx.nChannels * sizeof(short)); if (instance->loop_begin > 0) { - instanceinternal->buffer.LoopBegin = std::min(num_remaining_samples, uint32_t(instance->loop_begin * soundinternal->wfx.nSamplesPerSec)); + instanceinternal->buffer.LoopBegin = AlignTo(std::min(num_remaining_samples, uint32_t(instance->loop_begin * soundinternal->wfx.nSamplesPerSec)), 4u); num_remaining_samples -= instanceinternal->buffer.LoopBegin; } - instanceinternal->buffer.LoopLength = std::min(num_remaining_samples, uint32_t(instance->loop_length * soundinternal->wfx.nSamplesPerSec)); + instanceinternal->buffer.LoopLength = AlignTo(std::min(num_remaining_samples, uint32_t(instance->loop_length * soundinternal->wfx.nSamplesPerSec)), 4u); instanceinternal->buffer.Flags = FAUDIO_END_OF_STREAM; instanceinternal->buffer.LoopCount = instance->IsLooped() ? FAUDIO_LOOP_INFINITE : 0; diff --git a/WickedEngine/wiAudio_BindLua.cpp b/WickedEngine/wiAudio_BindLua.cpp index df3b8caa09d..35e087fd9af 100644 --- a/WickedEngine/wiAudio_BindLua.cpp +++ b/WickedEngine/wiAudio_BindLua.cpp @@ -32,8 +32,8 @@ namespace wi::lua Sound_BindLua* sound = Luna::lightcheck(L, 2); if (sound != nullptr) { - bool result = wi::audio::CreateSound(wi::lua::SGetString(L, 1), &sound->sound); - wi::lua::SSetBool(L, result); + sound->soundResource = wi::resourcemanager::Load(wi::lua::SGetString(L, 1)); + wi::lua::SSetBool(L, sound->soundResource.GetSound().IsValid()); return 1; } else @@ -50,11 +50,12 @@ namespace wi::lua int argc = wi::lua::SGetArgCount(L); if (argc > 0) { - Sound_BindLua* sound = Luna::lightcheck(L, 1); + Sound_BindLua* s = Luna::lightcheck(L, 1); SoundInstance_BindLua* soundinstance = Luna::lightcheck(L, 2); - if (sound != nullptr && soundinstance != nullptr) + if (s != nullptr && soundinstance != nullptr) { - bool result = wi::audio::CreateSoundInstance(&sound->sound, &soundinstance->soundinstance); + const wi::audio::Sound& sound = s->soundResource.GetSound(); + bool result = wi::audio::CreateSoundInstance(&sound, &soundinstance->soundinstance); wi::lua::SSetBool(L, result); return 1; } @@ -296,9 +297,18 @@ REVERB_PRESET_PLATE = 29 { NULL, NULL } }; + Sound_BindLua::Sound_BindLua(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc > 0) + { + soundResource = wi::resourcemanager::Load(wi::lua::SGetString(L, 1)); + } + } + int Sound_BindLua::IsValid(lua_State* L) { - wi::lua::SSetBool(L, sound.IsValid()); + wi::lua::SSetBool(L, soundResource.IsValid() && soundResource.GetSound().IsValid()); return 1; } @@ -336,6 +346,35 @@ REVERB_PRESET_PLATE = 29 { NULL, NULL } }; + SoundInstance_BindLua::SoundInstance_BindLua(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc > 0) + { + Sound_BindLua* s = Luna::lightcheck(L, 1); + if (s == nullptr) + { + wi::lua::SError(L, "SoundInstance(Sound sound, opt float begin,length) : first argument is not a Sound!"); + return; + } + if (argc > 1) + { + soundinstance.begin = wi::lua::SGetFloat(L, 2); + if (argc > 2) + { + soundinstance.length = wi::lua::SGetFloat(L, 3); + } + } + const wi::audio::Sound& sound = s->soundResource.GetSound(); + if (!sound.IsValid()) + { + wi::lua::SError(L, "SoundInstance(Sound sound, opt float begin,end) : Sound is not valid!"); + return; + } + wi::audio::CreateSoundInstance(&sound, &soundinstance); + } + } + int SoundInstance_BindLua::SetSubmixType(lua_State* L) { int argc = wi::lua::SGetArgCount(L); diff --git a/WickedEngine/wiAudio_BindLua.h b/WickedEngine/wiAudio_BindLua.h index f909a674369..551a33502c7 100644 --- a/WickedEngine/wiAudio_BindLua.h +++ b/WickedEngine/wiAudio_BindLua.h @@ -2,6 +2,7 @@ #include "wiLua.h" #include "wiLuna.h" #include "wiAudio.h" +#include "wiResourceManager.h" namespace wi::lua { @@ -35,14 +36,21 @@ namespace wi::lua class Sound_BindLua { public: - wi::audio::Sound sound; + wi::Resource soundResource; inline static constexpr char className[] = "Sound"; static Luna::FunctionType methods[]; static Luna::PropertyType properties[]; - Sound_BindLua(lua_State* L) {} - Sound_BindLua(const wi::audio::Sound& sound) :sound(sound) {} + Sound_BindLua(lua_State* L); + Sound_BindLua(const wi::audio::Sound& sound) + { + soundResource.SetSound(sound); + } + Sound_BindLua(const wi::Resource resource) + { + soundResource = resource; + } int IsValid(lua_State* L); @@ -58,7 +66,11 @@ namespace wi::lua static Luna::FunctionType methods[]; static Luna::PropertyType properties[]; - SoundInstance_BindLua(lua_State* L) { } + SoundInstance_BindLua(lua_State* L); + SoundInstance_BindLua(const wi::audio::SoundInstance& instance) + { + soundinstance = instance; + } ~SoundInstance_BindLua() { } int SetSubmixType(lua_State* L); diff --git a/WickedEngine/wiECS.h b/WickedEngine/wiECS.h index 99baf729543..b9550d90339 100644 --- a/WickedEngine/wiECS.h +++ b/WickedEngine/wiECS.h @@ -30,6 +30,7 @@ namespace wi::ecs return next.fetch_add(1); } + class ComponentLibrary; struct EntitySerializer { wi::jobsystem::context ctx; // allow components to spawn serialization subtasks @@ -37,6 +38,7 @@ namespace wi::ecs bool allow_remap = true; uint64_t version = 0; // The ComponentLibrary serialization will modify this by the registered component's version number wi::unordered_set resource_registration; // register for resource manager serialization + ComponentLibrary* componentlibrary = nullptr; ~EntitySerializer() { @@ -189,24 +191,24 @@ namespace wi::ecs { if (archive.IsReadMode()) { - Clear(); // If we deserialize, we start from empty + const size_t prev_count = components.size(); size_t count; archive >> count; - components.resize(count); + components.resize(prev_count + count); for (size_t i = 0; i < count; ++i) { - components[i].Serialize(archive, seri); + components[prev_count + i].Serialize(archive, seri); } - entities.resize(count); + entities.resize(prev_count + count); for (size_t i = 0; i < count; ++i) { Entity entity; SerializeEntity(archive, entity, seri); - entities[i] = entity; - lookup[entity] = i; + entities[prev_count + i] = entity; + lookup[entity] = prev_count + i; } } else @@ -461,16 +463,43 @@ namespace wi::ecs // The name must be unique, it will be used in serialization // version is optional, it will be propagated to ComponentManager::Serialize() inside the EntitySerializer parameter template - inline ComponentManager& Register(std::string name, uint64_t version = 0) + inline ComponentManager& Register(const std::string& name, uint64_t version = 0) { entries[name].component_manager = std::make_unique>(); entries[name].version = version; return static_cast&>(*entries[name].component_manager); } + template + inline ComponentManager* Get(const std::string& name) + { + auto it = entries.find(name); + if (it == entries.end()) + return nullptr; + return static_cast*>(it->second.component_manager.get()); + } + + template + inline const ComponentManager* Get(const std::string& name) const + { + auto it = entries.find(name); + if (it == entries.end()) + return nullptr; + return static_cast*>(it->second.component_manager.get()); + } + + inline uint64_t GetVersion(std::string name) const + { + auto it = entries.find(name); + if (it == entries.end()) + return 0; + return it->second.version; + } + // Serialize all registered component managers inline void Serialize(wi::Archive& archive, EntitySerializer& seri) { + seri.componentlibrary = this; if(archive.IsReadMode()) { bool has_next = false; @@ -517,6 +546,7 @@ namespace wi::ecs // Serialize all components for one entity inline void Entity_Serialize(Entity entity, wi::Archive& archive, EntitySerializer& seri) { + seri.componentlibrary = this; if(archive.IsReadMode()) { bool has_next = false; diff --git a/WickedEngine/wiEmittedParticle.cpp b/WickedEngine/wiEmittedParticle.cpp index 7dfd6b339e0..3d1e6d2f725 100644 --- a/WickedEngine/wiEmittedParticle.cpp +++ b/WickedEngine/wiEmittedParticle.cpp @@ -948,6 +948,18 @@ namespace wi bd.independent_blend_enable = false; blendStates[BLENDMODE_PREMULTIPLIED] = bd; + bd.render_target[0].src_blend = Blend::DEST_COLOR; + bd.render_target[0].dest_blend = Blend::ZERO; + bd.render_target[0].blend_op = BlendOp::ADD; + bd.render_target[0].src_blend_alpha = Blend::DEST_ALPHA; + bd.render_target[0].dest_blend_alpha = Blend::ZERO; + bd.render_target[0].blend_op_alpha = BlendOp::ADD; + bd.render_target[0].blend_enable = true; + bd.render_target[0].render_target_write_mask = ColorWrite::ENABLE_ALL; + bd.alpha_to_coverage_enable = false; + bd.independent_blend_enable = false; + blendStates[BLENDMODE_MULTIPLY] = bd; + bd.render_target[0].blend_enable = false; blendStates[BLENDMODE_OPAQUE] = bd; diff --git a/WickedEngine/wiEnums.h b/WickedEngine/wiEnums.h index e960582913a..4524c05069e 100644 --- a/WickedEngine/wiEnums.h +++ b/WickedEngine/wiEnums.h @@ -88,6 +88,7 @@ namespace wi::enums enum TEXTYPES { TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW, + TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED, TEXTYPE_2D_SKYATMOSPHERE_TRANSMITTANCELUT, TEXTYPE_2D_SKYATMOSPHERE_MULTISCATTEREDLUMINANCELUT, TEXTYPE_2D_SKYATMOSPHERE_SKYVIEWLUT, @@ -295,10 +296,15 @@ namespace wi::enums CSTYPE_POSTPROCESS_MSAO_BLURUPSAMPLE_PREMIN, CSTYPE_POSTPROCESS_MSAO_BLURUPSAMPLE_PREMIN_BLENDOUT, CSTYPE_POSTPROCESS_RTREFLECTION, + CSTYPE_POSTPROCESS_SSGI_DEINTERLEAVE, + CSTYPE_POSTPROCESS_SSGI, + CSTYPE_POSTPROCESS_SSGI_WIDE, + CSTYPE_POSTPROCESS_SSGI_UPSAMPLE, + CSTYPE_POSTPROCESS_SSGI_UPSAMPLE_WIDE, CSTYPE_POSTPROCESS_RTDIFFUSE, CSTYPE_POSTPROCESS_RTDIFFUSE_SPATIAL, CSTYPE_POSTPROCESS_RTDIFFUSE_TEMPORAL, - CSTYPE_POSTPROCESS_RTDIFFUSE_BILATERAL, + CSTYPE_POSTPROCESS_RTDIFFUSE_UPSAMPLE, CSTYPE_POSTPROCESS_SSR_TILEMAXROUGHNESS_HORIZONTAL, CSTYPE_POSTPROCESS_SSR_TILEMAXROUGHNESS_VERTICAL, CSTYPE_POSTPROCESS_SSR_DEPTHHIERARCHY, @@ -307,7 +313,7 @@ namespace wi::enums CSTYPE_POSTPROCESS_SSR_RAYTRACE_CHEAP, CSTYPE_POSTPROCESS_SSR_RESOLVE, CSTYPE_POSTPROCESS_SSR_TEMPORAL, - CSTYPE_POSTPROCESS_SSR_BILATERAL, + CSTYPE_POSTPROCESS_SSR_UPSAMPLE, CSTYPE_POSTPROCESS_LIGHTSHAFTS, CSTYPE_POSTPROCESS_DEPTHOFFIELD_TILEMAXCOC_HORIZONTAL, CSTYPE_POSTPROCESS_DEPTHOFFIELD_TILEMAXCOC_VERTICAL, @@ -359,7 +365,6 @@ namespace wi::enums CSTYPE_POSTPROCESS_UPSAMPLE_BILATERAL_UNORM1, CSTYPE_POSTPROCESS_UPSAMPLE_BILATERAL_FLOAT4, CSTYPE_POSTPROCESS_UPSAMPLE_BILATERAL_UNORM4, - CSTYPE_POSTPROCESS_UPSAMPLE_BILATERAL_UINT4, CSTYPE_POSTPROCESS_DOWNSAMPLE4X, CSTYPE_POSTPROCESS_LINEARDEPTH, CSTYPE_POSTPROCESS_NORMALSFROMDEPTH, diff --git a/WickedEngine/wiFFTGenerator.cpp b/WickedEngine/wiFFTGenerator.cpp index 75805c517fb..e72250598a7 100644 --- a/WickedEngine/wiFFTGenerator.cpp +++ b/WickedEngine/wiFFTGenerator.cpp @@ -14,6 +14,20 @@ namespace wi::fftgenerator Shader radix008A_CS; Shader radix008A_CS2; + struct CSFFT512x512_Plan + { + // More than one array can be transformed at same time + uint32_t slices; + + // For 512x512 config, we need 6 constant buffers + wi::graphics::GPUBuffer pRadix008A_CB[6]; + + wi::graphics::GPUBuffer pBuffer_Tmp; + + inline bool IsValid() const { return pBuffer_Tmp.IsValid(); } + }; + CSFFT512x512_Plan fft_plan; + #define TWO_PI 6.283185307179586476925286766559 #define FFT_DIMENSIONS 3U @@ -23,7 +37,6 @@ namespace wi::fftgenerator #define FFT_INVERSE 1 void radix008A( - const CSFFT512x512_Plan& fft_plan, const GPUResource& pUAV_Dst, const GPUResource& pSRV_Src, uint32_t thread_count, @@ -64,127 +77,118 @@ namespace wi::fftgenerator } void fft_512x512_c2c( - const CSFFT512x512_Plan& fft_plan, const GPUResource& pUAV_Dst, const GPUResource& pSRV_Dst, const GPUResource& pSRV_Src, CommandList cmd) { - const uint32_t thread_count = fft_plan.slices * (512 * 512) / 8; GraphicsDevice* device = wi::graphics::GetDevice(); - const GPUBuffer* cs_cbs; - uint32_t istride = 512 * 512 / 8; - cs_cbs = &fft_plan.pRadix008A_CB[0]; - device->BindConstantBuffer(cs_cbs, CB_GETBINDSLOT(FFTGeneratorCB), cmd); - radix008A(fft_plan, fft_plan.pBuffer_Tmp, pSRV_Src, thread_count, istride, cmd); + if (!fft_plan.IsValid()) + { + fft_plan.slices = 3; - istride /= 8; - cs_cbs = &fft_plan.pRadix008A_CB[1]; - device->BindConstantBuffer(cs_cbs, CB_GETBINDSLOT(FFTGeneratorCB), cmd); - radix008A(fft_plan, pUAV_Dst, fft_plan.pBuffer_Tmp, thread_count, istride, cmd); + // Create 6 cbuffers for 512x512 transform. - istride /= 8; - cs_cbs = &fft_plan.pRadix008A_CB[2]; - device->BindConstantBuffer(cs_cbs, CB_GETBINDSLOT(FFTGeneratorCB), cmd); - radix008A(fft_plan, fft_plan.pBuffer_Tmp, pSRV_Dst, thread_count, istride, cmd); + GPUBufferDesc cb_desc; + cb_desc.bind_flags = BindFlag::CONSTANT_BUFFER; + cb_desc.size = sizeof(FFTGeneratorCB); + cb_desc.stride = 0; - istride /= 8; - cs_cbs = &fft_plan.pRadix008A_CB[3]; - device->BindConstantBuffer(cs_cbs, CB_GETBINDSLOT(FFTGeneratorCB), cmd); - radix008A(fft_plan, pUAV_Dst, fft_plan.pBuffer_Tmp, thread_count, istride, cmd); - - istride /= 8; - cs_cbs = &fft_plan.pRadix008A_CB[4]; - device->BindConstantBuffer(cs_cbs, CB_GETBINDSLOT(FFTGeneratorCB), cmd); - radix008A(fft_plan, fft_plan.pBuffer_Tmp, pSRV_Dst, thread_count, istride, cmd); + // Buffer 0 + const uint32_t thread_count = fft_plan.slices * (512 * 512) / 8; + uint32_t ostride = 512 * 512 / 8; + uint32_t istride = ostride; + double phase_base = -TWO_PI / (512.0 * 512.0); - istride /= 8; - cs_cbs = &fft_plan.pRadix008A_CB[5]; - device->BindConstantBuffer(cs_cbs, CB_GETBINDSLOT(FFTGeneratorCB), cmd); - radix008A(fft_plan, pUAV_Dst, fft_plan.pBuffer_Tmp, thread_count, istride, cmd); - } + FFTGeneratorCB cb_data_buf0 = { thread_count, ostride, istride, 512, (float)phase_base }; - void create_cbuffers_512x512(CSFFT512x512_Plan& plan, GraphicsDevice* device, uint32_t slices) - { - // Create 6 cbuffers for 512x512 transform. + device->CreateBuffer(&cb_desc, &cb_data_buf0, &fft_plan.pRadix008A_CB[0]); - GPUBufferDesc cb_desc; - cb_desc.bind_flags = BindFlag::CONSTANT_BUFFER; - cb_desc.size = sizeof(FFTGeneratorCB); - cb_desc.stride = 0; + // Buffer 1 + istride /= 8; + phase_base *= 8.0; - // Buffer 0 - const uint32_t thread_count = slices * (512 * 512) / 8; - uint32_t ostride = 512 * 512 / 8; - uint32_t istride = ostride; - double phase_base = -TWO_PI / (512.0 * 512.0); + FFTGeneratorCB cb_data_buf1 = { thread_count, ostride, istride, 512, (float)phase_base }; - FFTGeneratorCB cb_data_buf0 = { thread_count, ostride, istride, 512, (float)phase_base }; + device->CreateBuffer(&cb_desc, &cb_data_buf1, &fft_plan.pRadix008A_CB[1]); - device->CreateBuffer(&cb_desc, &cb_data_buf0, &plan.pRadix008A_CB[0]); + // Buffer 2 + istride /= 8; + phase_base *= 8.0; - // Buffer 1 - istride /= 8; - phase_base *= 8.0; + FFTGeneratorCB cb_data_buf2 = { thread_count, ostride, istride, 512, (float)phase_base }; - FFTGeneratorCB cb_data_buf1 = { thread_count, ostride, istride, 512, (float)phase_base }; + device->CreateBuffer(&cb_desc, &cb_data_buf2, &fft_plan.pRadix008A_CB[2]); - device->CreateBuffer(&cb_desc, &cb_data_buf1, &plan.pRadix008A_CB[1]); + // Buffer 3 + istride /= 8; + phase_base *= 8.0; + ostride /= 512; - // Buffer 2 - istride /= 8; - phase_base *= 8.0; + FFTGeneratorCB cb_data_buf3 = { thread_count, ostride, istride, 1, (float)phase_base }; - FFTGeneratorCB cb_data_buf2 = { thread_count, ostride, istride, 512, (float)phase_base }; + device->CreateBuffer(&cb_desc, &cb_data_buf3, &fft_plan.pRadix008A_CB[3]); - device->CreateBuffer(&cb_desc, &cb_data_buf2, &plan.pRadix008A_CB[2]); + // Buffer 4 + istride /= 8; + phase_base *= 8.0; - // Buffer 3 - istride /= 8; - phase_base *= 8.0; - ostride /= 512; + FFTGeneratorCB cb_data_buf4 = { thread_count, ostride, istride, 1, (float)phase_base }; - FFTGeneratorCB cb_data_buf3 = { thread_count, ostride, istride, 1, (float)phase_base }; + device->CreateBuffer(&cb_desc, &cb_data_buf4, &fft_plan.pRadix008A_CB[4]); - device->CreateBuffer(&cb_desc, &cb_data_buf3, &plan.pRadix008A_CB[3]); + // Buffer 5 + istride /= 8; + phase_base *= 8.0; - // Buffer 4 - istride /= 8; - phase_base *= 8.0; + FFTGeneratorCB cb_data_buf5 = { thread_count, ostride, istride, 1, (float)phase_base }; - FFTGeneratorCB cb_data_buf4 = { thread_count, ostride, istride, 1, (float)phase_base }; + device->CreateBuffer(&cb_desc, &cb_data_buf5, &fft_plan.pRadix008A_CB[5]); - device->CreateBuffer(&cb_desc, &cb_data_buf4, &plan.pRadix008A_CB[4]); + // Temp buffer + GPUBufferDesc buf_desc; + buf_desc.size = sizeof(float) * 2 * (512 * fft_plan.slices) * 512; + buf_desc.usage = Usage::DEFAULT; + buf_desc.bind_flags = BindFlag::UNORDERED_ACCESS | BindFlag::SHADER_RESOURCE; + buf_desc.misc_flags = ResourceMiscFlag::BUFFER_STRUCTURED; + buf_desc.stride = sizeof(float) * 2; - // Buffer 5 - istride /= 8; - phase_base *= 8.0; + device->CreateBuffer(&buf_desc, nullptr, &fft_plan.pBuffer_Tmp); + } - FFTGeneratorCB cb_data_buf5 = { thread_count, ostride, istride, 1, (float)phase_base }; + const uint32_t thread_count = fft_plan.slices * (512 * 512) / 8; + const GPUBuffer* cs_cbs; - device->CreateBuffer(&cb_desc, &cb_data_buf5, &plan.pRadix008A_CB[5]); - } + uint32_t istride = 512 * 512 / 8; + cs_cbs = &fft_plan.pRadix008A_CB[0]; + device->BindConstantBuffer(cs_cbs, CB_GETBINDSLOT(FFTGeneratorCB), cmd); + radix008A(fft_plan.pBuffer_Tmp, pSRV_Src, thread_count, istride, cmd); - void fft512x512_create_plan(CSFFT512x512_Plan& plan, uint32_t slices) - { - GraphicsDevice* device = wi::graphics::GetDevice(); + istride /= 8; + cs_cbs = &fft_plan.pRadix008A_CB[1]; + device->BindConstantBuffer(cs_cbs, CB_GETBINDSLOT(FFTGeneratorCB), cmd); + radix008A(pUAV_Dst, fft_plan.pBuffer_Tmp, thread_count, istride, cmd); - plan.slices = slices; + istride /= 8; + cs_cbs = &fft_plan.pRadix008A_CB[2]; + device->BindConstantBuffer(cs_cbs, CB_GETBINDSLOT(FFTGeneratorCB), cmd); + radix008A(fft_plan.pBuffer_Tmp, pSRV_Dst, thread_count, istride, cmd); - // Constants - // Create 6 cbuffers for 512x512 transform - create_cbuffers_512x512(plan, device, slices); + istride /= 8; + cs_cbs = &fft_plan.pRadix008A_CB[3]; + device->BindConstantBuffer(cs_cbs, CB_GETBINDSLOT(FFTGeneratorCB), cmd); + radix008A(pUAV_Dst, fft_plan.pBuffer_Tmp, thread_count, istride, cmd); - // Temp buffer - GPUBufferDesc buf_desc; - buf_desc.size = sizeof(float) * 2 * (512 * slices) * 512; - buf_desc.usage = Usage::DEFAULT; - buf_desc.bind_flags = BindFlag::UNORDERED_ACCESS | BindFlag::SHADER_RESOURCE; - buf_desc.misc_flags = ResourceMiscFlag::BUFFER_STRUCTURED; - buf_desc.stride = sizeof(float) * 2; + istride /= 8; + cs_cbs = &fft_plan.pRadix008A_CB[4]; + device->BindConstantBuffer(cs_cbs, CB_GETBINDSLOT(FFTGeneratorCB), cmd); + radix008A(fft_plan.pBuffer_Tmp, pSRV_Dst, thread_count, istride, cmd); - device->CreateBuffer(&buf_desc, nullptr, &plan.pBuffer_Tmp); + istride /= 8; + cs_cbs = &fft_plan.pRadix008A_CB[5]; + device->BindConstantBuffer(cs_cbs, CB_GETBINDSLOT(FFTGeneratorCB), cmd); + radix008A(pUAV_Dst, fft_plan.pBuffer_Tmp, thread_count, istride, cmd); } void LoadShaders() diff --git a/WickedEngine/wiFFTGenerator.h b/WickedEngine/wiFFTGenerator.h index 97ce2268240..0d6394c006d 100644 --- a/WickedEngine/wiFFTGenerator.h +++ b/WickedEngine/wiFFTGenerator.h @@ -4,23 +4,7 @@ namespace wi::fftgenerator { - - struct CSFFT512x512_Plan - { - // More than one array can be transformed at same time - uint32_t slices; - - // For 512x512 config, we need 6 constant buffers - wi::graphics::GPUBuffer pRadix008A_CB[6]; - - wi::graphics::GPUBuffer pBuffer_Tmp; - }; - - - void fft512x512_create_plan(CSFFT512x512_Plan& plan, uint32_t slices); - void fft_512x512_c2c( - const CSFFT512x512_Plan& fft_plan, const wi::graphics::GPUResource& pUAV_Dst, const wi::graphics::GPUResource& pSRV_Dst, const wi::graphics::GPUResource& pSRV_Src, diff --git a/WickedEngine/wiFadeManager.cpp b/WickedEngine/wiFadeManager.cpp index 34d6f0bdaaf..4469537e96c 100644 --- a/WickedEngine/wiFadeManager.cpp +++ b/WickedEngine/wiFadeManager.cpp @@ -11,6 +11,7 @@ namespace wi void FadeManager::Update(float dt) { + fadeEventTriggeredThisFrame = false; if (!IsActive()) return; @@ -19,6 +20,7 @@ namespace wi // skip fade, just launch the job onFade(); state = FADE_FINISHED; + fadeEventTriggeredThisFrame = true; } float t = timer / targetFadeTimeInSeconds; @@ -39,6 +41,7 @@ namespace wi opacity = 1.0f; onFade(); timer = 0; + fadeEventTriggeredThisFrame = true; } else if (state == FADE_OUT) { diff --git a/WickedEngine/wiFadeManager.h b/WickedEngine/wiFadeManager.h index 70fe13e0c07..d5e7757d6a3 100644 --- a/WickedEngine/wiFadeManager.h +++ b/WickedEngine/wiFadeManager.h @@ -23,6 +23,7 @@ namespace wi } state = FADE_FINISHED; wi::Color color = wi::Color(0, 0, 0, 255); std::function onFade = [] {}; + bool fadeEventTriggeredThisFrame = false; FadeManager() { @@ -34,15 +35,23 @@ namespace wi targetFadeTimeInSeconds = seconds; this->color = color; timer = 0; - state = FADE_IN; + if (IsFaded()) + { + // If starting a new fade on mid-fadeout, it will start from faded and just transition out of mid + state = FADE_MID; + } + else + { + state = FADE_IN; + } onFade = onFadeFunction; } void Update(float dt); - bool IsFaded() + bool IsFaded() const { - return state == FADE_MID; + return fadeEventTriggeredThisFrame; } - bool IsActive() + bool IsActive() const { return state != FADE_FINISHED; } diff --git a/WickedEngine/wiFont.cpp b/WickedEngine/wiFont.cpp index 11d8d4a7f9d..94f8f184f00 100644 --- a/WickedEngine/wiFont.cpp +++ b/WickedEngine/wiFont.cpp @@ -140,7 +140,7 @@ namespace wi::font if (status.last_word_begin > 0 && params.h_wrap >= 0 && status.cursor.position.x >= params.h_wrap - 1) { // Word ended and wrap detected, push down last word by one line: - float word_offset = vertexList[status.last_word_begin].pos.x + whitespace_size; + const float word_offset = vertexList[status.last_word_begin].pos.x; for (size_t i = status.last_word_begin; i < status.quadCount * 4; ++i) { vertexList[i].pos.x -= word_offset; diff --git a/WickedEngine/wiGUI.cpp b/WickedEngine/wiGUI.cpp index 5b2a4113495..833407ce486 100644 --- a/WickedEngine/wiGUI.cpp +++ b/WickedEngine/wiGUI.cpp @@ -880,10 +880,10 @@ namespace wi::gui switch (font_description.params.h_align) { case wi::font::WIFALIGN_LEFT: - font_description.params.posX = translation.x + scale.x; + font_description.params.posX = translation.x + scale.x + shadow; break; case wi::font::WIFALIGN_RIGHT: - font_description.params.posX = translation.x; + font_description.params.posX = translation.x - shadow; break; case wi::font::WIFALIGN_CENTER: default: @@ -893,10 +893,10 @@ namespace wi::gui switch (font_description.params.v_align) { case wi::font::WIFALIGN_TOP: - font_description.params.posY = translation.y + scale.y; + font_description.params.posY = translation.y + scale.y + shadow; break; case wi::font::WIFALIGN_BOTTOM: - font_description.params.posY = translation.y; + font_description.params.posY = translation.y - shadow; break; case wi::font::WIFALIGN_CENTER: default: @@ -2630,6 +2630,7 @@ namespace wi::gui items.clear(); selected = -1; + //firstItemVisible = 0; } void ComboBox::SetMaxVisibleItemCount(int value) { @@ -2959,7 +2960,14 @@ namespace wi::gui void Window::AddWidget(Widget* widget, AttachmentOptions options) { widget->SetEnabled(this->IsEnabled()); - widget->SetVisible(this->IsVisible()); + if (IsVisible() && !IsMinimized()) + { + widget->SetVisible(true); + } + else + { + widget->SetVisible(false); + } if (has_flag(options, AttachmentOptions::SCROLLABLE)) { widget->AttachTo(&scrollable_area); @@ -3249,13 +3257,24 @@ namespace wi::gui void Window::SetVisible(bool value) { Widget::SetVisible(value); - //SetMinimized(!value); - if (!IsMinimized()) + bool minimized = IsMinimized(); + for (auto& x : widgets) { - for (auto& x : widgets) + if ( + x == &resizeDragger_UpperLeft || + x == &resizeDragger_UpperRight || + x == &closeButton || + x == &collapseButton || + x == &moveDragger || + x == &label + ) { x->SetVisible(value); } + else + { + x->SetVisible(!minimized); + } } } void Window::SetEnabled(bool value) @@ -3296,18 +3315,23 @@ namespace wi::gui { minimized = value; - scrollable_area.SetVisible(!value); - if (resizeDragger_BottomLeft.parent != nullptr) - { - resizeDragger_BottomLeft.SetVisible(!value); - } - if (resizeDragger_BottomRight.parent != nullptr) + for (auto& x : widgets) { - resizeDragger_BottomRight.SetVisible(!value); + if ( + x == &resizeDragger_UpperLeft || + x == &resizeDragger_UpperRight || + x == &closeButton || + x == &collapseButton || + x == &moveDragger || + x == &label + ) + { + continue; + } + x->SetVisible(!value); } - scrollbar_horizontal.SetVisible(!value); - scrollbar_vertical.SetVisible(!value); + scrollable_area.SetVisible(!value); if (IsMinimized()) { @@ -3407,19 +3431,19 @@ namespace wi::gui { moveDragger.Detach(); float rem = 0; - if (closeButton.parent != nullptr) + if (resizeDragger_UpperLeft.parent != nullptr) { rem++; } - if (collapseButton.parent != nullptr) + if (resizeDragger_UpperRight.parent != nullptr) { rem++; } - if (resizeDragger_UpperLeft.parent != nullptr) + if (closeButton.parent != nullptr) { rem++; } - if (resizeDragger_UpperRight.parent != nullptr) + if (collapseButton.parent != nullptr) { rem++; } @@ -3429,6 +3453,14 @@ namespace wi::gui { offset++; } + if (closeButton.parent != nullptr) + { + offset++; + } + if (collapseButton.parent != nullptr) + { + offset++; + } moveDragger.SetPos(XMFLOAT2(translation.x + control_size * offset, translation.y)); moveDragger.AttachTo(this); } @@ -3436,28 +3468,28 @@ namespace wi::gui { closeButton.Detach(); closeButton.SetSize(XMFLOAT2(control_size, control_size)); - float offset = 1; - if (resizeDragger_UpperRight.parent != nullptr) + float offset = 0; + if (resizeDragger_UpperLeft.parent != nullptr) { offset++; } - closeButton.SetPos(XMFLOAT2(translation.x + scale.x - control_size * offset, translation.y)); + closeButton.SetPos(XMFLOAT2(translation.x + control_size * offset, translation.y)); closeButton.AttachTo(this); } if (collapseButton.parent != nullptr) { collapseButton.Detach(); collapseButton.SetSize(XMFLOAT2(control_size, control_size)); - float offset = 1; + float offset = 0; if (closeButton.parent != nullptr) { offset++; } - if (resizeDragger_UpperRight.parent != nullptr) + if (resizeDragger_UpperLeft.parent != nullptr) { offset++; } - collapseButton.SetPos(XMFLOAT2(translation.x + scale.x - control_size * offset, translation.y)); + collapseButton.SetPos(XMFLOAT2(translation.x + control_size * offset, translation.y)); collapseButton.AttachTo(this); } if (resizeDragger_UpperLeft.parent != nullptr) @@ -3499,15 +3531,17 @@ namespace wi::gui label_size.x -= control_size; label_pos.x += control_size; } - if (resizeDragger_UpperRight.parent != nullptr) + if (closeButton.parent != nullptr) { label_size.x -= control_size; + label_pos.x += control_size; } - if (closeButton.parent != nullptr) + if (collapseButton.parent != nullptr) { label_size.x -= control_size; + label_pos.x += control_size; } - if (collapseButton.parent != nullptr) + if (resizeDragger_UpperRight.parent != nullptr) { label_size.x -= control_size; } diff --git a/WickedEngine/wiGraphics.h b/WickedEngine/wiGraphics.h index 97ec8c0e6c3..0d41536a061 100644 --- a/WickedEngine/wiGraphics.h +++ b/WickedEngine/wiGraphics.h @@ -395,16 +395,22 @@ namespace wi::graphics PREDICATION = 1 << 5, TRANSIENT_ATTACHMENT = 1 << 6, // hint: used in renderpass, without needing to write content to memory (VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) SPARSE = 1 << 7, // sparse resource without backing memory allocation - SPARSE_TILE_POOL_BUFFER = 1 << 8, // buffer only, makes it suitable for containing tile memory for sparse buffers - SPARSE_TILE_POOL_TEXTURE_NON_RT_DS = 1 << 9, // buffer only, makes it suitable for containing tile memory for sparse textures that are non render targets nor depth stencils - SPARSE_TILE_POOL_TEXTURE_RT_DS = 1 << 10, // buffer only, makes it suitable for containing tile memory for sparse textures that are either render targets or depth stencils - SPARSE_TILE_POOL = SPARSE_TILE_POOL_BUFFER | SPARSE_TILE_POOL_TEXTURE_NON_RT_DS | SPARSE_TILE_POOL_TEXTURE_RT_DS, // buffer only, makes it suitable for containing tile memory for all kinds of sparse resources. Requires GraphicsDeviceCapability::GENERIC_SPARSE_TILE_POOL to be supported + ALIASING_BUFFER = 1 << 8, // memory allocation will be suitable for buffers + ALIASING_TEXTURE_NON_RT_DS = 1 << 9,// memory allocation will be suitable for textures that are non render targets nor depth stencils + ALIASING_TEXTURE_RT_DS = 1 << 10, // memory allocation will be suitable for textures that are either render targets or depth stencils + ALIASING = ALIASING_BUFFER | ALIASING_TEXTURE_NON_RT_DS | ALIASING_TEXTURE_RT_DS, // memory allocation will be suitable for all kinds of resources. Requires GraphicsDeviceCapability::ALIASING_GENERIC to be supported TYPED_FORMAT_CASTING = 1 << 11, // enable casting formats between same type and different modifiers: eg. UNORM -> SRGB TYPELESS_FORMAT_CASTING = 1 << 12, // enable casting formats to other formats that have the same bit-width and channel layout: eg. R32_FLOAT -> R32_UINT VIDEO_DECODE = 1 << 13, // resource is usabe in video decoding operations NO_DEFAULT_DESCRIPTORS = 1 << 14, // skips creation of default descriptors for resources TEXTURE_COMPATIBLE_COMPRESSION = 1 << 15, // optimization that can enable sampling from compressed textures SHARED = 1 << 16, // shared texture + + // Compat: + SPARSE_TILE_POOL_BUFFER = ALIASING_BUFFER, + SPARSE_TILE_POOL_TEXTURE_NON_RT_DS = ALIASING_TEXTURE_NON_RT_DS, + SPARSE_TILE_POOL_TEXTURE_RT_DS = ALIASING_TEXTURE_RT_DS, + SPARSE_TILE_POOL = ALIASING, }; enum class GraphicsDeviceCapability @@ -427,13 +433,16 @@ namespace wi::graphics SPARSE_TEXTURE2D = 1 << 14, SPARSE_TEXTURE3D = 1 << 15, SPARSE_NULL_MAPPING = 1 << 16, - GENERIC_SPARSE_TILE_POOL = 1 << 17, // allows using ResourceMiscFlag::SPARSE_TILE_POOL (non resource type specific version) + ALIASING_GENERIC = 1 << 17, // allows using ResourceMiscFlag::ALIASING (non resource type specific version) DEPTH_RESOLVE_MIN_MAX = 1 << 18, STENCIL_RESOLVE_MIN_MAX = 1 << 19, CACHE_COHERENT_UMA = 1 << 20, // https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_feature_data_architecture VIDEO_DECODE_H264 = 1 << 21, R9G9B9E5_SHAREDEXP_RENDERABLE = 1 << 22, // indicates supporting R9G9B9E5_SHAREDEXP format for rendering to COPY_BETWEEN_DIFFERENT_IMAGE_ASPECTS_NOT_SUPPORTED = 1 << 23, // indicates that CopyTexture src and dst ImageAspect must match + + // Compat: + GENERIC_SPARSE_TILE_POOL = ALIASING_GENERIC, }; enum class ResourceState @@ -661,6 +670,7 @@ namespace wi::graphics MEMORY, // UAV accesses IMAGE, // image layout transition BUFFER, // buffer state transition + ALIASING, // memory aliasing transition } type = Type::MEMORY; struct Memory @@ -682,11 +692,17 @@ namespace wi::graphics ResourceState state_before; ResourceState state_after; }; + struct Aliasing + { + const GPUResource* resource_before; + const GPUResource* resource_after; + }; union { Memory memory; Image image; Buffer buffer; + Aliasing aliasing; }; static GPUBarrier Memory(const GPUResource* resource = nullptr) @@ -718,6 +734,14 @@ namespace wi::graphics barrier.buffer.state_after = after; return barrier; } + static GPUBarrier Aliasing(const GPUResource* before, const GPUResource* after) + { + GPUBarrier barrier; + barrier.type = Type::ALIASING; + barrier.aliasing.resource_before = before; + barrier.aliasing.resource_after = after; + return barrier; + } }; struct SwapChainDesc diff --git a/WickedEngine/wiGraphicsDevice.h b/WickedEngine/wiGraphicsDevice.h index f90faf7f241..191034ff019 100644 --- a/WickedEngine/wiGraphicsDevice.h +++ b/WickedEngine/wiGraphicsDevice.h @@ -72,8 +72,8 @@ namespace wi::graphics // Create a SwapChain. If the SwapChain is to be recreated, the window handle can be nullptr. virtual bool CreateSwapChain(const SwapChainDesc* desc, wi::platform::window_type window, SwapChain* swapchain) const = 0; // Create a buffer with a callback to initialize its data. Note: don't read from callback's dest pointer, reads will be very slow! Use memcpy to write to it to make sure only writes happen! - virtual bool CreateBuffer2(const GPUBufferDesc* desc, const std::function& init_callback, GPUBuffer* buffer) const = 0; - virtual bool CreateTexture(const TextureDesc* desc, const SubresourceData* initial_data, Texture* texture) const = 0; + virtual bool CreateBuffer2(const GPUBufferDesc* desc, const std::function& init_callback, GPUBuffer* buffer, const GPUResource* alias = nullptr, uint64_t alias_offset = 0ull) const = 0; + virtual bool CreateTexture(const TextureDesc* desc, const SubresourceData* initial_data, Texture* texture, const GPUResource* alias = nullptr, uint64_t alias_offset = 0ull) const = 0; virtual bool CreateShader(ShaderStage stage, const void* shadercode, size_t shadercode_size, Shader* shader) const = 0; virtual bool CreateSampler(const SamplerDesc* desc, Sampler* sampler) const = 0; virtual bool CreateQueryHeap(const GPUQueryHeapDesc* desc, GPUQueryHeap* queryheap) const = 0; @@ -234,13 +234,13 @@ namespace wi::graphics // Some useful helpers: - bool CreateBuffer(const GPUBufferDesc* desc, const void* initial_data, GPUBuffer* buffer) const + bool CreateBuffer(const GPUBufferDesc* desc, const void* initial_data, GPUBuffer* buffer, const GPUResource* alias = nullptr, uint64_t alias_offset = 0ull) const { if (initial_data == nullptr) { - return CreateBuffer2(desc, nullptr, buffer); + return CreateBuffer2(desc, nullptr, buffer, alias, alias_offset); } - return CreateBuffer2(desc, [&](void* dest) { std::memcpy(dest, initial_data, desc->size); }, buffer); + return CreateBuffer2(desc, [&](void* dest) { std::memcpy(dest, initial_data, desc->size); }, buffer, alias, alias_offset); } void Barrier(const GPUBarrier& barrier, CommandList cmd) diff --git a/WickedEngine/wiGraphicsDevice_DX12.cpp b/WickedEngine/wiGraphicsDevice_DX12.cpp index 5109b8c6528..a8e96ee8557 100644 --- a/WickedEngine/wiGraphicsDevice_DX12.cpp +++ b/WickedEngine/wiGraphicsDevice_DX12.cpp @@ -2529,7 +2529,6 @@ using namespace dx12_internal; } } - if (SUCCEEDED(device.As(&video_device))) { queues[QUEUE_VIDEO_DECODE].desc.Type = D3D12_COMMAND_LIST_TYPE_VIDEO_DECODE; @@ -2842,7 +2841,7 @@ using namespace dx12_internal; if (resource_heap_tier >= D3D12_RESOURCE_HEAP_TIER_2) { - capabilities |= GraphicsDeviceCapability::GENERIC_SPARSE_TILE_POOL; + capabilities |= GraphicsDeviceCapability::ALIASING_GENERIC; } if (features.CacheCoherentUMA()) @@ -3272,7 +3271,7 @@ using namespace dx12_internal; internal_state->dummyTexture.desc.height = desc->height; return true; } - bool GraphicsDevice_DX12::CreateBuffer2(const GPUBufferDesc* desc, const std::function& init_callback, GPUBuffer* buffer) const + bool GraphicsDevice_DX12::CreateBuffer2(const GPUBufferDesc* desc, const std::function& init_callback, GPUBuffer* buffer, const GPUResource* alias, uint64_t alias_offset) const { auto internal_state = std::make_shared(); internal_state->allocationhandler = allocationhandler; @@ -3332,31 +3331,28 @@ using namespace dx12_internal; wi::graphics::xbox::ApplyBufferCreationFlags(*desc, resourceDesc.Flags, allocationDesc.ExtraHeapFlags); #endif // PLATFORM_XBOX - if (has_flag(desc->misc_flags, ResourceMiscFlag::SPARSE_TILE_POOL_BUFFER) || - has_flag(desc->misc_flags, ResourceMiscFlag::SPARSE_TILE_POOL_TEXTURE_NON_RT_DS) || - has_flag(desc->misc_flags, ResourceMiscFlag::SPARSE_TILE_POOL_TEXTURE_RT_DS)) + if (has_flag(desc->misc_flags, ResourceMiscFlag::ALIASING_BUFFER) || + has_flag(desc->misc_flags, ResourceMiscFlag::ALIASING_TEXTURE_NON_RT_DS) || + has_flag(desc->misc_flags, ResourceMiscFlag::ALIASING_TEXTURE_RT_DS)) { - // Sparse tile pool must not be a committed resource because that uses implicit heap which returns nullptr, + // Aliasing memory pool must not be a committed resource because that uses implicit heap which returns nullptr, // thus it cannot be offsetted. This is why we create custom allocation here which will never be committed resource // (since it has no resource) - D3D12_RESOURCE_ALLOCATION_INFO allocationInfo = {}; - allocationInfo.Alignment = D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES; - allocationInfo.SizeInBytes = AlignTo(desc->size, (uint64_t)D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES); + D3D12_RESOURCE_ALLOCATION_INFO allocationInfo = device->GetResourceAllocationInfo(0, 1, &resourceDesc); if (resource_heap_tier >= D3D12_RESOURCE_HEAP_TIER_2) { - // tile pool memory can be used for sparse buffers and textures alike (requires resource heap tier 2): allocationDesc.ExtraHeapFlags = D3D12_HEAP_FLAG_ALLOW_ALL_BUFFERS_AND_TEXTURES; } - else if (has_flag(desc->misc_flags, ResourceMiscFlag::SPARSE_TILE_POOL_BUFFER)) + else if (has_flag(desc->misc_flags, ResourceMiscFlag::ALIASING_BUFFER)) { allocationDesc.ExtraHeapFlags = D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS; } - else if (has_flag(desc->misc_flags, ResourceMiscFlag::SPARSE_TILE_POOL_TEXTURE_NON_RT_DS)) + else if (has_flag(desc->misc_flags, ResourceMiscFlag::ALIASING_TEXTURE_NON_RT_DS)) { allocationDesc.ExtraHeapFlags = D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES; } - else if (has_flag(desc->misc_flags, ResourceMiscFlag::SPARSE_TILE_POOL_TEXTURE_RT_DS)) + else if (has_flag(desc->misc_flags, ResourceMiscFlag::ALIASING_TEXTURE_RT_DS)) { allocationDesc.ExtraHeapFlags = D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES; } @@ -3391,14 +3387,30 @@ using namespace dx12_internal; } else { - hr = allocationhandler->allocator->CreateResource( - &allocationDesc, - &resourceDesc, - resourceState, - nullptr, - &internal_state->allocation, - PPV_ARGS(internal_state->resource) - ); + if (alias == nullptr) + { + hr = allocationhandler->allocator->CreateResource( + &allocationDesc, + &resourceDesc, + resourceState, + nullptr, + &internal_state->allocation, + PPV_ARGS(internal_state->resource) + ); + } + else + { + // Aliasing: https://gpuopen-librariesandsdks.github.io/D3D12MemoryAllocator/html/resource_aliasing.html + auto alias_internal = to_internal(alias); + hr = allocationhandler->allocator->CreateAliasingResource( + alias_internal->allocation.Get(), + alias_offset, + &resourceDesc, + resourceState, + nullptr, + PPV_ARGS(internal_state->resource) + ); + } assert(SUCCEEDED(hr)); } @@ -3484,7 +3496,7 @@ using namespace dx12_internal; return SUCCEEDED(hr); } - bool GraphicsDevice_DX12::CreateTexture(const TextureDesc* desc, const SubresourceData* initial_data, Texture* texture) const + bool GraphicsDevice_DX12::CreateTexture(const TextureDesc* desc, const SubresourceData* initial_data, Texture* texture, const GPUResource* alias, uint64_t alias_offset) const { auto internal_state = std::make_shared(); internal_state->allocationhandler = allocationhandler; @@ -3644,7 +3656,51 @@ using namespace dx12_internal; wi::graphics::xbox::ApplyTextureCreationFlags(texture->desc, resourcedesc.Flags, allocationDesc.ExtraHeapFlags); #endif // PLATFORM_XBOX - if (has_flag(texture->desc.misc_flags, ResourceMiscFlag::SPARSE)) + + if (has_flag(desc->misc_flags, ResourceMiscFlag::ALIASING_BUFFER) || + has_flag(desc->misc_flags, ResourceMiscFlag::ALIASING_TEXTURE_NON_RT_DS) || + has_flag(desc->misc_flags, ResourceMiscFlag::ALIASING_TEXTURE_RT_DS)) + { + // Aliasing memory pool must not be a committed resource because that uses implicit heap which returns nullptr, + // thus it cannot be offsetted. This is why we create custom allocation here which will never be committed resource + // (since it has no resource) + D3D12_RESOURCE_ALLOCATION_INFO allocationInfo = device->GetResourceAllocationInfo(0, 1, &resourcedesc); + + if (resource_heap_tier >= D3D12_RESOURCE_HEAP_TIER_2) + { + allocationDesc.ExtraHeapFlags = D3D12_HEAP_FLAG_ALLOW_ALL_BUFFERS_AND_TEXTURES; + } + else if (has_flag(desc->misc_flags, ResourceMiscFlag::ALIASING_BUFFER)) + { + allocationDesc.ExtraHeapFlags = D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS; + } + else if (has_flag(desc->misc_flags, ResourceMiscFlag::ALIASING_TEXTURE_NON_RT_DS)) + { + allocationDesc.ExtraHeapFlags = D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES; + } + else if (has_flag(desc->misc_flags, ResourceMiscFlag::ALIASING_TEXTURE_RT_DS)) + { + allocationDesc.ExtraHeapFlags = D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES; + } + + hr = allocationhandler->allocator->AllocateMemory( + &allocationDesc, + &allocationInfo, + &internal_state->allocation + ); + assert(SUCCEEDED(hr)); + + hr = device->CreatePlacedResource( + internal_state->allocation->GetHeap(), + internal_state->allocation->GetOffset(), + &resourcedesc, + resourceState, + useClearValue ? &optimizedClearValue : nullptr, + PPV_ARGS(internal_state->resource) + ); + assert(SUCCEEDED(hr)); + } + else if (has_flag(texture->desc.misc_flags, ResourceMiscFlag::SPARSE)) { resourcedesc.Layout = D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE; hr = device->CreateReservedResource( @@ -3692,14 +3748,30 @@ using namespace dx12_internal; allocationDesc.ExtraHeapFlags |= D3D12_HEAP_FLAG_SHARED; } - hr = allocationhandler->allocator->CreateResource( - &allocationDesc, - &resourcedesc, - resourceState, - useClearValue ? &optimizedClearValue : nullptr, - &internal_state->allocation, - PPV_ARGS(internal_state->resource) - ); + if (alias == nullptr) + { + hr = allocationhandler->allocator->CreateResource( + &allocationDesc, + &resourcedesc, + resourceState, + useClearValue ? &optimizedClearValue : nullptr, + &internal_state->allocation, + PPV_ARGS(internal_state->resource) + ); + } + else + { + // Aliasing: https://gpuopen-librariesandsdks.github.io/D3D12MemoryAllocator/html/resource_aliasing.html + auto alias_internal = to_internal(alias); + hr = allocationhandler->allocator->CreateAliasingResource( + alias_internal->allocation.Get(), + alias_offset, + &resourcedesc, + resourceState, + useClearValue ? &optimizedClearValue : nullptr, + PPV_ARGS(internal_state->resource) + ); + } } assert(SUCCEEDED(hr)); @@ -5348,6 +5420,8 @@ using namespace dx12_internal; for (int q = 0; q < QUEUE_COUNT; ++q) { CommandQueue& queue = queues[q]; + if (queue.queue == nullptr) + continue; if (!queue.submit_cmds.empty()) { @@ -5416,6 +5490,8 @@ using namespace dx12_internal; const uint32_t bufferindex = GetBufferIndex(); for (int queue = 0; queue < QUEUE_COUNT; ++queue) { + if (queues[queue].queue == nullptr) + continue; if (FRAMECOUNT >= BUFFERCOUNT && frame_fence[bufferindex][queue]->GetCompletedValue() < 1) { // NULL event handle will simply wait immediately: @@ -5666,6 +5742,8 @@ using namespace dx12_internal; for (auto& queue : queues) { + if (queue.queue == nullptr) + continue; hr = queue.queue->Signal(fence.Get(), 1); assert(SUCCEEDED(hr)); if (fence->GetCompletedValue() < 1) @@ -7041,6 +7119,14 @@ using namespace dx12_internal; } } break; + case GPUBarrier::Type::ALIASING: + { + barrierdesc.Type = D3D12_RESOURCE_BARRIER_TYPE_ALIASING; + barrierdesc.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; + barrierdesc.Aliasing.pResourceBefore = to_internal(barrier.aliasing.resource_before)->resource.Get(); + barrierdesc.Aliasing.pResourceAfter = to_internal(barrier.aliasing.resource_after)->resource.Get(); + } + break; } if (barrierdesc.Type == D3D12_RESOURCE_BARRIER_TYPE_TRANSITION && commandlist.queue > QUEUE_GRAPHICS) @@ -7296,24 +7382,68 @@ using namespace dx12_internal; } void GraphicsDevice_DX12::ClearUAV(const GPUResource* resource, uint32_t value, CommandList cmd) { + const UINT values[4] = { value,value,value,value }; + auto internal_state = to_internal(resource); - // We cannot clear eg. a StructuredBuffer, so in those cases we must clear the RAW view with uav_raw - const SingleDescriptor& descriptor = internal_state->uav_raw.IsValid() ? internal_state->uav_raw : internal_state->uav; - D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle = descriptorheap_res.start_gpu; - gpu_handle.ptr += descriptor.index * resource_descriptor_size; - D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle = descriptor.handle; + if (internal_state->uav_raw.IsValid()) + { + // We cannot clear eg. a StructuredBuffer, so in those cases we must clear the RAW view with uav_raw + const SingleDescriptor& descriptor = internal_state->uav_raw; + D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle = descriptorheap_res.start_gpu; + gpu_handle.ptr += descriptor.index * resource_descriptor_size; + D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle = descriptor.handle; - const UINT values[4] = { value,value,value,value }; + CommandList_DX12& commandlist = GetCommandList(cmd); + commandlist.GetGraphicsCommandList()->ClearUnorderedAccessViewUint( + gpu_handle, + cpu_handle, + internal_state->resource.Get(), + values, + 0, + nullptr + ); + } + else + { + if (internal_state->subresources_uav.empty()) + { + const SingleDescriptor& descriptor = internal_state->uav; + D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle = descriptorheap_res.start_gpu; + gpu_handle.ptr += descriptor.index * resource_descriptor_size; + D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle = descriptor.handle; - CommandList_DX12& commandlist = GetCommandList(cmd); - commandlist.GetGraphicsCommandList()->ClearUnorderedAccessViewUint( - gpu_handle, - cpu_handle, - internal_state->resource.Get(), - values, - 0, - nullptr - ); + CommandList_DX12& commandlist = GetCommandList(cmd); + commandlist.GetGraphicsCommandList()->ClearUnorderedAccessViewUint( + gpu_handle, + cpu_handle, + internal_state->resource.Get(), + values, + 0, + nullptr + ); + } + else + { + // This is clearing every subresource (for example every mip since they can't be referenced by single UAV) + for (auto& uav : internal_state->subresources_uav) + { + const SingleDescriptor& descriptor = uav; + D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle = descriptorheap_res.start_gpu; + gpu_handle.ptr += descriptor.index * resource_descriptor_size; + D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle = descriptor.handle; + + CommandList_DX12& commandlist = GetCommandList(cmd); + commandlist.GetGraphicsCommandList()->ClearUnorderedAccessViewUint( + gpu_handle, + cpu_handle, + internal_state->resource.Get(), + values, + 0, + nullptr + ); + } + } + } } void GraphicsDevice_DX12::VideoDecode(const VideoDecoder* video_decoder, const VideoDecodeOperation* op, CommandList cmd) { diff --git a/WickedEngine/wiGraphicsDevice_DX12.h b/WickedEngine/wiGraphicsDevice_DX12.h index a23e6e3498c..97b38006cf5 100644 --- a/WickedEngine/wiGraphicsDevice_DX12.h +++ b/WickedEngine/wiGraphicsDevice_DX12.h @@ -251,8 +251,8 @@ namespace wi::graphics ~GraphicsDevice_DX12() override; bool CreateSwapChain(const SwapChainDesc* desc, wi::platform::window_type window, SwapChain* swapchain) const override; - bool CreateBuffer2(const GPUBufferDesc * desc, const std::function& init_callback, GPUBuffer* buffer) const override; - bool CreateTexture(const TextureDesc* desc, const SubresourceData* initial_data, Texture* texture) const override; + bool CreateBuffer2(const GPUBufferDesc * desc, const std::function& init_callback, GPUBuffer* buffer, const GPUResource* alias = nullptr, uint64_t alias_offset = 0ull) const override; + bool CreateTexture(const TextureDesc* desc, const SubresourceData* initial_data, Texture* texture, const GPUResource* alias = nullptr, uint64_t alias_offset = 0ull) const override; bool CreateShader(ShaderStage stage, const void* shadercode, size_t shadercode_size, Shader* shader) const override; bool CreateSampler(const SamplerDesc* desc, Sampler* sampler) const override; bool CreateQueryHeap(const GPUQueryHeapDesc* desc, GPUQueryHeap* queryheap) const override; diff --git a/WickedEngine/wiGraphicsDevice_Vulkan.cpp b/WickedEngine/wiGraphicsDevice_Vulkan.cpp index d277ae30d14..f98986ece0a 100644 --- a/WickedEngine/wiGraphicsDevice_Vulkan.cpp +++ b/WickedEngine/wiGraphicsDevice_Vulkan.cpp @@ -2334,6 +2334,7 @@ using namespace vulkan_internal; GraphicsDevice_Vulkan::GraphicsDevice_Vulkan(wi::platform::window_type window, ValidationMode validationMode_, GPUPreference preference) { wi::Timer timer; + capabilities |= GraphicsDeviceCapability::ALIASING_GENERIC; // This functionalty is missing from Vulkan but might be added in the future: // Issue: https://github.com/KhronosGroup/Vulkan-Docs/issues/2079 @@ -2842,7 +2843,6 @@ using namespace vulkan_internal; { capabilities |= GraphicsDeviceCapability::SPARSE_TEXTURE3D; } - capabilities |= GraphicsDeviceCapability::GENERIC_SPARSE_TILE_POOL; } if ( @@ -3702,7 +3702,7 @@ using namespace vulkan_internal; return success; } - bool GraphicsDevice_Vulkan::CreateBuffer2(const GPUBufferDesc* desc, const std::function& init_callback, GPUBuffer* buffer) const + bool GraphicsDevice_Vulkan::CreateBuffer2(const GPUBufferDesc* desc, const std::function& init_callback, GPUBuffer* buffer, const GPUResource* alias, uint64_t alias_offset) const { auto internal_state = std::make_shared(); internal_state->allocationhandler = allocationhandler; @@ -3796,9 +3796,9 @@ using namespace vulkan_internal; VkResult res; - if (has_flag(desc->misc_flags, ResourceMiscFlag::SPARSE_TILE_POOL_BUFFER) || - has_flag(desc->misc_flags, ResourceMiscFlag::SPARSE_TILE_POOL_TEXTURE_NON_RT_DS) || - has_flag(desc->misc_flags, ResourceMiscFlag::SPARSE_TILE_POOL_TEXTURE_RT_DS)) + if (has_flag(desc->misc_flags, ResourceMiscFlag::ALIASING_BUFFER) || + has_flag(desc->misc_flags, ResourceMiscFlag::ALIASING_TEXTURE_NON_RT_DS) || + has_flag(desc->misc_flags, ResourceMiscFlag::ALIASING_TEXTURE_RT_DS)) { VkMemoryRequirements memory_requirements = {}; memory_requirements.alignment = desc->alignment; @@ -3868,7 +3868,43 @@ using namespace vulkan_internal; allocInfo.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT; } - res = vmaCreateBuffer(allocationhandler->allocator, &bufferInfo, &allocInfo, &internal_state->resource, &internal_state->allocation, nullptr); + if (alias == nullptr) + { + res = vmaCreateBuffer( + allocationhandler->allocator, + &bufferInfo, + &allocInfo, + &internal_state->resource, + &internal_state->allocation, + nullptr + ); + } + else + { + // Aliasing: https://gpuopen-librariesandsdks.github.io/VulkanMemoryAllocator/html/resource_aliasing.html + if (alias->IsTexture()) + { + auto alias_internal = to_internal((const Texture*)alias); + res = vmaCreateAliasingBuffer2( + allocationhandler->allocator, + alias_internal->allocation, + alias_offset, + &bufferInfo, + &internal_state->resource + ); + } + else + { + auto alias_internal = to_internal((const GPUBuffer*)alias); + res = vmaCreateAliasingBuffer2( + allocationhandler->allocator, + alias_internal->allocation, + alias_offset, + &bufferInfo, + &internal_state->resource + ); + } + } assert(res == VK_SUCCESS); } @@ -3992,7 +4028,7 @@ using namespace vulkan_internal; return res == VK_SUCCESS; } - bool GraphicsDevice_Vulkan::CreateTexture(const TextureDesc* desc, const SubresourceData* initial_data, Texture* texture) const + bool GraphicsDevice_Vulkan::CreateTexture(const TextureDesc* desc, const SubresourceData* initial_data, Texture* texture, const GPUResource* alias, uint64_t alias_offset) const { auto internal_state = std::make_shared(); internal_state->allocationhandler = allocationhandler; @@ -4140,7 +4176,6 @@ using namespace vulkan_internal; if (has_flag(texture->desc.misc_flags, ResourceMiscFlag::SPARSE)) { - assert(CheckCapability(GraphicsDeviceCapability::GENERIC_SPARSE_TILE_POOL)); assert(CheckCapability(GraphicsDeviceCapability::SPARSE_TEXTURE2D) || imageInfo.imageType != VK_IMAGE_TYPE_2D); assert(CheckCapability(GraphicsDeviceCapability::SPARSE_TEXTURE3D) || imageInfo.imageType != VK_IMAGE_TYPE_3D); imageInfo.flags |= VK_IMAGE_CREATE_SPARSE_BINDING_BIT; @@ -4292,7 +4327,43 @@ using namespace vulkan_internal; allocInfo.flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT; } - res = vmaCreateImage(allocator, &imageInfo, &allocInfo, &internal_state->resource, &internal_state->allocation, nullptr); + if (alias == nullptr) + { + res = vmaCreateImage( + allocator, + &imageInfo, + &allocInfo, + &internal_state->resource, + &internal_state->allocation, + nullptr + ); + } + else + { + // Aliasing: https://gpuopen-librariesandsdks.github.io/VulkanMemoryAllocator/html/resource_aliasing.html + if (alias->IsTexture()) + { + auto alias_internal = to_internal((const Texture*)alias); + res = vmaCreateAliasingImage2( + allocator, + alias_internal->allocation, + alias_offset, + &imageInfo, + &internal_state->resource + ); + } + else + { + auto alias_internal = to_internal((const GPUBuffer*)alias); + res = vmaCreateAliasingImage2( + allocator, + alias_internal->allocation, + alias_offset, + &imageInfo, + &internal_state->resource + ); + } + } assert(res == VK_SUCCESS); if (has_flag(texture->desc.misc_flags, ResourceMiscFlag::SHARED)) @@ -8626,6 +8697,7 @@ using namespace vulkan_internal; { default: case GPUBarrier::Type::MEMORY: + case GPUBarrier::Type::ALIASING: { VkMemoryBarrier2 barrierdesc = {}; barrierdesc.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER_2; diff --git a/WickedEngine/wiGraphicsDevice_Vulkan.h b/WickedEngine/wiGraphicsDevice_Vulkan.h index b714a60dbad..aa89e4c4299 100644 --- a/WickedEngine/wiGraphicsDevice_Vulkan.h +++ b/WickedEngine/wiGraphicsDevice_Vulkan.h @@ -289,8 +289,8 @@ namespace wi::graphics ~GraphicsDevice_Vulkan() override; bool CreateSwapChain(const SwapChainDesc* desc, wi::platform::window_type window, SwapChain* swapchain) const override; - bool CreateBuffer2(const GPUBufferDesc* desc, const std::function& init_callback, GPUBuffer* buffer) const override; - bool CreateTexture(const TextureDesc* desc, const SubresourceData* initial_data, Texture* texture) const override; + bool CreateBuffer2(const GPUBufferDesc* desc, const std::function& init_callback, GPUBuffer* buffer, const GPUResource* alias = nullptr, uint64_t alias_offset = 0ull) const override; + bool CreateTexture(const TextureDesc* desc, const SubresourceData* initial_data, Texture* texture, const GPUResource* alias = nullptr, uint64_t alias_offset = 0ull) const override; bool CreateShader(ShaderStage stage, const void* shadercode, size_t shadercode_size, Shader* shader) const override; bool CreateSampler(const SamplerDesc* desc, Sampler* sampler) const override; bool CreateQueryHeap(const GPUQueryHeapDesc* desc, GPUQueryHeap* queryheap) const override; diff --git a/WickedEngine/wiHairParticle.h b/WickedEngine/wiHairParticle.h index 6f6317007f0..5d5d4ef8fca 100644 --- a/WickedEngine/wiHairParticle.h +++ b/WickedEngine/wiHairParticle.h @@ -73,6 +73,7 @@ namespace wi EMPTY = 0, _DEPRECATED_REGENERATE_FRAME = 1 << 0, REBUILD_BUFFERS = 1 << 1, + DIRTY = 1 << 2, }; uint32_t _flags = EMPTY; @@ -107,5 +108,8 @@ namespace wi constexpr uint32_t GetParticleCount() const { return strandCount * segmentCount; } uint64_t GetMemorySizeInBytes() const; + + constexpr bool IsDirty() const { return _flags & DIRTY; } + constexpr void SetDirty(bool value = true) { if (value) { _flags |= DIRTY; } else { _flags &= ~DIRTY; } } }; } diff --git a/WickedEngine/wiHelper.cpp b/WickedEngine/wiHelper.cpp index 0c0d75f4705..015316c91de 100644 --- a/WickedEngine/wiHelper.cpp +++ b/WickedEngine/wiHelper.cpp @@ -1218,6 +1218,54 @@ namespace wi::helper #endif // PLATFORM_UWP } + bool DirectoryExists(const std::string& fileName) + { +#ifndef PLATFORM_UWP + bool exists = std::filesystem::exists(ToNativeString(fileName)); + return exists; +#else + using namespace winrt::Windows::Storage; + using namespace winrt::Windows::Storage::Streams; + using namespace winrt::Windows::Foundation; + std::wstring wstr; + std::filesystem::path filepath = fileName; + filepath = std::filesystem::absolute(filepath); + StringConvert(filepath.string(), wstr); + bool success = false; + + auto async_helper = [&]() -> IAsyncAction { + try + { + auto file = co_await StorageFolder::GetFolderFromPathAsync(wstr); + success = true; + } + catch (winrt::hresult_error const& ex) + { + switch (ex.code()) + { + case E_ACCESSDENIED: + wi::backlog::post("Opening folder failed: " + fileName + " | Reason: Permission Denied!"); + break; + default: + break; + } + } + + }; + + if (winrt::impl::is_sta_thread()) + { + std::thread([&] { async_helper().get(); }).join(); // can't block coroutine from ui thread + } + else + { + async_helper().get(); + } + + return success; +#endif // PLATFORM_UWP + } + uint64_t FileTimestamp(const std::string& fileName) { auto tim = std::filesystem::last_write_time(ToNativeString(fileName)); @@ -1477,14 +1525,31 @@ namespace wi::helper for (const auto& entry : std::filesystem::directory_iterator(directory_path)) { + if (entry.is_directory()) + continue; std::string filename = entry.path().filename().generic_u8string(); - if (filter_extension.empty() || wi::helper::toUpper(wi::helper::GetExtensionFromFileName(filename)).compare(filter_extension) == 0) + if (filter_extension.empty() || wi::helper::toUpper(wi::helper::GetExtensionFromFileName(filename)).compare(wi::helper::toUpper(filter_extension)) == 0) { onSuccess(directory + filename); } } } + void GetFolderNamesInDirectory(const std::string& directory, std::function onSuccess) + { + std::filesystem::path directory_path = ToNativeString(directory); + if (!std::filesystem::exists(directory_path)) + return; + + for (const auto& entry : std::filesystem::directory_iterator(directory_path)) + { + if (!entry.is_directory()) + continue; + std::string filename = entry.path().filename().generic_u8string(); + onSuccess(directory + filename); + } + } + bool Bin2H(const uint8_t* data, size_t size, const std::string& dst_filename, const char* dataName) { std::string ss; @@ -1642,7 +1707,7 @@ namespace wi::helper #endif // PLATFORM_UWP #ifdef PLATFORM_WINDOWS_DESKTOP - std::string op = "start " + url; + std::string op = "start \"\" \"" + url + "\""; int status = system(op.c_str()); wi::backlog::post("wi::helper::OpenUrl(" + url + ") returned status: " + std::to_string(status)); return; diff --git a/WickedEngine/wiHelper.h b/WickedEngine/wiHelper.h index 685bb15e891..e918171ff43 100644 --- a/WickedEngine/wiHelper.h +++ b/WickedEngine/wiHelper.h @@ -98,6 +98,8 @@ namespace wi::helper bool FileExists(const std::string& fileName); + bool DirectoryExists(const std::string& fileName); + uint64_t FileTimestamp(const std::string& fileName); std::string GetTempDirectoryPath(); @@ -118,6 +120,8 @@ namespace wi::helper void GetFileNamesInDirectory(const std::string& directory, std::function onSuccess, const std::string& filter_extension = ""); + void GetFolderNamesInDirectory(const std::string& directory, std::function onSuccess); + // Converts a file into a C++ header file that contains the file contents as byte array. // dataName : the byte array's name bool Bin2H(const uint8_t* data, size_t size, const std::string& dst_filename, const char* dataName); diff --git a/WickedEngine/wiImageParams_BindLua.cpp b/WickedEngine/wiImageParams_BindLua.cpp index a1035d16faa..35acef66d11 100644 --- a/WickedEngine/wiImageParams_BindLua.cpp +++ b/WickedEngine/wiImageParams_BindLua.cpp @@ -45,6 +45,8 @@ namespace wi::lua lunamethod(ImageParams_BindLua, DisableBackgroundBlur), lunamethod(ImageParams_BindLua, EnableBackground), lunamethod(ImageParams_BindLua, DisableBackground), + lunamethod(ImageParams_BindLua, SetMaskAlphaRange), + lunamethod(ImageParams_BindLua, GetMaskAlphaRange), { nullptr, nullptr } }; Luna::PropertyType ImageParams_BindLua::properties[] = { @@ -431,6 +433,24 @@ namespace wi::lua params.disableBackground(); return 0; } + int ImageParams_BindLua::SetMaskAlphaRange(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 2) + { + wi::lua::SError(L, "SetMaskAlphaRange(float start, end): not enough arguments!"); + return 0; + } + params.mask_alpha_range_start = wi::lua::SGetFloat(L, 1); + params.mask_alpha_range_end = wi::lua::SGetFloat(L, 2); + return 0; + } + int ImageParams_BindLua::GetMaskAlphaRange(lua_State* L) + { + wi::lua::SSetFloat(L, params.mask_alpha_range_start); + wi::lua::SSetFloat(L, params.mask_alpha_range_end); + return 2; + } ImageParams_BindLua::ImageParams_BindLua(lua_State* L) { diff --git a/WickedEngine/wiImageParams_BindLua.h b/WickedEngine/wiImageParams_BindLua.h index 3cea747c751..7c415f91054 100644 --- a/WickedEngine/wiImageParams_BindLua.h +++ b/WickedEngine/wiImageParams_BindLua.h @@ -58,6 +58,8 @@ namespace wi::lua int DisableBackgroundBlur(lua_State* L); int EnableBackground(lua_State* L); int DisableBackground(lua_State* L); + int SetMaskAlphaRange(lua_State* L); + int GetMaskAlphaRange(lua_State* L); static void Bind(); }; diff --git a/WickedEngine/wiInitializer.cpp b/WickedEngine/wiInitializer.cpp index cc4d3c5aba1..a1c0de84d70 100644 --- a/WickedEngine/wiInitializer.cpp +++ b/WickedEngine/wiInitializer.cpp @@ -14,7 +14,10 @@ namespace wi::initializer void InitializeComponentsImmediate() { - InitializeComponentsAsync(); + if (!initializationStarted) + { + InitializeComponentsAsync(); + } wi::jobsystem::Wait(ctx); } void InitializeComponentsAsync() @@ -55,6 +58,7 @@ namespace wi::initializer wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { wi::GPUBVH::Initialize(); systems[INITIALIZED_SYSTEM_GPUBVH].store(true); }); wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { wi::physics::Initialize(); systems[INITIALIZED_SYSTEM_PHYSICS].store(true); }); wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { wi::audio::Initialize(); systems[INITIALIZED_SYSTEM_AUDIO].store(true); }); + wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { wi::TrailRenderer::Initialize(); systems[INITIALIZED_SYSTEM_TRAILRENDERER].store(true); }); // Initialize this immediately: wi::lua::Initialize(); systems[INITIALIZED_SYSTEM_LUA].store(true); diff --git a/WickedEngine/wiInitializer.h b/WickedEngine/wiInitializer.h index b0cfef1c012..dadb42a92cd 100644 --- a/WickedEngine/wiInitializer.h +++ b/WickedEngine/wiInitializer.h @@ -17,6 +17,7 @@ namespace wi::initializer INITIALIZED_SYSTEM_PHYSICS, INITIALIZED_SYSTEM_LUA, INITIALIZED_SYSTEM_AUDIO, + INITIALIZED_SYSTEM_TRAILRENDERER, INITIALIZED_SYSTEM_COUNT }; diff --git a/WickedEngine/wiLoadingScreen.cpp b/WickedEngine/wiLoadingScreen.cpp index c201ef5788f..95ca3febf31 100644 --- a/WickedEngine/wiLoadingScreen.cpp +++ b/WickedEngine/wiLoadingScreen.cpp @@ -1,16 +1,33 @@ #include "wiLoadingScreen.h" #include "wiApplication.h" +#include "wiEventHandler.h" #include +using namespace wi::graphics; + namespace wi { - bool LoadingScreen::isActive() + bool LoadingScreen::isActive() const { return wi::jobsystem::IsBusy(ctx); } + bool LoadingScreen::isFinished() const + { + return tasks.empty(); + } + + int LoadingScreen::getProgress() const + { + if (launchedTasks == 0) + return 100; + uint32_t counter = ctx.counter.load(); + float percent = 1 - float(counter) / float(launchedTasks); + return (int)std::round(percent * 100); + } + void LoadingScreen::addLoadingFunction(std::function loadingFunction) { if (loadingFunction != nullptr) @@ -37,24 +54,60 @@ namespace wi void LoadingScreen::Start() { + launchedTasks = (uint32_t)tasks.size(); for (auto& x : tasks) { wi::jobsystem::Execute(ctx, x); } std::thread([this]() { wi::jobsystem::Wait(ctx); - finish(); - }).detach(); + wi::eventhandler::Subscribe_Once(wi::eventhandler::EVENT_THREAD_SAFE_POINT, [this](uint64_t) { + if (finish != nullptr) + finish(); + tasks.clear(); + launchedTasks = 0; + finish = nullptr; + }); + }).detach(); - RenderPath2D::Start(); + RenderPath2D::Start(); } - void LoadingScreen::Stop() + void LoadingScreen::Compose(wi::graphics::CommandList cmd) const { - tasks.clear(); - finish = nullptr; + if (backgroundTexture.IsValid()) + { + wi::image::Params fx; + const Texture& tex = backgroundTexture.GetTexture(); + const TextureDesc& desc = tex.GetDesc(); + + const float canvas_aspect = GetLogicalWidth() / GetLogicalHeight(); + const float image_aspect = float(desc.width) / float(desc.height); + + if (canvas_aspect > image_aspect) + { + // display aspect is wider than image: + fx.siz.x = GetLogicalWidth() / canvas_aspect * image_aspect; + fx.siz.y = GetLogicalHeight(); + } + else + { + // image aspect is wider or equal to display + fx.siz.x = GetLogicalWidth(); + fx.siz.y = GetLogicalHeight() * canvas_aspect / image_aspect; + } + + fx.pos = XMFLOAT3(GetLogicalWidth() * 0.5f, GetLogicalHeight() * 0.5f, 0); + fx.pivot = XMFLOAT2(0.5f, 0.5f); + fx.blendFlag = wi::enums::BLENDMODE_ALPHA; + if (colorspace != ColorSpace::SRGB) + { + fx.enableLinearOutputMapping(hdr_scaling); + } + wi::image::Draw(&tex, fx, cmd); + } - RenderPath2D::Stop(); + RenderPath2D::Compose(cmd); } } diff --git a/WickedEngine/wiLoadingScreen.h b/WickedEngine/wiLoadingScreen.h index 647b2ce6847..7752590004f 100644 --- a/WickedEngine/wiLoadingScreen.h +++ b/WickedEngine/wiLoadingScreen.h @@ -14,27 +14,31 @@ namespace wi class LoadingScreen : public RenderPath2D { - private: + protected: wi::jobsystem::context ctx; wi::vector> tasks; std::function finish; + uint32_t launchedTasks = 0; public: + wi::Resource backgroundTexture; //Add a loading task which should be executed - //use std::bind( YourFunctionPointer ) void addLoadingFunction(std::function loadingFunction); //Helper for loading a whole renderable component void addLoadingComponent(RenderPath* component, Application* main, float fadeSeconds = 0, wi::Color fadeColor = wi::Color(0, 0, 0, 255)); //Set a function that should be called when the loading finishes - //use std::bind( YourFunctionPointer ) void onFinished(std::function finishFunction); //See if the loading is currently running - bool isActive(); + bool isActive() const; + // See if there are any loading tasks that are still not finished + bool isFinished() const; + // Returns the percentage of loading tasks that are finished (0% - 100%) + int getProgress() const; //Start Executing the tasks and mark the loading as active - virtual void Start() override; - //Clear all tasks - virtual void Stop() override; + void Start() override; + + void Compose(wi::graphics::CommandList cmd) const override; }; } diff --git a/WickedEngine/wiLoadingScreen_BindLua.cpp b/WickedEngine/wiLoadingScreen_BindLua.cpp index a0104b983a8..479167c7de5 100644 --- a/WickedEngine/wiLoadingScreen_BindLua.cpp +++ b/WickedEngine/wiLoadingScreen_BindLua.cpp @@ -1,4 +1,14 @@ #include "wiLoadingScreen_BindLua.h" +#include "wiScene_BindLua.h" +#include "wiTexture_BindLua.h" +#include "wiApplication_BindLua.h" +#include "wiRenderPath3D_BindLua.h" + +#include + +using namespace wi::lua::scene; +using namespace wi::scene; +using namespace wi::ecs; namespace wi::lua { @@ -21,54 +31,246 @@ namespace wi::lua lunamethod(RenderPath_BindLua, GetLayerMask), lunamethod(RenderPath_BindLua, SetLayerMask), - lunamethod(LoadingScreen_BindLua, AddLoadingTask), - lunamethod(LoadingScreen_BindLua, OnFinished), + lunamethod(LoadingScreen_BindLua, AddLoadModelTask), + lunamethod(LoadingScreen_BindLua, AddRenderPathActivationTask), + lunamethod(LoadingScreen_BindLua, IsFinished), + lunamethod(LoadingScreen_BindLua, GetProgress), + lunamethod(LoadingScreen_BindLua, SetBackgroundTexture), + lunamethod(LoadingScreen_BindLua, GetBackgroundTexture), { NULL, NULL } }; Luna::PropertyType LoadingScreen_BindLua::properties[] = { { NULL, NULL } }; - int LoadingScreen_BindLua::AddLoadingTask(lua_State* L) + int LoadingScreen_BindLua::AddLoadModelTask(lua_State* L) { + LoadingScreen* loading = dynamic_cast(component); + if (loading == nullptr) + { + wi::lua::SError(L, "AddLoadModelTask(Scene scene, string fileName, opt Matrix transform): loading screen is invalid!"); + return 0; + } + int argc = wi::lua::SGetArgCount(L); if (argc > 0) { - std::string task = wi::lua::SGetString(L, 1); - LoadingScreen* loading = dynamic_cast(component); - if (loading != nullptr) + Scene_BindLua* custom_scene = Luna::lightcheck(L, 1); + if (custom_scene) { - loading->addLoadingFunction([=](wi::jobsystem::JobArgs args) { - wi::lua::RunText(task); + // Overload 1: thread safe version + if (argc > 1) + { + std::string fileName = wi::lua::SGetString(L, 2); + XMMATRIX transform = XMMatrixIdentity(); + if (argc > 2) + { + Matrix_BindLua* matrix = Luna::lightcheck(L, 3); + if (matrix != nullptr) + { + transform = XMLoadFloat4x4(&matrix->data); + } + else + { + wi::lua::SError(L, "AddLoadModelTask(Scene scene, string fileName, opt Matrix transform) argument is not a matrix!"); + } + } + Entity root = CreateEntity(); + loading->addLoadingFunction([=](wi::jobsystem::JobArgs args) { + Scene scene; + wi::scene::LoadModel2(scene, fileName, transform, root); + + // Note: we lock the scene for merging from multiple loading screen tasks + // Because we don't have fine control over thread execution in lua, and this significantly + // simplifies loading into scene from loadingscreen + std::scoped_lock lck(custom_scene->scene->locker); + custom_scene->scene->Merge(scene); }); + wi::lua::SSetLongLong(L, root); + return 1; + } + else + { + wi::lua::SError(L, "AddLoadModelTask(Scene scene, string fileName, opt Matrix transform) not enough arguments!"); + return 0; + } } else - wi::lua::SError(L, "AddLoader(string taskScript) component is not a LoadingScreen!"); + { + // Overload 2: global scene version + std::string fileName = wi::lua::SGetString(L, 1); + XMMATRIX transform = XMMatrixIdentity(); + if (argc > 1) + { + Matrix_BindLua* matrix = Luna::lightcheck(L, 2); + if (matrix != nullptr) + { + transform = XMLoadFloat4x4(&matrix->data); + } + else + { + wi::lua::SError(L, "AddLoadModelTask(string fileName, opt Matrix transform) argument is not a matrix!"); + } + } + Entity root = CreateEntity(); + loading->addLoadingFunction([=](wi::jobsystem::JobArgs args) { + Scene scene; + wi::scene::LoadModel2(scene, fileName, transform, root); + + // Note: we lock the scene for merging from multiple loading screen tasks + // Because we don't have fine control over thread execution in lua, and this significantly + // simplifies loading into scene from loadingscreen + std::scoped_lock lck(GetGlobalScene()->locker); + GetGlobalScene()->Merge(scene); + }); + wi::lua::SSetLongLong(L, root); + return 1; + } } else - wi::lua::SError(L, "AddLoader(string taskScript) not enough arguments!"); + { + wi::lua::SError(L, "AddLoadModelTask(string fileName, opt Matrix transform) not enough arguments!"); + } return 0; } - int LoadingScreen_BindLua::OnFinished(lua_State* L) + int LoadingScreen_BindLua::AddRenderPathActivationTask(lua_State* L) { + LoadingScreen* loading = dynamic_cast(component); + if (loading == nullptr) + { + wi::lua::SError(L, "AddRenderPathActivationTask(RenderPath path, opt float fadeSeconds = 0, opt int fadeR = 0,fadeG = 0,fadeB = 0): loading screen is invalid!"); + return 0; + } + int argc = wi::lua::SGetArgCount(L); - if (argc > 0) + if (argc < 2) + { + wi::lua::SError(L, "AddRenderPathActivationTask(RenderPath path, Application app, opt float fadeSeconds = 0, opt int fadeR = 0,fadeG = 0,fadeB = 0): not enough arguments!"); + return 0; + } + RenderPath* path = nullptr; + + RenderPath3D_BindLua* comp3D = Luna::lightcheck(L, 1); + if (comp3D == nullptr) { - std::string task = wi::lua::SGetString(L, 1); - LoadingScreen* loading = dynamic_cast(component); - if (loading != nullptr) + RenderPath2D_BindLua* comp2D = Luna::lightcheck(L, 1); + if (comp2D == nullptr) { - loading->onFinished([=] { - wi::lua::RunText(task); - }); + LoadingScreen_BindLua* compLoading = Luna::lightcheck(L, 1); + if (compLoading == nullptr) + { + RenderPath_BindLua* comp = Luna::lightcheck(L, 1); + if (comp == nullptr) + { + wi::lua::SError(L, "AddRenderPathActivationTask(RenderPath path, Application app, opt float fadeSeconds = 0, opt int fadeR = 0,fadeG = 0,fadeB = 0): first argument is not a RenderPath!"); + return 0; + } + else + { + path = comp->component; + } + } + else + { + path = compLoading->component; + } } else - wi::lua::SError(L, "OnFinished(string taskScript) component is not a LoadingScreen!"); + { + path = comp2D->component; + } } else - wi::lua::SError(L, "OnFinished(string taskScript) not enough arguments!"); + { + path = comp3D->component; + } + + Application_BindLua* app = Luna::lightcheck(L, 2); + if (app == nullptr) + { + wi::lua::SError(L, "AddRenderPathActivationTask(RenderPath path, Application app, opt float fadeSeconds = 0, opt int fadeR = 0,fadeG = 0,fadeB = 0): second argument is not an Application!"); + return 0; + } + + float fadeSeconds = 0; + wi::Color fadeColor = wi::Color::Black(); + + if (argc > 2) + { + fadeSeconds = wi::lua::SGetFloat(L, 3); + if (argc > 3) + { + fadeColor.setR((uint8_t)wi::lua::SGetInt(L, 4)); + if (argc > 4) + { + fadeColor.setG((uint8_t)wi::lua::SGetInt(L, 5)); + if (argc > 5) + { + fadeColor.setB((uint8_t)wi::lua::SGetInt(L, 6)); + } + } + } + } + + loading->addLoadingComponent(path, app->component, fadeSeconds, fadeColor); + return 0; + } + int LoadingScreen_BindLua::IsFinished(lua_State* L) + { + LoadingScreen* loading = dynamic_cast(component); + if (loading != nullptr) + { + wi::lua::SSetBool(L, loading->isFinished()); + return 1; + } + wi::lua::SError(L, "IsFinished(): loading screen is invalid!"); + return 0; + } + int LoadingScreen_BindLua::GetProgress(lua_State* L) + { + LoadingScreen* loading = dynamic_cast(component); + if (loading != nullptr) + { + wi::lua::SSetInt(L, loading->getProgress()); + return 1; + } + wi::lua::SError(L, "GetProgress(): loading screen is invalid!"); return 0; } + int LoadingScreen_BindLua::SetBackgroundTexture(lua_State* L) + { + LoadingScreen* loading = dynamic_cast(component); + if (loading == nullptr) + { + wi::lua::SError(L, "SetBackgroundTexture(Texture tex): loading screen is not valid!"); + return 0; + } + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "SetBackgroundTexture(Texture tex): not enough arguments!"); + return 0; + } + Texture_BindLua* tex = Luna::lightcheck(L, 1); + if (tex == nullptr) + { + wi::lua::SError(L, "SetBackgroundTexture(Texture tex): argument is not a Texture!"); + return 0; + } + loading->backgroundTexture = tex->resource; + return 0; + } + int LoadingScreen_BindLua::GetBackgroundTexture(lua_State* L) + { + LoadingScreen* loading = dynamic_cast(component); + if (loading == nullptr) + { + wi::lua::SError(L, "GetBackgroundTexture(): loading screen is not valid!"); + return 0; + } + Luna::push(L, loading->backgroundTexture); + return 1; + } void LoadingScreen_BindLua::Bind() { diff --git a/WickedEngine/wiLoadingScreen_BindLua.h b/WickedEngine/wiLoadingScreen_BindLua.h index 925c11f6f59..947cd9dee75 100644 --- a/WickedEngine/wiLoadingScreen_BindLua.h +++ b/WickedEngine/wiLoadingScreen_BindLua.h @@ -25,8 +25,12 @@ namespace wi::lua this->component = &loadingscreen; } - int AddLoadingTask(lua_State* L); - int OnFinished(lua_State* L); + int AddLoadModelTask(lua_State* L); + int AddRenderPathActivationTask(lua_State* L); + int IsFinished(lua_State* L); + int GetProgress(lua_State* L); + int SetBackgroundTexture(lua_State* L); + int GetBackgroundTexture(lua_State* L); static void Bind(); }; diff --git a/WickedEngine/wiLua.cpp b/WickedEngine/wiLua.cpp index 009a45bbbfb..be46f469029 100644 --- a/WickedEngine/wiLua.cpp +++ b/WickedEngine/wiLua.cpp @@ -21,6 +21,9 @@ #include "wiNetwork_BindLua.h" #include "wiPrimitive_BindLua.h" #include "wiPhysics_BindLua.h" +#include "wiVoxelGrid_BindLua.h" +#include "wiPathQuery_BindLua.h" +#include "wiTrailRenderer_BindLua.h" #include "wiTimer.h" #include "wiVector.h" @@ -201,6 +204,9 @@ namespace wi::lua Network_BindLua::Bind(); primitive::Bind(); Physics_BindLua::Bind(); + VoxelGrid_BindLua::Bind(); + PathQuery_BindLua::Bind(); + TrailRenderer_BindLua::Bind(); wi::backlog::post("wi::lua Initialized (" + std::to_string((int)std::round(timer.elapsed())) + " ms)"); } diff --git a/WickedEngine/wiMath.h b/WickedEngine/wiMath.h index 40688a2d1eb..59dd6edc9e6 100644 --- a/WickedEngine/wiMath.h +++ b/WickedEngine/wiMath.h @@ -348,6 +348,32 @@ namespace wi::math return XMVector3TransformNormal(param, M); } + // Centripetal Catmull-Rom avoids self intersections that can appear with XMVectorCatmullRom + // But it doesn't support the case when p0 == p1 or p2 == p3! + // This also supports tension to control curve smoothness + // Note: Catmull-Rom interpolates between p1 and p2 by value of t + inline XMVECTOR XM_CALLCONV CatmullRomCentripetal(XMVECTOR p0, XMVECTOR p1, XMVECTOR p2, XMVECTOR p3, float t, float tension = 0.5f) + { + float alpha = 1.0f - tension; + float t0 = 0.0f; + float t1 = t0 + std::pow(DistanceEstimated(p0, p1), alpha); + float t2 = t1 + std::pow(DistanceEstimated(p1, p2), alpha); + float t3 = t2 + std::pow(DistanceEstimated(p2, p3), alpha); + t = Lerp(t1, t2, t); + float t1t0 = 1.0f / std::max(0.001f, t1 - t0); + float t2t1 = 1.0f / std::max(0.001f, t2 - t1); + float t3t2 = 1.0f / std::max(0.001f, t3 - t2); + float t2t0 = 1.0f / std::max(0.001f, t2 - t0); + float t3t1 = 1.0f / std::max(0.001f, t3 - t1); + XMVECTOR A1 = (t1 - t) * t1t0 * p0 + (t - t0) * t1t0 * p1; + XMVECTOR A2 = (t2 - t) * t2t1 * p1 + (t - t1) * t2t1 * p2; + XMVECTOR A3 = (t3 - t) * t3t2 * p2 + (t - t2) * t3t2 * p3; + XMVECTOR B1 = (t2 - t) * t2t0 * A1 + (t - t0) * t2t0 * A2; + XMVECTOR B2 = (t3 - t) * t3t1 * A2 + (t - t1) * t3t1 * A3; + XMVECTOR C = (t2 - t) * t2t1 * B1 + (t - t1) * t2t1 * B2; + return C; + } + XMFLOAT3 QuaternionToRollPitchYaw(const XMFLOAT4& quaternion); XMVECTOR GetClosestPointToLine(const XMVECTOR& A, const XMVECTOR& B, const XMVECTOR& P, bool segmentClamp = false); @@ -367,6 +393,19 @@ namespace wi::math void ConstructTriangleEquilateral(float radius, XMFLOAT4& A, XMFLOAT4& B, XMFLOAT4& C); void GetBarycentric(const XMVECTOR& p, const XMVECTOR& a, const XMVECTOR& b, const XMVECTOR& c, float &u, float &v, float &w, bool clamp = false); + inline XMFLOAT3 GetForward(const XMFLOAT4X4& _m) + { + return XMFLOAT3(_m.m[2][0], _m.m[2][1], _m.m[2][2]); + } + inline XMFLOAT3 GetUp(const XMFLOAT4X4& _m) + { + return XMFLOAT3(_m.m[1][0], _m.m[1][1], _m.m[1][2]); + } + inline XMFLOAT3 GetRight(const XMFLOAT4X4& _m) + { + return XMFLOAT3(_m.m[0][0], _m.m[0][1], _m.m[0][2]); + } + // Returns an element of a precomputed halton sequence. Specify which iteration to get with idx >= 0 const XMFLOAT4& GetHaltonSequence(int idx); diff --git a/WickedEngine/wiMath_BindLua.cpp b/WickedEngine/wiMath_BindLua.cpp index 4b070f7715b..27deaa80258 100644 --- a/WickedEngine/wiMath_BindLua.cpp +++ b/WickedEngine/wiMath_BindLua.cpp @@ -27,6 +27,7 @@ namespace wi::lua lunamethod(Vector_BindLua, QuaternionSlerp), lunamethod(Vector_BindLua, Slerp), lunamethod(Vector_BindLua, Clamp), + lunamethod(Vector_BindLua, QuaternionIdentity), lunamethod(Vector_BindLua, QuaternionInverse), lunamethod(Vector_BindLua, QuaternionNormalize), lunamethod(Vector_BindLua, QuaternionMultiply), @@ -426,6 +427,11 @@ namespace wi::lua } + int Vector_BindLua::QuaternionIdentity(lua_State* L) + { + Luna::push(L, XMQuaternionIdentity()); + return 1; + } int Vector_BindLua::QuaternionInverse(lua_State* L) { int argc = wi::lua::SGetArgCount(L); @@ -914,11 +920,6 @@ namespace wi::lua wi::lua::SError(L, "Inverse(Matrix m) not enough arguments!"); return 0; } - static XMVECTOR GetForward(XMMATRIX* _m) - { - XMVECTOR V = XMVectorSet(XMVectorGetX(_m->r[2]), XMVectorGetY(_m->r[2]), XMVectorGetZ(_m->r[2]), 0.0f); - return V; - } int Matrix_BindLua::GetForward(lua_State* L) { int argc = wi::lua::SGetArgCount(L); @@ -927,19 +928,12 @@ namespace wi::lua Matrix_BindLua* m1 = Luna::lightcheck(L, 1); if (m1) { - XMMATRIX matrix = XMLoadFloat4x4(&m1->data); - XMVECTOR V = XMVectorSet(XMVectorGetX(matrix.r[2]), XMVectorGetY(matrix.r[2]), XMVectorGetZ(matrix.r[2]), 0.0f); - Luna::push(L, V); + Luna::push(L, wi::math::GetForward(m1->data)); return 1; } } - wi::lua::SError(L, "GetForward(Matrix m) not enough arguments!"); - return 0; - } - static XMVECTOR GetUp(XMMATRIX* _m) - { - XMVECTOR V = XMVectorSet(XMVectorGetX(_m->r[1]), XMVectorGetY(_m->r[1]), XMVectorGetZ(_m->r[1]), 0.0f); - return V; + Luna::push(L, wi::math::GetForward(data)); + return 1; } int Matrix_BindLua::GetUp(lua_State* L) { @@ -949,19 +943,12 @@ namespace wi::lua Matrix_BindLua* m1 = Luna::lightcheck(L, 1); if (m1) { - XMMATRIX matrix = XMLoadFloat4x4(&m1->data); - XMVECTOR V = XMVectorSet(XMVectorGetX(matrix.r[1]), XMVectorGetY(matrix.r[1]), XMVectorGetZ(matrix.r[1]), 0.0f); - Luna::push(L, V); + Luna::push(L, wi::math::GetUp(m1->data)); return 1; } } - wi::lua::SError(L, "GetUp(Matrix m) not enough arguments!"); - return 0; - } - static XMVECTOR GetRight(XMMATRIX* _m) - { - XMVECTOR V = XMVectorSet(XMVectorGetX(_m->r[0]), XMVectorGetY(_m->r[0]), XMVectorGetZ(_m->r[0]), 0.0f); - return V; + Luna::push(L, wi::math::GetUp(data)); + return 1; } int Matrix_BindLua::GetRight(lua_State* L) { @@ -971,14 +958,12 @@ namespace wi::lua Matrix_BindLua* m1 = Luna::lightcheck(L, 1); if (m1) { - XMMATRIX matrix = XMLoadFloat4x4(&m1->data); - XMVECTOR V = XMVectorSet(XMVectorGetX(matrix.r[0]), XMVectorGetY(matrix.r[0]), XMVectorGetZ(matrix.r[0]), 0.0f); - Luna::push(L, V); + Luna::push(L, wi::math::GetRight(m1->data)); return 1; } } - wi::lua::SError(L, "GetRight(Matrix m) not enough arguments!"); - return 0; + Luna::push(L, wi::math::GetRight(data)); + return 1; } void Matrix_BindLua::Bind() diff --git a/WickedEngine/wiMath_BindLua.h b/WickedEngine/wiMath_BindLua.h index 3384bcb0f95..d9b4c2f8af8 100644 --- a/WickedEngine/wiMath_BindLua.h +++ b/WickedEngine/wiMath_BindLua.h @@ -6,7 +6,6 @@ namespace wi::lua { - class Vector_BindLua { public: @@ -51,6 +50,7 @@ namespace wi::lua int Rotate(lua_State* L); + int QuaternionIdentity(lua_State* L); int QuaternionInverse(lua_State* L); int QuaternionNormalize(lua_State* L); int QuaternionMultiply(lua_State* L); diff --git a/WickedEngine/wiOcean.cpp b/WickedEngine/wiOcean.cpp index 82380fb5e25..0bd26b27c91 100644 --- a/WickedEngine/wiOcean.cpp +++ b/WickedEngine/wiOcean.cpp @@ -31,8 +31,6 @@ namespace wi PipelineState PSO, PSO_wire; - wi::fftgenerator::CSFFT512x512_Plan m_fft_plan; - void LoadShaders() { @@ -312,7 +310,7 @@ namespace wi // ------------------------------------ Perform FFT ------------------------------------------- - fft_512x512_c2c(m_fft_plan, buffer_Float_Dxyz, buffer_Float_Dxyz, buffer_Float2_Ht, cmd); + wi::fftgenerator::fft_512x512_c2c(buffer_Float_Dxyz, buffer_Float_Dxyz, buffer_Float2_Ht, cmd); @@ -490,7 +488,6 @@ namespace wi LoadShaders(); wi::fftgenerator::LoadShaders(); - fft512x512_create_plan(m_fft_plan, 3); wi::backlog::post("wi::Ocean Initialized (" + std::to_string((int)std::round(timer.elapsed())) + " ms)"); } diff --git a/WickedEngine/wiPathQuery.cpp b/WickedEngine/wiPathQuery.cpp new file mode 100644 index 00000000000..5c625ac5064 --- /dev/null +++ b/WickedEngine/wiPathQuery.cpp @@ -0,0 +1,692 @@ +#include "wiPathQuery.h" +#include "wiRenderer.h" +#include "wiEventHandler.h" +#include "wiProfiler.h" +#include "wiPrimitive.h" + +using namespace wi::graphics; +using namespace wi::primitive; + +namespace wi +{ + + void PathQuery::process( + const XMFLOAT3& startpos, + const XMFLOAT3& goalpos, + const wi::VoxelGrid& voxelgrid + ) + { + frontier = {}; + came_from.clear(); + cost_so_far.clear(); + result_path_goal_to_start.clear(); + result_path_goal_to_start_simplified.clear(); + process_startpos = startpos; + Node start = Node::create(voxelgrid.world_to_coord(startpos)); + Node goal = Node::create(voxelgrid.world_to_coord(goalpos)); + debugstartnode = voxelgrid.coord_to_world(start.coord()); + debuggoalnode = voxelgrid.coord_to_world(goal.coord()); + debugvoxelsize = voxelgrid.voxelSize; + + auto cost_to_goal = [&](XMUINT3 coord, XMUINT3 goal) { + // manhattan distance: + return std::abs(int(coord.x) - int(goal.x)) + std::abs(int(coord.y) - int(goal.y)) + std::abs(int(coord.z) - int(goal.z)); + }; + auto dda = [&](const XMUINT3& start, const XMUINT3& goal) + { + const int dx = int(goal.x) - int(start.x); + const int dy = int(goal.y) - int(start.y); + const int dz = int(goal.z) - int(start.z); + + const int step = std::max(std::abs(dx), std::max(std::abs(dy), std::abs(dz))); + + const float x_incr = float(dx) / step; + const float y_incr = float(dy) / step; + const float z_incr = float(dz) / step; + + float x = float(start.x); + float y = float(start.y); + float z = float(start.z); + + for (int i = 0; i < step; i++) + { + XMUINT3 coord = XMUINT3(uint32_t(std::round(x)), uint32_t(std::round(y)), uint32_t(std::round(z))); + if (!is_voxel_valid(voxelgrid, coord)) + return false; + x += x_incr; + y += y_incr; + z += z_incr; + } + return true; + }; + + if (!is_voxel_valid(voxelgrid, goal.coord())) + { + // If goal is unreachable because it is not a valid voxel, check immediate neighborhood: + // This works better than abandoning when goal happens to be in an invalid voxel because + // that happens often because mismatching voxel resolution from real geometry + bool found = false; + const int allow_width = agent_width + 1; + const int allow_height = agent_height + 1; + for (int x = -allow_width; x <= allow_width && !found; ++x) + { + for (int y = -allow_height; y <= allow_height && !found; ++y) + { + for (int z = -allow_width; z <= allow_width && !found; ++z) + { + if (x == 0 && y == 0 && z == 0) + { + continue; + } + XMUINT3 neighbor_coord = XMUINT3(uint32_t(goal.x + x), uint32_t(goal.y + y), uint32_t(goal.z + z)); + if (is_voxel_valid(voxelgrid, neighbor_coord)) + { + goal = Node::create(neighbor_coord); + found = true; + break; + } + } + } + } + if (!found) + { + // if neighborhood was not valid at all, then abandon the search: + return; + } + } + + // A* explanation at: https://www.redblobgames.com/pathfinding/a-star/introduction.html + frontier.emplace(start); + came_from[start] = Node::invalid(); + cost_so_far[start] = 0; + + while (!frontier.empty()) + { + Node current = frontier.top(); + frontier.pop(); + + if (current == goal) + break; + + XMUINT3 coord = current.coord(); + +#if 1 + // The neighbors to which traversal can happen from the current cell: + // Horizontal diagonal is not allowed, only vertical (to support stairs) + // Note: diagonal can be supported, but since the path will be simplified, + // diagonal voxel movements do not seem to contribute much improvement, + // in fact non-diagonal movements can keep away better from wall corners + XMUINT3 neighbors[] = { + // left-right: + XMUINT3(coord.x - 1, coord.y, coord.z), + XMUINT3(coord.x + 1, coord.y, coord.z), + + // left-right up: + XMUINT3(coord.x - 1, coord.y - 1, coord.z), + XMUINT3(coord.x + 1, coord.y - 1, coord.z), + + // left-right down: + XMUINT3(coord.x - 1, coord.y + 1, coord.z), + XMUINT3(coord.x + 1, coord.y + 1, coord.z), + + // up-down: + XMUINT3(coord.x, coord.y - 1, coord.z), + XMUINT3(coord.x, coord.y + 1, coord.z), + + // forward-back: + XMUINT3(coord.x, coord.y, coord.z - 1), + XMUINT3(coord.x, coord.y, coord.z + 1), + + // forward-back up: + XMUINT3(coord.x, coord.y - 1, coord.z - 1), + XMUINT3(coord.x, coord.y - 1, coord.z + 1), + + // forward-back down: + XMUINT3(coord.x, coord.y + 1, coord.z - 1), + XMUINT3(coord.x, coord.y + 1, coord.z + 1), + }; + uint32_t neighbor_count = arraysize(neighbors); +#else + uint32_t neighbor_count = 0; + XMUINT3 neighbors[26]; + for (int x = -1; x <= 1; ++x) + { + for (int y = -1; y <= 1; ++y) + { + for (int z = -1; z <= 1; ++z) + { + if (x == 0 && y == 0 && z == 0) + { + continue; + } + neighbors[neighbor_count++] = XMUINT3(uint32_t(coord.x + x), uint32_t(coord.y + y), uint32_t(coord.z + z)); + } + } + } +#endif + + for (uint32_t i = 0; i < neighbor_count; ++i) + { + if (!is_voxel_valid(voxelgrid, neighbors[i])) + continue; + Node next = Node::create(neighbors[i]); + uint16_t new_cost = cost_so_far[current] + cost_to_goal(current.coord(), next.coord()); + if (cost_so_far.find(next) == cost_so_far.end() || new_cost < cost_so_far[next]) + { + cost_so_far[next] = new_cost; + next.cost = new_cost + cost_to_goal(neighbors[i], goal.coord()); + frontier.push(next); + came_from[next] = current; + } + } + } + + if (came_from[goal] != Node::invalid()) + { + // If goal is reachable, add that as the first result waypoint: + result_path_goal_to_start.push_back(voxelgrid.coord_to_world(goal.coord())); + } + + // Add rest of the path to result waypoints: + Node current = goal; + while (came_from[current] != Node::invalid()) + { + Node node = came_from[current]; + result_path_goal_to_start.push_back(voxelgrid.coord_to_world(node.coord())); + current = node; + } + + // Simplification: + if (!result_path_goal_to_start.empty()) + { + // first waypoint will always need to be in the simplified path: + result_path_goal_to_start_simplified.push_back(result_path_goal_to_start[0]); + + for (size_t i = 0; i < result_path_goal_to_start.size() - 1;) + { + Node current = Node::create(voxelgrid.world_to_coord(result_path_goal_to_start[i])); + + // If no occlusion test was successful, then the next will be inserted. + // We don't check occlusion for this as this is definitely traversible from previous node + size_t next_candidate = i + 1; + + // Occlusion tests will be performed further down from next node: + for (size_t j = next_candidate + 1; j < result_path_goal_to_start.size(); ++j) + { + Node next = Node::create(voxelgrid.world_to_coord(result_path_goal_to_start[j])); + + // Visibility check from current to next by drawing a line with DDA and checking validity at each step: + if (dda(current.coord(), next.coord())) + { + // if visible from current, this is accepted as a good next candidate: + next_candidate = j; + } + else + { + // if not visible from current we abandon testing anything further: + break; + } + } + + // Always insert the next best candidate node to the simplified path: + result_path_goal_to_start_simplified.push_back(result_path_goal_to_start[next_candidate]); + i = next_candidate; // the next candidate will be the current node of the next iteration + } + } + } + + bool PathQuery::search_cover( + const XMFLOAT3& observer, + const XMFLOAT3& subject, + const XMFLOAT3& direction, + float max_distance, + const wi::VoxelGrid& voxelgrid + ) + { + XMFLOAT3 goal_world; + XMStoreFloat3(&goal_world, XMLoadFloat3(&subject) + XMLoadFloat3(&direction) * max_distance); + + XMINT3 start = voxelgrid.world_to_coord_signed(observer); + XMINT3 goal = voxelgrid.world_to_coord_signed(goal_world); + start.y = goal.y; + XMUINT3 observer_coord = voxelgrid.world_to_coord(observer); + if (!flying) + { + // place visibility start check above ground if not flying + observer_coord.y -= 1; + } + const XMFLOAT3 observer_point = voxelgrid.coord_to_world(observer_coord); + + auto is_cover = [&](const XMUINT3& coord) { + if (!is_voxel_valid(voxelgrid, coord)) + return false; + XMUINT3 visibility_coord = coord; + if (visibility_coord.y > 0 && !flying) + { + // place visibility end check above ground if not flying + visibility_coord.y -= 1; + } + XMFLOAT3 center = voxelgrid.coord_to_world(visibility_coord); + float width = agent_width * voxelgrid.voxelSize.x * 2; + float height = agent_height * voxelgrid.voxelSize.y * 2; + AABB subject_aabb(XMFLOAT3(center.x - width, center.y, center.z - width), XMFLOAT3(center.x + width, center.y + height, center.z + width)); + if (voxelgrid.is_visible(observer_point, subject_aabb)) + return false; + process(subject, voxelgrid.coord_to_world(coord), voxelgrid); + return is_succesful(); + }; + + const int dx = int(goal.x) - int(start.x); + const int dy = int(goal.y) - int(start.y); + const int dz = int(goal.z) - int(start.z); + + const int step = std::max(std::abs(dx), std::max(std::abs(dy), std::abs(dz))); + + const float x_incr = float(dx) / step; + const float y_incr = float(dy) / step; + const float z_incr = float(dz) / step; + + float x = float(start.x); + float y = float(start.y); + float z = float(start.z); + + for (int i = 0; i < step; i++) + { + XMUINT3 coord = XMUINT3(uint32_t(std::round(x)), uint32_t(std::round(y)), uint32_t(std::round(z))); + if (coord.x == goal.x && coord.y == goal.y && coord.z == goal.z) + return false; + if (!voxelgrid.is_coord_valid(coord)) + return false; + + if (is_cover(coord)) + { + return true; + } + + x += x_incr; + y += y_incr; + z += z_incr; + } + return false; + } + + bool PathQuery::is_succesful() const + { + return !result_path_goal_to_start.empty(); + } + + XMFLOAT3 PathQuery::get_next_waypoint() const + { + const wi::vector& results = result_path_goal_to_start_simplified.empty() ? result_path_goal_to_start : result_path_goal_to_start_simplified; + if (results.size() < 2) + return process_startpos; + return results[results.size() - 2]; + } + + size_t PathQuery::get_waypoint_count() const + { + const wi::vector& results = result_path_goal_to_start_simplified.empty() ? result_path_goal_to_start : result_path_goal_to_start_simplified; + return results.size(); + } + + XMFLOAT3 PathQuery::get_waypoint(size_t index) const + { + const wi::vector& results = result_path_goal_to_start_simplified.empty() ? result_path_goal_to_start : result_path_goal_to_start_simplified; + if (results.size() <= index) + return process_startpos; + return results[results.size() - 1 - index]; // return results in direction: start -> goal + } + + XMFLOAT3 PathQuery::get_goal() const + { + const wi::vector& results = result_path_goal_to_start_simplified.empty() ? result_path_goal_to_start : result_path_goal_to_start_simplified; + if (results.empty()) + return process_startpos; + return results.front(); + } + + bool PathQuery::is_voxel_valid(const VoxelGrid& voxelgrid, XMUINT3 coord) const + { + if (flying) + { + // Flying checks: + + // Center voxel must be within voxel grid: + if (!voxelgrid.is_coord_valid(coord)) + return false; + + // Neighbor voxels around center must be empty according to agent width and height: + for (int x = -agent_width; x <= agent_width; ++x) + { + for (int z = -agent_width; z <= agent_width; ++z) + { + for (int y = 0; y < agent_height; ++y) + { + XMUINT3 neighbor_coord = XMUINT3(uint32_t(coord.x + x), uint32_t(coord.y - y), uint32_t(coord.z + z)); + if (voxelgrid.check_voxel(neighbor_coord)) + return false; + } + } + } + } + else + { + // Grounded checks: + + // Center voxel must be ground (valid): + if (!voxelgrid.check_voxel(coord)) + return false; + + // Neighbor voxels above center must be empty according to agent width and height: + for (int x = -agent_width; x <= agent_width; ++x) + { + for (int z = -agent_width; z <= agent_width; ++z) + { + for (int y = 0; y < 0 + agent_height; ++y) + { + // Note that we check above ground only (-1 on Y)! + XMUINT3 neighbor_coord = XMUINT3(uint32_t(coord.x + x), uint32_t(coord.y - y - 1), uint32_t(coord.z + z)); + if (voxelgrid.check_voxel(neighbor_coord)) + return false; + } + } + } + } + return true; + } + + namespace PathQuery_internal + { + PipelineState pso_curve; + PipelineState pso_waypoint; + static void LoadShaders() + { + PipelineStateDesc desc; + desc.vs = wi::renderer::GetShader(wi::enums::VSTYPE_VERTEXCOLOR); + desc.ps = wi::renderer::GetShader(wi::enums::PSTYPE_VERTEXCOLOR); + desc.il = wi::renderer::GetInputLayout(wi::enums::ILTYPE_VERTEXCOLOR); + desc.dss = wi::renderer::GetDepthStencilState(wi::enums::DSSTYPE_DEPTHREAD); + desc.rs = wi::renderer::GetRasterizerState(wi::enums::RSTYPE_DOUBLESIDED); + desc.bs = wi::renderer::GetBlendState(wi::enums::BSTYPE_TRANSPARENT); + desc.pt = PrimitiveTopology::TRIANGLESTRIP; + + GraphicsDevice* device = GetDevice(); + device->CreatePipelineState(&desc, &pso_curve); + + desc.rs = wi::renderer::GetRasterizerState(wi::enums::RSTYPE_FRONT); + desc.bs = wi::renderer::GetBlendState(wi::enums::BSTYPE_ADDITIVE); + desc.pt = PrimitiveTopology::TRIANGLELIST; + device->CreatePipelineState(&desc, &pso_waypoint); + } + } + using namespace PathQuery_internal; + + void PathQuery::debugdraw(const XMFLOAT4X4& ViewProjection, CommandList cmd) const + { + const wi::vector& results = result_path_goal_to_start_simplified.empty() ? result_path_goal_to_start : result_path_goal_to_start_simplified; + + static bool shaders_loaded = false; + if (!shaders_loaded) + { + shaders_loaded = true; + static wi::eventhandler::Handle handle = wi::eventhandler::Subscribe(wi::eventhandler::EVENT_RELOAD_SHADERS, [](uint64_t userdata) { LoadShaders(); }); + LoadShaders(); + } + + struct Vertex + { + XMFLOAT4 position; + XMFLOAT4 color; + }; + + GraphicsDevice* device = GetDevice(); + device->EventBegin("PathQuery::debugdraw", cmd); + + MiscCB sb; + sb.g_xTransform = ViewProjection; + sb.g_xColor = XMFLOAT4(1, 1, 1, 1); + device->BindDynamicConstantBuffer(sb, CBSLOT_RENDERER_MISC, cmd); + + if (debug_voxels) + { + static constexpr Vertex cubeVerts[] = { + {XMFLOAT4(-1,1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,-1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,-1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,-1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,-1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,-1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,-1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,-1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,-1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,-1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,-1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,-1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,-1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,-1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,-1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,-1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,-1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,-1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,-1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,1,-1,1), XMFLOAT4(1,1,1,1)}, + }; + + if (results.size() >= 2) + { + // Waypoint cubes: + size_t numVoxels = result_path_goal_to_start_simplified.size() + result_path_goal_to_start.size(); + auto mem = device->AllocateGPU(sizeof(cubeVerts) * numVoxels, cmd); + + const XMVECTOR VOXELSIZE = XMLoadFloat3(&debugvoxelsize); + + size_t dst_offset = 0; + for (size_t i = 0; i < numVoxels; ++i) + { + const wi::vector& srcarray = i < result_path_goal_to_start.size() ? result_path_goal_to_start : result_path_goal_to_start_simplified; + const size_t idx = i < result_path_goal_to_start.size() ? i : (i - result_path_goal_to_start.size()); + const XMFLOAT4 color = i < result_path_goal_to_start.size() ? XMFLOAT4(0, 0, 1, 1) : XMFLOAT4(1, 0, 0, 1); + + const XMVECTOR P = XMLoadFloat3(srcarray.data() + idx); + + Vertex verts[arraysize(cubeVerts)]; + std::memcpy(verts, cubeVerts, sizeof(cubeVerts)); + for (auto& v : verts) + { + XMVECTOR C = XMLoadFloat4(&v.position); + C *= VOXELSIZE; + C += P; + C = XMVectorSetW(C, 1); + XMStoreFloat4(&v.position, C); + v.color = color; + } + std::memcpy((uint8_t*)mem.data + dst_offset, verts, sizeof(verts)); + dst_offset += sizeof(verts); + } + + device->BindPipelineState(&pso_waypoint, cmd); + + const GPUBuffer* vbs[] = { + &mem.buffer, + }; + const uint32_t strides[] = { + sizeof(Vertex), + }; + const uint64_t offsets[] = { + mem.offset, + }; + device->BindVertexBuffers(vbs, 0, arraysize(vbs), strides, offsets, cmd); + + device->Draw(uint32_t(arraysize(cubeVerts) * numVoxels), 0, cmd); + } + else + { + // Start and goal positions: + const size_t numVoxels = 2; + auto mem = device->AllocateGPU(sizeof(cubeVerts) * numVoxels, cmd); + + const XMVECTOR VOXELSIZE = XMLoadFloat3(&debugvoxelsize); + + size_t dst_offset = 0; + { + XMVECTOR P = XMLoadFloat3(&debugstartnode); + Vertex verts[arraysize(cubeVerts)]; + std::memcpy(verts, cubeVerts, sizeof(cubeVerts)); + for (auto& v : verts) + { + XMVECTOR C = XMLoadFloat4(&v.position); + C *= VOXELSIZE; + C += P; + C = XMVectorSetW(C, 1); + XMStoreFloat4(&v.position, C); + v.color = XMFLOAT4(1, 0, 0, 1); + } + std::memcpy((uint8_t*)mem.data + dst_offset, verts, sizeof(verts)); + dst_offset += sizeof(verts); + } + { + XMVECTOR P = XMLoadFloat3(&debuggoalnode); + Vertex verts[arraysize(cubeVerts)]; + std::memcpy(verts, cubeVerts, sizeof(cubeVerts)); + for (auto& v : verts) + { + XMVECTOR C = XMLoadFloat4(&v.position); + C *= VOXELSIZE; + C += P; + C = XMVectorSetW(C, 1); + XMStoreFloat4(&v.position, C); + v.color = XMFLOAT4(1, 0, 0, 1); + } + std::memcpy((uint8_t*)mem.data + dst_offset, verts, sizeof(verts)); + dst_offset += sizeof(verts); + } + + device->BindPipelineState(&pso_waypoint, cmd); + + const GPUBuffer* vbs[] = { + &mem.buffer, + }; + const uint32_t strides[] = { + sizeof(Vertex), + }; + const uint64_t offsets[] = { + mem.offset, + }; + device->BindVertexBuffers(vbs, 0, arraysize(vbs), strides, offsets, cmd); + + device->Draw(uint32_t(arraysize(cubeVerts) * numVoxels), 0, cmd); + } + } + + // Curve: + if (results.size() >= 2) + { + static uint32_t resolution = 100; + const float resolution_rcp = 1.0f / resolution; + uint32_t numSegments = uint32_t(results.size()) * resolution; + uint32_t numVertices = numSegments * 2; + + auto mem = device->AllocateGPU(sizeof(Vertex) * numVertices, cmd); + + static float width = std::max(debugvoxelsize.x, debugvoxelsize.z) * 0.2f; + debugtimer += 0.16f; + float segmenti = 0; + static float gradientsize = 5.0f / resolution; + static XMFLOAT4 color0 = wi::Color(10, 10, 20, 255); + static XMFLOAT4 color1 = wi::Color(70, 150, 170, 255); + static float curve_tension = 0.5f; + + const XMVECTOR topalign = XMVectorSet(0, flying ? 0 : debugvoxelsize.y, 0, 0); // align line to top of voxels (if not flying) + + numVertices = 0; + Vertex* vertices = (Vertex*)mem.data; + int count = (int)results.size(); + for (int i = 0; i < count; ++i) + { + XMVECTOR P0 = XMLoadFloat3(&results[std::max(0, std::min(i - 1, count - 1))]); + XMVECTOR P1 = XMLoadFloat3(&results[std::max(0, std::min(i, count - 1))]); + XMVECTOR P2 = XMLoadFloat3(&results[std::max(0, std::min(i + 1, count - 1))]); + XMVECTOR P3 = XMLoadFloat3(&results[std::max(0, std::min(i + 2, count - 1))]); + + if (i == 0) + { + // when P0 == P1, centripetal catmull doesn't work, so we have to do a dummy control point + P0 += P1 - P2; + } + if (i >= count - 2) + { + // when P2 == P3, centripetal catmull doesn't work, so we have to do a dummy control point + P3 += P2 - P1; + } + + bool cap = i == (count - 1); + uint32_t segment_resolution = cap ? 1 : resolution; + + for (uint32_t j = 0; j < segment_resolution; ++j) + { + float t = float(j) / float(segment_resolution); + +#if 1 + XMVECTOR P = cap ? XMVectorLerp(P1, P2, t) : wi::math::CatmullRomCentripetal(P0, P1, P2, P3, t, curve_tension); + XMVECTOR P_prev = cap ? XMVectorLerp(P0, P1, t - resolution_rcp) : wi::math::CatmullRomCentripetal(P0, P1, P2, P3, t - resolution_rcp, curve_tension); + XMVECTOR P_next = cap ? XMVectorLerp(P1, P2, t + resolution_rcp) : wi::math::CatmullRomCentripetal(P0, P1, P2, P3, t + resolution_rcp, curve_tension); +#else + XMVECTOR P = XMVectorLerp(P1, P2, t); + XMVECTOR P_prev = XMVectorLerp(P0, P1, t - resolution_rcp); + XMVECTOR P_next = XMVectorLerp(P1, P2, t + resolution_rcp); +#endif + + XMVECTOR T = XMVector3Normalize(P_next - P_prev); + XMVECTOR B = XMVector3Normalize(XMVector3Cross(T, XMVectorSet(0, 1, 0, 0))); + B *= width; + + Vertex vert; + vert.color = wi::math::Lerp(color0, color1, wi::math::saturate(std::sin(segmenti + debugtimer) * 0.5f + 0.5f)); + + XMStoreFloat4(&vert.position, XMVectorSetW(P - B + topalign, 1)); + std::memcpy(vertices + numVertices, &vert, sizeof(vert)); + numVertices++; + + XMStoreFloat4(&vert.position, XMVectorSetW(P + B + topalign, 1)); + std::memcpy(vertices + numVertices, &vert, sizeof(vert)); + numVertices++; + + segmenti += gradientsize; + } + } + + device->BindPipelineState(&pso_curve, cmd); + + const GPUBuffer* vbs[] = { + &mem.buffer, + }; + const uint32_t strides[] = { + sizeof(Vertex), + }; + const uint64_t offsets[] = { + mem.offset, + }; + device->BindVertexBuffers(vbs, 0, arraysize(vbs), strides, offsets, cmd); + + device->Draw(numVertices, 0, cmd); + } + + device->EventEnd(cmd); + } +} diff --git a/WickedEngine/wiPathQuery.h b/WickedEngine/wiPathQuery.h new file mode 100644 index 00000000000..21d0cb91a20 --- /dev/null +++ b/WickedEngine/wiPathQuery.h @@ -0,0 +1,97 @@ +#pragma once +#include "CommonInclude.h" +#include "wiUnorderedMap.h" +#include "wiVector.h" +#include "wiVoxelGrid.h" +#include "wiGraphicsDevice.h" +#include "wiPrimitive.h" + +#include + +namespace wi +{ + struct PathQuery + { + struct Node + { + uint16_t x = 0; + uint16_t y = 0; + uint16_t z = 0; + uint16_t cost = 0; + constexpr XMUINT3 coord() const + { + return XMUINT3(x, y, z); + } + static constexpr Node create(XMUINT3 coord) + { + Node node = {}; + node.x = coord.x; + node.y = coord.y; + node.z = coord.z; + return node; + } + static constexpr Node invalid() + { + return {}; + } + constexpr bool operator>(const Node& other) const { return cost > other.cost; } // for priority_queue + constexpr bool operator<(const Node& other) const { return cost < other.cost; } // for priority_queue + constexpr operator uint64_t() const { return uint64_t(uint64_t(x) | (uint64_t(y) << 16ull) | (uint64_t(z) << 32ull)); } // for unordered_map + }; + + std::priority_queue, std::greater> frontier; + wi::unordered_map came_from; + wi::unordered_map cost_so_far; + wi::vector result_path_goal_to_start; + wi::vector result_path_goal_to_start_simplified; + XMFLOAT3 process_startpos = XMFLOAT3(0, 0, 0); + bool flying = false; // if set to true, it will switch to navigating on empty voxels + int agent_height = 1; // keep away from vertical obstacles by this many voxels + int agent_width = 0; // keep away from horizontal obstacles by this many voxels + + // Find the path between startpos and goalpos in the voxel grid: + void process( + const XMFLOAT3& startpos, + const XMFLOAT3& goalpos, + const wi::VoxelGrid& voxelgrid + ); + + bool is_succesful() const; + + // Search for a cover location that can hide the subject from observer. + // observer: location to hide from + // subject: location of who wants to hide + // direction: subject's search direction + // max_distance: maximum search distance + // voxelgrid: voxel grid to perform the search in + // returns whether a suitable cover was found or not + bool search_cover( + const XMFLOAT3& observer, + const XMFLOAT3& subject, + const XMFLOAT3& direction, + float max_distance, + const wi::VoxelGrid& voxelgrid + ); + + // Gets the next upcoming waypoint between start and goal that was used in process(): + XMFLOAT3 get_next_waypoint() const; + + // Gets the number of resulting waypoints + size_t get_waypoint_count() const; + + // Gets the result waypoint at specified index (direction: start -> goal) + XMFLOAT3 get_waypoint(size_t index) const; + + XMFLOAT3 get_goal() const; + + bool is_voxel_valid(const VoxelGrid& voxelgrid, XMUINT3 coord) const; + + bool debug_voxels = true; + mutable float debugtimer = 0; + XMFLOAT3 debugvoxelsize = XMFLOAT3(0, 0, 0); + XMFLOAT3 debugstartnode = XMFLOAT3(0, 0, 0); + XMFLOAT3 debuggoalnode = XMFLOAT3(0, 0, 0); + bool debug_waypoints = false; // if true, waypoint voxels will be drawn. Blue = waypoint, Pink = simplified waypoint + void debugdraw(const XMFLOAT4X4& ViewProjection, wi::graphics::CommandList cmd) const; + }; +} diff --git a/WickedEngine/wiPathQuery_BindLua.cpp b/WickedEngine/wiPathQuery_BindLua.cpp new file mode 100644 index 00000000000..3c8dd4d0b41 --- /dev/null +++ b/WickedEngine/wiPathQuery_BindLua.cpp @@ -0,0 +1,201 @@ +#include "wiPathQuery_BindLua.h" +#include "wiMath_BindLua.h" +#include "wiVoxelGrid_BindLua.h" + +namespace wi::lua +{ + Luna::FunctionType PathQuery_BindLua::methods[] = { + lunamethod(PathQuery_BindLua, Process), + lunamethod(PathQuery_BindLua, SearchCover), + lunamethod(PathQuery_BindLua, IsSuccessful), + lunamethod(PathQuery_BindLua, GetNextWaypoint), + lunamethod(PathQuery_BindLua, SetDebugDrawWaypointsEnabled), + lunamethod(PathQuery_BindLua, SetFlying), + lunamethod(PathQuery_BindLua, IsFlying), + lunamethod(PathQuery_BindLua, SetAgentWidth), + lunamethod(PathQuery_BindLua, GetAgentWidth), + lunamethod(PathQuery_BindLua, SetAgentHeight), + lunamethod(PathQuery_BindLua, GetAgentHeight), + lunamethod(PathQuery_BindLua, GetWaypointCount), + lunamethod(PathQuery_BindLua, GetWaypoint), + lunamethod(PathQuery_BindLua, GetGoal), + { NULL, NULL } + }; + Luna::PropertyType PathQuery_BindLua::properties[] = { + { NULL, NULL } + }; + + int PathQuery_BindLua::Process(lua_State* L) + { + int args = wi::lua::SGetArgCount(L); + if (args < 3) + { + wi::lua::SError(L, "PathQuery::Process(Vector start,goal, VoxelGrid voxelgrid) not enough arguments!"); + return 0; + } + Vector_BindLua* start = Luna::lightcheck(L, 1); + if (start == nullptr) + { + wi::lua::SError(L, "PathQuery::Process(Vector start,goal, VoxelGrid voxelgrid) first argument is not a Vector!"); + return 0; + } + Vector_BindLua* goal = Luna::lightcheck(L, 2); + if (start == nullptr) + { + wi::lua::SError(L, "PathQuery::Process(Vector start,goal, VoxelGrid voxelgrid) second argument is not a Vector!"); + return 0; + } + VoxelGrid_BindLua* voxelgrid = Luna::lightcheck(L, 3); + if (voxelgrid == nullptr) + { + wi::lua::SError(L, "PathQuery::Process(Vector start,goal, VoxelGrid voxelgrid) third argument is not a VoxelGrid!"); + return 0; + } + + pathquery.process(start->GetFloat3(), goal->GetFloat3(), *voxelgrid->voxelgrid); + + return 0; + } + int PathQuery_BindLua::SearchCover(lua_State* L) + { + int args = wi::lua::SGetArgCount(L); + if (args < 5) + { + wi::lua::SError(L, "PathQuery::SearchCover(Vector observer,subject,direction, float max_distance, VoxelGrid voxelgrid) not enough arguments!"); + return 0; + } + Vector_BindLua* observer = Luna::lightcheck(L, 1); + if (observer == nullptr) + { + wi::lua::SError(L, "PathQuery::SearchCover(Vector observer,subject,direction, float max_distance, VoxelGrid voxelgrid) first argument is not a Vector!"); + return 0; + } + Vector_BindLua* subject = Luna::lightcheck(L, 2); + if (subject == nullptr) + { + wi::lua::SError(L, "PathQuery::SearchCover(Vector observer,subject,direction, float max_distance, VoxelGrid voxelgrid) second argument is not a Vector!"); + return 0; + } + Vector_BindLua* direction = Luna::lightcheck(L, 3); + if (direction == nullptr) + { + wi::lua::SError(L, "PathQuery::SearchCover(Vector observer,subject,direction, float max_distance, VoxelGrid voxelgrid) third argument is not a Vector!"); + return 0; + } + float max_distance = wi::lua::SGetFloat(L, 4); + VoxelGrid_BindLua* voxelgrid = Luna::lightcheck(L, 5); + if (voxelgrid == nullptr) + { + wi::lua::SError(L, "PathQuery::SearchCover(Vector observer,subject,direction, float max_distance, VoxelGrid voxelgrid) fifth argument is not a VoxelGrid!"); + return 0; + } + + bool result = pathquery.search_cover( + observer->GetFloat3(), + subject->GetFloat3(), + direction->GetFloat3(), + max_distance, + *voxelgrid->voxelgrid + ); + + wi::lua::SSetBool(L, result); + + return 1; + } + int PathQuery_BindLua::IsSuccessful(lua_State* L) + { + wi::lua::SSetBool(L, pathquery.is_succesful()); + return 1; + } + int PathQuery_BindLua::GetNextWaypoint(lua_State* L) + { + Luna::push(L, pathquery.get_next_waypoint()); + return 1; + } + int PathQuery_BindLua::SetDebugDrawWaypointsEnabled(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 0) + { + wi::lua::SError(L, "PathQuery::SetDebugDrawWaypointsEnabled(bool value) not enough arguments!"); + return 0; + } + pathquery.debug_waypoints = wi::lua::SGetBool(L, 1); + return 0; + } + int PathQuery_BindLua::SetFlying(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 0) + { + wi::lua::SError(L, "PathQuery::SetFlying(bool value) not enough arguments!"); + return 0; + } + pathquery.flying = wi::lua::SGetBool(L, 1); + return 0; + } + int PathQuery_BindLua::IsFlying(lua_State* L) + { + wi::lua::SSetBool(L, pathquery.flying); + return 1; + } + int PathQuery_BindLua::SetAgentHeight(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 0) + { + wi::lua::SError(L, "PathQuery::SetAgentHeight(int value) not enough arguments!"); + return 0; + } + pathquery.agent_height = wi::lua::SGetInt(L, 1); + return 0; + } + int PathQuery_BindLua::GetAgentHeight(lua_State* L) + { + wi::lua::SSetInt(L, pathquery.agent_height); + return 1; + } + int PathQuery_BindLua::SetAgentWidth(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 0) + { + wi::lua::SError(L, "PathQuery::SetAgentWidth(int value) not enough arguments!"); + return 0; + } + pathquery.agent_width = wi::lua::SGetInt(L, 1); + return 0; + } + int PathQuery_BindLua::GetAgentWidth(lua_State* L) + { + wi::lua::SSetInt(L, pathquery.agent_width); + return 1; + } + int PathQuery_BindLua::GetWaypointCount(lua_State* L) + { + wi::lua::SSetInt(L, (int)pathquery.get_waypoint_count()); + return 1; + } + int PathQuery_BindLua::GetWaypoint(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "PathQuery::GetWaypoint(int index) not enough arguments!"); + return 0; + } + int index = wi::lua::SGetInt(L, 1); + Luna::push(L, pathquery.get_waypoint(size_t(index))); + return 1; + } + int PathQuery_BindLua::GetGoal(lua_State* L) + { + Luna::push(L, pathquery.get_goal()); + return 1; + } + + void PathQuery_BindLua::Bind() + { + Luna::Register(wi::lua::GetLuaState()); + } +} diff --git a/WickedEngine/wiPathQuery_BindLua.h b/WickedEngine/wiPathQuery_BindLua.h new file mode 100644 index 00000000000..5d1e13fe8e5 --- /dev/null +++ b/WickedEngine/wiPathQuery_BindLua.h @@ -0,0 +1,37 @@ +#pragma once +#include "CommonInclude.h" +#include "wiLua.h" +#include "wiLuna.h" +#include "wiPathQuery.h" + +namespace wi::lua +{ + class PathQuery_BindLua + { + public: + wi::PathQuery pathquery; + inline static constexpr char className[] = "PathQuery"; + static Luna::FunctionType methods[]; + static Luna::PropertyType properties[]; + + PathQuery_BindLua() = default; + PathQuery_BindLua(lua_State* L) {} + + int Process(lua_State* L); + int SearchCover(lua_State* L); + int IsSuccessful(lua_State* L); + int GetNextWaypoint(lua_State* L); + int SetDebugDrawWaypointsEnabled(lua_State* L); + int SetFlying(lua_State* L); + int IsFlying(lua_State* L); + int SetAgentWidth(lua_State* L); + int GetAgentWidth(lua_State* L); + int SetAgentHeight(lua_State* L); + int GetAgentHeight(lua_State* L); + int GetWaypointCount(lua_State* L); + int GetWaypoint(lua_State* L); + int GetGoal(lua_State* L); + + static void Bind(); + }; +} diff --git a/WickedEngine/wiPhysics_Bullet.cpp b/WickedEngine/wiPhysics_Bullet.cpp index 1b1f02f504c..ee19913fb8a 100644 --- a/WickedEngine/wiPhysics_Bullet.cpp +++ b/WickedEngine/wiPhysics_Bullet.cpp @@ -680,13 +680,13 @@ namespace wi::physics float mass = scale; float capsule_height = scale; - float capsule_radius = scale; + float capsule_radius = scale * humanoid.ragdoll_fatness; if (c == BODYPART_HEAD) { // Head doesn't necessarily have a child, so make up something reasonable: capsule_height = 0.05f * scale; - capsule_radius = 0.1f * scale; + capsule_radius = 0.1f * scale * humanoid.ragdoll_headsize; } else { @@ -698,29 +698,29 @@ namespace wi::physics switch (c) { case BODYPART_PELVIS: - capsule_radius = 0.1f * scale; + capsule_radius = 0.1f * scale * humanoid.ragdoll_fatness; break; case BODYPART_SPINE: - capsule_radius = 0.1f * scale; + capsule_radius = 0.1f * scale * humanoid.ragdoll_fatness; capsule_height -= capsule_radius * 2; break; case BODYPART_LEFT_LOWER_ARM: case BODYPART_RIGHT_LOWER_ARM: - capsule_radius = capsule_height * 0.15f; + capsule_radius = capsule_height * 0.15f * humanoid.ragdoll_fatness; capsule_height += capsule_radius; break; case BODYPART_LEFT_UPPER_LEG: case BODYPART_RIGHT_UPPER_LEG: - capsule_radius = capsule_height * 0.15f; + capsule_radius = capsule_height * 0.15f * humanoid.ragdoll_fatness; capsule_height -= capsule_radius * 2; break; case BODYPART_LEFT_LOWER_LEG: case BODYPART_RIGHT_LOWER_LEG: - capsule_radius = capsule_height * 0.15f; + capsule_radius = capsule_height * 0.15f * humanoid.ragdoll_fatness; capsule_height -= capsule_radius; break; default: - capsule_radius = capsule_height * 0.2f; + capsule_radius = capsule_height * 0.2f * humanoid.ragdoll_fatness; capsule_height -= capsule_radius * 2; break; } @@ -1237,6 +1237,26 @@ namespace wi::physics ); rigidbody->setFriction(physicscomponent.friction); rigidbody->setRestitution(physicscomponent.restitution); + if (physicscomponent.IsKinematic() && (rigidbody->getCollisionFlags() & btCollisionObject::CF_KINEMATIC_OBJECT) == 0) + { + // It became kinematic when it wasn't before: + rigidbody->setCollisionFlags(rigidbody->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + btVector3 localInertia(0, 0, 0); + rigidbody->setMassProps(0, localInertia); + dynamicsWorld.removeRigidBody(rigidbody); + dynamicsWorld.addRigidBody(rigidbody); + } + if (!physicscomponent.IsKinematic() && (rigidbody->getCollisionFlags() & btCollisionObject::CF_KINEMATIC_OBJECT) != 0) + { + // It became non-kinematic when it was kinematic before: + rigidbody->setCollisionFlags(rigidbody->getCollisionFlags() ^ btCollisionObject::CF_KINEMATIC_OBJECT); + btVector3 localInertia(0, 0, 0); + rigidbody->getCollisionShape()->calculateLocalInertia(physicscomponent.mass, localInertia); + rigidbody->setMassProps(physicscomponent.mass, localInertia); + dynamicsWorld.removeRigidBody(rigidbody); + dynamicsWorld.addRigidBody(rigidbody); + scene.Component_Detach(entity); + } } }); @@ -1768,6 +1788,8 @@ namespace wi::physics PickDragOperation& op ) { + if (scene.physics_scene == nullptr) + return; btSoftRigidDynamicsWorld& dynamicsWorld = ((PhysicsScene*)scene.physics_scene.get())->dynamicsWorld; float tmin = wi::math::Clamp(ray.TMin, 0, 1000000); float tmax = wi::math::Clamp(ray.TMax, 0, 1000000); diff --git a/WickedEngine/wiRenderPath2D.h b/WickedEngine/wiRenderPath2D.h index bc1c4834192..a7fd5c9a7dc 100644 --- a/WickedEngine/wiRenderPath2D.h +++ b/WickedEngine/wiRenderPath2D.h @@ -13,7 +13,7 @@ namespace wi class RenderPath2D : public RenderPath { - private: + protected: wi::graphics::Texture rtStenciled; wi::graphics::Texture rtStenciled_resolved; wi::graphics::Texture rtFinal; diff --git a/WickedEngine/wiRenderPath3D.cpp b/WickedEngine/wiRenderPath3D.cpp index 71bc54f2d02..4a8932b1d3c 100644 --- a/WickedEngine/wiRenderPath3D.cpp +++ b/WickedEngine/wiRenderPath3D.cpp @@ -27,10 +27,9 @@ namespace wi rtSceneCopy = {}; rtSceneCopy_tmp = {}; rtWaterRipple = {}; + rtParticleDistortion_render = {}; rtParticleDistortion = {}; - rtParticleDistortion_Resolved = {}; - rtVolumetricLights[0] = {}; - rtVolumetricLights[1] = {}; + rtVolumetricLights = {}; rtBloom = {}; rtBloom_tmp = {}; rtAO = {}; @@ -99,7 +98,6 @@ namespace wi desc.width = internalResolution.x; desc.height = internalResolution.y; desc.sample_count = 1; - device->CreateTexture(&desc, nullptr, &rtMain); device->SetName(&rtMain, "rtMain"); @@ -128,6 +126,7 @@ namespace wi desc.height = internalResolution.y; desc.sample_count = 1; desc.layout = ResourceState::SHADER_RESOURCE_COMPUTE; + desc.misc_flags = ResourceMiscFlag::ALIASING_TEXTURE_RT_DS; device->CreateTexture(&desc, nullptr, &rtPrimitiveID); device->SetName(&rtPrimitiveID, "rtPrimitiveID"); @@ -135,6 +134,7 @@ namespace wi { desc.sample_count = getMSAASampleCount(); desc.bind_flags = BindFlag::RENDER_TARGET | BindFlag::SHADER_RESOURCE; + desc.misc_flags = ResourceMiscFlag::NONE; device->CreateTexture(&desc, nullptr, &rtPrimitiveID_render); device->SetName(&rtPrimitiveID_render, "rtPrimitiveID_render"); } @@ -149,14 +149,20 @@ namespace wi desc.format = Format::R16G16_FLOAT; desc.width = internalResolution.x; desc.height = internalResolution.y; - desc.sample_count = getMSAASampleCount(); + desc.sample_count = 1; + desc.misc_flags = ResourceMiscFlag::ALIASING_TEXTURE_RT_DS; device->CreateTexture(&desc, nullptr, &rtParticleDistortion); device->SetName(&rtParticleDistortion, "rtParticleDistortion"); if (getMSAASampleCount() > 1) { - desc.sample_count = 1; - device->CreateTexture(&desc, nullptr, &rtParticleDistortion_Resolved); - device->SetName(&rtParticleDistortion_Resolved, "rtParticleDistortion_Resolved"); + desc.sample_count = getMSAASampleCount(); + desc.misc_flags = ResourceMiscFlag::NONE; + device->CreateTexture(&desc, nullptr, &rtParticleDistortion_render); + device->SetName(&rtParticleDistortion_render, "rtParticleDistortion_render"); + } + else + { + rtParticleDistortion_render = rtParticleDistortion; } } { @@ -168,8 +174,8 @@ namespace wi desc.mip_levels = std::min(8u, (uint32_t)std::log2(std::max(desc.width, desc.height))); device->CreateTexture(&desc, nullptr, &rtSceneCopy); device->SetName(&rtSceneCopy, "rtSceneCopy"); - desc.bind_flags = BindFlag::SHADER_RESOURCE | BindFlag::UNORDERED_ACCESS; - device->CreateTexture(&desc, nullptr, &rtSceneCopy_tmp); + desc.bind_flags = BindFlag::SHADER_RESOURCE | BindFlag::UNORDERED_ACCESS | BindFlag::RENDER_TARGET; // render target for aliasing + device->CreateTexture(&desc, nullptr, &rtSceneCopy_tmp, &rtParticleDistortion); // aliased! device->SetName(&rtSceneCopy_tmp, "rtSceneCopy_tmp"); for (uint32_t i = 0; i < rtSceneCopy.GetDesc().mip_levels; ++i) @@ -184,6 +190,8 @@ namespace wi subresource_index = device->CreateSubresource(&rtSceneCopy_tmp, SubresourceType::UAV, 0, 1, i, 1); assert(subresource_index == i); } + + clearableTextures.push_back(&rtSceneCopy); // because this is used by SSR and SSGI before it gets a chance to be normally rendered, it MUST be cleared! } { TextureDesc desc; @@ -191,7 +199,8 @@ namespace wi desc.format = wi::renderer::format_rendertarget_main; desc.width = internalResolution.x; desc.height = internalResolution.y; - device->CreateTexture(&desc, nullptr, &rtPostprocess); + assert(ComputeTextureMemorySizeInBytes(desc) <= ComputeTextureMemorySizeInBytes(rtPrimitiveID.desc)); // Aliased check + device->CreateTexture(&desc, nullptr, &rtPostprocess, &rtPrimitiveID); // Aliased! device->SetName(&rtPostprocess, "rtPostprocess"); } { @@ -284,7 +293,6 @@ namespace wi } } - // Other resources: { TextureDesc desc; @@ -301,19 +309,17 @@ namespace wi device->CreateTexture(&desc, nullptr, &debugUAV); device->SetName(&debugUAV, "debugUAV"); } - wi::renderer::CreateVisibilityResources(visibilityResources, internalResolution); wi::renderer::CreateTiledLightResources(tiledLightResources, internalResolution); wi::renderer::CreateScreenSpaceShadowResources(screenspaceshadowResources, internalResolution); // These can trigger resource creations if needed: setAO(ao); setSSREnabled(ssrEnabled); + setSSGIEnabled(ssgiEnabled); setRaytracedReflectionsEnabled(raytracedReflectionsEnabled); setRaytracedDiffuseEnabled(raytracedDiffuseEnabled); setFSREnabled(fsrEnabled); setFSR2Enabled(fsr2Enabled); - setMotionBlurEnabled(motionBlurEnabled); - setDepthOfFieldEnabled(depthOfFieldEnabled); setEyeAdaptionEnabled(eyeAdaptionEnabled); setReflectionsEnabled(reflectionsEnabled); setBloomEnabled(bloomEnabled); @@ -440,6 +446,10 @@ namespace wi { rtSSR = {}; } + if (!getSSGIEnabled()) + { + rtSSGI = {}; + } if (!getRaytracedDiffuseEnabled()) { rtRaytracedDiffuse = {}; @@ -449,7 +459,7 @@ namespace wi rtAO = {}; } - if (device->CheckCapability(GraphicsDeviceCapability::RAYTRACING)) + if (wi::renderer::GetRaytracedShadowsEnabled() && device->CheckCapability(GraphicsDeviceCapability::RAYTRACING)) { if (!rtshadowResources.denoised.IsValid()) { @@ -516,7 +526,8 @@ namespace wi desc.format = Format::R16G16_FLOAT; desc.width = internalResolution.x / 8; desc.height = internalResolution.y / 8; - device->CreateTexture(&desc, nullptr, &rtWaterRipple); + assert(ComputeTextureMemorySizeInBytes(desc) <= ComputeTextureMemorySizeInBytes(rtParticleDistortion.desc)); // aliasing check + device->CreateTexture(&desc, nullptr, &rtWaterRipple, &rtParticleDistortion); // aliased! device->SetName(&rtWaterRipple, "rtWaterRipple"); } } @@ -550,6 +561,7 @@ namespace wi getMotionBlurEnabled() || wi::renderer::GetTemporalAAEnabled() || getSSREnabled() || + getSSGIEnabled() || getRaytracedReflectionEnabled() || getRaytracedDiffuseEnabled() || wi::renderer::GetRaytracedShadowsEnabled() || @@ -562,7 +574,7 @@ namespace wi { TextureDesc desc; desc.format = Format::R16G16_FLOAT; - desc.bind_flags = BindFlag::SHADER_RESOURCE | BindFlag::UNORDERED_ACCESS; + desc.bind_flags = BindFlag::SHADER_RESOURCE | BindFlag::UNORDERED_ACCESS | BindFlag::RENDER_TARGET; desc.width = internalResolution.x; desc.height = internalResolution.y; desc.layout = ResourceState::SHADER_RESOURCE_COMPUTE; @@ -595,17 +607,6 @@ namespace wi rtShadow = {}; } - // Motion blur and depth of field recreation was possibly requested by FSR2 toggling on/off - // Because these need to run either in display of internal resolution depending on FSR2 on/off - if (getMotionBlurEnabled() && !motionblurResources.IsValid()) - { - setMotionBlurEnabled(true); - } - if (getDepthOfFieldEnabled() && !depthoffieldResources.IsValid()) - { - setDepthOfFieldEnabled(true); - } - if (getFSR2Enabled()) { // FSR2 also acts as a temporal AA, so we inform the shaders about it here @@ -616,6 +617,67 @@ namespace wi frameCB.temporalaa_samplerotation = (x & 0x000000FF) | ((y & 0x000000FF) << 8); } + // Check whether visibility resources are required: + if ( + visibility_shading_in_compute || + getSSREnabled() || + getSSGIEnabled() || + getRaytracedReflectionEnabled() || + getRaytracedDiffuseEnabled() || + wi::renderer::GetScreenSpaceShadowsEnabled() || + wi::renderer::GetRaytracedShadowsEnabled() || + wi::renderer::GetVXGIEnabled() + ) + { + if (!visibilityResources.IsValid()) + { + wi::renderer::CreateVisibilityResources(visibilityResources, internalResolution); + } + } + else + { + visibilityResources = {}; + } + + // Check for depth of field allocation: + if (getDepthOfFieldEnabled() && + getDepthOfFieldStrength() > 0 && + camera->aperture_size > 0 + ) + { + if (!depthoffieldResources.IsValid()) + { + XMUINT2 resolution = GetInternalResolution(); + if (getFSR2Enabled()) + { + resolution = XMUINT2(GetPhysicalWidth(), GetPhysicalHeight()); + } + wi::renderer::CreateDepthOfFieldResources(depthoffieldResources, resolution); + } + } + else + { + depthoffieldResources = {}; + } + + // Check for motion blur allocation: + if (getMotionBlurEnabled() && getMotionBlurStrength() > 0) + { + if (!motionblurResources.IsValid()) + { + XMUINT2 resolution = GetInternalResolution(); + if (getFSR2Enabled()) + { + resolution = XMUINT2(GetPhysicalWidth(), GetPhysicalHeight()); + } + wi::renderer::CreateMotionBlurResources(motionblurResources, resolution); + } + } + else + { + motionblurResources = {}; + } + // Keep a copy of last frame's depth buffer for temporal disocclusion checks, so swap with current one every frame: std::swap(depthBuffer_Copy, depthBuffer_Copy1); @@ -648,6 +710,7 @@ namespace wi camera->texture_waterriples_index = device->GetDescriptorIndex(&rtWaterRipple, SubresourceType::SRV); camera->texture_ao_index = device->GetDescriptorIndex(&rtAO, SubresourceType::SRV); camera->texture_ssr_index = device->GetDescriptorIndex(&rtSSR, SubresourceType::SRV); + camera->texture_ssgi_index = device->GetDescriptorIndex(&rtSSGI, SubresourceType::SRV); camera->texture_rtshadow_index = device->GetDescriptorIndex(&rtShadow, SubresourceType::SRV); camera->texture_rtdiffuse_index = device->GetDescriptorIndex(&rtRaytracedDiffuse, SubresourceType::SRV); camera->texture_surfelgi_index = device->GetDescriptorIndex(&surfelGIResources.result, SubresourceType::SRV); @@ -682,6 +745,7 @@ namespace wi camera_reflection.texture_waterriples_index = -1; camera_reflection.texture_ao_index = -1; camera_reflection.texture_ssr_index = -1; + camera_reflection.texture_ssgi_index = -1; camera_reflection.texture_rtshadow_index = -1; camera_reflection.texture_rtdiffuse_index = -1; camera_reflection.texture_surfelgi_index = -1; @@ -731,6 +795,22 @@ namespace wi wi::renderer::ProcessDeferredTextureRequests(cmd); // Execute it first thing in the frame here, on main thread, to not allow other thread steal it and execute on different command list! wi::jobsystem::Execute(ctx, [this, cmd](wi::jobsystem::JobArgs args) { GraphicsDevice* device = wi::graphics::GetDevice(); + + // Initialization clears: + for (auto& x : clearableTextures) + { + device->Barrier(GPUBarrier::Image(x, x->desc.layout, ResourceState::UNORDERED_ACCESS), cmd); + } + for (auto& x : clearableTextures) + { + device->ClearUAV(x, 0, cmd); + } + for (auto& x : clearableTextures) + { + device->Barrier(GPUBarrier::Image(x, ResourceState::UNORDERED_ACCESS, x->desc.layout), cmd); + } + clearableTextures.clear(); + wi::renderer::BindCameraCB( *camera, camera_previous, @@ -739,14 +819,15 @@ namespace wi ); wi::renderer::UpdateRenderData(visibility_main, frameCB, cmd); - uint32_t num_barriers = 1; - GPUBarrier barriers[2] = { + uint32_t num_barriers = 2; + GPUBarrier barriers[] = { GPUBarrier::Image(&debugUAV, debugUAV.desc.layout, ResourceState::UNORDERED_ACCESS), + GPUBarrier::Aliasing(&rtPostprocess, &rtPrimitiveID), + GPUBarrier::Image(&rtMain, rtMain.desc.layout, ResourceState::SHADER_RESOURCE_COMPUTE), // prepares transition for discard in dx12 }; if (visibility_shading_in_compute) { - num_barriers = 2; - barriers[1] = GPUBarrier::Image(&rtMain, rtMain.desc.layout, ResourceState::SHADER_RESOURCE_COMPUTE); // prepares transition for discard in dx12 + num_barriers++; } device->Barrier(barriers, num_barriers, cmd); @@ -950,6 +1031,7 @@ namespace wi } else if ( getSSREnabled() || + getSSGIEnabled() || getRaytracedReflectionEnabled() || getRaytracedDiffuseEnabled() || wi::renderer::GetScreenSpaceShadowsEnabled() || @@ -967,7 +1049,6 @@ namespace wi if (rtVelocity.IsValid()) { wi::renderer::Visibility_Velocity( - visibilityResources, rtVelocity, cmd ); @@ -996,6 +1077,8 @@ namespace wi RenderSSR(cmd); + RenderSSGI(cmd); + if (wi::renderer::GetScreenSpaceShadowsEnabled()) { wi::renderer::Postprocess_ScreenSpaceShadow( @@ -1466,6 +1549,11 @@ namespace wi device->Barrier(&barrier, 1, cmd); } + if (rtAO.IsValid()) + { + device->Barrier(GPUBarrier::Aliasing(&rtAO, &rtParticleDistortion), cmd); + } + device->EventEnd(cmd); }); @@ -1582,6 +1670,10 @@ namespace wi void RenderPath3D::RenderAO(CommandList cmd) const { + if (rtAO.IsValid()) + { + GetDevice()->Barrier(GPUBarrier::Aliasing(&rtParticleDistortion, &rtAO), cmd); + } if (getAOEnabled()) { @@ -1646,6 +1738,21 @@ namespace wi ); } } + void RenderPath3D::RenderSSGI(CommandList cmd) const + { + if (getSSGIEnabled()) + { + wi::renderer::Postprocess_SSGI( + ssgiResources, + rtSceneCopy, + depthBuffer_Copy, + visibilityResources.texture_normals, + rtSSGI, + cmd, + getSSGIDepthRejection() + ); + } + } void RenderPath3D::RenderOutline(CommandList cmd) const { if (getOutlineEnabled()) @@ -1754,27 +1861,19 @@ namespace wi GraphicsDevice* device = wi::graphics::GetDevice(); RenderPassImage rp[] = { - RenderPassImage::RenderTarget(&rtVolumetricLights[0], RenderPassImage::LoadOp::CLEAR), + RenderPassImage::RenderTarget(&rtVolumetricLights, RenderPassImage::LoadOp::CLEAR), }; device->RenderPassBegin(rp, arraysize(rp), cmd); Viewport vp; - vp.width = (float)rtVolumetricLights[0].GetDesc().width; - vp.height = (float)rtVolumetricLights[0].GetDesc().height; + vp.width = (float)rtVolumetricLights.GetDesc().width; + vp.height = (float)rtVolumetricLights.GetDesc().height; device->BindViewports(1, &vp, cmd); wi::renderer::DrawVolumeLights(visibility_main, cmd); device->RenderPassEnd(cmd); - wi::renderer::Postprocess_Blur_Bilateral( - rtVolumetricLights[0], - rtLinearDepth, - rtVolumetricLights[1], - rtVolumetricLights[0], - cmd - ); - wi::profiler::EndRange(range); } } @@ -1785,12 +1884,25 @@ namespace wi auto range = wi::profiler::BeginRangeGPU("Scene MIP Chain", cmd); device->EventBegin("RenderSceneMIPChain", cmd); + { + GPUBarrier barriers[] = { + GPUBarrier::Aliasing(&rtParticleDistortion, &rtSceneCopy_tmp), + GPUBarrier::Image(&rtSceneCopy_tmp, rtSceneCopy_tmp.desc.layout, ResourceState::UNORDERED_ACCESS), + }; + device->Barrier(barriers, arraysize(barriers), cmd); + device->ClearUAV(&rtSceneCopy_tmp, 0, cmd); + } + wi::renderer::Postprocess_Downsample4x(rtMain, rtSceneCopy, cmd); + device->Barrier(GPUBarrier::Image(&rtSceneCopy_tmp, ResourceState::UNORDERED_ACCESS, rtSceneCopy_tmp.desc.layout), cmd); + wi::renderer::MIPGEN_OPTIONS mipopt; mipopt.gaussian_temp = &rtSceneCopy_tmp; wi::renderer::GenerateMipChain(rtSceneCopy, wi::renderer::MIPGENFILTER_GAUSSIAN, cmd, mipopt); + device->Barrier(GPUBarrier::Aliasing(&rtSceneCopy_tmp, &rtParticleDistortion), cmd); + device->EventEnd(cmd); wi::profiler::EndRange(range); } @@ -1801,6 +1913,7 @@ namespace wi // Water ripple rendering: if (!scene->waterRipples.empty()) { + device->Barrier(GPUBarrier::Aliasing(&rtParticleDistortion, &rtWaterRipple), cmd); RenderPassImage rp[] = { RenderPassImage::RenderTarget(&rtWaterRipple, RenderPassImage::LoadOp::CLEAR), }; @@ -1905,7 +2018,7 @@ namespace wi { device->EventBegin("Contribute Volumetric Lights", cmd); wi::renderer::Postprocess_Upsample_Bilateral( - rtVolumetricLights[0], + rtVolumetricLights, rtLinearDepth, rtMain, cmd, @@ -1939,10 +2052,15 @@ namespace wi // Distortion particles: { + if (rtWaterRipple.IsValid()) + { + device->Barrier(GPUBarrier::Aliasing(&rtWaterRipple, &rtParticleDistortion), cmd); + } + if (getMSAASampleCount() > 1) { RenderPassImage rp[] = { - RenderPassImage::RenderTarget(&rtParticleDistortion, RenderPassImage::LoadOp::CLEAR), + RenderPassImage::RenderTarget(&rtParticleDistortion_render, RenderPassImage::LoadOp::CLEAR), RenderPassImage::DepthStencil( &depthBuffer_Main, RenderPassImage::LoadOp::LOAD, @@ -1951,7 +2069,7 @@ namespace wi ResourceState::DEPTHSTENCIL, ResourceState::DEPTHSTENCIL ), - RenderPassImage::Resolve(&rtParticleDistortion_Resolved) + RenderPassImage::Resolve(&rtParticleDistortion) }; device->RenderPassBegin(rp, arraysize(rp), cmd); } @@ -1981,6 +2099,8 @@ namespace wi device->RenderPassEnd(cmd); } + + wi::renderer::Postprocess_Downsample4x(rtMain, rtSceneCopy, cmd); } void RenderPath3D::RenderPostprocessChain(CommandList cmd) const { @@ -1990,6 +2110,17 @@ namespace wi const Texture* rt_read = &rtMain; const Texture* rt_write = &rtPostprocess; + // rtPostprocess aliasing transition: + { + GPUBarrier barriers[] = { + GPUBarrier::Aliasing(&rtPrimitiveID, &rtPostprocess), + GPUBarrier::Image(&rtPostprocess, rtPostprocess.desc.layout, ResourceState::UNORDERED_ACCESS), + }; + device->Barrier(barriers, arraysize(barriers), cmd); + device->ClearUAV(&rtPostprocess, 0, cmd); + device->Barrier(GPUBarrier::Image(&rtPostprocess, ResourceState::UNORDERED_ACCESS, rtPostprocess.desc.layout), cmd); + } + // 1.) HDR post process chain { if (getFSR2Enabled() && fsr2Resources.IsValid()) @@ -2125,7 +2256,7 @@ namespace wi getSaturation(), getDitherEnabled(), getColorGradingEnabled() ? (scene->weather.colorGradingMap.IsValid() ? &scene->weather.colorGradingMap.GetTexture() : nullptr) : nullptr, - getMSAASampleCount() > 1 ? &rtParticleDistortion_Resolved : &rtParticleDistortion, + &rtParticleDistortion, getEyeAdaptionEnabled() ? &luminanceResources.luminance : nullptr, getBloomEnabled() ? &bloomResources.texture_bloom : nullptr, colorspace, @@ -2217,7 +2348,7 @@ namespace wi return; TextureDesc desc; - desc.bind_flags = BindFlag::SHADER_RESOURCE | BindFlag::UNORDERED_ACCESS; + desc.bind_flags = BindFlag::SHADER_RESOURCE | BindFlag::UNORDERED_ACCESS | BindFlag::RENDER_TARGET; // render target binding for aliasing (in case resource heap tier < 2) desc.format = Format::R8_UNORM; desc.layout = ResourceState::SHADER_RESOURCE_COMPUTE; @@ -2244,7 +2375,8 @@ namespace wi } GraphicsDevice* device = wi::graphics::GetDevice(); - device->CreateTexture(&desc, nullptr, &rtAO); + assert(ComputeTextureMemorySizeInBytes(desc) <= ComputeTextureMemorySizeInBytes(rtParticleDistortion.desc)); // aliasing check + device->CreateTexture(&desc, nullptr, &rtAO, &rtParticleDistortion); // aliasing! device->SetName(&rtAO, "rtAO"); } void RenderPath3D::setSSREnabled(bool value) @@ -2274,6 +2406,33 @@ namespace wi ssrResources = {}; } } + void RenderPath3D::setSSGIEnabled(bool value) + { + ssgiEnabled = value; + + if (value) + { + GraphicsDevice* device = wi::graphics::GetDevice(); + XMUINT2 internalResolution = GetInternalResolution(); + if (internalResolution.x == 0 || internalResolution.y == 0) + return; + + TextureDesc desc; + desc.bind_flags = BindFlag::SHADER_RESOURCE | BindFlag::UNORDERED_ACCESS; + desc.format = Format::R16G16B16A16_FLOAT; + desc.width = internalResolution.x; + desc.height = internalResolution.y; + desc.layout = ResourceState::SHADER_RESOURCE_COMPUTE; + device->CreateTexture(&desc, nullptr, &rtSSGI); + device->SetName(&rtSSGI, "rtSSGI"); + + wi::renderer::CreateSSGIResources(ssgiResources, internalResolution); + } + else + { + ssgiResources = {}; + } + } void RenderPath3D::setRaytracedReflectionsEnabled(bool value) { raytracedReflectionsEnabled = value; @@ -2427,38 +2586,10 @@ namespace wi void RenderPath3D::setMotionBlurEnabled(bool value) { motionBlurEnabled = value; - - if (value) - { - XMUINT2 resolution = GetInternalResolution(); - if (getFSR2Enabled()) - { - resolution = XMUINT2(GetPhysicalWidth(), GetPhysicalHeight()); - } - wi::renderer::CreateMotionBlurResources(motionblurResources, resolution); - } - else - { - motionblurResources = {}; - } } void RenderPath3D::setDepthOfFieldEnabled(bool value) { depthOfFieldEnabled = value; - - if (value) - { - XMUINT2 resolution = GetInternalResolution(); - if (getFSR2Enabled()) - { - resolution = XMUINT2(GetPhysicalWidth(), GetPhysicalHeight()); - } - wi::renderer::CreateDepthOfFieldResources(depthoffieldResources, resolution); - } - else - { - depthoffieldResources = {}; - } } void RenderPath3D::setEyeAdaptionEnabled(bool value) { @@ -2536,15 +2667,12 @@ namespace wi desc.bind_flags = BindFlag::RENDER_TARGET | BindFlag::SHADER_RESOURCE | BindFlag::UNORDERED_ACCESS; desc.width = internalResolution.x / 2; desc.height = internalResolution.y / 2; - device->CreateTexture(&desc, nullptr, &rtVolumetricLights[0]); - device->SetName(&rtVolumetricLights[0], "rtVolumetricLights[0]"); - device->CreateTexture(&desc, nullptr, &rtVolumetricLights[1]); - device->SetName(&rtVolumetricLights[1], "rtVolumetricLights[1]"); + device->CreateTexture(&desc, nullptr, &rtVolumetricLights); + device->SetName(&rtVolumetricLights, "rtVolumetricLights"); } else { - rtVolumetricLights[0] = {}; - rtVolumetricLights[1] = {}; + rtVolumetricLights = {}; } } void RenderPath3D::setLightShaftsEnabled(bool value) diff --git a/WickedEngine/wiRenderPath3D.h b/WickedEngine/wiRenderPath3D.h index 5815a345c73..a841e819c11 100644 --- a/WickedEngine/wiRenderPath3D.h +++ b/WickedEngine/wiRenderPath3D.h @@ -55,11 +55,13 @@ namespace wi float raytracedDiffuseRange = 10; float raytracedReflectionsRange = 10000.0f; float reflectionRoughnessCutoff = 0.6f; + float ssgiDepthRejection = 8; wi::renderer::Tonemap tonemap = wi::renderer::Tonemap::ACES; AO ao = AO_DISABLED; bool fxaaEnabled = false; bool ssrEnabled = false; + bool ssgiEnabled = false; bool raytracedReflectionsEnabled = false; bool raytracedDiffuseEnabled = false; bool reflectionsEnabled = true; @@ -83,6 +85,8 @@ namespace wi uint32_t msaaSampleCount = 1; + mutable wi::vector clearableTextures; + public: wi::graphics::Texture rtMain; wi::graphics::Texture rtMain_render; // can be MSAA @@ -92,12 +96,13 @@ namespace wi wi::graphics::Texture rtReflection; // contains the scene rendered for planar reflections wi::graphics::Texture rtRaytracedDiffuse; // raytraced diffuse screen space texture wi::graphics::Texture rtSSR; // standard screen-space reflection results + wi::graphics::Texture rtSSGI; // standard screen-space GI results wi::graphics::Texture rtSceneCopy; // contains the rendered scene that can be fed into transparent pass for distortion effect wi::graphics::Texture rtSceneCopy_tmp; // temporary for gaussian mipchain wi::graphics::Texture rtWaterRipple; // water ripple sprite normal maps are rendered into this + wi::graphics::Texture rtParticleDistortion_render; // contains distortive particles (can be MSAA) wi::graphics::Texture rtParticleDistortion; // contains distortive particles - wi::graphics::Texture rtParticleDistortion_Resolved; // contains distortive particles - wi::graphics::Texture rtVolumetricLights[2]; // contains the volumetric light results + wi::graphics::Texture rtVolumetricLights; // contains the volumetric light results wi::graphics::Texture rtBloom; // contains the bright parts of the image + mipchain wi::graphics::Texture rtBloom_tmp; // temporary for bloom downsampling wi::graphics::Texture rtAO; // full res AO @@ -127,6 +132,7 @@ namespace wi wi::renderer::RTDiffuseResources rtdiffuseResources; wi::renderer::RTReflectionResources rtreflectionResources; wi::renderer::SSRResources ssrResources; + wi::renderer::SSGIResources ssgiResources; wi::renderer::RTShadowResources rtshadowResources; wi::renderer::ScreenSpaceShadowResources screenspaceshadowResources; wi::renderer::DepthOfFieldResources depthoffieldResources; @@ -154,6 +160,7 @@ namespace wi virtual void RenderAO(wi::graphics::CommandList cmd) const; virtual void RenderSSR(wi::graphics::CommandList cmd) const; + virtual void RenderSSGI(wi::graphics::CommandList cmd) const; virtual void RenderOutline(wi::graphics::CommandList cmd) const; virtual void RenderLightShafts(wi::graphics::CommandList cmd) const; virtual void RenderVolumetrics(wi::graphics::CommandList cmd) const; @@ -229,11 +236,13 @@ namespace wi constexpr float getRaytracedDiffuseRange() const { return raytracedDiffuseRange; } constexpr float getRaytracedReflectionsRange() const { return raytracedReflectionsRange; } constexpr float getReflectionRoughnessCutoff() const { return reflectionRoughnessCutoff; } + constexpr float getSSGIDepthRejection() const { return ssgiDepthRejection; } constexpr wi::renderer::Tonemap getTonemap() const { return tonemap; } constexpr bool getAOEnabled() const { return ao != AO_DISABLED; } constexpr AO getAO() const { return ao; } constexpr bool getSSREnabled() const { return ssrEnabled; } + constexpr bool getSSGIEnabled() const { return ssgiEnabled; } constexpr bool getRaytracedDiffuseEnabled() const { return raytracedDiffuseEnabled; } constexpr bool getRaytracedReflectionEnabled() const { return raytracedReflectionsEnabled; } constexpr bool getShadowsEnabled() const { return shadowsEnabled; } @@ -283,10 +292,12 @@ namespace wi constexpr void setRaytracedDiffuseRange(float value) { raytracedDiffuseRange = value; } constexpr void setRaytracedReflectionsRange(float value) { raytracedReflectionsRange = value; } constexpr void setReflectionRoughnessCutoff(float value) { reflectionRoughnessCutoff = value; } + constexpr void setSSGIDepthRejection(float value) { ssgiDepthRejection = value; } constexpr void setTonemap(wi::renderer::Tonemap value) { tonemap = value; } void setAO(AO value); void setSSREnabled(bool value); + void setSSGIEnabled(bool value); void setRaytracedReflectionsEnabled(bool value); void setRaytracedDiffuseEnabled(bool value); void setMotionBlurEnabled(bool value); diff --git a/WickedEngine/wiRenderPath3D_BindLua.cpp b/WickedEngine/wiRenderPath3D_BindLua.cpp index 5bdb4c67ae3..24fb6fc8f93 100644 --- a/WickedEngine/wiRenderPath3D_BindLua.cpp +++ b/WickedEngine/wiRenderPath3D_BindLua.cpp @@ -27,6 +27,7 @@ namespace wi::lua lunamethod(RenderPath3D_BindLua, SetAO), lunamethod(RenderPath3D_BindLua, SetAOPower), lunamethod(RenderPath3D_BindLua, SetSSREnabled), + lunamethod(RenderPath3D_BindLua, SetSSGIEnabled), lunamethod(RenderPath3D_BindLua, SetRaytracedDiffuseEnabled), lunamethod(RenderPath3D_BindLua, SetRaytracedReflectionsEnabled), lunamethod(RenderPath3D_BindLua, SetShadowsEnabled), @@ -135,6 +136,19 @@ namespace wi::lua wi::lua::SError(L, "SetSSREnabled(bool value) not enough arguments!"); return 0; } + int RenderPath3D_BindLua::SetSSGIEnabled(lua_State* L) + { + if (component == nullptr) + { + wi::lua::SError(L, "SetSSGIEnabled(bool value) component is null!"); + return 0; + } + if (wi::lua::SGetArgCount(L) > 0) + ((RenderPath3D*)component)->setSSGIEnabled(wi::lua::SGetBool(L, 1)); + else + wi::lua::SError(L, "SetSSGIEnabled(bool value) not enough arguments!"); + return 0; + } int RenderPath3D_BindLua::SetRaytracedDiffuseEnabled(lua_State* L) { if (component == nullptr) diff --git a/WickedEngine/wiRenderPath3D_BindLua.h b/WickedEngine/wiRenderPath3D_BindLua.h index f0edcdd5a71..ab66cded711 100644 --- a/WickedEngine/wiRenderPath3D_BindLua.h +++ b/WickedEngine/wiRenderPath3D_BindLua.h @@ -33,6 +33,7 @@ namespace wi::lua int SetAO(lua_State* L); int SetAOPower(lua_State* L); int SetSSREnabled(lua_State* L); + int SetSSGIEnabled(lua_State* L); int SetRaytracedDiffuseEnabled(lua_State* L); int SetRaytracedReflectionsEnabled(lua_State* L); int SetShadowsEnabled(lua_State* L); diff --git a/WickedEngine/wiRenderer.cpp b/WickedEngine/wiRenderer.cpp index 979d6a60405..e6fa9b245be 100644 --- a/WickedEngine/wiRenderer.cpp +++ b/WickedEngine/wiRenderer.cpp @@ -20,6 +20,9 @@ #include "wiTimer.h" #include "wiUnorderedMap.h" // leave it here for shader dump! #include "wiFont.h" +#include "wiVoxelGrid.h" +#include "wiPathQuery.h" +#include "wiTrailRenderer.h" #include "shaders/ShaderInterop_Postprocess.h" #include "shaders/ShaderInterop_Raytracing.h" @@ -148,6 +151,10 @@ wi::vector renderableTriangles_solid; wi::vector renderableTriangles_wireframe; wi::vector debugTextStorage; // A stream of DebugText struct + text characters wi::vector paintrads; +wi::vector painttextures; +wi::vector renderableVoxelgrids; +wi::vector renderablePathqueries; +wi::vector renderableTrails; wi::SpinLock deferredMIPGenLock; wi::vector> deferredMIPGens; @@ -976,7 +983,7 @@ void LoadShaders() wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_SSR_RAYTRACE_CHEAP], "ssr_raytraceCS_cheap.cso"); }); wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_SSR_RESOLVE], "ssr_resolveCS.cso"); }); wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_SSR_TEMPORAL], "ssr_temporalCS.cso"); }); - wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_SSR_BILATERAL], "ssr_bilateralCS.cso"); }); + wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_SSR_UPSAMPLE], "ssr_upsampleCS.cso"); }); wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_LIGHTSHAFTS], "lightShaftsCS.cso"); }); wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_DEPTHOFFIELD_TILEMAXCOC_HORIZONTAL], "depthoffield_tileMaxCOC_horizontalCS.cso"); }); wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_DEPTHOFFIELD_TILEMAXCOC_VERTICAL], "depthoffield_tileMaxCOC_verticalCS.cso"); }); @@ -1028,18 +1035,22 @@ void LoadShaders() wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_UPSAMPLE_BILATERAL_UNORM1], "upsample_bilateral_unorm1CS.cso"); }); wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_UPSAMPLE_BILATERAL_FLOAT4], "upsample_bilateral_float4CS.cso"); }); wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_UPSAMPLE_BILATERAL_UNORM4], "upsample_bilateral_unorm4CS.cso"); }); - wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_UPSAMPLE_BILATERAL_UINT4], "upsample_bilateral_uint4CS.cso"); }); wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_DOWNSAMPLE4X], "downsample4xCS.cso"); }); wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_LINEARDEPTH], "lineardepthCS.cso"); }); wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_NORMALSFROMDEPTH], "normalsfromdepthCS.cso"); }); wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_SCREENSPACESHADOW], "screenspaceshadowCS.cso"); }); + wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_SSGI_DEINTERLEAVE], "ssgi_deinterleaveCS.cso"); }); + wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_SSGI], "ssgiCS.cso"); }); + wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_SSGI_WIDE], "ssgiCS.cso", wi::graphics::ShaderModel::SM_5_0, { "WIDE" }); }); + wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_SSGI_UPSAMPLE], "ssgi_upsampleCS.cso"); }); + wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_SSGI_UPSAMPLE_WIDE], "ssgi_upsampleCS.cso", wi::graphics::ShaderModel::SM_5_0, { "WIDE" }); }); + wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_RTDIFFUSE_SPATIAL], "rtdiffuse_spatialCS.cso"); }); + wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_RTDIFFUSE_TEMPORAL], "rtdiffuse_temporalCS.cso"); }); + wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_RTDIFFUSE_UPSAMPLE], "rtdiffuse_upsampleCS.cso"); }); if (device->CheckCapability(GraphicsDeviceCapability::RAYTRACING)) { wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_RTDIFFUSE], "rtdiffuseCS.cso", ShaderModel::SM_6_5); }); - wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_RTDIFFUSE_SPATIAL], "rtdiffuse_spatialCS.cso"); }); - wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_RTDIFFUSE_TEMPORAL], "rtdiffuse_temporalCS.cso"); }); - wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_RTDIFFUSE_BILATERAL], "rtdiffuse_bilateralCS.cso"); }); wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_RTREFLECTION], "rtreflectionCS.cso", ShaderModel::SM_6_5); }); @@ -2994,6 +3005,76 @@ void RenderImpostors( void ProcessDeferredTextureRequests(CommandList cmd) { + if(!painttextures.empty()) + { + device->EventBegin("Paint Into Texture", cmd); + + // batch begin barriers: + for (auto& params : painttextures) + { + barrier_stack.push_back(GPUBarrier::Image(¶ms.editTex, params.editTex.desc.layout, ResourceState::UNORDERED_ACCESS)); + } + barrier_stack_flush(cmd); + + // render splats: + device->BindComputeShader(&shaders[CSTYPE_PAINT_TEXTURE], cmd); + for (auto& params : painttextures) + { + // overwrites some params! + if (params.brushTex.IsValid()) + { + params.push.texture_brush = device->GetDescriptorIndex(¶ms.brushTex, SubresourceType::SRV); + } + else + { + params.push.texture_brush = -1; + } + if (params.revealTex.IsValid()) + { + params.push.texture_reveal = device->GetDescriptorIndex(¶ms.revealTex, SubresourceType::SRV); + } + else + { + params.push.texture_reveal = -1; + } + params.push.texture_output = device->GetDescriptorIndex(¶ms.editTex, SubresourceType::UAV); + assert(params.push.texture_output >= 0); + + if (params.push.texture_output < 0) + continue; + + device->PushConstants(¶ms.push, sizeof(params.push), cmd); + + const uint diameter = params.push.xPaintBrushRadius * 2; + const uint dispatch_dim = (diameter + PAINT_TEXTURE_BLOCKSIZE - 1) / PAINT_TEXTURE_BLOCKSIZE; + device->Dispatch(dispatch_dim, dispatch_dim, 1, cmd); + + device->Barrier(GPUBarrier::Memory(¶ms.editTex), cmd); + } + + // ending barriers: + for (auto& params : painttextures) + { + barrier_stack.push_back(GPUBarrier::Image(¶ms.editTex, ResourceState::UNORDERED_ACCESS, params.editTex.desc.layout)); + } + barrier_stack_flush(cmd); + + // mipgen tasks after paint: + for (auto& params : painttextures) + { + if (params.editTex.desc.mip_levels > 1) + { + GenerateMipChain(params.editTex, MIPGENFILTER::MIPGENFILTER_LINEAR, cmd); + } + } + + // clear all paint tasks for this frame: + painttextures.clear(); + + device->EventEnd(cmd); + } + + deferredMIPGenLock.lock(); for (auto& it : deferredMIPGens) { @@ -3177,43 +3258,24 @@ void UpdateVisibility(Visibility& vis) if (vis.flags & Visibility::ALLOW_DECALS) { - const uint32_t decal_loop = (uint32_t)std::min(vis.scene->aabb_decals.size(), vis.scene->decals.GetCount()); - vis.visibleDecals.resize(decal_loop); - wi::jobsystem::Dispatch(ctx, decal_loop, groupSize, [&](wi::jobsystem::JobArgs args) { - - // Setup stream compaction: - uint32_t& group_count = *(uint32_t*)args.sharedmemory; - uint32_t* group_list = (uint32_t*)args.sharedmemory + 1; - if (args.isFirstJobInGroup) - { - group_count = 0; // first thread initializes local counter - } - - const AABB& aabb = vis.scene->aabb_decals[args.jobIndex]; - - if ((aabb.layerMask & vis.layerMask) && vis.frustum.CheckBoxFast(aabb)) + // Note: decals must be appended in order for correct blending, must not use parallelization! + wi::jobsystem::Execute(ctx, [&](wi::jobsystem::JobArgs args) { + for (size_t i = 0; i < vis.scene->aabb_decals.size(); ++i) { - // Local stream compaction: - group_list[group_count++] = args.jobIndex; - } + const AABB& aabb = vis.scene->aabb_decals[i]; - // Global stream compaction: - if (args.isLastJobInGroup && group_count > 0) - { - uint32_t prev_count = vis.decal_counter.fetch_add(group_count); - for (uint32_t i = 0; i < group_count; ++i) + if ((aabb.layerMask & vis.layerMask) && vis.frustum.CheckBoxFast(aabb)) { - vis.visibleDecals[prev_count + i] = group_list[i]; + vis.visibleDecals.push_back(uint32_t(i)); } } - - }, sharedmemory_size); + }); } if (vis.flags & Visibility::ALLOW_ENVPROBES) { + // Note: probes must be appended in order for correct blending, must not use parallelization! wi::jobsystem::Execute(ctx, [&](wi::jobsystem::JobArgs args) { - // Cull probes: for (size_t i = 0; i < vis.scene->aabb_probes.size(); ++i) { const AABB& aabb = vis.scene->aabb_probes[i]; @@ -3273,7 +3335,6 @@ void UpdateVisibility(Visibility& vis) // finalize stream compaction: vis.visibleObjects.resize((size_t)vis.object_counter.load()); - vis.visibleDecals.resize((size_t)vis.decal_counter.load()); vis.visibleLights.resize((size_t)vis.light_counter.load()); if (vis.scene->weather.IsOceanEnabled()) @@ -3471,6 +3532,8 @@ void UpdatePerFrameData( desc.layout = ResourceState::SHADER_RESOURCE_COMPUTE; device->CreateTexture(&desc, nullptr, &textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW]); device->SetName(&textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW], "textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW]"); + device->CreateTexture(&desc, nullptr, &textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED]); + device->SetName(&textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED], "textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED]"); } const float cloudShadowSnapLength = 5000.0f; @@ -3506,7 +3569,7 @@ void UpdatePerFrameData( XMStoreFloat4x4(&frameCB.cloudShadowLightSpaceMatrix, cloudShadowLightSpaceMatrix); XMStoreFloat4x4(&frameCB.cloudShadowLightSpaceMatrixInverse, cloudShadowLightSpaceMatrixInverse); frameCB.cloudShadowFarPlaneKm = cloudShadowFarPlane * metersToSkyUnit; - frameCB.texture_volumetricclouds_shadow_index = device->GetDescriptorIndex(&textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW], SubresourceType::SRV); + frameCB.texture_volumetricclouds_shadow_index = device->GetDescriptorIndex(&textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED], SubresourceType::SRV); } if (scene.weather.IsRealisticSky() && !textures[TEXTYPE_2D_SKYATMOSPHERE_TRANSMITTANCELUT].IsValid()) @@ -3919,6 +3982,8 @@ void UpdateRenderData( shaderentity.shadowAtlasMulAdd = decal.texMulAdd; shaderentity.SetConeAngleCos(decal.slopeBlendPower); shaderentity.SetDirection(decal.front); + shaderentity.SetAngleScale(decal.normal_strength); + shaderentity.SetLength(decal.displacement_strength); shaderentity.SetIndices(matrixCounter, 0); shadermatrix = XMMatrixInverse(nullptr, XMLoadFloat4x4(&decal.world)); @@ -3938,10 +4003,16 @@ void UpdateRenderData( { surfacemap = device->GetDescriptorIndex(&decal.surfacemap.GetTexture(), SubresourceType::SRV); } + int displacementmap = -1; + if (decal.displacementmap.IsValid()) + { + displacementmap = device->GetDescriptorIndex(&decal.displacementmap.GetTexture(), SubresourceType::SRV); + } + shadermatrix.r[0] = XMVectorSetW(shadermatrix.r[0], *(float*)&texture); shadermatrix.r[1] = XMVectorSetW(shadermatrix.r[1], *(float*)&normal); - shadermatrix.r[2] = XMVectorSetW(shadermatrix.r[2], decal.normal_strength); - shadermatrix.r[3] = XMVectorSetW(shadermatrix.r[3], *(float*)&surfacemap); + shadermatrix.r[2] = XMVectorSetW(shadermatrix.r[2], *(float*)&surfacemap); + shadermatrix.r[3] = XMVectorSetW(shadermatrix.r[3], *(float*)&displacementmap); std::memcpy(matrixArray + matrixCounter, &shadermatrix, sizeof(XMMATRIX)); matrixCounter++; @@ -4009,6 +4080,8 @@ void UpdateRenderData( // Write lights into entity array: const XMFLOAT2 atlas_dim_rcp = XMFLOAT2(1.0f / float(shadowMapAtlas.desc.width), 1.0f / float(shadowMapAtlas.desc.height)); + ShaderEntity shaderentity; + for (uint32_t lightIndex : vis.visibleLights) { if (entityCounter == SHADER_ENTITY_COUNT) @@ -4017,7 +4090,7 @@ void UpdateRenderData( entityCounter--; break; } - ShaderEntity shaderentity = {}; + shaderentity = {}; const LightComponent& light = vis.scene->lights[lightIndex]; @@ -4286,16 +4359,16 @@ void UpdateRenderData( { auto range = wi::profiler::BeginRangeGPU("Wind", cmd); device->EventBegin("Wind", cmd); + device->ClearUAV(&textures[TEXTYPE_3D_WIND], 0, cmd); + device->ClearUAV(&textures[TEXTYPE_3D_WIND_PREV], 0, cmd); + barrier_stack.push_back(GPUBarrier::Memory(&textures[TEXTYPE_3D_WIND])); + barrier_stack.push_back(GPUBarrier::Memory(&textures[TEXTYPE_3D_WIND_PREV])); + barrier_stack_flush(cmd); if ( - vis.scene->weather.windDirection.x == 0 && - vis.scene->weather.windDirection.y == 0 && - vis.scene->weather.windDirection.z == 0 + vis.scene->weather.windDirection.x != 0 || + vis.scene->weather.windDirection.y != 0 || + vis.scene->weather.windDirection.z != 0 ) - { - device->ClearUAV(&textures[TEXTYPE_3D_WIND], 0, cmd); - device->ClearUAV(&textures[TEXTYPE_3D_WIND_PREV], 0, cmd); - } - else { device->BindComputeShader(&shaders[CSTYPE_WIND], cmd); device->BindUAV(&textures[TEXTYPE_3D_WIND], 0, cmd); @@ -5402,6 +5475,7 @@ void DrawVolumeLights( BindCommonResources(cmd); XMMATRIX VP = vis.camera->GetViewProjection(); + const XMVECTOR CamPos = vis.camera->GetEye(); for (int type = 0; type < LightComponent::LIGHTTYPE_COUNT; ++type) { @@ -5447,11 +5521,21 @@ void DrawVolumeLights( { MiscCB miscCb; miscCb.g_xColor.x = float(i); + miscCb.g_xColor.y = std::pow(std::sin(light.outerConeAngle), 2.0f); + miscCb.g_xColor.z = std::pow(std::cos(light.outerConeAngle), 2.0f); + + const XMVECTOR LightPos = XMLoadFloat3(&light.position); + const XMVECTOR LightDirection = XMLoadFloat3(&light.direction); + const XMVECTOR L = XMVector3Normalize(LightPos - CamPos); + const float spot_factor = XMVectorGetX(XMVector3Dot(L, LightDirection)); + const float spot_cutoff = std::cos(light.outerConeAngle); + miscCb.g_xColor.w = (spot_factor < spot_cutoff) ? 1.0f : 0.0f; + const float coneS = (const float)(light.outerConeAngle * 2 / XM_PIDIV4); XMStoreFloat4x4(&miscCb.g_xTransform, - XMMatrixScaling(coneS*light.GetRange(), light.GetRange(), coneS*light.GetRange())* - XMMatrixRotationQuaternion(XMLoadFloat4(&light.rotation))* - XMMatrixTranslationFromVector(XMLoadFloat3(&light.position)) * + XMMatrixScaling(coneS * light.GetRange(), light.GetRange(), coneS * light.GetRange()) * + XMMatrixRotationQuaternion(XMLoadFloat4(&light.rotation)) * + XMMatrixTranslationFromVector(LightPos) * VP ); device->BindDynamicConstantBuffer(miscCb, CB_GETBINDSLOT(MiscCB), cmd); @@ -6046,7 +6130,7 @@ void DrawScene( const bool occlusion = (flags & DRAWSCENE_OCCLUSIONCULLING) && (vis.flags & Visibility::ALLOW_OCCLUSION_CULLING) && GetOcclusionCullingEnabled(); const bool ocean = flags & DRAWSCENE_OCEAN; const bool skip_planar_reflection_objects = flags & DRAWSCENE_SKIP_PLANAR_REFLECTION_OBJECTS; - const bool foreground_only = flags & DRAWSCENE_FOREGROUND_ONLY; + const bool foreground = flags & DRAWSCENE_FOREGROUND_ONLY; const bool maincamera = flags & DRAWSCENE_MAINCAMERA; device->EventBegin("DrawScene", cmd); @@ -6088,7 +6172,7 @@ void DrawScene( const ObjectComponent& object = vis.scene->objects[instanceIndex]; if (!object.IsRenderable()) continue; - if (foreground_only && !object.IsForeground()) + if (foreground != object.IsForeground()) continue; if (maincamera && object.IsNotVisibleInMainCamera()) continue; @@ -6187,6 +6271,24 @@ void DrawDebugWorld( BindCommonResources(cmd); + for (auto& x : renderableVoxelgrids) + { + x->debugdraw(camera.VP, cmd); + } + renderableVoxelgrids.clear(); + + for (auto& x : renderablePathqueries) + { + x->debugdraw(camera.VP, cmd); + } + renderablePathqueries.clear(); + + for (auto& x : renderableTrails) + { + x->Draw(camera, cmd); + } + renderableTrails.clear(); + if (debugCameras) { device->EventBegin("DebugCameras", cmd); @@ -7163,7 +7265,14 @@ void DrawDebugWorld( Entity entity = scene.emitters.GetEntity(i); const MeshComponent* mesh = scene.meshes.GetComponent(emitter.meshID); - XMStoreFloat4x4(&sb.g_xTransform, XMLoadFloat4x4(&emitter.worldMatrix)*camera.GetViewProjection()); + XMMATRIX W = XMLoadFloat4x4(&emitter.worldMatrix) * camera.GetViewProjection(); + if (mesh != nullptr && IsFormatUnorm(mesh->position_format) && !mesh->so_pos.IsValid()) + { + XMMATRIX R = mesh->aabb.getUnormRemapMatrix(); + W = R * W; + } + + XMStoreFloat4x4(&sb.g_xTransform, W); sb.g_xColor = float4(0, 1, 0, 1); device->BindDynamicConstantBuffer(sb, CB_GETBINDSLOT(MiscCB), cmd); @@ -7331,6 +7440,7 @@ void DrawDebugWorld( params.size = x.params.pixel_height; params.scaling = 1.0f / params.size * x.params.scaling; params.color = wi::Color::fromFloat4(x.params.color); + params.intensity = x.params.color.w > 1 ? x.params.color.w : 1; params.h_align = wi::font::WIFALIGN_CENTER; params.v_align = wi::font::WIFALIGN_CENTER; params.softness = 0.0f; @@ -7445,28 +7555,27 @@ void ComputeVolumetricCloudShadows( device->BindResource(&textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW], 0, cmd); const GPUResource* uavs[] = { - &textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW], + &textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED], }; device->BindUAVs(uavs, 0, arraysize(uavs), cmd); { GPUBarrier barriers[] = { - GPUBarrier::Image(&textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW], textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW].desc.layout, ResourceState::UNORDERED_ACCESS), + GPUBarrier::Image(&textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED], textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED].desc.layout, ResourceState::UNORDERED_ACCESS), }; device->Barrier(barriers, arraysize(barriers), cmd); } device->Dispatch( - (textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW].GetDesc().width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, - (textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW].GetDesc().height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, + (textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED].GetDesc().width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, + (textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED].GetDesc().height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, 1, cmd ); { GPUBarrier barriers[] = { - GPUBarrier::Memory(), - GPUBarrier::Image(&textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW], ResourceState::UNORDERED_ACCESS, textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW].desc.layout), + GPUBarrier::Image(&textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED], ResourceState::UNORDERED_ACCESS, textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED].desc.layout), }; device->Barrier(barriers, arraysize(barriers), cmd); } @@ -7828,7 +7937,7 @@ void RefreshEnvProbes(const Visibility& vis, CommandList cmd) { desc.mip_levels = 1; desc.bind_flags = BindFlag::DEPTH_STENCIL | BindFlag::SHADER_RESOURCE; - desc.format = wi::renderer::format_depthbuffer_envprobe; + desc.format = format_depthbuffer_envprobe; desc.layout = ResourceState::SHADER_RESOURCE; desc.sample_count = required_sample_count; if (required_sample_count == 1) @@ -7854,7 +7963,7 @@ void RefreshEnvProbes(const Visibility& vis, CommandList cmd) { desc.mip_levels = probe.texture.desc.mip_levels; desc.bind_flags = BindFlag::RENDER_TARGET | BindFlag::SHADER_RESOURCE | BindFlag::UNORDERED_ACCESS; - desc.format = wi::renderer::format_rendertarget_envprobe; + desc.format = format_rendertarget_envprobe; desc.layout = ResourceState::SHADER_RESOURCE; desc.misc_flags = ResourceMiscFlag::TEXTURECUBE; desc.sample_count = 1; @@ -7887,7 +7996,7 @@ void RefreshEnvProbes(const Visibility& vis, CommandList cmd) { desc.mip_levels = probe.texture.desc.mip_levels; desc.bind_flags = BindFlag::SHADER_RESOURCE | BindFlag::UNORDERED_ACCESS; - desc.format = wi::renderer::format_rendertarget_envprobe; + desc.format = format_rendertarget_envprobe; desc.layout = ResourceState::SHADER_RESOURCE; desc.misc_flags = ResourceMiscFlag::TEXTURECUBE; desc.sample_count = 1; @@ -7932,7 +8041,7 @@ void RefreshEnvProbes(const Visibility& vis, CommandList cmd) desc.bind_flags = BindFlag::RENDER_TARGET; desc.misc_flags = ResourceMiscFlag::TRANSIENT_ATTACHMENT; desc.layout = ResourceState::RENDERTARGET; - desc.format = wi::renderer::format_rendertarget_envprobe; + desc.format = format_rendertarget_envprobe; device->CreateTexture(&desc, nullptr, &envrenderingColorBuffer_MSAA); device->SetName(&envrenderingColorBuffer_MSAA, "envrenderingColorBuffer_MSAA"); render_textures[id_color_msaa.raw] = envrenderingColorBuffer_MSAA; @@ -9784,6 +9893,7 @@ void BindCameraCB( shadercam.texture_waterriples_index = camera.texture_waterriples_index; shadercam.texture_ao_index = camera.texture_ao_index; shadercam.texture_ssr_index = camera.texture_ssr_index; + shadercam.texture_ssgi_index = camera.texture_ssgi_index; shadercam.texture_rtshadow_index = camera.texture_rtshadow_index; shadercam.texture_rtdiffuse_index = camera.texture_rtdiffuse_index; shadercam.texture_surfelgi_index = camera.texture_surfelgi_index; @@ -10082,7 +10192,11 @@ void Visibility_Prepare( BindCommonResources(cmd); + // Note: the tile_count here must be valid whether the VisibilityResources was created or not! + XMUINT2 tile_count = GetVisibilityTileCount(XMUINT2(input_primitiveID.desc.width, input_primitiveID.desc.height)); + // Beginning barriers, clears: + if(res.IsValid()) { ShaderTypeBin bins[SHADERTYPE_BIN_COUNT + 1]; for (uint i = 0; i < arraysize(bins); ++i) @@ -10108,10 +10222,19 @@ void Visibility_Prepare( device->BindResource(&input_primitiveID, 0, cmd); - device->BindUAV(&res.bins, 0, cmd); - device->BindUAV(&res.binned_tiles, 1, cmd); - GPUResource unbind; + + if (res.IsValid()) + { + device->BindUAV(&res.bins, 0, cmd); + device->BindUAV(&res.binned_tiles, 1, cmd); + } + else + { + device->BindUAV(&unbind, 0, cmd); + device->BindUAV(&unbind, 1, cmd); + } + if (res.depthbuffer) { device->BindUAV(res.depthbuffer, 3, cmd, 0); @@ -10160,8 +10283,8 @@ void Visibility_Prepare( device->BindComputeShader(&shaders[msaa ? CSTYPE_VISIBILITY_RESOLVE_MSAA : CSTYPE_VISIBILITY_RESOLVE], cmd); device->Dispatch( - res.tile_count.x, - res.tile_count.y, + tile_count.x, + tile_count.y, 1, cmd ); @@ -10178,8 +10301,11 @@ void Visibility_Prepare( { barrier_stack.push_back(GPUBarrier::Image(res.primitiveID_resolved, ResourceState::UNORDERED_ACCESS, res.primitiveID_resolved->desc.layout)); } - barrier_stack.push_back(GPUBarrier::Buffer(&res.bins, ResourceState::UNORDERED_ACCESS, ResourceState::INDIRECT_ARGUMENT)); - barrier_stack.push_back(GPUBarrier::Buffer(&res.binned_tiles, ResourceState::UNORDERED_ACCESS, ResourceState::SHADER_RESOURCE)); + if (res.IsValid()) + { + barrier_stack.push_back(GPUBarrier::Buffer(&res.bins, ResourceState::UNORDERED_ACCESS, ResourceState::INDIRECT_ARGUMENT)); + barrier_stack.push_back(GPUBarrier::Buffer(&res.binned_tiles, ResourceState::UNORDERED_ACCESS, ResourceState::SHADER_RESOURCE)); + } barrier_stack_flush(cmd); device->EventEnd(cmd); @@ -10330,7 +10456,6 @@ void Visibility_Shade( device->EventEnd(cmd); } void Visibility_Velocity( - const VisibilityResources& res, const Texture& output, CommandList cmd ) @@ -10889,7 +11014,6 @@ void Postprocess_Blur_Gaussian( { GPUBarrier barriers[] = { - GPUBarrier::Memory(), GPUBarrier::Image(&temp, ResourceState::UNORDERED_ACCESS, temp.desc.layout, mip_dst), }; device->Barrier(barriers, arraysize(barriers), cmd); @@ -10934,7 +11058,6 @@ void Postprocess_Blur_Gaussian( { GPUBarrier barriers[] = { - GPUBarrier::Memory(), GPUBarrier::Image(&output, ResourceState::UNORDERED_ACCESS, output.desc.layout, mip_dst), }; device->Barrier(barriers, arraysize(barriers), cmd); @@ -11127,10 +11250,15 @@ void Postprocess_SSAO( { GPUBarrier barriers[] = { GPUBarrier::Image(&output, output.desc.layout, ResourceState::UNORDERED_ACCESS), + GPUBarrier::Image(&res.temp, res.temp.desc.layout, ResourceState::UNORDERED_ACCESS), }; device->Barrier(barriers, arraysize(barriers), cmd); } + device->ClearUAV(&output, 0, cmd); + device->ClearUAV(&res.temp, 0, cmd); + device->Barrier(GPUBarrier::Memory(&output), cmd); + device->Dispatch( (desc.width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, (desc.height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, @@ -11140,8 +11268,8 @@ void Postprocess_SSAO( { GPUBarrier barriers[] = { - GPUBarrier::Memory(), GPUBarrier::Image(&output, ResourceState::UNORDERED_ACCESS, output.desc.layout), + GPUBarrier::Image(&res.temp, ResourceState::UNORDERED_ACCESS, res.temp.desc.layout), }; device->Barrier(barriers, arraysize(barriers), cmd); } @@ -11166,7 +11294,6 @@ void Postprocess_HBAO( device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_HBAO], cmd); - const TextureDesc& desc = output.GetDesc(); PostProcess postprocess; @@ -11205,21 +11332,26 @@ void Postprocess_HBAO( { GPUBarrier barriers[] = { + GPUBarrier::Image(&output, output.desc.layout, ResourceState::UNORDERED_ACCESS), GPUBarrier::Image(&res.temp, res.temp.desc.layout, ResourceState::UNORDERED_ACCESS), }; device->Barrier(barriers, arraysize(barriers), cmd); } + device->ClearUAV(&output, 0, cmd); + device->ClearUAV(&res.temp, 0, cmd); + device->Barrier(GPUBarrier::Memory(&res.temp), cmd); + device->Dispatch( (postprocess.resolution.x + POSTPROCESS_HBAO_THREADCOUNT - 1) / POSTPROCESS_HBAO_THREADCOUNT, postprocess.resolution.y, 1, cmd - ); + ); { GPUBarrier barriers[] = { - GPUBarrier::Memory(), + GPUBarrier::Memory(&output), GPUBarrier::Image(&res.temp, ResourceState::UNORDERED_ACCESS, res.temp.desc.layout), }; device->Barrier(barriers, arraysize(barriers), cmd); @@ -11239,23 +11371,15 @@ void Postprocess_HBAO( }; device->BindUAVs(uavs, 0, arraysize(uavs), cmd); - { - GPUBarrier barriers[] = { - GPUBarrier::Image(&output, output.desc.layout, ResourceState::UNORDERED_ACCESS), - }; - device->Barrier(barriers, arraysize(barriers), cmd); - } - device->Dispatch( postprocess.resolution.x, (postprocess.resolution.y + POSTPROCESS_HBAO_THREADCOUNT - 1) / POSTPROCESS_HBAO_THREADCOUNT, 1, cmd - ); + ); { GPUBarrier barriers[] = { - GPUBarrier::Memory(), GPUBarrier::Image(&output, ResourceState::UNORDERED_ACCESS, output.desc.layout), }; device->Barrier(barriers, arraysize(barriers), cmd); @@ -11263,13 +11387,15 @@ void Postprocess_HBAO( } - Postprocess_Blur_Bilateral(output, lineardepth, res.temp, output, cmd, 1.2f, -1, -1, true); + //Postprocess_Blur_Bilateral(output, lineardepth, res.temp, output, cmd, 1.2f, -1, -1, true); wi::profiler::EndRange(prof_range); device->EventEnd(cmd); } void CreateMSAOResources(MSAOResources& res, XMUINT2 resolution) { + res.cleared = false; + TextureDesc saved_desc; saved_desc.format = Format::R32_FLOAT; saved_desc.width = resolution.x; @@ -11512,8 +11638,8 @@ void Postprocess_MSAO( SampleThickness[9] = sqrt(1.0f - 0.4f * 0.4f - 0.6f * 0.6f); SampleThickness[10] = sqrt(1.0f - 0.4f * 0.4f - 0.8f * 0.8f); SampleThickness[11] = sqrt(1.0f - 0.6f * 0.6f - 0.6f * 0.6f); - static float RejectionFalloff = 2.0f; - const float Accentuation = 0.1f * power; + const float RejectionFalloff = 2.0f * power; + const float Accentuation = 0.1f; // The msao_compute will be called repeatedly, so create a local lambda for it: auto msao_compute = [&](const Texture& write_result, const Texture& read_depth) @@ -11850,7 +11976,6 @@ void Postprocess_RTAO( { // Maybe we don't need to clear them all, but it's safer this way: GPUBarrier barriers[] = { - GPUBarrier::Image(&output, output.desc.layout, ResourceState::UNORDERED_ACCESS), GPUBarrier::Image(&res.normals, res.normals.desc.layout, ResourceState::UNORDERED_ACCESS), GPUBarrier::Image(&res.scratch[0], res.scratch[0].desc.layout, ResourceState::UNORDERED_ACCESS), GPUBarrier::Image(&res.scratch[1], res.scratch[1].desc.layout, ResourceState::UNORDERED_ACCESS), @@ -11858,7 +11983,6 @@ void Postprocess_RTAO( GPUBarrier::Image(&res.moments[1], res.moments[1].desc.layout, ResourceState::UNORDERED_ACCESS), }; device->Barrier(barriers, arraysize(barriers), cmd); - device->ClearUAV(&output, 0, cmd); device->ClearUAV(&res.normals, 0, cmd); device->ClearUAV(&res.scratch[0], 0, cmd); device->ClearUAV(&res.scratch[1], 0, cmd); @@ -11983,6 +12107,9 @@ void Postprocess_RTAO( device->BindResource(&res.normals, 0, cmd); device->BindResource(&res.metadata, 1, cmd); + device->ClearUAV(&output, 0, cmd); + device->Barrier(GPUBarrier::Memory(&output), cmd); + // pass0: { device->BindResource(&res.scratch[0], 2, cmd); @@ -12103,11 +12230,6 @@ void CreateRTDiffuseResources(RTDiffuseResources& res, XMUINT2 resolution) device->CreateTexture(&desc, nullptr, &res.texture_spatial_variance); device->CreateTexture(&desc, nullptr, &res.texture_temporal_variance[0]); device->CreateTexture(&desc, nullptr, &res.texture_temporal_variance[1]); - - desc.format = Format::R11G11B10_FLOAT; - desc.width = resolution.x; - desc.height = resolution.y; - device->CreateTexture(&desc, nullptr, &res.texture_bilateral_temp); } void Postprocess_RTDiffuse( const RTDiffuseResources& res, @@ -12134,7 +12256,6 @@ void Postprocess_RTDiffuse( GPUBarrier::Image(&res.texture_rayIndirectDiffuse, res.texture_rayIndirectDiffuse.desc.layout, ResourceState::UNORDERED_ACCESS), GPUBarrier::Image(&res.texture_spatial, res.texture_spatial.desc.layout, ResourceState::UNORDERED_ACCESS), GPUBarrier::Image(&res.texture_spatial_variance, res.texture_spatial_variance.desc.layout, ResourceState::UNORDERED_ACCESS), - GPUBarrier::Image(&res.texture_bilateral_temp, res.texture_bilateral_temp.desc.layout, ResourceState::UNORDERED_ACCESS), GPUBarrier::Image(&res.texture_temporal[temporal_output], res.texture_temporal[temporal_output].desc.layout, ResourceState::UNORDERED_ACCESS), GPUBarrier::Image(&res.texture_temporal_variance[temporal_output], res.texture_temporal_variance[temporal_output].desc.layout, ResourceState::UNORDERED_ACCESS), GPUBarrier::Image(&res.texture_temporal[temporal_history], res.texture_temporal[temporal_output].desc.layout, ResourceState::UNORDERED_ACCESS), @@ -12147,7 +12268,6 @@ void Postprocess_RTDiffuse( device->ClearUAV(&res.texture_rayIndirectDiffuse, 0, cmd); device->ClearUAV(&res.texture_spatial, 0, cmd); device->ClearUAV(&res.texture_spatial_variance, 0, cmd); - device->ClearUAV(&res.texture_bilateral_temp, 0, cmd); device->ClearUAV(&res.texture_temporal[temporal_output], 0, cmd); device->ClearUAV(&res.texture_temporal_variance[temporal_output], 0, cmd); if (res.frame == 0) @@ -12162,7 +12282,6 @@ void Postprocess_RTDiffuse( GPUBarrier::Memory(&res.texture_rayIndirectDiffuse), GPUBarrier::Memory(&res.texture_spatial), GPUBarrier::Memory(&res.texture_spatial_variance), - GPUBarrier::Memory(&res.texture_bilateral_temp), GPUBarrier::Memory(&res.texture_temporal[temporal_output]), GPUBarrier::Memory(&res.texture_temporal_variance[temporal_output]), GPUBarrier::Image(&res.texture_temporal[temporal_history], ResourceState::UNORDERED_ACCESS, res.texture_temporal[temporal_output].desc.layout), @@ -12188,7 +12307,7 @@ void Postprocess_RTDiffuse( std::memcpy(&postprocess.params1.x, &instanceInclusionMask, sizeof(instanceInclusionMask)); { - device->EventBegin("RTDiffuse Raytrace pass", cmd); + device->EventBegin("RTDiffuse - ray trace", cmd); device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_RTDIFFUSE], cmd); @@ -12218,7 +12337,7 @@ void Postprocess_RTDiffuse( // Spatial pass: { - device->EventBegin("RTDiffuse - spatial filter", cmd); + device->EventBegin("RTDiffuse - spatial resolve", cmd); device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_RTDIFFUSE_SPATIAL], cmd); const GPUResource* resarray[] = { @@ -12252,7 +12371,7 @@ void Postprocess_RTDiffuse( // Temporal pass: { - device->EventBegin("RTDiffuse temporal filter", cmd); + device->EventBegin("RTDiffuse - temporal resolve", cmd); device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_RTDIFFUSE_TEMPORAL], cmd); device->PushConstants(&postprocess, sizeof(postprocess), cmd); @@ -12297,71 +12416,34 @@ void Postprocess_RTDiffuse( // Bilateral blur pass: { - device->EventBegin("RTDiffuse - bilateral filter", cmd); - device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_RTDIFFUSE_BILATERAL], cmd); - - // Horizontal: - { - postprocess.params0.x = 1; - postprocess.params0.y = 0; - device->PushConstants(&postprocess, sizeof(postprocess), cmd); + device->EventBegin("RTDiffuse - upsample", cmd); + device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_RTDIFFUSE_UPSAMPLE], cmd); - const GPUResource* resarray[] = { - &res.texture_temporal[temporal_output], - &res.texture_temporal_variance[temporal_output], - }; - device->BindResources(resarray, 0, arraysize(resarray), cmd); + device->PushConstants(&postprocess, sizeof(postprocess), cmd); - const GPUResource* uavs[] = { - &res.texture_bilateral_temp, - }; - device->BindUAVs(uavs, 0, arraysize(uavs), cmd); + const GPUResource* resarray[] = { + &res.texture_temporal[temporal_output], + &res.texture_temporal_variance[temporal_output], + }; + device->BindResources(resarray, 0, arraysize(resarray), cmd); - device->Dispatch( - (res.texture_bilateral_temp.GetDesc().width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, - (res.texture_bilateral_temp.GetDesc().height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, - 1, - cmd - ); + const GPUResource* uavs[] = { + &output, + }; + device->BindUAVs(uavs, 0, arraysize(uavs), cmd); - { - GPUBarrier barriers[] = { - GPUBarrier::Image(&res.texture_bilateral_temp, ResourceState::UNORDERED_ACCESS, res.texture_bilateral_temp.desc.layout), - }; - device->Barrier(barriers, arraysize(barriers), cmd); - } - } + device->Dispatch( + (output.GetDesc().width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, + (output.GetDesc().height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, + 1, + cmd + ); - // Vertical: { - postprocess.params0.x = 0; - postprocess.params0.y = 1; - device->PushConstants(&postprocess, sizeof(postprocess), cmd); - - const GPUResource* resarray[] = { - &res.texture_bilateral_temp, - &res.texture_temporal_variance[temporal_output], - }; - device->BindResources(resarray, 0, arraysize(resarray), cmd); - - const GPUResource* uavs[] = { - &output, + GPUBarrier barriers[] = { + GPUBarrier::Image(&output, ResourceState::UNORDERED_ACCESS, output.desc.layout), }; - device->BindUAVs(uavs, 0, arraysize(uavs), cmd); - - device->Dispatch( - (output.GetDesc().width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, - (output.GetDesc().height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, - 1, - cmd - ); - - { - GPUBarrier barriers[] = { - GPUBarrier::Image(&output, ResourceState::UNORDERED_ACCESS, output.desc.layout), - }; - device->Barrier(barriers, arraysize(barriers), cmd); - } + device->Barrier(barriers, arraysize(barriers), cmd); } device->EventEnd(cmd); @@ -12372,61 +12454,541 @@ void Postprocess_RTDiffuse( wi::profiler::EndRange(profilerRange); device->EventEnd(cmd); } -void CreateRTReflectionResources(RTReflectionResources& res, XMUINT2 resolution) +void CreateSSGIResources(SSGIResources& res, XMUINT2 resolution) { - res.frame = 0; + res.cleared = false; TextureDesc desc; desc.type = TextureDesc::Type::TEXTURE_2D; - desc.width = resolution.x / 2; - desc.height = resolution.y / 2; desc.bind_flags = BindFlag::SHADER_RESOURCE | BindFlag::UNORDERED_ACCESS; desc.layout = ResourceState::SHADER_RESOURCE_COMPUTE; + desc.format = Format::R11G11B10_FLOAT; - desc.format = Format::R16G16B16A16_FLOAT; - device->CreateTexture(&desc, nullptr, &res.texture_rayIndirectSpecular); - device->CreateTexture(&desc, nullptr, &res.texture_rayDirectionPDF); - desc.format = Format::R16_FLOAT; - device->CreateTexture(&desc, nullptr, &res.texture_rayLengths); - device->SetName(&res.texture_rayLengths, "ssr_rayLengths"); + resolution.x = AlignTo(resolution.x, 64u); + resolution.y = AlignTo(resolution.y, 64u); - desc.width = resolution.x; - desc.height = resolution.y; - desc.format = Format::R16G16B16A16_FLOAT; - device->CreateTexture(&desc, nullptr, &res.texture_resolve); - device->CreateTexture(&desc, nullptr, &res.texture_temporal[0]); - device->CreateTexture(&desc, nullptr, &res.texture_temporal[1]); - device->CreateTexture(&desc, nullptr, &res.texture_bilateral_temp); - desc.format = Format::R16_FLOAT; - device->CreateTexture(&desc, nullptr, &res.texture_resolve_variance); - device->CreateTexture(&desc, nullptr, &res.texture_resolve_reprojectionDepth); - device->CreateTexture(&desc, nullptr, &res.texture_temporal_variance[0]); - device->CreateTexture(&desc, nullptr, &res.texture_temporal_variance[1]); + desc.width = (resolution.x + 7) / 8; + desc.height = (resolution.y + 7) / 8; + desc.array_size = 16; + desc.mip_levels = 4; + desc.format = Format::R32_FLOAT; + device->CreateTexture(&desc, nullptr, &res.texture_atlas_depth); + desc.format = Format::R11G11B10_FLOAT; + device->CreateTexture(&desc, nullptr, &res.texture_atlas_color); + + desc.array_size = 1; + desc.mip_levels = 4; + desc.width = (resolution.x + 1) / 2; + desc.height = (resolution.y + 1) / 2; + desc.format = Format::R32_FLOAT; + device->CreateTexture(&desc, nullptr, &res.texture_depth_mips); + desc.format = Format::R16G16_FLOAT; + device->CreateTexture(&desc, nullptr, &res.texture_normal_mips); + desc.format = Format::R11G11B10_FLOAT; + device->CreateTexture(&desc, nullptr, &res.texture_diffuse_mips); + + for (uint32_t i = 0; i < 4u; ++i) + { + int subresource_index; + subresource_index = device->CreateSubresource(&res.texture_atlas_depth, SubresourceType::SRV, 0, 16, i, 1); + assert(subresource_index == i); + subresource_index = device->CreateSubresource(&res.texture_atlas_depth, SubresourceType::UAV, 0, 16, i, 1); + assert(subresource_index == i); + subresource_index = device->CreateSubresource(&res.texture_atlas_color, SubresourceType::SRV, 0, 16, i, 1); + assert(subresource_index == i); + subresource_index = device->CreateSubresource(&res.texture_atlas_color, SubresourceType::UAV, 0, 16, i, 1); + assert(subresource_index == i); + subresource_index = device->CreateSubresource(&res.texture_depth_mips, SubresourceType::SRV, 0, 1, i, 1); + assert(subresource_index == i); + subresource_index = device->CreateSubresource(&res.texture_depth_mips, SubresourceType::UAV, 0, 1, i, 1); + assert(subresource_index == i); + subresource_index = device->CreateSubresource(&res.texture_normal_mips, SubresourceType::SRV, 0, 1, i, 1); + assert(subresource_index == i); + subresource_index = device->CreateSubresource(&res.texture_normal_mips, SubresourceType::UAV, 0, 1, i, 1); + assert(subresource_index == i); + subresource_index = device->CreateSubresource(&res.texture_diffuse_mips, SubresourceType::SRV, 0, 1, i, 1); + assert(subresource_index == i); + subresource_index = device->CreateSubresource(&res.texture_diffuse_mips, SubresourceType::UAV, 0, 1, i, 1); + assert(subresource_index == i); + } } -void Postprocess_RTReflection( - const RTReflectionResources& res, - const Scene& scene, +void Postprocess_SSGI( + const SSGIResources& res, + const Texture& input, + const Texture& input_depth, + const Texture& input_normal, const Texture& output, CommandList cmd, - float range, - float roughnessCutoff + float depthRejection ) { - if (!device->CheckCapability(GraphicsDeviceCapability::RAYTRACING)) - return; + device->EventBegin("Postprocess_SSGI", cmd); + auto profilerRange = wi::profiler::BeginRangeGPU("SSGI", cmd); - if (!scene.TLAS.IsValid() && !scene.BVH.IsValid()) - return; + { + GPUBarrier barriers[] = { + GPUBarrier::Image(&res.texture_atlas_depth, res.texture_atlas_depth.desc.layout, ResourceState::UNORDERED_ACCESS), + GPUBarrier::Image(&res.texture_atlas_color, res.texture_atlas_color.desc.layout, ResourceState::UNORDERED_ACCESS), + GPUBarrier::Image(&res.texture_depth_mips, res.texture_depth_mips.desc.layout, ResourceState::UNORDERED_ACCESS), + GPUBarrier::Image(&res.texture_normal_mips, res.texture_normal_mips.desc.layout, ResourceState::UNORDERED_ACCESS), + GPUBarrier::Image(&res.texture_diffuse_mips, res.texture_diffuse_mips.desc.layout, ResourceState::UNORDERED_ACCESS), + GPUBarrier::Image(&output, output.desc.layout, ResourceState::UNORDERED_ACCESS), + }; + device->Barrier(barriers, arraysize(barriers), cmd); + } - device->EventBegin("Postprocess_RTReflection", cmd); - auto profilerRange = wi::profiler::BeginRangeGPU("RTReflection", cmd); + if (!res.cleared) + { + res.cleared = true; + device->ClearUAV(&res.texture_atlas_depth, 0, cmd); + device->ClearUAV(&res.texture_atlas_color, 0, cmd); + device->ClearUAV(&res.texture_depth_mips, 0, cmd); + device->ClearUAV(&res.texture_normal_mips, 0, cmd); + } + device->ClearUAV(&res.texture_diffuse_mips, 0, cmd); + device->ClearUAV(&output, 0, cmd); + + { + GPUBarrier barriers[] = { + GPUBarrier::Memory(), + }; + device->Barrier(barriers, arraysize(barriers), cmd); + } BindCommonResources(cmd); - const TextureDesc& desc = output.desc; + PostProcess postprocess = {}; - // Render half-res: - PostProcess postprocess; + { + device->EventBegin("SSGI - deinterleave", cmd); + device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_SSGI_DEINTERLEAVE], cmd); + + device->BindResource(&input, 0, cmd); + + device->BindUAV(&res.texture_atlas_depth, 0, cmd, 0); + device->BindUAV(&res.texture_atlas_depth, 1, cmd, 1); + device->BindUAV(&res.texture_atlas_depth, 2, cmd, 2); + device->BindUAV(&res.texture_atlas_depth, 3, cmd, 3); + + device->BindUAV(&res.texture_atlas_color, 4, cmd, 0); + device->BindUAV(&res.texture_atlas_color, 5, cmd, 1); + device->BindUAV(&res.texture_atlas_color, 6, cmd, 2); + device->BindUAV(&res.texture_atlas_color, 7, cmd, 3); + + device->BindUAV(&res.texture_depth_mips, 8, cmd, 0); + device->BindUAV(&res.texture_depth_mips, 9, cmd, 1); + device->BindUAV(&res.texture_depth_mips, 10, cmd, 2); + device->BindUAV(&res.texture_depth_mips, 11, cmd, 3); + + device->BindUAV(&res.texture_normal_mips, 12, cmd, 0); + device->BindUAV(&res.texture_normal_mips, 13, cmd, 1); + device->BindUAV(&res.texture_normal_mips, 14, cmd, 2); + device->BindUAV(&res.texture_normal_mips, 15, cmd, 3); + + const TextureDesc& desc = res.texture_atlas_depth.GetDesc(); + device->Dispatch( + desc.width >> 1, + desc.height >> 1, + 1, + cmd + ); + + device->EventEnd(cmd); + } + + { + GPUBarrier barriers[] = { + GPUBarrier::Image(&res.texture_atlas_depth, ResourceState::UNORDERED_ACCESS, res.texture_atlas_depth.desc.layout), + GPUBarrier::Image(&res.texture_atlas_color, ResourceState::UNORDERED_ACCESS, res.texture_atlas_color.desc.layout), + GPUBarrier::Image(&res.texture_depth_mips, ResourceState::UNORDERED_ACCESS, res.texture_depth_mips.desc.layout), + GPUBarrier::Image(&res.texture_normal_mips, ResourceState::UNORDERED_ACCESS, res.texture_normal_mips.desc.layout), + }; + device->Barrier(barriers, arraysize(barriers), cmd); + } + + { + device->EventBegin("SSGI - diffuse", cmd); + + postprocess.params0.w = 1.0f / depthRejection; + + // Wide sampling passes: + device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_SSGI_WIDE], cmd); + + // 16x: + { + device->BindResource(&res.texture_atlas_depth, 0, cmd, 3); + device->BindResource(&res.texture_atlas_color, 1, cmd, 3); + device->BindResource(&res.texture_normal_mips, 2, cmd, 3); + device->BindUAV(&res.texture_diffuse_mips, 0, cmd, 3); + + const TextureDesc& desc = res.texture_atlas_depth.GetDesc(); + + postprocess.resolution.x = desc.width >> 3; + postprocess.resolution.y = desc.height >> 3; + postprocess.resolution_rcp.x = 1.0f / postprocess.resolution.x; + postprocess.resolution_rcp.y = 1.0f / postprocess.resolution.y; + postprocess.params0.x = 8; // range + postprocess.params0.y = 2; // spread + postprocess.params0.z = std::pow(1.0f / (postprocess.params0.x * postprocess.params0.y), 2.0f); // rangespread_rcp2 + device->PushConstants(&postprocess, sizeof(postprocess), cmd); + + device->Dispatch( + (postprocess.resolution.x + 15) / 16, + (postprocess.resolution.y + 15) / 16, + 16, + cmd + ); + } + // 8x: + { + device->BindResource(&res.texture_atlas_depth, 0, cmd, 2); + device->BindResource(&res.texture_atlas_color, 1, cmd, 2); + device->BindResource(&res.texture_normal_mips, 2, cmd, 2); + device->BindUAV(&res.texture_diffuse_mips, 0, cmd, 2); + + const TextureDesc& desc = res.texture_atlas_depth.GetDesc(); + + postprocess.resolution.x = desc.width >> 2; + postprocess.resolution.y = desc.height >> 2; + postprocess.resolution_rcp.x = 1.0f / postprocess.resolution.x; + postprocess.resolution_rcp.y = 1.0f / postprocess.resolution.y; + postprocess.params0.x = 4; // range + postprocess.params0.y = 4; // spread + postprocess.params0.z = std::pow(1.0f / (postprocess.params0.x * postprocess.params0.y), 2.0f); // rangespread_rcp2 + device->PushConstants(&postprocess, sizeof(postprocess), cmd); + + device->Dispatch( + (postprocess.resolution.x + 15) / 16, + (postprocess.resolution.y + 15) / 16, + 16, + cmd + ); + } + + // Narrow sampling passes: + device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_SSGI], cmd); + + // 4x: + { + device->BindResource(&res.texture_atlas_depth, 0, cmd, 1); + device->BindResource(&res.texture_atlas_color, 1, cmd, 1); + device->BindResource(&res.texture_normal_mips, 2, cmd, 1); + device->BindUAV(&res.texture_diffuse_mips, 0, cmd, 1); + + const TextureDesc& desc = res.texture_atlas_depth.GetDesc(); + + postprocess.resolution.x = desc.width >> 1u; + postprocess.resolution.y = desc.height >> 1u; + postprocess.resolution_rcp.x = 1.0f / postprocess.resolution.x; + postprocess.resolution_rcp.y = 1.0f / postprocess.resolution.y; + postprocess.params0.x = 2; // range + postprocess.params0.y = 2; // spread + postprocess.params0.z = std::pow(1.0f / (postprocess.params0.x * postprocess.params0.y), 2.0f); // rangespread_rcp2 + device->PushConstants(&postprocess, sizeof(postprocess), cmd); + + device->Dispatch( + (postprocess.resolution.x + 7) / 8, + (postprocess.resolution.y + 7) / 8, + 16, + cmd + ); + } + + // 2x: + { + device->BindResource(&res.texture_atlas_depth, 0, cmd, 0); + device->BindResource(&res.texture_atlas_color, 1, cmd, 0); + device->BindResource(&res.texture_normal_mips, 2, cmd, 0); + device->BindUAV(&res.texture_diffuse_mips, 0, cmd, 0); + + const TextureDesc& desc = res.texture_atlas_depth.GetDesc(); + + postprocess.resolution.x = desc.width; + postprocess.resolution.y = desc.height; + postprocess.resolution_rcp.x = 1.0f / postprocess.resolution.x; + postprocess.resolution_rcp.y = 1.0f / postprocess.resolution.y; + postprocess.params0.x = 2; // range + postprocess.params0.y = 2; // spread + postprocess.params0.z = std::pow(1.0f / (postprocess.params0.x * postprocess.params0.y), 2.0f); // rangespread_rcp2 + device->PushConstants(&postprocess, sizeof(postprocess), cmd); + + device->Dispatch( + (postprocess.resolution.x + 7) / 8, + (postprocess.resolution.y + 7) / 8, + 16, + cmd + ); + } + + device->EventEnd(cmd); + } + + { + GPUBarrier barriers[] = { + GPUBarrier::Image(&res.texture_diffuse_mips, ResourceState::UNORDERED_ACCESS, res.texture_diffuse_mips.desc.layout, 3), + }; + device->Barrier(barriers, arraysize(barriers), cmd); + } + + { + device->EventBegin("SSGI - upsample", cmd); + + device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_SSGI_UPSAMPLE_WIDE], cmd); + + // 16x -> 8x + { + device->BindResource(&res.texture_depth_mips, 0, cmd, 3); + device->BindResource(&res.texture_normal_mips, 1, cmd, 3); + device->BindResource(&res.texture_diffuse_mips, 2, cmd, 3); + device->BindResource(&res.texture_depth_mips, 3, cmd, 2); + device->BindResource(&res.texture_normal_mips, 4, cmd, 2); + device->BindUAV(&res.texture_diffuse_mips, 0, cmd, 2); + + const TextureDesc& desc = res.texture_diffuse_mips.desc; + postprocess.resolution.x = desc.width >> 2; + postprocess.resolution.y = desc.height >> 2; + postprocess.resolution_rcp.x = 1.0f / postprocess.resolution.x; + postprocess.resolution_rcp.y = 1.0f / postprocess.resolution.y; + postprocess.params0.x = 3; // range + postprocess.params0.y = 2; // spread + postprocess.params1.x = float(desc.width >> 3); + postprocess.params1.y = float(desc.height >> 3); + postprocess.params1.z = 1.0f / postprocess.params1.x; + postprocess.params1.w = 1.0f / postprocess.params1.y; + device->PushConstants(&postprocess, sizeof(postprocess), cmd); + + device->Dispatch( + (postprocess.resolution.x + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, + (postprocess.resolution.y + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, + 1, + cmd + ); + + { + GPUBarrier barriers[] = { + GPUBarrier::Image(&res.texture_diffuse_mips, ResourceState::UNORDERED_ACCESS, res.texture_diffuse_mips.desc.layout, 2), + }; + device->Barrier(barriers, arraysize(barriers), cmd); + } + } + + // 8x -> 4x + { + device->BindResource(&res.texture_depth_mips, 0, cmd, 2); + device->BindResource(&res.texture_normal_mips, 1, cmd, 2); + device->BindResource(&res.texture_diffuse_mips, 2, cmd, 2); + device->BindResource(&res.texture_depth_mips, 3, cmd, 1); + device->BindResource(&res.texture_normal_mips, 4, cmd, 1); + device->BindUAV(&res.texture_diffuse_mips, 0, cmd, 1); + + const TextureDesc& desc = res.texture_diffuse_mips.desc; + postprocess.resolution.x = desc.width >> 1; + postprocess.resolution.y = desc.height >> 1; + postprocess.resolution_rcp.x = 1.0f / postprocess.resolution.x; + postprocess.resolution_rcp.y = 1.0f / postprocess.resolution.y; + postprocess.params0.x = 2; // range + postprocess.params0.y = 3; // spread + postprocess.params1.x = float(desc.width >> 2); + postprocess.params1.y = float(desc.height >> 2); + postprocess.params1.z = 1.0f / postprocess.params1.x; + postprocess.params1.w = 1.0f / postprocess.params1.y; + device->PushConstants(&postprocess, sizeof(postprocess), cmd); + + device->Dispatch( + (postprocess.resolution.x + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, + (postprocess.resolution.y + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, + 1, + cmd + ); + + { + GPUBarrier barriers[] = { + GPUBarrier::Image(&res.texture_diffuse_mips, ResourceState::UNORDERED_ACCESS, res.texture_diffuse_mips.desc.layout, 1), + }; + device->Barrier(barriers, arraysize(barriers), cmd); + } + } + + device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_SSGI_UPSAMPLE], cmd); + + // 4x -> 2x + { + device->BindResource(&res.texture_depth_mips, 0, cmd, 1); + device->BindResource(&res.texture_normal_mips, 1, cmd, 1); + device->BindResource(&res.texture_diffuse_mips, 2, cmd, 1); + device->BindResource(&res.texture_depth_mips, 3, cmd, 0); + device->BindResource(&res.texture_normal_mips, 4, cmd, 0); + device->BindUAV(&res.texture_diffuse_mips, 0, cmd, 0); + + const TextureDesc& desc = res.texture_diffuse_mips.desc; + postprocess.resolution.x = desc.width; + postprocess.resolution.y = desc.height; + postprocess.resolution_rcp.x = 1.0f / postprocess.resolution.x; + postprocess.resolution_rcp.y = 1.0f / postprocess.resolution.y; + postprocess.params0.x = 1; // range + postprocess.params0.y = 2; // spread + postprocess.params1.x = float(desc.width >> 1); + postprocess.params1.y = float(desc.height >> 1); + postprocess.params1.z = 1.0f / postprocess.params1.x; + postprocess.params1.w = 1.0f / postprocess.params1.y; + device->PushConstants(&postprocess, sizeof(postprocess), cmd); + + device->Dispatch( + (postprocess.resolution.x + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, + (postprocess.resolution.y + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, + 1, + cmd + ); + + { + GPUBarrier barriers[] = { + GPUBarrier::Image(&res.texture_diffuse_mips, ResourceState::UNORDERED_ACCESS, res.texture_diffuse_mips.desc.layout, 0), + }; + device->Barrier(barriers, arraysize(barriers), cmd); + } + } + + // 2x -> output + { + device->BindResource(&res.texture_depth_mips, 0, cmd, 0); + device->BindResource(&res.texture_normal_mips, 1, cmd, 0); + device->BindResource(&res.texture_diffuse_mips, 2, cmd, 0); + device->BindResource(&input_depth, 3, cmd); + device->BindResource(&input_normal, 4, cmd); + device->BindUAV(&output, 0, cmd); + + const TextureDesc& desc = output.desc; + postprocess.resolution.x = AlignTo(desc.width, 64u); // align = uv correction! + postprocess.resolution.y = AlignTo(desc.height, 64u); // align = uv correction! + postprocess.resolution_rcp.x = 1.0f / postprocess.resolution.x; + postprocess.resolution_rcp.y = 1.0f / postprocess.resolution.y; + postprocess.params0.x = 1; // range + postprocess.params0.y = 1; // spread + const TextureDesc& desc2 = res.texture_diffuse_mips.desc; + postprocess.params1.x = float(desc2.width); + postprocess.params1.y = float(desc2.height); + postprocess.params1.z = 1.0f / postprocess.params1.x; + postprocess.params1.w = 1.0f / postprocess.params1.y; + device->PushConstants(&postprocess, sizeof(postprocess), cmd); + + device->Dispatch( + (desc.width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, // dispatch is using desc size (unaligned!) + (desc.height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, // dispatch is using desc size (unaligned!) + 1, + cmd + ); + + { + GPUBarrier barriers[] = { + GPUBarrier::Image(&output, ResourceState::UNORDERED_ACCESS, output.desc.layout), + }; + device->Barrier(barriers, arraysize(barriers), cmd); + } + } + + device->EventEnd(cmd); + } + + wi::profiler::EndRange(profilerRange); + device->EventEnd(cmd); +} +void CreateRTReflectionResources(RTReflectionResources& res, XMUINT2 resolution) +{ + res.frame = 0; + + TextureDesc desc; + desc.type = TextureDesc::Type::TEXTURE_2D; + desc.width = resolution.x / 2; + desc.height = resolution.y / 2; + desc.bind_flags = BindFlag::SHADER_RESOURCE | BindFlag::UNORDERED_ACCESS; + desc.layout = ResourceState::SHADER_RESOURCE_COMPUTE; + + desc.format = Format::R16G16B16A16_FLOAT; + device->CreateTexture(&desc, nullptr, &res.texture_rayIndirectSpecular); + device->CreateTexture(&desc, nullptr, &res.texture_rayDirectionPDF); + desc.format = Format::R16_FLOAT; + device->CreateTexture(&desc, nullptr, &res.texture_rayLengths); + device->SetName(&res.texture_rayLengths, "ssr_rayLengths"); + + desc.width = resolution.x / 2; + desc.height = resolution.y / 2; + desc.format = Format::R16G16B16A16_FLOAT; + device->CreateTexture(&desc, nullptr, &res.texture_resolve); + device->CreateTexture(&desc, nullptr, &res.texture_temporal[0]); + device->CreateTexture(&desc, nullptr, &res.texture_temporal[1]); + desc.format = Format::R16_FLOAT; + device->CreateTexture(&desc, nullptr, &res.texture_resolve_variance); + device->CreateTexture(&desc, nullptr, &res.texture_resolve_reprojectionDepth); + device->CreateTexture(&desc, nullptr, &res.texture_temporal_variance[0]); + device->CreateTexture(&desc, nullptr, &res.texture_temporal_variance[1]); +} +void Postprocess_RTReflection( + const RTReflectionResources& res, + const Scene& scene, + const Texture& output, + CommandList cmd, + float range, + float roughnessCutoff +) +{ + if (!device->CheckCapability(GraphicsDeviceCapability::RAYTRACING)) + return; + + if (!scene.TLAS.IsValid() && !scene.BVH.IsValid()) + return; + + device->EventBegin("Postprocess_RTReflection", cmd); + auto profilerRange = wi::profiler::BeginRangeGPU("RTReflection", cmd); + + BindCommonResources(cmd); + + const int temporal_output = res.frame % 2; + const int temporal_history = 1 - temporal_output; + + { + GPUBarrier barriers[] = { + GPUBarrier::Image(&res.texture_resolve, res.texture_resolve.desc.layout, ResourceState::UNORDERED_ACCESS), + GPUBarrier::Image(&res.texture_resolve_variance, res.texture_resolve_variance.desc.layout, ResourceState::UNORDERED_ACCESS), + GPUBarrier::Image(&res.texture_resolve_reprojectionDepth, res.texture_resolve_reprojectionDepth.desc.layout, ResourceState::UNORDERED_ACCESS), + GPUBarrier::Image(&res.texture_temporal[temporal_output], res.texture_temporal[temporal_output].desc.layout, ResourceState::UNORDERED_ACCESS), + GPUBarrier::Image(&res.texture_temporal_variance[temporal_output], res.texture_temporal_variance[temporal_output].desc.layout, ResourceState::UNORDERED_ACCESS), + GPUBarrier::Image(&output, output.desc.layout, ResourceState::UNORDERED_ACCESS), + }; + device->Barrier(barriers, arraysize(barriers), cmd); + } + + if (res.frame == 0) + { + { + GPUBarrier barriers[] = { + GPUBarrier::Image(&res.texture_temporal[temporal_history], res.texture_temporal[temporal_history].desc.layout, ResourceState::UNORDERED_ACCESS), + GPUBarrier::Image(&res.texture_temporal_variance[temporal_history], res.texture_temporal_variance[temporal_history].desc.layout, ResourceState::UNORDERED_ACCESS), + }; + device->Barrier(barriers, arraysize(barriers), cmd); + } + device->ClearUAV(&res.texture_resolve, 0, cmd); + device->ClearUAV(&res.texture_resolve_variance, 0, cmd); + device->ClearUAV(&res.texture_resolve_reprojectionDepth, 0, cmd); + device->ClearUAV(&res.texture_temporal[0], 0, cmd); + device->ClearUAV(&res.texture_temporal[1], 0, cmd); + device->ClearUAV(&res.texture_temporal_variance[0], 0, cmd); + device->ClearUAV(&res.texture_temporal_variance[1], 0, cmd); + { + GPUBarrier barriers[] = { + GPUBarrier::Memory(), + GPUBarrier::Image(&res.texture_temporal[temporal_history], ResourceState::UNORDERED_ACCESS, res.texture_temporal[temporal_history].desc.layout), + GPUBarrier::Image(&res.texture_temporal_variance[temporal_history], ResourceState::UNORDERED_ACCESS, res.texture_temporal_variance[temporal_history].desc.layout), + }; + device->Barrier(barriers, arraysize(barriers), cmd); + } + } + + device->ClearUAV(&output, 0, cmd); + + const TextureDesc& desc = output.desc; + + // Render half-res: + PostProcess postprocess; postprocess.resolution.x = desc.width / 2; postprocess.resolution.y = desc.height / 2; postprocess.resolution_rcp.x = 1.0f / postprocess.resolution.x; @@ -12507,7 +13069,6 @@ void Postprocess_RTReflection( { GPUBarrier barriers[] = { - GPUBarrier::Memory(), GPUBarrier::Image(&res.texture_rayIndirectSpecular, ResourceState::UNORDERED_ACCESS, res.texture_rayIndirectSpecular.desc.layout), GPUBarrier::Image(&res.texture_rayDirectionPDF, ResourceState::UNORDERED_ACCESS, res.texture_rayDirectionPDF.desc.layout), GPUBarrier::Image(&res.texture_rayLengths, ResourceState::UNORDERED_ACCESS, res.texture_rayLengths.desc.layout), @@ -12518,17 +13079,11 @@ void Postprocess_RTReflection( //device->EventEnd(cmd); } - // Upscale to full-res: - postprocess.resolution.x = desc.width; - postprocess.resolution.y = desc.height; - postprocess.resolution_rcp.x = 1.0f / postprocess.resolution.x; - postprocess.resolution_rcp.y = 1.0f / postprocess.resolution.y; - device->PushConstants(&postprocess, sizeof(postprocess), cmd); - // Resolve pass: { - device->EventBegin("RTReflection Resolve pass", cmd); + device->EventBegin("RTReflection - spatial resolve", cmd); device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_SSR_RESOLVE], cmd); + device->PushConstants(&postprocess, sizeof(postprocess), cmd); const GPUResource* resarray[] = { &res.texture_rayIndirectSpecular, @@ -12573,13 +13128,11 @@ void Postprocess_RTReflection( device->EventEnd(cmd); } - int temporal_output = device->GetFrameCount() % 2; - int temporal_history = 1 - temporal_output; - // Temporal pass: { - device->EventBegin("RTReflection Temporal pass", cmd); + device->EventBegin("RTReflection - temporal resolve", cmd); device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_SSR_TEMPORAL], cmd); + device->PushConstants(&postprocess, sizeof(postprocess), cmd); const GPUResource* resarray[] = { &res.texture_resolve, @@ -12613,9 +13166,9 @@ void Postprocess_RTReflection( { GPUBarrier barriers[] = { - GPUBarrier::Memory(), GPUBarrier::Image(&res.texture_temporal[temporal_output], ResourceState::UNORDERED_ACCESS, res.texture_temporal[temporal_output].desc.layout), GPUBarrier::Image(&res.texture_temporal_variance[temporal_output], ResourceState::UNORDERED_ACCESS, res.texture_temporal_variance[temporal_output].desc.layout), + GPUBarrier::Memory(&output), }; device->Barrier(barriers, arraysize(barriers), cmd); } @@ -12623,89 +13176,41 @@ void Postprocess_RTReflection( device->EventEnd(cmd); } + // Upscale to full-res: + postprocess.resolution.x = desc.width; + postprocess.resolution.y = desc.height; + postprocess.resolution_rcp.x = 1.0f / postprocess.resolution.x; + postprocess.resolution_rcp.y = 1.0f / postprocess.resolution.y; + // Bilateral blur pass: { - device->EventBegin("RTReflection Bilateral blur pass", cmd); - device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_SSR_BILATERAL], cmd); - - // Horizontal: - { - postprocess.params0.x = 1; - postprocess.params0.y = 0; - device->PushConstants(&postprocess, sizeof(postprocess), cmd); - - const GPUResource* resarray[] = { - &res.texture_temporal[temporal_output], - &res.texture_temporal_variance[temporal_output], - }; - device->BindResources(resarray, 0, arraysize(resarray), cmd); - - const GPUResource* uavs[] = { - &res.texture_bilateral_temp, - }; - device->BindUAVs(uavs, 0, arraysize(uavs), cmd); + device->EventBegin("RTReflection - upsample", cmd); + device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_SSR_UPSAMPLE], cmd); + device->PushConstants(&postprocess, sizeof(postprocess), cmd); - { - GPUBarrier barriers[] = { - GPUBarrier::Image(&res.texture_bilateral_temp, res.texture_bilateral_temp.desc.layout, ResourceState::UNORDERED_ACCESS), - }; - device->Barrier(barriers, arraysize(barriers), cmd); - } + const GPUResource* resarray[] = { + &res.texture_temporal[temporal_output], + &res.texture_temporal_variance[temporal_output], + }; + device->BindResources(resarray, 0, arraysize(resarray), cmd); - device->Dispatch( - (res.texture_bilateral_temp.GetDesc().width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, - (res.texture_bilateral_temp.GetDesc().height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, - 1, - cmd - ); + const GPUResource* uavs[] = { + &output, + }; + device->BindUAVs(uavs, 0, arraysize(uavs), cmd); - { - GPUBarrier barriers[] = { - GPUBarrier::Memory(), - GPUBarrier::Image(&res.texture_bilateral_temp, ResourceState::UNORDERED_ACCESS, res.texture_bilateral_temp.desc.layout), - }; - device->Barrier(barriers, arraysize(barriers), cmd); - } - } + device->Dispatch( + (output.GetDesc().width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, + (output.GetDesc().height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, + 1, + cmd + ); - // Vertical: { - postprocess.params0.x = 0; - postprocess.params0.y = 1; - device->PushConstants(&postprocess, sizeof(postprocess), cmd); - - const GPUResource* resarray[] = { - &res.texture_bilateral_temp, - &res.texture_temporal_variance[temporal_output], - }; - device->BindResources(resarray, 0, arraysize(resarray), cmd); - - const GPUResource* uavs[] = { - &output, + GPUBarrier barriers[] = { + GPUBarrier::Image(&output, ResourceState::UNORDERED_ACCESS, output.desc.layout), }; - device->BindUAVs(uavs, 0, arraysize(uavs), cmd); - - { - GPUBarrier barriers[] = { - GPUBarrier::Image(&output, output.desc.layout, ResourceState::UNORDERED_ACCESS), - }; - device->Barrier(barriers, arraysize(barriers), cmd); - } - - device->Dispatch( - (output.GetDesc().width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, - (output.GetDesc().height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, - 1, - cmd - ); - - { - GPUBarrier barriers[] = { - GPUBarrier::Memory(), - GPUBarrier::Image(&output, ResourceState::UNORDERED_ACCESS, output.desc.layout), - }; - device->Barrier(barriers, arraysize(barriers), cmd); - } + device->Barrier(barriers, arraysize(barriers), cmd); } device->EventEnd(cmd); @@ -12729,8 +13234,9 @@ void CreateSSRResources(SSRResources& res, XMUINT2 resolution) tile_desc.layout = ResourceState::SHADER_RESOURCE_COMPUTE; device->CreateTexture(&tile_desc, nullptr, &res.texture_tile_minmax_roughness); - tile_desc.height = resolution.y; - device->CreateTexture(&tile_desc, nullptr, &res.texture_tile_minmax_roughness_horizontal); + TextureDesc tile_desc2 = tile_desc; + tile_desc2.height = resolution.y; + device->CreateTexture(&tile_desc2, nullptr, &res.texture_tile_minmax_roughness_horizontal); GPUBufferDesc bufferdesc; bufferdesc.stride = sizeof(PostprocessTileStatistics); @@ -12760,13 +13266,12 @@ void CreateSSRResources(SSRResources& res, XMUINT2 resolution) device->CreateTexture(&desc, nullptr, &res.texture_rayLengths); device->SetName(&res.texture_rayLengths, "ssr_rayLengths"); - desc.width = resolution.x; - desc.height = resolution.y; + desc.width = resolution.x / 2; + desc.height = resolution.y / 2; desc.format = Format::R16G16B16A16_FLOAT; device->CreateTexture(&desc, nullptr, &res.texture_resolve); device->CreateTexture(&desc, nullptr, &res.texture_temporal[0]); device->CreateTexture(&desc, nullptr, &res.texture_temporal[1]); - device->CreateTexture(&desc, nullptr, &res.texture_bilateral_temp); desc.format = Format::R16_FLOAT; device->CreateTexture(&desc, nullptr, &res.texture_resolve_variance); device->CreateTexture(&desc, nullptr, &res.texture_resolve_reprojectionDepth); @@ -12802,28 +13307,51 @@ void Postprocess_SSR( BindCommonResources(cmd); - int temporal_output = device->GetFrameCount() % 2; - int temporal_history = 1 - temporal_output; + const int temporal_output = res.frame % 2; + const int temporal_history = 1 - temporal_output; { GPUBarrier barriers[] = { GPUBarrier::Image(&res.texture_tile_minmax_roughness_horizontal, res.texture_tile_minmax_roughness_horizontal.desc.layout, ResourceState::UNORDERED_ACCESS), GPUBarrier::Image(&res.texture_tile_minmax_roughness, res.texture_tile_minmax_roughness.desc.layout, ResourceState::UNORDERED_ACCESS), - GPUBarrier::Buffer(&res.buffer_tile_tracing_statistics, ResourceState::UNDEFINED, ResourceState::COPY_DST), - GPUBarrier::Buffer(&res.buffer_tiles_tracing_earlyexit, ResourceState::UNDEFINED, ResourceState::UNORDERED_ACCESS), - GPUBarrier::Buffer(&res.buffer_tiles_tracing_cheap, ResourceState::UNDEFINED, ResourceState::UNORDERED_ACCESS), - GPUBarrier::Buffer(&res.buffer_tiles_tracing_expensive, ResourceState::UNDEFINED, ResourceState::UNORDERED_ACCESS), GPUBarrier::Image(&res.texture_resolve, res.texture_resolve.desc.layout, ResourceState::UNORDERED_ACCESS), GPUBarrier::Image(&res.texture_resolve_variance, res.texture_resolve_variance.desc.layout, ResourceState::UNORDERED_ACCESS), GPUBarrier::Image(&res.texture_resolve_reprojectionDepth, res.texture_resolve_reprojectionDepth.desc.layout, ResourceState::UNORDERED_ACCESS), GPUBarrier::Image(&res.texture_temporal[temporal_output], res.texture_temporal[temporal_output].desc.layout, ResourceState::UNORDERED_ACCESS), GPUBarrier::Image(&res.texture_temporal_variance[temporal_output], res.texture_temporal_variance[temporal_output].desc.layout, ResourceState::UNORDERED_ACCESS), - GPUBarrier::Image(&res.texture_bilateral_temp, res.texture_bilateral_temp.desc.layout, ResourceState::UNORDERED_ACCESS), GPUBarrier::Image(&output, output.desc.layout, ResourceState::UNORDERED_ACCESS), }; device->Barrier(barriers, arraysize(barriers), cmd); } + if (res.frame == 0) + { + { + GPUBarrier barriers[] = { + GPUBarrier::Image(&res.texture_temporal[temporal_history], res.texture_temporal[temporal_history].desc.layout, ResourceState::UNORDERED_ACCESS), + GPUBarrier::Image(&res.texture_temporal_variance[temporal_history], res.texture_temporal_variance[temporal_history].desc.layout, ResourceState::UNORDERED_ACCESS), + }; + device->Barrier(barriers, arraysize(barriers), cmd); + } + device->ClearUAV(&res.texture_tile_minmax_roughness_horizontal, 0, cmd); + device->ClearUAV(&res.texture_tile_minmax_roughness, 0, cmd); + device->ClearUAV(&res.texture_resolve, 0, cmd); + device->ClearUAV(&res.texture_resolve_variance, 0, cmd); + device->ClearUAV(&res.texture_resolve_reprojectionDepth, 0, cmd); + device->ClearUAV(&res.texture_temporal[0], 0, cmd); + device->ClearUAV(&res.texture_temporal[1], 0, cmd); + device->ClearUAV(&res.texture_temporal_variance[0], 0, cmd); + device->ClearUAV(&res.texture_temporal_variance[1], 0, cmd); + { + GPUBarrier barriers[] = { + GPUBarrier::Memory(), + GPUBarrier::Image(&res.texture_temporal[temporal_history], ResourceState::UNORDERED_ACCESS, res.texture_temporal[temporal_history].desc.layout), + GPUBarrier::Image(&res.texture_temporal_variance[temporal_history], ResourceState::UNORDERED_ACCESS, res.texture_temporal_variance[temporal_history].desc.layout), + }; + device->Barrier(barriers, arraysize(barriers), cmd); + } + } + device->ClearUAV(&output, 0, cmd); PostprocessTileStatistics tile_stats = {}; @@ -12840,7 +13368,6 @@ void Postprocess_SSR( { GPUBarrier barriers[] = { - GPUBarrier::Memory(), GPUBarrier::Buffer(&res.buffer_tile_tracing_statistics, ResourceState::COPY_DST, ResourceState::UNORDERED_ACCESS), }; device->Barrier(barriers, arraysize(barriers), cmd); @@ -12852,7 +13379,7 @@ void Postprocess_SSR( // Compute tile classification (horizontal): { - device->EventBegin("SSR Tile Classification - Horizontal", cmd); + device->EventBegin("SSR - tile classification horizontal", cmd); device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_SSR_TILEMAXROUGHNESS_HORIZONTAL], cmd); const GPUResource* uavs[] = { @@ -12879,7 +13406,7 @@ void Postprocess_SSR( // Compute tile classification (vertical): { - device->EventBegin("SSR Tile Classification - Vertical", cmd); + device->EventBegin("SSR - tile classification vertical", cmd); device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_SSR_TILEMAXROUGHNESS_VERTICAL], cmd); device->PushConstants(&postprocess, sizeof(postprocess), cmd); @@ -12916,7 +13443,7 @@ void Postprocess_SSR( // Depth hierarchy: { - device->EventBegin("SSR Depth hierarchy pass", cmd); + device->EventBegin("SSR - depth hierarchy", cmd); device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_SSR_DEPTHHIERARCHY], cmd); TextureDesc hierarchyDesc = res.texture_depth_hierarchy.GetDesc(); @@ -12945,7 +13472,6 @@ void Postprocess_SSR( { GPUBarrier barriers[] = { - GPUBarrier::Memory(), GPUBarrier::Image(&res.texture_depth_hierarchy, ResourceState::UNORDERED_ACCESS, res.texture_depth_hierarchy.desc.layout, 0), }; device->Barrier(barriers, arraysize(barriers), cmd); @@ -12976,8 +13502,8 @@ void Postprocess_SSR( device->PushConstants(&postprocess, sizeof(postprocess), cmd); device->Dispatch( - std::max(1u, hierarchyDesc.width / POSTPROCESS_BLOCKSIZE), - std::max(1u, hierarchyDesc.height / POSTPROCESS_BLOCKSIZE), + std::max(1u, (hierarchyDesc.width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE), + std::max(1u, (hierarchyDesc.height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE), 1, cmd ); @@ -13011,7 +13537,7 @@ void Postprocess_SSR( // Raytrace pass: { - device->EventBegin("SSR Raytrace pass", cmd); + device->EventBegin("SSR - ray trace", cmd); const GPUResource* resarray[] = { &res.texture_depth_hierarchy, @@ -13065,15 +13591,9 @@ void Postprocess_SSR( device->EventEnd(cmd); } - // Upscale to full-res: - postprocess.resolution.x = desc.width; - postprocess.resolution.y = desc.height; - postprocess.resolution_rcp.x = 1.0f / postprocess.resolution.x; - postprocess.resolution_rcp.y = 1.0f / postprocess.resolution.y; - // Resolve pass: { - device->EventBegin("SSR Resolve pass", cmd); + device->EventBegin("SSR - spatial resolve", cmd); device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_SSR_RESOLVE], cmd); device->PushConstants(&postprocess, sizeof(postprocess), cmd); @@ -13100,7 +13620,6 @@ void Postprocess_SSR( { GPUBarrier barriers[] = { - GPUBarrier::Memory(), GPUBarrier::Image(&res.texture_resolve, ResourceState::UNORDERED_ACCESS, res.texture_resolve.desc.layout), GPUBarrier::Image(&res.texture_resolve_variance, ResourceState::UNORDERED_ACCESS, res.texture_resolve_variance.desc.layout), GPUBarrier::Image(&res.texture_resolve_reprojectionDepth, ResourceState::UNORDERED_ACCESS, res.texture_resolve_reprojectionDepth.desc.layout), @@ -13113,7 +13632,7 @@ void Postprocess_SSR( // Temporal pass: { - device->EventBegin("SSR Temporal pass", cmd); + device->EventBegin("SSR - temporal resolve", cmd); device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_SSR_TEMPORAL], cmd); device->PushConstants(&postprocess, sizeof(postprocess), cmd); @@ -13143,6 +13662,7 @@ void Postprocess_SSR( GPUBarrier barriers[] = { GPUBarrier::Image(&res.texture_temporal[temporal_output], ResourceState::UNORDERED_ACCESS, res.texture_temporal[temporal_output].desc.layout), GPUBarrier::Image(&res.texture_temporal_variance[temporal_output], ResourceState::UNORDERED_ACCESS, res.texture_temporal_variance[temporal_output].desc.layout), + GPUBarrier::Memory(&output), }; device->Barrier(barriers, arraysize(barriers), cmd); } @@ -13150,73 +13670,41 @@ void Postprocess_SSR( device->EventEnd(cmd); } + // Upscale to full-res: + postprocess.resolution.x = desc.width; + postprocess.resolution.y = desc.height; + postprocess.resolution_rcp.x = 1.0f / postprocess.resolution.x; + postprocess.resolution_rcp.y = 1.0f / postprocess.resolution.y; + // Bilateral blur pass: { - device->EventBegin("SSR Bilateral blur pass", cmd); - device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_SSR_BILATERAL], cmd); - - // Horizontal: - { - postprocess.params0.x = 1; - postprocess.params0.y = 0; - device->PushConstants(&postprocess, sizeof(postprocess), cmd); - - const GPUResource* resarray[] = { - &res.texture_temporal[temporal_output], - &res.texture_temporal_variance[temporal_output], - }; - device->BindResources(resarray, 0, arraysize(resarray), cmd); + device->EventBegin("SSR - upsample", cmd); + device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_SSR_UPSAMPLE], cmd); + device->PushConstants(&postprocess, sizeof(postprocess), cmd); - const GPUResource* uavs[] = { - &res.texture_bilateral_temp, - }; - device->BindUAVs(uavs, 0, arraysize(uavs), cmd); + const GPUResource* resarray[] = { + &res.texture_temporal[temporal_output], + &res.texture_temporal_variance[temporal_output], + }; + device->BindResources(resarray, 0, arraysize(resarray), cmd); - device->Dispatch( - (res.texture_bilateral_temp.GetDesc().width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, - (res.texture_bilateral_temp.GetDesc().height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, - 1, - cmd - ); + const GPUResource* uavs[] = { + &output, + }; + device->BindUAVs(uavs, 0, arraysize(uavs), cmd); - { - GPUBarrier barriers[] = { - GPUBarrier::Image(&res.texture_bilateral_temp, ResourceState::UNORDERED_ACCESS, res.texture_bilateral_temp.desc.layout), - }; - device->Barrier(barriers, arraysize(barriers), cmd); - } - } + device->Dispatch( + (output.GetDesc().width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, + (output.GetDesc().height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, + 1, + cmd + ); - // Vertical: { - postprocess.params0.x = 0; - postprocess.params0.y = 1; - device->PushConstants(&postprocess, sizeof(postprocess), cmd); - - const GPUResource* resarray[] = { - &res.texture_bilateral_temp, - &res.texture_temporal_variance[temporal_output], - }; - device->BindResources(resarray, 0, arraysize(resarray), cmd); - - const GPUResource* uavs[] = { - &output, + GPUBarrier barriers[] = { + GPUBarrier::Image(&output, ResourceState::UNORDERED_ACCESS, output.desc.layout), }; - device->BindUAVs(uavs, 0, arraysize(uavs), cmd); - - device->Dispatch( - (output.GetDesc().width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, - (output.GetDesc().height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, - 1, - cmd - ); - - { - GPUBarrier barriers[] = { - GPUBarrier::Image(&output, ResourceState::UNORDERED_ACCESS, output.desc.layout), - }; - device->Barrier(barriers, arraysize(barriers), cmd); - } + device->Barrier(barriers, arraysize(barriers), cmd); } device->EventEnd(cmd); @@ -14598,7 +15086,7 @@ void Postprocess_VolumetricClouds( camera_previous_clouds.jitter = XMFLOAT2(0, 0); camera_previous_clouds.UpdateCamera(); - wi::renderer::BindCameraCB(camera_clouds, camera_previous_clouds, camera_reflection, cmd); + BindCameraCB(camera_clouds, camera_previous_clouds, camera_reflection, cmd); } BindCommonResources(cmd); @@ -15941,22 +16429,23 @@ void Postprocess_Upsample_Bilateral( postprocess.resolution_rcp.x = 1.0f / postprocess.resolution.x; postprocess.resolution_rcp.y = 1.0f / postprocess.resolution.y; postprocess.params0.x = threshold; - postprocess.params0.y = 1.0f / (float)input.GetDesc().width; - postprocess.params0.z = 1.0f / (float)input.GetDesc().height; - // select mip from lowres depth mipchain: - postprocess.params0.w = std::floor(std::max(1.0f, log2f(std::max((float)desc.width / (float)input.GetDesc().width, (float)desc.height / (float)input.GetDesc().height)))); - postprocess.params1.x = (float)input.GetDesc().width; - postprocess.params1.y = (float)input.GetDesc().height; + postprocess.params0.w = float(input.desc.width) / float(output.desc.width); + postprocess.params1.x = (float)input.desc.width; + postprocess.params1.y = (float)input.desc.height; postprocess.params1.z = 1.0f / postprocess.params1.x; postprocess.params1.w = 1.0f / postprocess.params1.y; + const int mip = (int)std::floor(std::max(1.0f, log2f(std::max((float)desc.width / (float)input.GetDesc().width, (float)desc.height / (float)input.GetDesc().height)))); + + device->BindResource(&input, 0, cmd); + device->BindResource(&lineardepth, 1, cmd); + device->BindResource(&lineardepth, 2, cmd, std::min((int)lineardepth.desc.mip_levels - 1, mip)); + if (pixelshader) { device->BindPipelineState(&PSO_upsample_bilateral, cmd); device->PushConstants(&postprocess, sizeof(postprocess), cmd); - device->BindResource(&input, 0, cmd); - device->Draw(3, 0, cmd); } else @@ -15983,9 +16472,6 @@ void Postprocess_Upsample_Bilateral( case Format::R32G32B32A32_FLOAT: cs = CSTYPE_POSTPROCESS_UPSAMPLE_BILATERAL_FLOAT4; break; - case Format::R32G32B32A32_UINT: - cs = CSTYPE_POSTPROCESS_UPSAMPLE_BILATERAL_UINT4; - break; default: assert(0); // implement format! break; @@ -15993,8 +16479,6 @@ void Postprocess_Upsample_Bilateral( device->BindComputeShader(&shaders[cs], cmd); device->PushConstants(&postprocess, sizeof(postprocess), cmd); - device->BindResource(&input, 0, cmd); - const GPUResource* uavs[] = { &output, }; @@ -16059,6 +16543,9 @@ void Postprocess_Downsample4x( device->Barrier(barriers, arraysize(barriers), cmd); } + device->ClearUAV(&output, 0, cmd); + device->Barrier(GPUBarrier::Memory(&output), cmd); + device->Dispatch( (desc.width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, (desc.height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, @@ -16518,6 +17005,22 @@ void DrawPaintRadius(const PaintRadius& paintrad) { paintrads.push_back(paintrad); } +void PaintIntoTexture(const PaintTextureParams& params) +{ + painttextures.push_back(params); +} +void DrawVoxelGrid(const wi::VoxelGrid* voxelgrid) +{ + renderableVoxelgrids.push_back(voxelgrid); +} +void DrawPathQuery(const wi::PathQuery* pathquery) +{ + renderablePathqueries.push_back(pathquery); +} +void DrawTrail(const wi::TrailRenderer* trail) +{ + renderableTrails.push_back(trail); +} void AddDeferredMIPGen(const Texture& texture, bool preserve_coverage) { @@ -16697,4 +17200,59 @@ float GetGIBoost() return GI_BOOST; } +wi::Resource CreatePaintableTexture(uint32_t width, uint32_t height, uint32_t mips, wi::Color initialColor) +{ + TextureDesc desc; + desc.width = width; + desc.height = height; + desc.mip_levels = mips; + if (desc.mip_levels == 0) + { + desc.mip_levels = GetMipCount(desc.width, desc.height); + } + desc.format = Format::R8G8B8A8_UNORM; + desc.bind_flags = BindFlag::SHADER_RESOURCE | BindFlag::UNORDERED_ACCESS; + wi::vector data(desc.width * desc.height); + std::fill(data.begin(), data.end(), initialColor); + SubresourceData initdata[32] = {}; + for (uint32_t mip = 0; mip < desc.mip_levels; ++mip) + { + initdata[mip].data_ptr = data.data(); + initdata[mip].row_pitch = std::max(1u, desc.width >> mip) * GetFormatStride(desc.format); + } + Texture texture; + GraphicsDevice* device = GetDevice(); + device->CreateTexture(&desc, initdata, &texture); + + static std::atomic cnt = 0; + device->SetName(&texture, std::string("PaintableTexture" + std::to_string(cnt.fetch_add(1u))).c_str()); + + for (uint32_t i = 0; i < texture.GetDesc().mip_levels; ++i) + { + int subresource_index; + subresource_index = device->CreateSubresource(&texture, SubresourceType::SRV, 0, 1, i, 1); + assert(subresource_index == i); + subresource_index = device->CreateSubresource(&texture, SubresourceType::UAV, 0, 1, i, 1); + assert(subresource_index == i); + } + + // This part must be AFTER mip level subresource creation: + int srgb_subresource = -1; + { + Format srgb_format = GetFormatSRGB(desc.format); + srgb_subresource = device->CreateSubresource( + &texture, + SubresourceType::SRV, + 0, -1, + 0, -1, + &srgb_format + ); + } + + wi::Resource resource; + resource.SetTexture(texture, srgb_subresource); + + return resource; +} + } diff --git a/WickedEngine/wiRenderer.h b/WickedEngine/wiRenderer.h index a02f04b1c25..ec841bc81c2 100644 --- a/WickedEngine/wiRenderer.h +++ b/WickedEngine/wiRenderer.h @@ -15,6 +15,13 @@ #include #include +namespace wi +{ + struct VoxelGrid; + struct PathQuery; + struct TrailRenderer; +} + namespace wi::renderer { inline constexpr wi::graphics::Format format_depthbuffer_main = wi::graphics::Format::D32_FLOAT_S8X24_UINT; @@ -130,7 +137,6 @@ namespace wi::renderer std::atomic object_counter; std::atomic light_counter; - std::atomic decal_counter; wi::SpinLock locker; bool planar_reflection_visible = false; @@ -149,7 +155,6 @@ namespace wi::renderer object_counter.store(0); light_counter.store(0); - decal_counter.store(0); closestRefPlane = std::numeric_limits::max(); planar_reflection_visible = false; @@ -362,7 +367,10 @@ namespace wi::renderer const wi::graphics::Texture* depthbuffer = nullptr; // depth buffer that matches with post projection const wi::graphics::Texture* lineardepth = nullptr; // depth buffer in linear space in [0,1] range const wi::graphics::Texture* primitiveID_resolved = nullptr; // resolved from MSAA texture_visibility input + + inline bool IsValid() const { return bins.IsValid(); } }; + void CreateVisibilityResourcesLightWeight(VisibilityResources& res, XMUINT2 resolution); void CreateVisibilityResources(VisibilityResources& res, XMUINT2 resolution); void Visibility_Prepare( const VisibilityResources& res, @@ -384,7 +392,6 @@ namespace wi::renderer wi::graphics::CommandList cmd ); void Visibility_Velocity( - const VisibilityResources& res, const wi::graphics::Texture& output, wi::graphics::CommandList cmd ); @@ -536,7 +543,6 @@ namespace wi::renderer wi::graphics::Texture texture_spatial_variance; wi::graphics::Texture texture_temporal[2]; wi::graphics::Texture texture_temporal_variance[2]; - wi::graphics::Texture texture_bilateral_temp; }; void CreateRTDiffuseResources(RTDiffuseResources& res, XMUINT2 resolution); void Postprocess_RTDiffuse( @@ -546,6 +552,25 @@ namespace wi::renderer wi::graphics::CommandList cmd, float range = 1000.0f ); + struct SSGIResources + { + mutable bool cleared = false; + wi::graphics::Texture texture_atlas_depth; + wi::graphics::Texture texture_atlas_color; + wi::graphics::Texture texture_depth_mips; + wi::graphics::Texture texture_normal_mips; + wi::graphics::Texture texture_diffuse_mips; + }; + void CreateSSGIResources(SSGIResources& res, XMUINT2 resolution); + void Postprocess_SSGI( + const SSGIResources& res, + const wi::graphics::Texture& input, + const wi::graphics::Texture& input_depth, + const wi::graphics::Texture& input_normal, + const wi::graphics::Texture& output, + wi::graphics::CommandList cmd, + float depthRejection = 8 + ); struct RTReflectionResources { mutable int frame = 0; @@ -557,7 +582,6 @@ namespace wi::renderer wi::graphics::Texture texture_resolve_reprojectionDepth; wi::graphics::Texture texture_temporal[2]; wi::graphics::Texture texture_temporal_variance[2]; - wi::graphics::Texture texture_bilateral_temp; }; void CreateRTReflectionResources(RTReflectionResources& res, XMUINT2 resolution); void Postprocess_RTReflection( @@ -582,7 +606,6 @@ namespace wi::renderer wi::graphics::Texture texture_resolve_reprojectionDepth; wi::graphics::Texture texture_temporal[2]; wi::graphics::Texture texture_temporal_variance[2]; - wi::graphics::Texture texture_bilateral_temp; wi::graphics::GPUBuffer buffer_tile_tracing_statistics; wi::graphics::GPUBuffer buffer_tiles_tracing_earlyexit; wi::graphics::GPUBuffer buffer_tiles_tracing_cheap; @@ -1137,6 +1160,28 @@ namespace wi::renderer }; void DrawPaintRadius(const PaintRadius& paintrad); + struct PaintTextureParams + { + wi::graphics::Texture editTex; // UAV writable texture + wi::graphics::Texture brushTex; // splat texture (optional) + wi::graphics::Texture revealTex; // mask texture that can be revealed (optional) + PaintTexturePushConstants push = {}; // shader parameters + }; + void PaintIntoTexture(const PaintTextureParams& params); + wi::Resource CreatePaintableTexture(uint32_t width, uint32_t height, uint32_t mips = 0, wi::Color initialColor = wi::Color::Transparent()); + + // Add voxel grid to be drawn in debug rendering phase. + // WARNING: This retains pointer until next call to DrawDebugScene(), so voxel grid must not be destroyed until then! + void DrawVoxelGrid(const wi::VoxelGrid* voxelgrid); + + // Add path query to be drawn in debug rendering phase. + // WARNING: This retains pointer until next call to DrawDebugScene(), so path query must not be destroyed until then! + void DrawPathQuery(const wi::PathQuery* pathquery); + + // Add trail to be drawn in debug rendering phase. + // WARNING: This retains pointer until next call to DrawDebugScene(), so trail must not be destroyed until then! + void DrawTrail(const wi::TrailRenderer* trail); + // Add a texture that should be mipmapped whenever it is feasible to do so void AddDeferredMIPGen(const wi::graphics::Texture& texture, bool preserve_coverage = false); void AddDeferredBlockCompression(const wi::graphics::Texture& texture_src, const wi::graphics::Texture& texture_bc); diff --git a/WickedEngine/wiRenderer_BindLua.cpp b/WickedEngine/wiRenderer_BindLua.cpp index 54721c04f70..e3495e16f0b 100644 --- a/WickedEngine/wiRenderer_BindLua.cpp +++ b/WickedEngine/wiRenderer_BindLua.cpp @@ -9,6 +9,9 @@ #include "wiHairParticle.h" #include "wiPrimitive_BindLua.h" #include "wiEventHandler.h" +#include "wiVoxelGrid_BindLua.h" +#include "wiPathQuery_BindLua.h" +#include "wiTrailRenderer_BindLua.h" using namespace wi::ecs; using namespace wi::graphics; @@ -421,6 +424,284 @@ namespace wi::lua::renderer return 0; } + int DrawVoxelGrid(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc > 0) + { + VoxelGrid_BindLua* a = Luna::lightcheck(L, 1); + if (a) + { + wi::renderer::DrawVoxelGrid(a->voxelgrid); + } + else + wi::lua::SError(L, "DrawVoxelGrid(VoxelGrid voxelgrid) first argument must be a VoxelGrid type!"); + } + else + wi::lua::SError(L, "DrawVoxelGrid(VoxelGrid voxelgrid) not enough arguments!"); + + return 0; + } + int DrawPathQuery(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc > 0) + { + PathQuery_BindLua* a = Luna::lightcheck(L, 1); + if (a) + { + wi::renderer::DrawPathQuery(&a->pathquery); + } + else + wi::lua::SError(L, "DrawPathQuery(PathQuery pathquery) first argument must be a PathQuery type!"); + } + else + wi::lua::SError(L, "DrawPathQuery(PathQuery pathquery) not enough arguments!"); + + return 0; + } + int DrawTrail(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc > 0) + { + TrailRenderer_BindLua* a = Luna::lightcheck(L, 1); + if (a) + { + wi::renderer::DrawTrail(&a->trail); + } + else + wi::lua::SError(L, "DrawTrail(TrailRenderer trail) first argument must be a TrailRenderer type!"); + } + else + wi::lua::SError(L, "DrawTrail(TrailRenderer trail) not enough arguments!"); + + return 0; + } + + class PaintTextureParams_BindLua + { + public: + wi::renderer::PaintTextureParams params; + + PaintTextureParams_BindLua(const wi::renderer::PaintTextureParams& params) : params(params) {} + PaintTextureParams_BindLua(lua_State* L) {} + + int SetEditTexture(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "SetEditTexture(Texture tex): not enough arguments!"); + return 0; + } + Texture_BindLua* tex = Luna::lightcheck(L, 1); + if (tex == nullptr) + { + wi::lua::SError(L, "SetEditTexture(Texture tex): argument is not a Texture!"); + return 0; + } + if (tex->resource.IsValid()) + { + params.editTex = tex->resource.GetTexture(); + } + return 0; + } + int SetBrushTexture(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "SetBrushTexture(Texture tex): not enough arguments!"); + return 0; + } + Texture_BindLua* tex = Luna::lightcheck(L, 1); + if (tex == nullptr) + { + wi::lua::SError(L, "SetBrushTexture(Texture tex): argument is not a Texture!"); + return 0; + } + if (tex->resource.IsValid()) + { + params.brushTex = tex->resource.GetTexture(); + } + return 0; + } + int SetRevealTexture(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "SetRevealTexture(Texture tex): not enough arguments!"); + return 0; + } + Texture_BindLua* tex = Luna::lightcheck(L, 1); + if (tex == nullptr) + { + wi::lua::SError(L, "SetRevealTexture(Texture tex): argument is not a Texture!"); + return 0; + } + if (tex->resource.IsValid()) + { + params.revealTex = tex->resource.GetTexture(); + } + return 0; + } + int SetCenterPixel(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "SetCenterPixel(Vector value): not enough arguments!"); + return 0; + } + Vector_BindLua* vec = Luna::lightcheck(L, 1); + if (vec == nullptr) + { + wi::lua::SError(L, "SetCenterPixel(Vector value): argument is not a Vector!"); + return 0; + } + params.push.xPaintBrushCenter.x = uint32_t(vec->data.x); + params.push.xPaintBrushCenter.y = uint32_t(vec->data.y); + return 0; + } + int SetBrushColor(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "SetBrushColor(Vector value): not enough arguments!"); + return 0; + } + Vector_BindLua* vec = Luna::lightcheck(L, 1); + if (vec == nullptr) + { + wi::lua::SError(L, "SetBrushColor(Vector value): argument is not a Vector!"); + return 0; + } + params.push.xPaintBrushColor = wi::Color::fromFloat4(vec->data); + return 0; + } + int SetBrushRadius(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "SetBrushRadius(int value): not enough arguments!"); + return 0; + } + params.push.xPaintBrushRadius = wi::lua::SGetInt(L, 1); + return 0; + } + int SetBrushAmount(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "SetBrushAmount(float value): not enough arguments!"); + return 0; + } + params.push.xPaintBrushAmount = wi::lua::SGetFloat(L, 1); + return 0; + } + int SetBrushSmoothness(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "SetBrushSmoothness(float value): not enough arguments!"); + return 0; + } + params.push.xPaintBrushSmoothness = wi::lua::SGetFloat(L, 1); + return 0; + } + int SetBrushRotation(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "SetBrushRotation(float value): not enough arguments!"); + return 0; + } + params.push.xPaintBrushRotation = wi::lua::SGetFloat(L, 1); + return 0; + } + int SetBrushShape(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "SetBrushShape(float value): not enough arguments!"); + return 0; + } + params.push.xPaintBrushShape = wi::lua::SGetInt(L, 1); + return 0; + } + + inline static constexpr char className[] = "PaintTextureParams"; + inline static constexpr Luna::FunctionType methods[] = { + lunamethod(PaintTextureParams_BindLua, SetEditTexture), + lunamethod(PaintTextureParams_BindLua, SetBrushTexture), + lunamethod(PaintTextureParams_BindLua, SetRevealTexture), + lunamethod(PaintTextureParams_BindLua, SetBrushColor), + lunamethod(PaintTextureParams_BindLua, SetCenterPixel), + lunamethod(PaintTextureParams_BindLua, SetBrushRadius), + lunamethod(PaintTextureParams_BindLua, SetBrushAmount), + lunamethod(PaintTextureParams_BindLua, SetBrushSmoothness), + lunamethod(PaintTextureParams_BindLua, SetBrushRotation), + lunamethod(PaintTextureParams_BindLua, SetBrushShape), + { nullptr, nullptr } + }; + inline static constexpr Luna::PropertyType properties[] = { + { nullptr, nullptr } + }; + }; + + int PaintIntoTexture(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "PaintIntoTexture(PaintTextureParams params): not enough arguments!"); + return 0; + } + PaintTextureParams_BindLua* params = Luna::lightcheck(L, 1); + if (params == nullptr) + { + wi::lua::SError(L, "PaintIntoTexture(PaintTextureParams params): argument is not a PaintTextureParams!"); + return 0; + } + wi::renderer::PaintIntoTexture(params->params); + return 0; + } + int CreatePaintableTexture(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 2) + { + wi::lua::SError(L, "CreatePaintableTexture(int width,height, opt int mips = 0, opt Vector initialColor = Vector()): not enough arguments!"); + return 0; + } + uint32_t width = (uint32_t)wi::lua::SGetInt(L, 1); + uint32_t height = (uint32_t)wi::lua::SGetInt(L, 2); + uint32_t mips = 0; + wi::Color color = wi::Color::Transparent(); + if (argc > 2) + { + mips = (uint32_t)wi::lua::SGetInt(L, 3); + if (argc > 3) + { + Vector_BindLua* v = Luna::lightcheck(L, 4); + if (v != nullptr) + { + color = wi::Color::fromFloat4(v->data); + } + } + } + Luna::push(L, wi::renderer::CreatePaintableTexture(width, height, mips, color)); + return 1; + } + int PutWaterRipple(lua_State* L) { int argc = wi::lua::SGetArgCount(L); @@ -479,6 +760,8 @@ namespace wi::lua::renderer { initialized = true; + Luna::Register(wi::lua::GetLuaState()); + wi::lua::RegisterFunc("SetGamma", SetGamma); wi::lua::RegisterFunc("SetGameSpeed", SetGameSpeed); wi::lua::RegisterFunc("GetGameSpeed", GetGameSpeed); @@ -506,6 +789,13 @@ namespace wi::lua::renderer wi::lua::RegisterFunc("DrawSphere", DrawSphere); wi::lua::RegisterFunc("DrawCapsule", DrawCapsule); wi::lua::RegisterFunc("DrawDebugText", DrawDebugText); + wi::lua::RegisterFunc("DrawVoxelGrid", DrawVoxelGrid); + wi::lua::RegisterFunc("DrawPathQuery", DrawPathQuery); + wi::lua::RegisterFunc("DrawTrail", DrawTrail); + + wi::lua::RegisterFunc("PaintIntoTexture", PaintIntoTexture); + wi::lua::RegisterFunc("CreatePaintableTexture", CreatePaintableTexture); + wi::lua::RegisterFunc("PutWaterRipple", PutWaterRipple); wi::lua::RegisterFunc("ClearWorld", ClearWorld); diff --git a/WickedEngine/wiScene.cpp b/WickedEngine/wiScene.cpp index b25f88a115a..087f9827ace 100644 --- a/WickedEngine/wiScene.cpp +++ b/WickedEngine/wiScene.cpp @@ -791,6 +791,21 @@ namespace wi::scene clipmap.extents = extents; } + { + for (size_t voxelgridIndex = 0; voxelgridIndex < voxel_grids.GetCount(); ++voxelgridIndex) + { + wi::VoxelGrid& voxelgrid = voxel_grids[voxelgridIndex]; + Entity entity = voxel_grids.GetEntity(voxelgridIndex); + + const TransformComponent* transform = transforms.GetComponent(entity); + if (transform != nullptr) + { + voxelgrid.center = transform->GetPosition(); + voxelgrid.set_voxelsize(transform->GetScale()); + } + } + } + // Shader scene resources: if (device->CheckCapability(GraphicsDeviceCapability::CACHE_COHERENT_UMA)) { @@ -921,6 +936,17 @@ namespace wi::scene surfelCellBuffer = {}; ddgi = {}; + + aabb_objects.clear(); + aabb_lights.clear(); + aabb_decals.clear(); + aabb_probes.clear(); + + matrix_objects.clear(); + matrix_objects_prev.clear(); + + collider_count_cpu = 0; + collider_count_gpu = 0; } void Scene::Merge(Scene& other) { @@ -935,6 +961,98 @@ namespace wi::scene { ddgi = std::move(other.ddgi); } + + aabb_objects.insert(aabb_objects.end(), other.aabb_objects.begin(), other.aabb_objects.end()); + aabb_lights.insert(aabb_lights.end(), other.aabb_lights.begin(), other.aabb_lights.end()); + aabb_decals.insert(aabb_decals.end(), other.aabb_decals.begin(), other.aabb_decals.end()); + aabb_probes.insert(aabb_probes.end(), other.aabb_probes.begin(), other.aabb_probes.end()); + + matrix_objects.insert(matrix_objects.end(), other.matrix_objects.begin(), other.matrix_objects.end()); + matrix_objects_prev.insert(matrix_objects_prev.end(), other.matrix_objects_prev.begin(), other.matrix_objects_prev.end()); + + // Recount colliders: + collider_allocator_cpu.store(0u); + collider_allocator_gpu.store(0u); + collider_deinterleaved_data.reserve( + sizeof(wi::primitive::AABB) * colliders.GetCount() + + sizeof(ColliderComponent) * colliders.GetCount() + + sizeof(ColliderComponent) * colliders.GetCount() + ); + aabb_colliders_cpu = (wi::primitive::AABB*)collider_deinterleaved_data.data(); + colliders_cpu = (ColliderComponent*)(aabb_colliders_cpu + colliders.GetCount()); + colliders_gpu = colliders_cpu + colliders.GetCount(); + + for (size_t i = 0; i < colliders.GetCount(); ++i) + { + ColliderComponent& collider = colliders[i]; + Entity entity = colliders.GetEntity(i); + const TransformComponent* transform = transforms.GetComponent(entity); + if (transform == nullptr) + return; + + XMFLOAT3 scale = transform->GetScale(); + collider.sphere.radius = collider.radius * std::max(scale.x, std::max(scale.y, scale.z)); + collider.capsule.radius = collider.sphere.radius; + + XMMATRIX W = XMLoadFloat4x4(&transform->world); + XMVECTOR offset = XMLoadFloat3(&collider.offset); + XMVECTOR tail = XMLoadFloat3(&collider.tail); + offset = XMVector3Transform(offset, W); + tail = XMVector3Transform(tail, W); + + XMStoreFloat3(&collider.sphere.center, offset); + XMVECTOR N = XMVector3Normalize(offset - tail); + offset += N * collider.capsule.radius; + tail -= N * collider.capsule.radius; + XMStoreFloat3(&collider.capsule.base, offset); + XMStoreFloat3(&collider.capsule.tip, tail); + + AABB aabb; + + switch (collider.shape) + { + default: + case ColliderComponent::Shape::Sphere: + aabb.createFromHalfWidth(collider.sphere.center, XMFLOAT3(collider.sphere.radius, collider.sphere.radius, collider.sphere.radius)); + break; + case ColliderComponent::Shape::Capsule: + aabb = collider.capsule.getAABB(); + break; + case ColliderComponent::Shape::Plane: + { + collider.plane.origin = collider.sphere.center; + XMVECTOR N = XMVectorSet(0, 1, 0, 0); + N = XMVector3Normalize(XMVector3TransformNormal(N, W)); + XMStoreFloat3(&collider.plane.normal, N); + + aabb.createFromHalfWidth(XMFLOAT3(0, 0, 0), XMFLOAT3(1, 1, 1)); + + XMMATRIX PLANE = XMMatrixScaling(collider.radius, 1, collider.radius); + PLANE = PLANE * XMMatrixTranslationFromVector(XMLoadFloat3(&collider.offset)); + PLANE = PLANE * W; + aabb = aabb.transform(PLANE); + + PLANE = XMMatrixInverse(nullptr, PLANE); + XMStoreFloat4x4(&collider.plane.projection, PLANE); + } + break; + } + + if (collider.IsCPUEnabled()) + { + uint32_t index = collider_allocator_cpu.fetch_add(1u); + colliders_cpu[index] = collider; + aabb_colliders_cpu[index] = aabb; + } + if (collider.IsGPUEnabled()) + { + uint32_t index = collider_allocator_gpu.fetch_add(1u); + colliders_gpu[index] = collider; + } + } + collider_count_cpu = collider_allocator_cpu.load(); + collider_count_gpu = collider_allocator_gpu.load(); + collider_bvh.Build(aabb_colliders_cpu, collider_count_cpu); } void Scene::FindAllEntities(wi::unordered_set& entities) const { @@ -1722,10 +1840,15 @@ namespace wi::scene } else if (channel.path == AnimationComponent::AnimationChannel::Path::WEIGHTS) { - ObjectComponent* object = objects.GetComponent(channel.target); - if (object == nullptr) - continue; - target_mesh = meshes.GetComponent(object->meshID); + target_mesh = meshes.GetComponent(channel.target); + if (target_mesh == nullptr) + { + // Also try going through object's mesh reference: + ObjectComponent* object = objects.GetComponent(channel.target); + if (object == nullptr) + continue; + target_mesh = meshes.GetComponent(object->meshID); + } if (target_mesh == nullptr) continue; animation.morph_weights_temp.resize(target_mesh->morph_targets.size()); @@ -4248,7 +4371,9 @@ namespace wi::scene decal.texture = material.textures[MaterialComponent::BASECOLORMAP].resource; decal.normal = material.textures[MaterialComponent::NORMALMAP].resource; decal.surfacemap = material.textures[MaterialComponent::SURFACEMAP].resource; + decal.displacementmap = material.textures[MaterialComponent::DISPLACEMENTMAP].resource; decal.normal_strength = material.normalMapStrength; + decal.displacement_strength = material.parallaxOcclusionMapping; decal.texMulAdd = material.texMulAdd; } } @@ -4401,6 +4526,11 @@ namespace wi::scene if (!transforms.Contains(entity)) return; + if (hair.IsDirty()) + { + hair.SetDirty(false); + } + const LayerComponent* layer = layers.GetComponent(entity); if (layer != nullptr) { @@ -4753,6 +4883,12 @@ namespace wi::scene { SoundComponent& sound = sounds[i]; + if (!sound.soundinstance.IsValid()) + { + sound.soundinstance.SetLooped(sound.IsLooped()); + wi::audio::CreateSoundInstance(&sound.soundResource.GetSound(), &sound.soundinstance); + } + if (!sound.IsDisable3D()) { Entity entity = sounds.GetEntity(i); @@ -4760,6 +4896,8 @@ namespace wi::scene if (transform != nullptr) { instance3D.emitterPos = transform->GetPosition(); + instance3D.emitterFront = transform->GetForward(); + instance3D.emitterUp = transform->GetUp(); wi::audio::Update3D(&sound.soundinstance, instance3D); } } @@ -4804,6 +4942,8 @@ namespace wi::scene } void Scene::RunScriptUpdateSystem(wi::jobsystem::context& ctx) { + if (dt == 0) + return; // not allowed to be run when dt == 0 as it could be on separate thread! auto range = wi::profiler::BeginRangeCPU("Script Components"); for (size_t i = 0; i < scripts.GetCount(); ++i) { @@ -4911,6 +5051,7 @@ namespace wi::scene result.bary = {}; result.entity = colliders.GetEntity(collider_index); result.normal = direction; + result.uv = {}; result.velocity = {}; XMStoreFloat3(&result.position, rayOrigin + rayDirection * dist); result.subsetIndex = -1; @@ -5011,6 +5152,32 @@ namespace wi::scene nor = XMVector3Normalize(XMVector3TransformNormal(nor, objectMat)); const XMVECTOR vel = pos - XMVector3Transform(pos_local, objectMatPrev); + result.uv = {}; + if (!mesh->vertex_uvset_0.empty()) + { + XMVECTOR uv = XMVectorBaryCentric( + XMLoadFloat2(&mesh->vertex_uvset_0[i0]), + XMLoadFloat2(&mesh->vertex_uvset_0[i1]), + XMLoadFloat2(&mesh->vertex_uvset_0[i2]), + bary.x, + bary.y + ); + result.uv.x = XMVectorGetX(uv); + result.uv.y = XMVectorGetY(uv); + } + if (!mesh->vertex_uvset_1.empty()) + { + XMVECTOR uv = XMVectorBaryCentric( + XMLoadFloat2(&mesh->vertex_uvset_1[i0]), + XMLoadFloat2(&mesh->vertex_uvset_1[i1]), + XMLoadFloat2(&mesh->vertex_uvset_1[i2]), + bary.x, + bary.y + ); + result.uv.z = XMVectorGetX(uv); + result.uv.w = XMVectorGetY(uv); + } + result.entity = entity; XMStoreFloat3(&result.position, pos); XMStoreFloat3(&result.normal, nor); @@ -5068,6 +5235,172 @@ namespace wi::scene return result; } + bool Scene::IntersectsFirst(const wi::primitive::Ray& ray, uint32_t filterMask, uint32_t layerMask, uint32_t lod) const + { + bool result = false; + + const XMVECTOR rayOrigin = XMLoadFloat3(&ray.origin); + const XMVECTOR rayDirection = XMVector3Normalize(XMLoadFloat3(&ray.direction)); + + if ((filterMask & FILTER_COLLIDER) && collider_bvh.IsValid()) + { + collider_bvh.IntersectsFirst(ray, [&](uint32_t collider_index) { + const ColliderComponent& collider = colliders_cpu[collider_index]; + + if ((collider.layerMask & layerMask) == 0) + return false; + + float dist = 0; + XMFLOAT3 direction = {}; + bool intersects = false; + + switch (collider.shape) + { + default: + case ColliderComponent::Shape::Sphere: + intersects = ray.intersects(collider.sphere, dist, direction); + break; + case ColliderComponent::Shape::Capsule: + intersects = ray.intersects(collider.capsule, dist, direction); + break; + case ColliderComponent::Shape::Plane: + intersects = ray.intersects(collider.plane, dist, direction); + break; + } + + if (intersects) + { + result = true; + return true; + } + return false; + }); + if (result) + return result; + } + + if (filterMask & FILTER_OBJECT_ALL) + { + for (size_t objectIndex = 0; objectIndex < aabb_objects.size(); ++objectIndex) + { + const AABB& aabb = aabb_objects[objectIndex]; + if (!ray.intersects(aabb) || (layerMask & aabb.layerMask) == 0) + continue; + + const ObjectComponent& object = objects[objectIndex]; + if (object.meshID == INVALID_ENTITY) + continue; + if ((filterMask & object.GetFilterMask()) == 0) + continue; + + const MeshComponent* mesh = meshes.GetComponent(object.meshID); + if (mesh == nullptr) + continue; + + const Entity entity = objects.GetEntity(objectIndex); + const SoftBodyPhysicsComponent* softbody = softbodies.GetComponent(object.meshID); + const XMMATRIX objectMat = XMLoadFloat4x4(&matrix_objects[objectIndex]); + const XMMATRIX objectMatPrev = XMLoadFloat4x4(&matrix_objects_prev[objectIndex]); + const XMMATRIX objectMat_Inverse = XMMatrixInverse(nullptr, objectMat); + const XMVECTOR rayOrigin_local = XMVector3Transform(rayOrigin, objectMat_Inverse); + const XMVECTOR rayDirection_local = XMVector3Normalize(XMVector3TransformNormal(rayDirection, objectMat_Inverse)); + const ArmatureComponent* armature = mesh->IsSkinned() ? armatures.GetComponent(mesh->armatureID) : nullptr; + + auto intersect_triangle = [&](uint32_t subsetIndex, uint32_t indexOffset, uint32_t triangleIndex) + { + const uint32_t i0 = mesh->indices[indexOffset + triangleIndex * 3 + 0]; + const uint32_t i1 = mesh->indices[indexOffset + triangleIndex * 3 + 1]; + const uint32_t i2 = mesh->indices[indexOffset + triangleIndex * 3 + 2]; + + XMVECTOR p0; + XMVECTOR p1; + XMVECTOR p2; + + const bool softbody_active = softbody != nullptr && softbody->HasVertices(); + if (softbody_active) + { + p0 = softbody->vertex_positions_simulation[i0].LoadPOS(); + p1 = softbody->vertex_positions_simulation[i1].LoadPOS(); + p2 = softbody->vertex_positions_simulation[i2].LoadPOS(); + } + else + { + if (armature == nullptr || armature->boneData.empty()) + { + p0 = XMLoadFloat3(&mesh->vertex_positions[i0]); + p1 = XMLoadFloat3(&mesh->vertex_positions[i1]); + p2 = XMLoadFloat3(&mesh->vertex_positions[i2]); + } + else + { + p0 = SkinVertex(*mesh, *armature, i0); + p1 = SkinVertex(*mesh, *armature, i1); + p2 = SkinVertex(*mesh, *armature, i2); + } + } + + float distance; + XMFLOAT2 bary; + if (wi::math::RayTriangleIntersects(rayOrigin_local, rayDirection_local, p0, p1, p2, distance, bary)) + { + const XMVECTOR pos_local = XMVectorAdd(rayOrigin_local, rayDirection_local * distance); + const XMVECTOR pos = XMVector3Transform(pos_local, objectMat); + distance = wi::math::Distance(pos, rayOrigin); + + // Note: we do the TMin, Tmax check here, in world space! We use the RayTriangleIntersects in local space, so we don't use those in there + if (distance >= ray.TMin && distance <= ray.TMax) + { + result = true; + return true; + } + } + return false; + }; + + if (mesh->bvh.IsValid()) + { + Ray ray_local = Ray(rayOrigin_local, rayDirection_local); + + mesh->bvh.IntersectsFirst(ray_local, [&](uint32_t index) { + const uint32_t userdata = mesh->bvh_leaf_aabbs[index].userdata; + const uint32_t triangleIndex = userdata & 0xFFFFFF; + const uint32_t subsetIndex = userdata >> 24u; + const MeshComponent::MeshSubset& subset = mesh->subsets[subsetIndex]; + if (subset.indexCount == 0) + return false; + const uint32_t indexOffset = subset.indexOffset; + return intersect_triangle(subsetIndex, indexOffset, triangleIndex); + }); + } + else + { + // Brute-force intersection test: + uint32_t first_subset = 0; + uint32_t last_subset = 0; + mesh->GetLODSubsetRange(lod, first_subset, last_subset); + for (uint32_t subsetIndex = first_subset; subsetIndex < last_subset; ++subsetIndex) + { + const MeshComponent::MeshSubset& subset = mesh->subsets[subsetIndex]; + if (subset.indexCount == 0) + continue; + const uint32_t indexOffset = subset.indexOffset; + const uint32_t triangleCount = subset.indexCount / 3; + + for (uint32_t triangleIndex = 0; triangleIndex < triangleCount; ++triangleIndex) + { + if (intersect_triangle(subsetIndex, indexOffset, triangleIndex)) + { + result = true; + return true; + } + } + } + } + + } + } + return result; + } Scene::SphereIntersectionResult Scene::Intersects(const Sphere& sphere, uint32_t filterMask, uint32_t layerMask, uint32_t lod) const { SphereIntersectionResult result; @@ -5740,6 +6073,195 @@ namespace wi::scene return result; } + void Scene::VoxelizeObject(size_t objectIndex, wi::VoxelGrid& grid, bool subtract, uint32_t lod) + { + if (objectIndex >= objects.GetCount() || objectIndex >= aabb_objects.size()) + return; + if (aabb_objects[objectIndex].intersects(grid.get_aabb()) == wi::primitive::AABB::OUTSIDE) + return; + const ObjectComponent& object = objects[objectIndex]; + const MeshComponent* mesh = meshes.GetComponent(object.meshID); + if (mesh == nullptr) + return; + const SoftBodyPhysicsComponent* softbody = softbodies.GetComponent(object.meshID); + const XMMATRIX objectMat = XMLoadFloat4x4(&matrix_objects[objectIndex]); + const ArmatureComponent* armature = mesh->IsSkinned() ? armatures.GetComponent(mesh->armatureID) : nullptr; + + uint32_t first_subset = 0; + uint32_t last_subset = 0; + mesh->GetLODSubsetRange(lod, first_subset, last_subset); + for (uint32_t subsetIndex = first_subset; subsetIndex < last_subset; ++subsetIndex) + { + const MeshComponent::MeshSubset& subset = mesh->subsets[subsetIndex]; + if (subset.indexCount == 0) + continue; + const uint32_t indexOffset = subset.indexOffset; + const uint32_t triangleCount = subset.indexCount / 3; + + for (uint32_t triangleIndex = 0; triangleIndex < triangleCount; ++triangleIndex) + { + const uint32_t i0 = mesh->indices[indexOffset + triangleIndex * 3 + 0]; + const uint32_t i1 = mesh->indices[indexOffset + triangleIndex * 3 + 1]; + const uint32_t i2 = mesh->indices[indexOffset + triangleIndex * 3 + 2]; + + XMVECTOR p0; + XMVECTOR p1; + XMVECTOR p2; + + const bool softbody_active = softbody != nullptr && softbody->HasVertices(); + if (softbody_active) + { + p0 = softbody->vertex_positions_simulation[i0].LoadPOS(); + p1 = softbody->vertex_positions_simulation[i1].LoadPOS(); + p2 = softbody->vertex_positions_simulation[i2].LoadPOS(); + } + else + { + if (armature == nullptr || armature->boneData.empty()) + { + p0 = XMLoadFloat3(&mesh->vertex_positions[i0]); + p1 = XMLoadFloat3(&mesh->vertex_positions[i1]); + p2 = XMLoadFloat3(&mesh->vertex_positions[i2]); + } + else + { + p0 = SkinVertex(*mesh, *armature, i0); + p1 = SkinVertex(*mesh, *armature, i1); + p2 = SkinVertex(*mesh, *armature, i2); + } + + p0 = XMVector3Transform(p0, objectMat); + p1 = XMVector3Transform(p1, objectMat); + p2 = XMVector3Transform(p2, objectMat); + } + + grid.inject_triangle(p0, p1, p2, subtract); + } + } + } + + void Scene::VoxelizeScene(wi::VoxelGrid& voxelgrid, bool subtract, uint32_t filterMask, uint32_t layerMask, uint32_t lod) + { + wi::jobsystem::context ctx; + if ((filterMask & FILTER_COLLIDER)) + { + for (size_t i = 0; i < collider_count_cpu; ++i) + { + const ColliderComponent& collider = colliders_cpu[i]; + + if ((collider.layerMask & layerMask) == 0) + continue; + + switch (collider.shape) + { + default: + case ColliderComponent::Shape::Sphere: + { + Sphere sphere = collider.sphere; + // TODO: fix heap allocating lambda capture! + wi::jobsystem::Execute(ctx, [&voxelgrid, subtract, sphere](wi::jobsystem::JobArgs args) { + voxelgrid.inject_sphere(sphere, subtract); + }); + } + break; + case ColliderComponent::Shape::Capsule: + { + Capsule capsule = collider.capsule; + // TODO: fix heap allocating lambda capture! + wi::jobsystem::Execute(ctx, [&voxelgrid, subtract, capsule](wi::jobsystem::JobArgs args) { + voxelgrid.inject_capsule(capsule, subtract); + }); + } + break; + case ColliderComponent::Shape::Plane: + { + XMMATRIX planeMatrix = XMMatrixInverse(nullptr, XMLoadFloat4x4(&collider.plane.projection)); + XMVECTOR P0 = XMVector3Transform(XMVectorSet(-1, 0, -1, 1), planeMatrix); + XMVECTOR P1 = XMVector3Transform(XMVectorSet(1, 0, -1, 1), planeMatrix); + XMVECTOR P2 = XMVector3Transform(XMVectorSet(1, 0, 1, 1), planeMatrix); + XMVECTOR P3 = XMVector3Transform(XMVectorSet(-1, 0, 1, 1), planeMatrix); + // TODO: fix heap allocating lambda capture! + wi::jobsystem::Execute(ctx, [&voxelgrid, subtract, P0, P1, P2, P3](wi::jobsystem::JobArgs args) { + voxelgrid.inject_triangle(P0, P1, P2, subtract); + voxelgrid.inject_triangle(P0, P2, P3, subtract); + }); + } + break; + } + } + } + if (filterMask & FILTER_OBJECT_ALL) + { + for (size_t i = 0; i < objects.GetCount(); ++i) + { + const ObjectComponent& object = objects[i]; + if ((filterMask & object.GetFilterMask()) == 0) + continue; + const AABB& aabb = aabb_objects[i]; + if ((layerMask & aabb.layerMask) == 0) + continue; + // TODO: fix heap allocating lambda capture! + wi::jobsystem::Execute(ctx, [this, &voxelgrid, subtract, lod, i](wi::jobsystem::JobArgs args) { + VoxelizeObject(i, voxelgrid, subtract, lod); + }); + } + } + wi::jobsystem::Wait(ctx); + } + + XMFLOAT3 Scene::GetPositionOnSurface(wi::ecs::Entity objectEntity, int vertexID0, int vertexID1, int vertexID2, const XMFLOAT2& bary) const + { + const ObjectComponent* object = objects.GetComponent(objectEntity); + if (object == nullptr || object->meshID == INVALID_ENTITY) + return XMFLOAT3(0, 0, 0); + const MeshComponent* mesh = meshes.GetComponent(object->meshID); + if (mesh == nullptr) + return XMFLOAT3(0, 0, 0); + + const SoftBodyPhysicsComponent* softbody = softbodies.GetComponent(object->meshID); + const ArmatureComponent* armature = mesh->IsSkinned() ? armatures.GetComponent(mesh->armatureID) : nullptr; + + XMVECTOR p0; + XMVECTOR p1; + XMVECTOR p2; + + const bool softbody_active = softbody != nullptr && softbody->HasVertices(); + if (softbody_active) + { + p0 = softbody->vertex_positions_simulation[vertexID0].LoadPOS(); + p1 = softbody->vertex_positions_simulation[vertexID1].LoadPOS(); + p2 = softbody->vertex_positions_simulation[vertexID2].LoadPOS(); + } + else + { + if (armature == nullptr || armature->boneData.empty()) + { + p0 = XMLoadFloat3(&mesh->vertex_positions[vertexID0]); + p1 = XMLoadFloat3(&mesh->vertex_positions[vertexID1]); + p2 = XMLoadFloat3(&mesh->vertex_positions[vertexID2]); + } + else + { + p0 = SkinVertex(*mesh, *armature, vertexID0); + p1 = SkinVertex(*mesh, *armature, vertexID1); + p2 = SkinVertex(*mesh, *armature, vertexID2); + } + } + + XMVECTOR P = XMVectorBaryCentric(p0, p1, p2, bary.x, bary.y); + + if (!softbody_active) + { + const size_t objectIndex = objects.GetIndex(objectEntity); + const XMMATRIX objectMat = XMLoadFloat4x4(&matrix_objects[objectIndex]); + P = XMVector3Transform(P, objectMat); + } + + XMFLOAT3 result; + XMStoreFloat3(&result, P); + return result; + } + void Scene::PutWaterRipple(const std::string& image, const XMFLOAT3& pos) { @@ -5816,58 +6338,79 @@ namespace wi::scene Entity LoadModel(const std::string& fileName, const XMMATRIX& transformMatrix, bool attached) + { + Entity rootEntity = INVALID_ENTITY; + if (attached) + { + rootEntity = CreateEntity(); + } + LoadModel2(fileName, transformMatrix, rootEntity); + return rootEntity; + } + + Entity LoadModel(Scene& scene, const std::string& fileName, const XMMATRIX& transformMatrix, bool attached) + { + Entity rootEntity = INVALID_ENTITY; + if (attached) + { + rootEntity = CreateEntity(); + } + LoadModel2(scene, fileName, transformMatrix, rootEntity); + return rootEntity; + } + + void LoadModel2(const std::string& fileName, const XMMATRIX& transformMatrix, Entity rootEntity) { Scene scene; - Entity root = LoadModel(scene, fileName, transformMatrix, attached); + LoadModel(scene, fileName, transformMatrix, rootEntity); GetScene().Merge(scene); - return root; } - Entity LoadModel(Scene& scene, const std::string& fileName, const XMMATRIX& transformMatrix, bool attached) + void LoadModel2(Scene& scene, const std::string& fileName, const XMMATRIX& transformMatrix, Entity rootEntity) { wi::Archive archive(fileName, true); - if (archive.IsOpen()) + if (!archive.IsOpen()) + return; + + // Serialize it from file: + scene.Serialize(archive); + + // First, create new root: + bool attached = true; + if (rootEntity == INVALID_ENTITY) { - // Serialize it from file: - scene.Serialize(archive); + rootEntity = CreateEntity(); + attached = false; + } + scene.transforms.Create(rootEntity); + scene.layers.Create(rootEntity).layerMask = ~0; - // First, create new root: - Entity root = CreateEntity(); - scene.transforms.Create(root); - scene.layers.Create(root).layerMask = ~0; + { + // Apply the optional transformation matrix to the new scene: + // Parent all unparented transforms to new root entity + for (size_t i = 0; i < scene.transforms.GetCount(); ++i) { - // Apply the optional transformation matrix to the new scene: - - // Parent all unparented transforms to new root entity - for (size_t i = 0; i < scene.transforms.GetCount() - 1; ++i) // GetCount() - 1 because the last added was the "root" + Entity entity = scene.transforms.GetEntity(i); + if (entity != rootEntity && !scene.hierarchy.Contains(entity)) { - Entity entity = scene.transforms.GetEntity(i); - if (!scene.hierarchy.Contains(entity)) - { - scene.Component_Attach(entity, root); - } + scene.Component_Attach(entity, rootEntity); } - - // The root component is transformed, scene is updated: - TransformComponent* root_transform = scene.transforms.GetComponent(root); - root_transform->MatrixTransform(transformMatrix); - - scene.Update(0); } - if (!attached) - { - // In this case, we don't care about the root anymore, so delete it. This will simplify overall hierarchy - scene.Component_DetachChildren(root); - scene.Entity_Remove(root); - root = INVALID_ENTITY; - } + // The root component is transformed, scene is updated: + TransformComponent* root_transform = scene.transforms.GetComponent(rootEntity); + root_transform->MatrixTransform(transformMatrix); - return root; + scene.Update(0); } - return INVALID_ENTITY; + if (!attached) + { + // In this case, we don't care about the root anymore, so delete it. This will simplify overall hierarchy + scene.Component_DetachChildren(rootEntity); + scene.Entity_Remove(rootEntity); + } } PickResult Pick(const wi::primitive::Ray& ray, uint32_t filterMask, uint32_t layerMask, const Scene& scene, uint32_t lod) diff --git a/WickedEngine/wiScene.h b/WickedEngine/wiScene.h index 3d1c11121c9..dd7ab6ade53 100644 --- a/WickedEngine/wiScene.h +++ b/WickedEngine/wiScene.h @@ -13,6 +13,8 @@ #include "wiTerrain.h" #include "wiBVH.h" #include "wiUnorderedSet.h" +#include "wiVoxelGrid.h" +#include "wiPathQuery.h" #include #include @@ -54,10 +56,11 @@ namespace wi::scene wi::ecs::ComponentManager& colliders = componentLibrary.Register("wi::scene::Scene::colliders", 2); // version = 2 wi::ecs::ComponentManager& scripts = componentLibrary.Register("wi::scene::Scene::scripts"); wi::ecs::ComponentManager& expressions = componentLibrary.Register("wi::scene::Scene::expressions"); - wi::ecs::ComponentManager& humanoids = componentLibrary.Register("wi::scene::Scene::humanoids"); - wi::ecs::ComponentManager& terrains = componentLibrary.Register("wi::scene::Scene::terrains", 3); // version = 3 + wi::ecs::ComponentManager& humanoids = componentLibrary.Register("wi::scene::Scene::humanoids", 1); // version = 1 + wi::ecs::ComponentManager& terrains = componentLibrary.Register("wi::scene::Scene::terrains", 4); // version = 4 wi::ecs::ComponentManager& sprites = componentLibrary.Register("wi::scene::Scene::sprites"); wi::ecs::ComponentManager& fonts = componentLibrary.Register("wi::scene::Scene::fonts"); + wi::ecs::ComponentManager& voxel_grids = componentLibrary.Register("wi::scene::Scene::voxel_grids"); // Non-serialized attributes: float dt = 0; @@ -432,6 +435,7 @@ namespace wi::scene wi::ecs::Entity entity = wi::ecs::INVALID_ENTITY; XMFLOAT3 position = XMFLOAT3(0, 0, 0); XMFLOAT3 normal = XMFLOAT3(0, 0, 0); + XMFLOAT4 uv = XMFLOAT4(0, 0, 0, 0); XMFLOAT3 velocity = XMFLOAT3(0, 0, 0); float distance = std::numeric_limits::max(); int subsetIndex = -1; @@ -446,12 +450,21 @@ namespace wi::scene return entity == other.entity; } }; - // Given a ray, finds the closest intersection point against all mesh instances + // Given a ray, finds the closest intersection point against all mesh instances or collliders // ray : the incoming ray that will be traced - // renderTypeMask : filter based on render type + // filterMask : filter based on type // layerMask : filter based on layer + // lod : specify min level of detail for meshes RayIntersectionResult Intersects(const wi::primitive::Ray& ray, uint32_t filterMask = wi::enums::FILTER_OPAQUE, uint32_t layerMask = ~0, uint32_t lod = 0) const; + // Given a ray, finds the first intersection point against all mesh instances or colliders + // returns true immediately if intersection was found, false otherwise + // ray : the incoming ray that will be traced + // filterMask : filter based on type + // layerMask : filter based on layer + // lod : specify min level of detail for meshes + bool IntersectsFirst(const wi::primitive::Ray& ray, uint32_t filterMask = wi::enums::FILTER_OPAQUE, uint32_t layerMask = ~0, uint32_t lod = 0) const; + struct SphereIntersectionResult { wi::ecs::Entity entity = wi::ecs::INVALID_ENTITY; @@ -484,6 +497,16 @@ namespace wi::scene // If you don't know which armature the bone is contained int, this function can be used to find the first such armature and return the bone's rest matrix // If not found, return identity matrix XMMATRIX FindBoneRestPose(wi::ecs::Entity bone) const; + + // All triangles of the object will be injected into the voxel grid + // subtract: if false (default), voxels will be added, if true then voxels will be removed + void VoxelizeObject(size_t objectIndex, wi::VoxelGrid& grid, bool subtract = false, uint32_t lod = 0); + + // Voxelize all meshes that match the filters into a voxel grid + void VoxelizeScene(wi::VoxelGrid& voxelgrid, bool subtract = false, uint32_t filterMask = wi::enums::FILTER_ALL, uint32_t layerMask = ~0, uint32_t lod = 0); + + // Get the current position on the surface of an object, tracked by the triangle barycentrics + XMFLOAT3 GetPositionOnSurface(wi::ecs::Entity objectEntity, int vertexID0, int vertexID1, int vertexID2, const XMFLOAT2& bary) const; }; // Returns skinned vertex position in armature local space @@ -524,6 +547,19 @@ namespace wi::scene // returns INVALID_ENTITY if attached argument was false, else it returns the base entity handle wi::ecs::Entity LoadModel(Scene& scene, const std::string& fileName, const XMMATRIX& transformMatrix = XMMatrixIdentity(), bool attached = false); + // Helper function to open a wiscene file and add the contents to the global scene + // fileName : file path + // transformMatrix : everything will be transformed by this matrix (optional) + // rootEntity : specify entity to attach whole scene to (optional) + void LoadModel2(const std::string& fileName, const XMMATRIX& transformMatrix = XMMatrixIdentity(), wi::ecs::Entity rootEntity = wi::ecs::INVALID_ENTITY); + + // Helper function to open a wiscene file and add the contents to the specified scene. This is thread safe as it doesn't modify global scene + // scene : the scene that will contain the model + // fileName : file path + // transformMatrix : everything will be transformed by this matrix (optional) + // rootEntity : specify entity to attach whole scene to (optional) + void LoadModel2(Scene& scene, const std::string& fileName, const XMMATRIX& transformMatrix = XMMatrixIdentity(), wi::ecs::Entity rootEntity = wi::ecs::INVALID_ENTITY); + // Deprecated, use Scene::Intersects() function instead using PickResult = Scene::RayIntersectionResult; PickResult Pick(const wi::primitive::Ray& ray, uint32_t filterMask = wi::enums::FILTER_OPAQUE, uint32_t layerMask = ~0, const Scene& scene = GetScene(), uint32_t lod = 0); diff --git a/WickedEngine/wiScene_BindLua.cpp b/WickedEngine/wiScene_BindLua.cpp index 75a539f940d..30b778990c1 100644 --- a/WickedEngine/wiScene_BindLua.cpp +++ b/WickedEngine/wiScene_BindLua.cpp @@ -10,6 +10,8 @@ #include "wiECS.h" #include "wiLua.h" #include "wiUnorderedMap.h" +#include "wiVoxelGrid_BindLua.h" +#include "wiAudio_BindLua.h" #include @@ -513,6 +515,7 @@ Luna::FunctionType Scene_BindLua::methods[] = { lunamethod(Scene_BindLua, Merge), lunamethod(Scene_BindLua, UpdateHierarchy), lunamethod(Scene_BindLua, Intersects), + lunamethod(Scene_BindLua, IntersectsFirst), lunamethod(Scene_BindLua, FindAllEntities), lunamethod(Scene_BindLua, Entity_FindByName), lunamethod(Scene_BindLua, Entity_Remove), @@ -521,6 +524,7 @@ Luna::FunctionType Scene_BindLua::methods[] = { lunamethod(Scene_BindLua, Component_CreateName), lunamethod(Scene_BindLua, Component_CreateLayer), lunamethod(Scene_BindLua, Component_CreateTransform), + lunamethod(Scene_BindLua, Component_CreateCamera), lunamethod(Scene_BindLua, Component_CreateEmitter), lunamethod(Scene_BindLua, Component_CreateHairParticleSystem), lunamethod(Scene_BindLua, Component_CreateLight), @@ -540,6 +544,7 @@ Luna::FunctionType Scene_BindLua::methods[] = { lunamethod(Scene_BindLua, Component_CreateDecal), lunamethod(Scene_BindLua, Component_CreateSprite), lunamethod(Scene_BindLua, Component_CreateFont), + lunamethod(Scene_BindLua, Component_CreateVoxelGrid), lunamethod(Scene_BindLua, Component_GetName), lunamethod(Scene_BindLua, Component_GetLayer), @@ -566,6 +571,7 @@ Luna::FunctionType Scene_BindLua::methods[] = { lunamethod(Scene_BindLua, Component_GetDecal), lunamethod(Scene_BindLua, Component_GetSprite), lunamethod(Scene_BindLua, Component_GetFont), + lunamethod(Scene_BindLua, Component_GetVoxelGrid), lunamethod(Scene_BindLua, Component_GetNameArray), lunamethod(Scene_BindLua, Component_GetLayerArray), @@ -592,6 +598,7 @@ Luna::FunctionType Scene_BindLua::methods[] = { lunamethod(Scene_BindLua, Component_GetDecalArray), lunamethod(Scene_BindLua, Component_GetSpriteArray), lunamethod(Scene_BindLua, Component_GetFontArray), + lunamethod(Scene_BindLua, Component_GetVoxelGridArray), lunamethod(Scene_BindLua, Entity_GetNameArray), lunamethod(Scene_BindLua, Entity_GetLayerArray), @@ -618,7 +625,7 @@ Luna::FunctionType Scene_BindLua::methods[] = { lunamethod(Scene_BindLua, Entity_GetHumanoidArray), lunamethod(Scene_BindLua, Entity_GetDecalArray), lunamethod(Scene_BindLua, Entity_GetSpriteArray), - lunamethod(Scene_BindLua, Entity_GetFontArray), + lunamethod(Scene_BindLua, Entity_GetVoxelGridArray), lunamethod(Scene_BindLua, Component_RemoveName), lunamethod(Scene_BindLua, Component_RemoveLayer), @@ -646,6 +653,7 @@ Luna::FunctionType Scene_BindLua::methods[] = { lunamethod(Scene_BindLua, Component_RemoveDecal), lunamethod(Scene_BindLua, Component_RemoveSprite), lunamethod(Scene_BindLua, Component_RemoveFont), + lunamethod(Scene_BindLua, Component_RemoveVoxelGrid), lunamethod(Scene_BindLua, Component_Attach), lunamethod(Scene_BindLua, Component_Detach), @@ -655,6 +663,8 @@ Luna::FunctionType Scene_BindLua::methods[] = { lunamethod(Scene_BindLua, GetWeather), lunamethod(Scene_BindLua, SetWeather), lunamethod(Scene_BindLua, RetargetAnimation), + lunamethod(Scene_BindLua, VoxelizeObject), + lunamethod(Scene_BindLua, VoxelizeScene), { NULL, NULL } }; Luna::PropertyType Scene_BindLua::properties[] = { @@ -849,7 +859,8 @@ int Scene_BindLua::Intersects(lua_State* L) Luna::push(L, result.velocity); wi::lua::SSetInt(L, result.subsetIndex); Luna::push(L, result.orientation); - return 7; + Luna::push(L, result.uv); + return 8; } Sphere_BindLua* sphere = Luna::lightcheck(L, 1); @@ -888,6 +899,43 @@ int Scene_BindLua::Intersects(lua_State* L) } return 0; } +int Scene_BindLua::IntersectsFirst(lua_State* L) +{ + int argc = wi::lua::SGetArgCount(L); + if (argc > 0) + { + uint32_t filterMask = wi::enums::FILTER_ALL; + uint32_t layerMask = ~0u; + uint lod = 0; + if (argc > 1) + { + filterMask = (uint32_t)wi::lua::SGetInt(L, 2); + if (argc > 2) + { + layerMask = (uint32_t)wi::lua::SGetInt(L, 3); + if (argc > 3) + { + lod = (uint32_t)wi::lua::SGetInt(L, 4); + } + } + } + + Ray_BindLua* ray = Luna::lightcheck(L, 1); + if (ray != nullptr) + { + bool result = scene->IntersectsFirst(ray->ray, filterMask, layerMask, lod); + wi::lua::SSetBool(L, result); + return 1; + } + + wi::lua::SError(L, "Scene::IntersectsFirst(Ray primitive, opt uint filterMask = ~0u, opt uint layerMask = ~0u, opt uint lod = 0) first argument is not a Ray!"); + } + else + { + wi::lua::SError(L, "Scene::IntersectsFirst(Ray primitive, opt uint filterMask = ~0u, opt uint layerMask = ~0u, opt uint lod = 0) not enough arguments!"); + } + return 0; +} int Scene_BindLua::Component_CreateName(lua_State* L) { @@ -940,6 +988,23 @@ int Scene_BindLua::Component_CreateTransform(lua_State* L) } return 0; } +int Scene_BindLua::Component_CreateCamera(lua_State* L) +{ + int argc = wi::lua::SGetArgCount(L); + if (argc > 0) + { + Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); + + CameraComponent& component = scene->cameras.Create(entity); + Luna::push(L, &component); + return 1; + } + else + { + wi::lua::SError(L, "Scene::Component_CreateCamera(Entity entity) not enough arguments!"); + } + return 0; +} int Scene_BindLua::Component_CreateLight(lua_State* L) { int argc = wi::lua::SGetArgCount(L); @@ -1263,6 +1328,23 @@ int Scene_BindLua::Component_CreateFont(lua_State* L) } return 0; } +int Scene_BindLua::Component_CreateVoxelGrid(lua_State* L) +{ + int argc = wi::lua::SGetArgCount(L); + if (argc > 0) + { + Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); + + wi::VoxelGrid& component = scene->voxel_grids.Create(entity); + Luna::push(L, component); + return 1; + } + else + { + wi::lua::SError(L, "Scene::Component_CreateVoxelGrid(Entity entity) not enough arguments!"); + } + return 0; +} int Scene_BindLua::Component_GetName(lua_State* L) { @@ -1814,6 +1896,28 @@ int Scene_BindLua::Component_GetFont(lua_State* L) } return 0; } +int Scene_BindLua::Component_GetVoxelGrid(lua_State* L) +{ + int argc = wi::lua::SGetArgCount(L); + if (argc > 0) + { + Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); + + wi::VoxelGrid* component = scene->voxel_grids.GetComponent(entity); + if (component == nullptr) + { + return 0; + } + + Luna::push(L, *component); + return 1; + } + else + { + wi::lua::SError(L, "Scene::Component_GetVoxelGrid(Entity entity) not enough arguments!"); + } + return 0; +} int Scene_BindLua::Component_GetNameArray(lua_State* L) { @@ -2090,6 +2194,17 @@ int Scene_BindLua::Component_GetFontArray(lua_State* L) } return 1; } +int Scene_BindLua::Component_GetVoxelGridArray(lua_State* L) +{ + lua_createtable(L, (int)scene->voxel_grids.GetCount(), 0); + int newTable = lua_gettop(L); + for (size_t i = 0; i < scene->voxel_grids.GetCount(); ++i) + { + Luna::push(L, scene->voxel_grids[i]); + lua_rawseti(L, newTable, lua_Integer(i + 1)); + } + return 1; +} int Scene_BindLua::Entity_GetNameArray(lua_State* L) { @@ -2377,6 +2492,17 @@ int Scene_BindLua::Entity_GetFontArray(lua_State* L) } return 1; } +int Scene_BindLua::Entity_GetVoxelGridArray(lua_State* L) +{ + lua_createtable(L, (int)scene->voxel_grids.GetCount(), 0); + int newTable = lua_gettop(L); + for (size_t i = 0; i < scene->voxel_grids.GetCount(); ++i) + { + wi::lua::SSetLongLong(L, scene->voxel_grids.GetEntity(i)); + lua_rawseti(L, newTable, lua_Integer(i + 1)); + } + return 1; +} int Scene_BindLua::Component_RemoveName(lua_State* L) { @@ -2820,6 +2946,23 @@ int Scene_BindLua::Component_RemoveFont(lua_State* L) } return 0; } +int Scene_BindLua::Component_RemoveVoxelGrid(lua_State* L) +{ + int argc = wi::lua::SGetArgCount(L); + if (argc > 0) + { + Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); + if (scene->voxel_grids.Contains(entity)) + { + scene->voxel_grids.Remove(entity); + } + } + else + { + wi::lua::SError(L, "Scene::Component_RemoveVoxelGrid(Entity entity) not enough arguments!"); + } + return 0; +} int Scene_BindLua::Component_Attach(lua_State* L) { @@ -2940,6 +3083,71 @@ int Scene_BindLua::RetargetAnimation(lua_State* L) return 0; } +int Scene_BindLua::VoxelizeObject(lua_State* L) +{ + int argc = wi::lua::SGetArgCount(L); + if (argc < 2) + { + wi::lua::SError(L, "VoxelizeObject(int objectIndex, VoxelGrid voxelgrid, opt bool subtract = false, opt int lod = 0) not enough arguments!"); + return 0; + } + size_t objectIndex = (size_t)wi::lua::SGetInt(L, 1); + VoxelGrid_BindLua* voxelgrid = Luna::lightcheck(L, 2); + if (voxelgrid == nullptr) + { + wi::lua::SError(L, "VoxelizeObject(int objectIndex, VoxelGrid voxelgrid, opt bool subtract = false, opt int lod = 0) second argument is not a VoxelGrid!"); + return 0; + } + bool subtract = false; + uint32_t lod = 0; + if (argc > 2) + { + subtract = wi::lua::SGetBool(L, 3); + if (argc > 3) + { + lod = (uint32_t)wi::lua::SGetInt(L, 4); + } + } + scene->VoxelizeObject(objectIndex, *voxelgrid->voxelgrid, subtract, lod); + return 0; +} +int Scene_BindLua::VoxelizeScene(lua_State* L) +{ + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "VoxelizeScene(VoxelGrid voxelgrid, opt bool subtract = false, opt uint filterMask = ~0u, opt uint layerMask = ~0u, opt uint lod = 0) not enough arguments!"); + return 0; + } + VoxelGrid_BindLua* voxelgrid = Luna::lightcheck(L, 1); + if (voxelgrid == nullptr) + { + wi::lua::SError(L, "VoxelizeScene(VoxelGrid voxelgrid, opt bool subtract = false, opt uint filterMask = ~0u, opt uint layerMask = ~0u, opt uint lod = 0) first argument is not a VoxelGrid!"); + return 0; + } + bool subtract = false; + uint32_t filterMask = wi::enums::FILTER_ALL; + uint32_t layerMask = ~0u; + uint32_t lod = 0; + if (argc > 1) + { + subtract = wi::lua::SGetBool(L, 2); + if (argc > 2) + { + filterMask = (uint32_t)wi::lua::SGetInt(L, 3); + if (argc > 3) + { + layerMask = (uint32_t)wi::lua::SGetInt(L, 4); + if (argc > 4) + { + lod = (uint32_t)wi::lua::SGetInt(L, 5); + } + } + } + } + scene->VoxelizeScene(*voxelgrid->voxelgrid, subtract, filterMask, layerMask, lod); + return 0; +} @@ -3027,6 +3235,9 @@ Luna::FunctionType TransformComponent_BindLua::metho lunamethod(TransformComponent_BindLua, GetPosition), lunamethod(TransformComponent_BindLua, GetRotation), lunamethod(TransformComponent_BindLua, GetScale), + lunamethod(TransformComponent_BindLua, GetForward), + lunamethod(TransformComponent_BindLua, GetUp), + lunamethod(TransformComponent_BindLua, GetRight), lunamethod(TransformComponent_BindLua, IsDirty), lunamethod(TransformComponent_BindLua, SetDirty), lunamethod(TransformComponent_BindLua, SetScale), @@ -3257,20 +3468,32 @@ int TransformComponent_BindLua::UpdateTransform(lua_State* L) } int TransformComponent_BindLua::GetPosition(lua_State* L) { - XMVECTOR V = component->GetPositionV(); - Luna::push(L, V); + Luna::push(L, component->GetPosition()); return 1; } int TransformComponent_BindLua::GetRotation(lua_State* L) { - XMVECTOR V = component->GetRotationV(); - Luna::push(L, V); + Luna::push(L, component->GetRotation()); return 1; } int TransformComponent_BindLua::GetScale(lua_State* L) { - XMVECTOR V = component->GetScaleV(); - Luna::push(L, V); + Luna::push(L, component->GetScale()); + return 1; +} +int TransformComponent_BindLua::GetForward(lua_State* L) +{ + Luna::push(L, component->GetForward()); + return 1; +} +int TransformComponent_BindLua::GetUp(lua_State* L) +{ + Luna::push(L, component->GetUp()); + return 1; +} +int TransformComponent_BindLua::GetRight(lua_State* L) +{ + Luna::push(L, component->GetRight()); return 1; } int TransformComponent_BindLua::IsDirty(lua_State *L) @@ -3867,6 +4090,8 @@ Luna::FunctionType MaterialComponent_BindLua::methods lunamethod(MaterialComponent_BindLua, GetStencilRef), lunamethod(MaterialComponent_BindLua, SetTexMulAdd), lunamethod(MaterialComponent_BindLua, GetTexMulAdd), + lunamethod(MaterialComponent_BindLua, SetCastShadow), + lunamethod(MaterialComponent_BindLua, IsCastingShadow), lunamethod(MaterialComponent_BindLua, SetTexture), lunamethod(MaterialComponent_BindLua, SetTextureUVSet), @@ -4144,6 +4369,22 @@ int MaterialComponent_BindLua::GetTextureUVSet(lua_State* L) } return 0; } +int MaterialComponent_BindLua::SetCastShadow(lua_State* L) +{ + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "SetCastShadow(bool value): not enough arguments!"); + return 0; + } + component->SetCastShadow(wi::lua::SGetBool(L, 1)); + return 0; +} +int MaterialComponent_BindLua::IsCastingShadow(lua_State* L) +{ + wi::lua::SSetBool(L, component->IsCastingShadow()); + return 1; +} @@ -4157,6 +4398,7 @@ int MaterialComponent_BindLua::GetTextureUVSet(lua_State* L) Luna::FunctionType MeshComponent_BindLua::methods[] = { lunamethod(MeshComponent_BindLua, SetMeshSubsetMaterialID), lunamethod(MeshComponent_BindLua, GetMeshSubsetMaterialID), + lunamethod(MeshComponent_BindLua, CreateSubset), { NULL, NULL } }; Luna::PropertyType MeshComponent_BindLua::properties[] = { @@ -4216,6 +4458,15 @@ int MeshComponent_BindLua::GetMeshSubsetMaterialID(lua_State* L) } return 0; } +int MeshComponent_BindLua::CreateSubset(lua_State* L) +{ + int index = (int)component->subsets.size(); + auto& subset = component->subsets.emplace_back(); + subset.indexOffset = 0; + subset.indexCount = (uint32_t)component->indices.size(); + wi::lua::SSetInt(L, index); + return 1; +} @@ -4238,6 +4489,8 @@ Luna::FunctionType EmitterComponent_BindLua::methods[] lunamethod(EmitterComponent_BindLua, SetScaleY), lunamethod(EmitterComponent_BindLua, SetRotation), lunamethod(EmitterComponent_BindLua, SetMotionBlurAmount), + lunamethod(EmitterComponent_BindLua, IsCollidersDisabled), + lunamethod(EmitterComponent_BindLua, SetCollidersDisabled), { NULL, NULL } }; Luna::PropertyType EmitterComponent_BindLua::properties[] = { @@ -4478,6 +4731,25 @@ int EmitterComponent_BindLua::SetMotionBlurAmount(lua_State* L) return 0; } +int EmitterComponent_BindLua::IsCollidersDisabled(lua_State* L) +{ + wi::lua::SSetBool(L, component->IsCollidersDisabled()); + return 1; +} +int EmitterComponent_BindLua::SetCollidersDisabled(lua_State* L) +{ + int argc = wi::lua::SGetArgCount(L); + if (argc > 0) + { + component->SetCollidersDisabled(wi::lua::SGetBool(L, 1)); + } + else + { + wi::lua::SError(L, "SetCollidersDisabled(bool value) not enough arguments!"); + } + + return 0; +} @@ -5889,6 +6161,10 @@ Luna::FunctionType SoundComponent_BindLua::methods[] = { lunamethod(SoundComponent_BindLua, Stop), lunamethod(SoundComponent_BindLua, SetLooped), lunamethod(SoundComponent_BindLua, SetDisable3D), + lunamethod(SoundComponent_BindLua, SetSound), + lunamethod(SoundComponent_BindLua, SetSoundInstance), + lunamethod(SoundComponent_BindLua, GetSound), + lunamethod(SoundComponent_BindLua, GetSoundInstance), { NULL, NULL } }; Luna::PropertyType SoundComponent_BindLua::properties[] = { @@ -5951,6 +6227,54 @@ int SoundComponent_BindLua::SetDisable3D(lua_State* L) return 0; } +int SoundComponent_BindLua::SetSound(lua_State* L) +{ + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "SetSound(Sound sound): not enough arguments!"); + return 0; + } + + Sound_BindLua* sound = Luna::lightcheck(L, 1); + if (sound == nullptr) + { + wi::lua::SError(L, "SetSound(Sound sound): argument is not a Sound!"); + return 0; + } + + component->soundResource = sound->soundResource; + return 0; +} +int SoundComponent_BindLua::SetSoundInstance(lua_State* L) +{ + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "SetSoundInstance(SoundInstance inst): not enough arguments!"); + return 0; + } + + SoundInstance_BindLua* inst = Luna::lightcheck(L, 1); + if (inst == nullptr) + { + wi::lua::SError(L, "SetSoundInstance(SoundInstance inst): argument is not a SoundInstance!"); + return 0; + } + + component->soundinstance = inst->soundinstance; + return 0; +} +int SoundComponent_BindLua::GetSound(lua_State* L) +{ + Luna::push(L, component->soundResource); + return 1; +} +int SoundComponent_BindLua::GetSoundInstance(lua_State* L) +{ + Luna::push(L, component->soundinstance); + return 1; +} @@ -6325,6 +6649,10 @@ Luna::FunctionType HumanoidComponent_BindLua::methods lunamethod(HumanoidComponent_BindLua, SetLookAt), lunamethod(HumanoidComponent_BindLua, SetRagdollPhysicsEnabled), lunamethod(HumanoidComponent_BindLua, IsRagdollPhysicsEnabled), + lunamethod(HumanoidComponent_BindLua, SetRagdollFatness), + lunamethod(HumanoidComponent_BindLua, SetRagdollHeadSize), + lunamethod(HumanoidComponent_BindLua, GetRagdollFatness), + lunamethod(HumanoidComponent_BindLua, GetRagdollHeadSize), { NULL, NULL } }; Luna::PropertyType HumanoidComponent_BindLua::properties[] = { @@ -6408,6 +6736,42 @@ int HumanoidComponent_BindLua::IsRagdollPhysicsEnabled(lua_State* L) wi::lua::SSetBool(L, component->IsRagdollPhysicsEnabled()); return 1; } +int HumanoidComponent_BindLua::SetRagdollFatness(lua_State* L) +{ + int argc = wi::lua::SGetArgCount(L); + if (argc > 0) + { + component->ragdoll_fatness = wi::lua::SGetFloat(L, 1); + } + else + { + wi::lua::SError(L, "SetRagdollFatness(float value) not enough arguments!"); + } + return 0; +} +int HumanoidComponent_BindLua::SetRagdollHeadSize(lua_State* L) +{ + int argc = wi::lua::SGetArgCount(L); + if (argc > 0) + { + component->ragdoll_headsize = wi::lua::SGetFloat(L, 1); + } + else + { + wi::lua::SError(L, "SetRagdollHeadSize(float value) not enough arguments!"); + } + return 0; +} +int HumanoidComponent_BindLua::GetRagdollFatness(lua_State* L) +{ + wi::lua::SSetFloat(L, component->ragdoll_fatness); + return 1; +} +int HumanoidComponent_BindLua::GetRagdollHeadSize(lua_State* L) +{ + wi::lua::SSetFloat(L, component->ragdoll_headsize); + return 1; +} diff --git a/WickedEngine/wiScene_BindLua.h b/WickedEngine/wiScene_BindLua.h index 92cec6c6666..107f46ded01 100644 --- a/WickedEngine/wiScene_BindLua.h +++ b/WickedEngine/wiScene_BindLua.h @@ -38,6 +38,7 @@ namespace wi::lua::scene int UpdateHierarchy(lua_State* L); int Intersects(lua_State* L); + int IntersectsFirst(lua_State* L); int FindAllEntities(lua_State* L); int Entity_FindByName(lua_State* L); @@ -48,6 +49,7 @@ namespace wi::lua::scene int Component_CreateName(lua_State* L); int Component_CreateLayer(lua_State* L); int Component_CreateTransform(lua_State* L); + int Component_CreateCamera(lua_State* L); int Component_CreateEmitter(lua_State* L); int Component_CreateHairParticleSystem(lua_State* L); int Component_CreateLight(lua_State* L); @@ -67,6 +69,7 @@ namespace wi::lua::scene int Component_CreateDecal(lua_State* L); int Component_CreateSprite(lua_State* L); int Component_CreateFont(lua_State* L); + int Component_CreateVoxelGrid(lua_State* L); int Component_GetName(lua_State* L); int Component_GetLayer(lua_State* L); @@ -93,6 +96,7 @@ namespace wi::lua::scene int Component_GetDecal(lua_State* L); int Component_GetSprite(lua_State* L); int Component_GetFont(lua_State* L); + int Component_GetVoxelGrid(lua_State* L); int Component_GetNameArray(lua_State* L); int Component_GetLayerArray(lua_State* L); @@ -119,6 +123,7 @@ namespace wi::lua::scene int Component_GetDecalArray(lua_State* L); int Component_GetSpriteArray(lua_State* L); int Component_GetFontArray(lua_State* L); + int Component_GetVoxelGridArray(lua_State* L); int Entity_GetNameArray(lua_State* L); int Entity_GetLayerArray(lua_State* L); @@ -146,6 +151,7 @@ namespace wi::lua::scene int Entity_GetDecalArray(lua_State* L); int Entity_GetSpriteArray(lua_State* L); int Entity_GetFontArray(lua_State* L); + int Entity_GetVoxelGridArray(lua_State* L); int Component_RemoveName(lua_State* L); int Component_RemoveLayer(lua_State* L); @@ -173,6 +179,7 @@ namespace wi::lua::scene int Component_RemoveDecal(lua_State* L); int Component_RemoveSprite(lua_State* L); int Component_RemoveFont(lua_State* L); + int Component_RemoveVoxelGrid(lua_State* L); int Component_Attach(lua_State* L); int Component_Detach(lua_State* L); @@ -184,6 +191,9 @@ namespace wi::lua::scene int SetWeather(lua_State* L); int RetargetAnimation(lua_State* L); + + int VoxelizeObject(lua_State* L); + int VoxelizeScene(lua_State* L); }; class NameComponent_BindLua @@ -270,6 +280,9 @@ namespace wi::lua::scene int GetPosition(lua_State* L); int GetRotation(lua_State* L); int GetScale(lua_State* L); + int GetForward(lua_State* L); + int GetUp(lua_State* L); + int GetRight(lua_State* L); int IsDirty(lua_State* L); int SetDirty(lua_State* L); int SetScale(lua_State* L); @@ -373,7 +386,7 @@ namespace wi::lua::scene { _flags = LongLongProperty(reinterpret_cast(&component->_flags)); ShaderType = IntProperty(reinterpret_cast(&component->shaderType)); - UserBlendMode = IntProperty(reinterpret_cast(&component->roughness)); + UserBlendMode = IntProperty(reinterpret_cast(&component->userBlendMode)); SpecularColor = VectorProperty(&component->specularColor); SubsurfaceScattering = VectorProperty(&component->subsurfaceScattering); TexMulAdd = VectorProperty(&component->texMulAdd); @@ -465,6 +478,8 @@ namespace wi::lua::scene int SetUserStencilRef(lua_State* L); int GetUserStencilRef(lua_State* L); int GetStencilRef(lua_State* L); + int SetCastShadow(lua_State* L); + int IsCastingShadow(lua_State* L); int SetTexture(lua_State* L); int SetTextureUVSet(lua_State* L); @@ -513,6 +528,7 @@ namespace wi::lua::scene int SetMeshSubsetMaterialID(lua_State* L); int GetMeshSubsetMaterialID(lua_State* L); + int CreateSubset(lua_State* L); }; class EmitterComponent_BindLua @@ -623,6 +639,8 @@ namespace wi::lua::scene int GetScaleY(lua_State* L); int GetRotation(lua_State* L); int GetMotionBlurAmount(lua_State* L); + int IsCollidersDisabled(lua_State* L); + int SetCollidersDisabled(lua_State* L); }; class HairParticleSystem_BindLua @@ -1624,6 +1642,10 @@ namespace wi::lua::scene int Stop(lua_State* L); int SetLooped(lua_State* L); int SetDisable3D(lua_State* L); + int SetSound(lua_State* L); + int SetSoundInstance(lua_State* L); + int GetSound(lua_State* L); + int GetSoundInstance(lua_State* L); }; class ColliderComponent_BindLua @@ -1720,6 +1742,10 @@ namespace wi::lua::scene int SetLookAt(lua_State* L); int SetRagdollPhysicsEnabled(lua_State* L); int IsRagdollPhysicsEnabled(lua_State* L); + int SetRagdollFatness(lua_State* L); + int SetRagdollHeadSize(lua_State* L); + int GetRagdollFatness(lua_State* L); + int GetRagdollHeadSize(lua_State* L); }; class DecalComponent_BindLua diff --git a/WickedEngine/wiScene_Components.cpp b/WickedEngine/wiScene_Components.cpp index dcb7de863f4..703c280ce2a 100644 --- a/WickedEngine/wiScene_Components.cpp +++ b/WickedEngine/wiScene_Components.cpp @@ -12,6 +12,8 @@ #include "wiUnorderedMap.h" #include "wiLua.h" +#include "Utility/mikktspace.h" + #if __has_include("OpenImageDenoise/oidn.hpp") #include "OpenImageDenoise/oidn.hpp" #if OIDN_VERSION_MAJOR >= 2 @@ -72,6 +74,33 @@ namespace wi::scene XMMatrixRotationQuaternion(R_local) * XMMatrixTranslationFromVector(T_local); } + XMFLOAT3 TransformComponent::GetForward() const + { + return wi::math::GetForward(world); + } + XMFLOAT3 TransformComponent::GetUp() const + { + return wi::math::GetUp(world); + } + XMFLOAT3 TransformComponent::GetRight() const + { + return wi::math::GetRight(world); + } + XMVECTOR TransformComponent::GetForwardV() const + { + XMFLOAT3 v = wi::math::GetForward(world); + return XMLoadFloat3(&v); + } + XMVECTOR TransformComponent::GetUpV() const + { + XMFLOAT3 v = wi::math::GetUp(world); + return XMLoadFloat3(&v); + } + XMVECTOR TransformComponent::GetRightV() const + { + XMFLOAT3 v = wi::math::GetRight(world); + return XMLoadFloat3(&v); + } void TransformComponent::UpdateTransform() { if (IsDirty()) @@ -459,6 +488,66 @@ namespace wi::scene return wi::renderer::CombineStencilrefs(engineStencilRef, userStencilRef); } + struct MikkTSpaceUserdata + { + MeshComponent* mesh = nullptr; + const uint32_t* indicesLOD0 = nullptr; + int faceCountLOD0 = 0; + }; + int get_num_faces(const SMikkTSpaceContext* context) + { + const MikkTSpaceUserdata* userdata = static_cast(context->m_pUserData); + return userdata->faceCountLOD0; + } + int get_num_vertices_of_face(const SMikkTSpaceContext* context, const int iFace) + { + return 3; + } + int get_vertex_index(const SMikkTSpaceContext* context, int iFace, int iVert) + { + const MikkTSpaceUserdata* userdata = static_cast(context->m_pUserData); + int face_size = get_num_vertices_of_face(context, iFace); + int indices_index = iFace * face_size + iVert; + int index = int(userdata->indicesLOD0[indices_index]); + return index; + } + void get_position(const SMikkTSpaceContext* context, float* outpos, const int iFace, const int iVert) + { + const MikkTSpaceUserdata* userdata = static_cast(context->m_pUserData); + int index = get_vertex_index(context, iFace, iVert); + const XMFLOAT3& vert = userdata->mesh->vertex_positions[index]; + outpos[0] = vert.x; + outpos[1] = vert.y; + outpos[2] = vert.z; + } + void get_normal(const SMikkTSpaceContext* context, float* outnormal, const int iFace, const int iVert) + { + const MikkTSpaceUserdata* userdata = static_cast(context->m_pUserData); + int index = get_vertex_index(context, iFace, iVert); + const XMFLOAT3& vert = userdata->mesh->vertex_normals[index]; + outnormal[0] = vert.x; + outnormal[1] = vert.y; + outnormal[2] = vert.z; + } + void get_tex_coords(const SMikkTSpaceContext* context, float* outuv, const int iFace, const int iVert) + { + const MikkTSpaceUserdata* userdata = static_cast(context->m_pUserData); + int index = get_vertex_index(context, iFace, iVert); + const XMFLOAT2& vert = userdata->mesh->vertex_uvset_0[index]; + outuv[0] = vert.x; + outuv[1] = vert.y; + } + void set_tspace_basic(const SMikkTSpaceContext* context, const float* tangentu, const float fSign, const int iFace, const int iVert) + { + const MikkTSpaceUserdata* userdata = static_cast(context->m_pUserData); + auto index = get_vertex_index(context, iFace, iVert); + XMFLOAT4& vert = userdata->mesh->vertex_tangents[index]; + vert.x = tangentu[0]; + vert.y = tangentu[1]; + vert.z = tangentu[2]; + vert.w = fSign; + } + void MeshComponent::DeleteRenderData() { generalBuffer = {}; @@ -493,6 +582,39 @@ namespace wi::scene // Generate tangents if not found: vertex_tangents.resize(vertex_positions.size()); +#if 1 + // MikkTSpace tangent generation: + MikkTSpaceUserdata userdata; + userdata.mesh = this; + uint32_t indexOffsetLOD0 = ~0u; + uint32_t indexCountLOD0 = 0; + uint32_t first_subset = 0; + uint32_t last_subset = 0; + GetLODSubsetRange(0, first_subset, last_subset); + for (uint32_t subsetIndex = first_subset; subsetIndex < last_subset; ++subsetIndex) + { + const MeshComponent::MeshSubset& subset = subsets[subsetIndex]; + indexOffsetLOD0 = std::min(indexOffsetLOD0, subset.indexOffset); + indexCountLOD0 = std::max(indexCountLOD0, subset.indexCount); + } + userdata.indicesLOD0 = indices.data() + indexOffsetLOD0; + userdata.faceCountLOD0 = int(indexCountLOD0) / 3; + + SMikkTSpaceInterface iface = {}; + iface.m_getNumFaces = get_num_faces; + iface.m_getNumVerticesOfFace = get_num_vertices_of_face; + iface.m_getNormal = get_normal; + iface.m_getPosition = get_position; + iface.m_getTexCoord = get_tex_coords; + iface.m_setTSpaceBasic = set_tspace_basic; + SMikkTSpaceContext context = {}; + context.m_pInterface = &iface; + context.m_pUserData = &userdata; + tbool mikktspace_result = genTangSpaceDefault(&context); + assert(mikktspace_result == 1); + +#else + // Old tangent generation logic: uint32_t first_subset = 0; uint32_t last_subset = 0; GetLODSubsetRange(0, first_subset, last_subset); @@ -564,6 +686,7 @@ namespace wi::scene vertex_tangents[i2].w = sign; } } +#endif } const size_t uv_count = std::max(vertex_uvset_0.size(), vertex_uvset_1.size()); @@ -820,10 +943,8 @@ namespace wi::scene buffer_offset += AlignTo(vb_nor.size, alignment); for (size_t i = 0; i < vertex_normals.size(); ++i) { - XMFLOAT3 nor = vertex_normals.empty() ? XMFLOAT3(1, 1, 1) : vertex_normals[i]; - XMStoreFloat3(&nor, XMVector3Normalize(XMLoadFloat3(&nor))); Vertex_NOR vert; - vert.FromFULL(nor); + vert.FromFULL(vertex_normals[i]); std::memcpy(vertices + i, &vert, sizeof(vert)); } } @@ -1933,8 +2054,6 @@ namespace wi::scene XMStoreFloat4x4(&InvView, _InvV); XMStoreFloat3x3(&rotationMatrix, _InvV); XMStoreFloat4x4(&InvVP, XMMatrixInverse(nullptr, _VP)); - XMStoreFloat4x4(&Projection, _P); - XMStoreFloat4x4(&InvProjection, XMMatrixInverse(nullptr, _P)); frustum.Create(_VP); } diff --git a/WickedEngine/wiScene_Components.h b/WickedEngine/wiScene_Components.h index 32b334f0f43..e63df21d260 100644 --- a/WickedEngine/wiScene_Components.h +++ b/WickedEngine/wiScene_Components.h @@ -70,6 +70,12 @@ namespace wi::scene XMVECTOR GetPositionV() const; XMVECTOR GetRotationV() const; XMVECTOR GetScaleV() const; + XMFLOAT3 GetForward() const; + XMFLOAT3 GetUp() const; + XMFLOAT3 GetRight() const; + XMVECTOR GetForwardV() const; + XMVECTOR GetUpV() const; + XMVECTOR GetRightV() const; // Computes the local space matrix from scale, rotation, translation and returns it XMMATRIX GetLocalMatrix() const; // Applies the local space to the world space matrix. This overwrites world matrix @@ -1136,6 +1142,7 @@ namespace wi::scene int texture_waterriples_index = -1; int texture_ao_index = -1; int texture_ssr_index = -1; + int texture_ssgi_index = -1; int texture_rtshadow_index = -1; int texture_rtdiffuse_index = -1; int texture_surfelgi_index = -1; @@ -1255,6 +1262,7 @@ namespace wi::scene XMFLOAT4 color; XMFLOAT3 front; float normal_strength; + float displacement_strength; XMFLOAT3 position; float range; XMFLOAT4X4 world; @@ -1263,6 +1271,7 @@ namespace wi::scene wi::Resource texture; wi::Resource normal; wi::Resource surfacemap; + wi::Resource displacementmap; inline float GetOpacity() const { return color.w; } @@ -1925,6 +1934,9 @@ namespace wi::scene XMFLOAT2 eye_rotation_max = XMFLOAT2(XM_PI / 20.0f, XM_PI / 20.0f); float eye_rotation_speed = 0.1f; + float ragdoll_fatness = 1.0f; + float ragdoll_headsize = 1.0f; + // Non-serialized attributes: XMFLOAT3 lookAt = {}; // lookAt target pos, can be set by user XMFLOAT4 lookAtDeltaRotationState_Head = XMFLOAT4(0, 0, 0, 1); diff --git a/WickedEngine/wiScene_Serializers.cpp b/WickedEngine/wiScene_Serializers.cpp index e3496ebea4e..4068d8a7637 100644 --- a/WickedEngine/wiScene_Serializers.cpp +++ b/WickedEngine/wiScene_Serializers.cpp @@ -376,7 +376,7 @@ namespace wi::scene archive << textures[ANISOTROPYMAP].uvset; } - if (seri.GetVersion() >= 2) + if (seri.GetVersion() >= 3) { archive << wi::helper::GetPathRelative(dir, textures[TRANSPARENCYMAP].name); archive << textures[TRANSPARENCYMAP].uvset; @@ -1727,8 +1727,9 @@ namespace wi::scene { filename = dir + filename; soundResource = wi::resourcemanager::Load(filename, wi::resourcemanager::Flags::IMPORT_RETAIN_FILEDATA); - soundinstance.SetLooped(IsLooped()); - wi::audio::CreateSoundInstance(&soundResource.GetSound(), &soundinstance); + // Note: sound instance can't be created yet, as soundResource is not necessarily ready at this point + // Consider when multiple threads are loading the same sound, one thread will be loading the data, + // the others return early with the resource that will be containing the data once it has been loaded. } }); } @@ -1988,6 +1989,12 @@ namespace wi::scene { SerializeEntity(archive, entity, seri); } + + if (seri.GetVersion() >= 1) + { + archive >> ragdoll_fatness; + archive >> ragdoll_headsize; + } } else { @@ -2002,6 +2009,12 @@ namespace wi::scene { SerializeEntity(archive, entity, seri); } + + if (seri.GetVersion() >= 1) + { + archive << ragdoll_fatness; + archive << ragdoll_headsize; + } } } diff --git a/WickedEngine/wiShaderCompiler.cpp b/WickedEngine/wiShaderCompiler.cpp index dfc2b84d939..38dcb126baf 100644 --- a/WickedEngine/wiShaderCompiler.cpp +++ b/WickedEngine/wiShaderCompiler.cpp @@ -19,7 +19,7 @@ #define SHADERCOMPILER_ENABLED #define SHADERCOMPILER_ENABLED_DXCOMPILER #define __RPC_FAR -#include "Utility/dxc/Support/WinAdapter.h" +#include "Utility/WinAdapter.h" #endif // PLATFORM_LINUX #ifdef SHADERCOMPILER_ENABLED_DXCOMPILER diff --git a/WickedEngine/wiSpriteFont_BindLua.cpp b/WickedEngine/wiSpriteFont_BindLua.cpp index adb9e161f8c..362ee6beff6 100644 --- a/WickedEngine/wiSpriteFont_BindLua.cpp +++ b/WickedEngine/wiSpriteFont_BindLua.cpp @@ -424,7 +424,7 @@ namespace wi::lua wi::lua::SError(L, "SetTypewriterSound(Sound sound, SoundInstance soundinstance) second argument is not a sound instance!"); return 0; } - font.anim.typewriter.sound = sound->sound; + font.anim.typewriter.sound = sound->soundResource.GetSound(); font.anim.typewriter.soundinstance = soundinstance->soundinstance; return 0; } diff --git a/WickedEngine/wiSprite_BindLua.cpp b/WickedEngine/wiSprite_BindLua.cpp index da7cc7c9b65..e43f633469d 100644 --- a/WickedEngine/wiSprite_BindLua.cpp +++ b/WickedEngine/wiSprite_BindLua.cpp @@ -15,6 +15,8 @@ namespace wi::lua lunamethod(Sprite_BindLua, GetTexture), lunamethod(Sprite_BindLua, SetMaskTexture), lunamethod(Sprite_BindLua, GetMaskTexture), + lunamethod(Sprite_BindLua, SetHidden), + lunamethod(Sprite_BindLua, IsHidden), { NULL, NULL } }; @@ -118,6 +120,7 @@ namespace wi::lua if (tex != nullptr) { sprite.maskResource = tex->resource; + sprite.params.setMaskMap(&tex->resource.GetTexture()); } } else @@ -131,6 +134,22 @@ namespace wi::lua Luna::push(L, sprite.maskResource); return 1; } + int Sprite_BindLua::SetHidden(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "SetHidden(bool value) not enough arguments!"); + return 0; + } + sprite.SetHidden(wi::lua::SGetBool(L, 1)); + return 0; + } + int Sprite_BindLua::IsHidden(lua_State* L) + { + wi::lua::SSetBool(L, sprite.IsHidden()); + return 1; + } void Sprite_BindLua::Bind() { diff --git a/WickedEngine/wiSprite_BindLua.h b/WickedEngine/wiSprite_BindLua.h index e9ac30b41d8..2d0babf8098 100644 --- a/WickedEngine/wiSprite_BindLua.h +++ b/WickedEngine/wiSprite_BindLua.h @@ -25,6 +25,8 @@ namespace wi::lua int GetTexture(lua_State* L); int SetMaskTexture(lua_State* L); int GetMaskTexture(lua_State* L); + int SetHidden(lua_State* L); + int IsHidden(lua_State* L); static void Bind(); }; diff --git a/WickedEngine/wiTerrain.cpp b/WickedEngine/wiTerrain.cpp index d638d6a740a..d2fbfbefb21 100644 --- a/WickedEngine/wiTerrain.cpp +++ b/WickedEngine/wiTerrain.cpp @@ -410,6 +410,28 @@ namespace wi::terrain Generation_Cancel(); generator->scene.Clear(); + // save material parameters: + wi::scene::MaterialComponent materials[MATERIAL_COUNT]; + for (int i = 0; i < MATERIAL_COUNT; ++i) + { + MaterialComponent* material = scene->materials.GetComponent(materialEntities[i]); + if (material == nullptr) + continue; + materials[i] = *material; + materials[i].SetDirty(false); + } + + // save grass parameters: + if (scene->hairs.Contains(grassEntity)) + { + grass_properties = *scene->hairs.GetComponent(grassEntity); + grass_properties.SetDirty(false); + } + if (scene->materials.Contains(grassEntity)) + { + grass_material = *scene->materials.GetComponent(grassEntity); + grass_material.SetDirty(false); + } for (auto it = chunks.begin(); it != chunks.end(); it++) { @@ -453,7 +475,7 @@ namespace wi::terrain } { - Entity sunEntity = scene->Entity_CreateLight("terrainSun"); + Entity sunEntity = scene->Entity_CreateLight("sun"); scene->Component_Attach(sunEntity, terrainEntity); LightComponent& light = *scene->lights.GetComponent(sunEntity); light.SetType(LightComponent::LightType::DIRECTIONAL); @@ -463,6 +485,76 @@ namespace wi::terrain transform.RotateRollPitchYaw(XMFLOAT3(XM_PIDIV4, 0, XM_PIDIV4)); transform.Translate(XMFLOAT3(0, 4, 0)); } + + // Restore surface source materials: + { + for (int i = 0; i < MATERIAL_COUNT; ++i) + { + if (materialEntities[i] == INVALID_ENTITY) + { + materialEntities[i] = CreateEntity(); + } + scene->Component_Attach(materialEntities[i], terrainEntity); + if (!scene->materials.Contains(materialEntities[i])) + { + scene->materials.Create(materialEntities[i]); + } + if (!scene->names.Contains(materialEntities[i])) + { + NameComponent& name = scene->names.Create(materialEntities[i]); + switch (i) + { + default: + case MATERIAL_BASE: + name = "material_base"; + break; + case MATERIAL_SLOPE: + name = "material_slope"; + break; + case MATERIAL_LOW_ALTITUDE: + name = "material_low_altitude"; + break; + case MATERIAL_HIGH_ALTITUDE: + name = "material_high_altitude"; + break; + } + } + *scene->materials.GetComponent(materialEntities[i]) = materials[i]; + } + } + + // Restore grass parameters: + { + if (grassEntity == INVALID_ENTITY) + { + grassEntity = CreateEntity(); + } + scene->Component_Attach(grassEntity, terrainEntity); + if (!scene->hairs.Contains(grassEntity)) + { + scene->hairs.Create(grassEntity); + } + if (!scene->materials.Contains(grassEntity)) + { + scene->materials.Create(grassEntity); + } + if (!scene->names.Contains(grassEntity)) + { + scene->names.Create(grassEntity) = "grass"; + } + *scene->hairs.GetComponent(grassEntity) = grass_properties; + *scene->materials.GetComponent(grassEntity) = grass_material; + } + + if (chunkGroupEntity == INVALID_ENTITY) + { + chunkGroupEntity = CreateEntity(); + } + scene->Component_Attach(chunkGroupEntity, terrainEntity); + if (!scene->names.Contains(chunkGroupEntity)) + { + scene->names.Create(chunkGroupEntity) = "chunks"; + } } void Terrain::Generation_Update(const CameraComponent& camera) @@ -470,9 +562,10 @@ namespace wi::terrain // The generation task is always cancelled every frame so we are sure that generation is not running at this point Generation_Cancel(); + bool restart_generation = false; if (!IsGenerationStarted()) { - Generation_Restart(); + restart_generation = true; } // Check whether any modifiers need to be removed, and we will really remove them here if so: @@ -489,9 +582,44 @@ namespace wi::terrain } } } - Generation_Restart(); + restart_generation = true; modifiers_to_remove.clear(); } + for (wi::ecs::Entity entity : materialEntities) + { + MaterialComponent* material = scene->materials.GetComponent(entity); + if (material == nullptr) + continue; + if (material->IsDirty()) + { + restart_generation = true; + break; + } + } + if (grassEntity != INVALID_ENTITY) + { + MaterialComponent* material_grassparticle_in_scene = scene->materials.GetComponent(grassEntity); + if (material_grassparticle_in_scene != nullptr) + { + if (material_grassparticle_in_scene->IsDirty()) + { + restart_generation = true; + } + } + wi::HairParticleSystem* hair = scene->hairs.GetComponent(grassEntity); + if (hair != nullptr) + { + if (hair->IsDirty()) + { + restart_generation = true; + } + } + } + + if (restart_generation) + { + Generation_Restart(); + } if (terrainEntity == INVALID_ENTITY) { @@ -507,6 +635,11 @@ namespace wi::terrain return; } + if (chunkGroupEntity == INVALID_ENTITY) + { + chunkGroupEntity = terrainEntity; + } + WeatherComponent* weather_component = scene->weathers.GetComponent(terrainEntity); if (weather_component != nullptr) { @@ -530,34 +663,50 @@ namespace wi::terrain // Check whether there are any materials that would write to virtual textures: bool virtual_texture_any = false; bool virtual_texture_available[TEXTURESLOT_COUNT] = {}; - MaterialComponent* virtual_materials[4] = { - &material_Base, - &material_Slope, - &material_LowAltitude, - &material_HighAltitude, - }; - for (auto& material : virtual_materials) + + if (scene->materials.GetCount() > 0) { - for (int i = 0; i < TEXTURESLOT_COUNT; ++i) + for (wi::ecs::Entity entity : materialEntities) { - virtual_texture_available[i] = false; - switch (i) + MaterialComponent* material = scene->materials.GetComponent(entity); + if (material == nullptr) + continue; + + for (int i = 0; i < TEXTURESLOT_COUNT; ++i) { - case MaterialComponent::BASECOLORMAP: - case MaterialComponent::NORMALMAP: - case MaterialComponent::SURFACEMAP: - if (material->textures[i].resource.IsValid()) + virtual_texture_available[i] = false; + switch (i) { - virtual_texture_available[i] = true; - virtual_texture_any = true; + case MaterialComponent::BASECOLORMAP: + case MaterialComponent::NORMALMAP: + case MaterialComponent::SURFACEMAP: + if (material->textures[i].resource.IsValid()) + { + virtual_texture_available[i] = true; + virtual_texture_any = true; + } + break; + default: + break; } - break; - default: - break; + } + } + virtual_texture_available[MaterialComponent::SURFACEMAP] = true; // this is always needed to bake individual material properties + + if (grassEntity != INVALID_ENTITY) + { + MaterialComponent* material_grassparticle_in_scene = scene->materials.GetComponent(grassEntity); + if (material_grassparticle_in_scene != nullptr) + { + grass_material = *material_grassparticle_in_scene; + } + HairParticleSystem* hair = scene->hairs.GetComponent(grassEntity); + if (hair != nullptr) + { + grass_properties = *hair; } } } - virtual_texture_available[MaterialComponent::SURFACEMAP] = true; // this is always needed to bake individual material properties for (auto it = chunks.begin(); it != chunks.end();) { @@ -734,7 +883,7 @@ namespace wi::terrain ObjectComponent& object = *generator->scene.objects.GetComponent(chunk_data.entity); object.lod_distance_multiplier = lod_multiplier; object.filterMask |= wi::enums::FILTER_NAVIGATION_MESH; - generator->scene.Component_Attach(chunk_data.entity, terrainEntity); + generator->scene.Component_Attach(chunk_data.entity, chunkGroupEntity); TransformComponent& transform = *generator->scene.transforms.GetComponent(chunk_data.entity); transform.ClearTransform(); @@ -763,6 +912,7 @@ namespace wi::terrain mesh.subsets_per_lod = 1; mesh.vertex_positions.resize(vertexCount); mesh.vertex_normals.resize(vertexCount); + mesh.vertex_tangents.resize(vertexCount); mesh.vertex_uvset_0.resize(vertexCount); chunk_data.region_weights.resize(vertexCount); @@ -829,6 +979,8 @@ namespace wi::terrain mesh.vertex_positions[index] = XMFLOAT3(x, height, z); mesh.vertex_normals[index] = normal; + XMStoreFloat4(&mesh.vertex_tangents[index], T); + mesh.vertex_tangents[index].w = 1; const XMFLOAT2 uv = XMFLOAT2(x * chunk_scale_rcp * chunk_width_rcp + 0.5f, z * chunk_scale_rcp * chunk_width_rcp + 0.5f); mesh.vertex_uvset_0[index] = uv; @@ -896,7 +1048,7 @@ namespace wi::terrain chunk_data.grass_density_current = grass_density; grass.strandCount = uint32_t(grass.strandCount * chunk_data.grass_density_current); grass.CreateRenderData(); - generator->scene.materials.Create(chunk_data.grass_entity) = material_GrassParticle; + generator->scene.materials.Create(chunk_data.grass_entity) = grass_material; generator->scene.transforms.Create(chunk_data.grass_entity); generator->scene.names.Create(chunk_data.grass_entity) = "grass"; generator->scene.Component_Attach(chunk_data.grass_entity, chunk_data.entity, true); @@ -1440,11 +1592,14 @@ namespace wi::terrain device->EventBegin("Render Tile Regions", cmd); - ShaderMaterial materials[4]; - material_Base.WriteShaderMaterial(&materials[0]); - material_Slope.WriteShaderMaterial(&materials[1]); - material_LowAltitude.WriteShaderMaterial(&materials[2]); - material_HighAltitude.WriteShaderMaterial(&materials[3]); + ShaderMaterial materials[MATERIAL_COUNT]; + for (size_t i = 0; i < MATERIAL_COUNT && scene->materials.GetCount() > 0; ++i) + { + const MaterialComponent* material = scene->materials.GetComponent(materialEntities[i]); + if (material == nullptr) + continue; + material->WriteShaderMaterial(&materials[i]); + } device->BindDynamicConstantBuffer(materials, 0, cmd); for (uint32_t map_type = 0; map_type < 3; map_type++) @@ -1639,11 +1794,18 @@ namespace wi::terrain { Generation_Cancel(); + // Note: separate component types serialized within terrain must NOT use the version of the terrain, but their own! + ComponentLibrary& library = *seri.componentlibrary; + const uint64_t terrain_version = seri.GetVersion(); + const uint64_t grass_version = library.GetVersion("wi::scene::Scene::hairs"); + const uint64_t material_version = library.GetVersion("wi::scene::Scene::materials"); + const uint64_t weather_version = library.GetVersion("wi::scene::Scene::weathers"); + if (archive.IsReadMode()) { archive >> _flags; archive >> lod_multiplier; - if (seri.GetVersion() < 3) + if (terrain_version < 3) { float texlod; archive >> texlod; @@ -1663,11 +1825,11 @@ namespace wi::terrain archive >> center_chunk.x; archive >> center_chunk.z; - if (seri.GetVersion() >= 1) + if (terrain_version >= 1) { archive >> physics_generation; } - if (seri.GetVersion() >= 2 && seri.GetVersion() < 3) + if (terrain_version >= 2 && terrain_version < 3) { uint32_t target_texture_resolution; archive >> target_texture_resolution; @@ -1679,7 +1841,7 @@ namespace wi::terrain for (size_t i = 0; i < props.size(); ++i) { Prop& prop = props[i]; - if (seri.GetVersion() >= 1) + if (terrain_version >= 1) { archive >> prop.data; @@ -1758,7 +1920,11 @@ namespace wi::terrain SerializeEntity(archive, chunk_data.grass_entity, seri); SerializeEntity(archive, chunk_data.props_entity, seri); archive >> chunk_data.prop_density_current; + + seri.version = grass_version; chunk_data.grass.Serialize(archive, seri); + seri.version = terrain_version; + archive >> chunk_data.grass_density_current; archive >> chunk_data.region_weights; archive >> chunk_data.sphere.center; @@ -1822,7 +1988,7 @@ namespace wi::terrain { archive << _flags; archive << lod_multiplier; - if (seri.GetVersion() < 3) + if (terrain_version < 3) { float texlod = 1; archive << texlod; @@ -1842,11 +2008,11 @@ namespace wi::terrain archive << center_chunk.x; archive << center_chunk.z; - if (seri.GetVersion() >= 1) + if (terrain_version >= 1) { archive << physics_generation; } - if (seri.GetVersion() >= 2 && seri.GetVersion() < 3) + if (terrain_version >= 2 && terrain_version < 3) { uint32_t target_texture_resolution = 1024; archive << target_texture_resolution; @@ -1881,7 +2047,11 @@ namespace wi::terrain SerializeEntity(archive, chunk_data.grass_entity, seri); SerializeEntity(archive, chunk_data.props_entity, seri); archive << chunk_data.prop_density_current; + + seri.version = grass_version; chunk_data.grass.Serialize(archive, seri); + seri.version = terrain_version; + archive << chunk_data.grass_density_current; archive << chunk_data.region_weights; archive << chunk_data.sphere.center; @@ -1923,13 +2093,63 @@ namespace wi::terrain } } - material_Base.Serialize(archive, seri); - material_Slope.Serialize(archive, seri); - material_LowAltitude.Serialize(archive, seri); - material_HighAltitude.Serialize(archive, seri); - material_GrassParticle.Serialize(archive, seri); + // Caution: seri.version changes must be handled carefully! + + if (terrain_version >= 4) + { + SerializeEntity(archive, chunkGroupEntity, seri); + for (size_t i = 0; i < MATERIAL_COUNT; ++i) + { + SerializeEntity(archive, materialEntities[i], seri); + } + SerializeEntity(archive, grassEntity, seri); + } + else + { + // Convert terrain version below 4 to newer version: + seri.version = material_version; + wi::scene::MaterialComponent materials[MATERIAL_COUNT]; + materials[MATERIAL_BASE].Serialize(archive, seri); + materials[MATERIAL_SLOPE].Serialize(archive, seri); + materials[MATERIAL_LOW_ALTITUDE].Serialize(archive, seri); + materials[MATERIAL_HIGH_ALTITUDE].Serialize(archive, seri); + grass_material.Serialize(archive, seri); + wi::jobsystem::Wait(seri.ctx); // wait for material CreateRenderData() that was asynchronously launched in Serialize()! + + materialEntities[MATERIAL_BASE] = CreateEntity(); + materialEntities[MATERIAL_SLOPE] = CreateEntity(); + materialEntities[MATERIAL_LOW_ALTITUDE] = CreateEntity(); + materialEntities[MATERIAL_HIGH_ALTITUDE] = CreateEntity(); + grassEntity = CreateEntity(); + + ComponentManager* scene_materials = library.Get("wi::scene::Scene::materials"); + scene_materials->Create(materialEntities[MATERIAL_BASE]) = materials[MATERIAL_BASE]; + scene_materials->Create(materialEntities[MATERIAL_SLOPE]) = materials[MATERIAL_SLOPE]; + scene_materials->Create(materialEntities[MATERIAL_LOW_ALTITUDE]) = materials[MATERIAL_LOW_ALTITUDE]; + scene_materials->Create(materialEntities[MATERIAL_HIGH_ALTITUDE]) = materials[MATERIAL_HIGH_ALTITUDE]; + scene_materials->Create(grassEntity) = grass_material; + + ComponentManager* scene_names = library.Get("wi::scene::Scene::names"); + scene_names->Create(materialEntities[MATERIAL_BASE]).name = "material_base"; + scene_names->Create(materialEntities[MATERIAL_SLOPE]).name = "material_slope"; + scene_names->Create(materialEntities[MATERIAL_LOW_ALTITUDE]).name = "material_low_altitude"; + scene_names->Create(materialEntities[MATERIAL_HIGH_ALTITUDE]).name = "material_high_altitude"; + scene_names->Create(grassEntity).name = "grass"; + } + + seri.version = weather_version; weather.Serialize(archive, seri); - grass_properties.Serialize(archive, seri); + + if (terrain_version < 4) + { + seri.version = grass_version; + grass_properties.Serialize(archive, seri); + seri.version = terrain_version; + + ComponentManager* scene_hairs = library.Get("wi::scene::Scene::hairs"); + scene_hairs->Create(grassEntity) = grass_properties; + } + perlin_noise.Serialize(archive); } diff --git a/WickedEngine/wiTerrain.h b/WickedEngine/wiTerrain.h index de779143761..7a3d9abc461 100644 --- a/WickedEngine/wiTerrain.h +++ b/WickedEngine/wiTerrain.h @@ -43,6 +43,14 @@ namespace wi::terrain static constexpr float chunk_half_width = (chunk_width - 1) * 0.5f; static constexpr float chunk_width_rcp = 1.0f / (chunk_width - 1); static constexpr uint32_t vertexCount = chunk_width * chunk_width; + enum + { + MATERIAL_BASE, + MATERIAL_SLOPE, + MATERIAL_LOW_ALTITUDE, + MATERIAL_HIGH_ALTITUDE, + MATERIAL_COUNT + }; struct VirtualTextureAtlas { @@ -207,14 +215,13 @@ namespace wi::terrain uint32_t _flags = CENTER_TO_CAM | REMOVAL | GRASS; wi::ecs::Entity terrainEntity = wi::ecs::INVALID_ENTITY; + wi::ecs::Entity chunkGroupEntity = wi::ecs::INVALID_ENTITY; wi::scene::Scene* scene = nullptr; - wi::scene::MaterialComponent material_Base; - wi::scene::MaterialComponent material_Slope; - wi::scene::MaterialComponent material_LowAltitude; - wi::scene::MaterialComponent material_HighAltitude; - wi::scene::MaterialComponent material_GrassParticle; + wi::ecs::Entity materialEntities[MATERIAL_COUNT] = {}; + wi::ecs::Entity grassEntity = wi::ecs::INVALID_ENTITY; wi::scene::WeatherComponent weather; wi::HairParticleSystem grass_properties; + wi::scene::MaterialComponent grass_material; wi::unordered_map chunks; Chunk center_chunk = {}; wi::noise::Perlin perlin_noise; diff --git a/WickedEngine/wiTextureHelper.cpp b/WickedEngine/wiTextureHelper.cpp index 545c52600e0..321c973c2b8 100644 --- a/WickedEngine/wiTextureHelper.cpp +++ b/WickedEngine/wiTextureHelper.cpp @@ -96,16 +96,6 @@ namespace wi::texturehelper const int width = 1; const int height = 1; - struct vector4b - { - unsigned char r; - unsigned char g; - unsigned char b; - unsigned char a; - - vector4b(unsigned char r = 0, unsigned char g = 0, unsigned char b = 0, unsigned char a = 0) :r(r), g(g), b(b), a(a) {} - }; - TextureDesc texDesc; texDesc.width = width; texDesc.height = height; @@ -118,16 +108,10 @@ namespace wi::texturehelper texDesc.misc_flags = ResourceMiscFlag::TEXTURECUBE; SubresourceData pData[6]; - vector4b d[6][width * height]; // 6 images of type vector4b = 4 * unsigned char + wi::Color d[6][width * height] = {}; // 6 images initialized to 0 (transparent black) for (int cubeMapFaceIndex = 0; cubeMapFaceIndex < 6; cubeMapFaceIndex++) { - // fill with black color - for (int pix = 0; pix < width*height; ++pix) - { - d[cubeMapFaceIndex][pix] = vector4b(0, 0, 0, 0); - } - pData[cubeMapFaceIndex].data_ptr = &d[cubeMapFaceIndex][0];// description.data; pData[cubeMapFaceIndex].row_pitch = width * 4; pData[cubeMapFaceIndex].slice_pitch = 0; @@ -146,7 +130,7 @@ namespace wi::texturehelper // Blue Noise: { - wi::vector bluenoise(128 * 128); + wi::Color bluenoise[128 * 128]; for (int y = 0; y < 128; ++y) { @@ -161,7 +145,7 @@ namespace wi::texturehelper } } - CreateTexture(helperTextures[HELPERTEXTURE_BLUENOISE], (uint8_t*)bluenoise.data(), 128, 128, Format::R8G8B8A8_UNORM); + CreateTexture(helperTextures[HELPERTEXTURE_BLUENOISE], (const uint8_t*)bluenoise, 128, 128, Format::R8G8B8A8_UNORM); device->SetName(&helperTextures[HELPERTEXTURE_BLUENOISE], "HELPERTEXTURE_BLUENOISE"); } @@ -178,7 +162,7 @@ namespace wi::texturehelper const uint32_t data_stride = GetFormatStride(desc.format); const uint32_t block_size = GetFormatBlockSize(desc.format); const uint8_t* src = waterriple; - wi::vector initdata(desc.mip_levels); + SubresourceData initdata[7] = {}; for (uint32_t mip = 0; mip < desc.mip_levels; ++mip) { const uint32_t num_blocks_x = std::max(1u, desc.width >> mip) / block_size; @@ -187,7 +171,7 @@ namespace wi::texturehelper initdata[mip].row_pitch = num_blocks_x * data_stride; src += num_blocks_x * num_blocks_y * data_stride; } - device->CreateTexture(&desc, initdata.data(), &helperTextures[HELPERTEXTURE_WATERRIPPLE]); + device->CreateTexture(&desc, initdata, &helperTextures[HELPERTEXTURE_WATERRIPPLE]); device->SetName(&helperTextures[HELPERTEXTURE_WATERRIPPLE], "HELPERTEXTURE_WATERRIPPLE"); } @@ -335,7 +319,7 @@ namespace wi::texturehelper { for (uint32_t x = 0; x < width; ++x) { - const XMFLOAT2 uv = XMFLOAT2(float(x) / float(width - 1), float(y) / float(height - 1)); + const XMFLOAT2 uv = XMFLOAT2((float(x) + 0.5f) / float(width), (float(y) + 0.5f) / float(height)); const XMVECTOR point_on_line = wi::math::ClosestPointOnLineSegment(a, b, XMLoadFloat2(&uv)); const float uv_distance = XMVectorGetX(XMVector3Length(point_on_line - a)); float gradient = wi::math::saturate(wi::math::InverseLerp(0, distance, uv_distance)); @@ -374,7 +358,7 @@ namespace wi::texturehelper { for (uint32_t x = 0; x < width; ++x) { - const XMFLOAT2 uv = XMFLOAT2(float(x) / float(width - 1), float(y) / float(height - 1)); + const XMFLOAT2 uv = XMFLOAT2((float(x) + 0.5f) / float(width), (float(y) + 0.5f) / float(height)); const float uv_distance = wi::math::Clamp(XMVectorGetX(XMVector3Length(XMLoadFloat2(&uv) - a)), 0, distance); float gradient = wi::math::saturate(wi::math::InverseLerp(0, distance, uv_distance)); if (has_flag(flags, GradientFlags::Inverse)) @@ -411,7 +395,7 @@ namespace wi::texturehelper { for (uint32_t x = 0; x < width; ++x) { - const XMFLOAT2 uv = XMFLOAT2(float(x) / float(width - 1), float(y) / float(height - 1)); + const XMFLOAT2 uv = XMFLOAT2((float(x) + 0.5f) / float(width), (float(y) + 0.5f) / float(height)); const XMFLOAT2 coord = XMFLOAT2(uv.x - uv_start.x, uv.y - uv_start.y); float gradient = wi::math::GetAngle(direction, coord) / XM_2PI; if (has_flag(flags, GradientFlags::Inverse)) @@ -467,7 +451,7 @@ namespace wi::texturehelper { for (uint32_t x = 0; x < width; ++x) { - const XMFLOAT2 coord = XMFLOAT2(float(x) / float(width - 1) * 2 - 1, -(float(y) / float(height - 1) * 2 - 1)); + const XMFLOAT2 coord = XMFLOAT2((float(x) + 0.5f) / float(width) * 2 - 1, -((float(y) + 0.5f) / float(height) * 2 - 1)); float gradient = wi::math::GetAngle(direction, coord) / XM_2PI; if (counter_clockwise) { diff --git a/WickedEngine/wiTrailRenderer.cpp b/WickedEngine/wiTrailRenderer.cpp new file mode 100644 index 00000000000..a6fce6521ab --- /dev/null +++ b/WickedEngine/wiTrailRenderer.cpp @@ -0,0 +1,338 @@ +#include "wiTrailRenderer.h" +#include "wiEventHandler.h" +#include "wiBacklog.h" +#include "wiTimer.h" +#include "wiRenderer.h" +#include "wiTextureHelper.h" +#include "wiScene.h" + +using namespace wi::graphics; +using namespace wi::enums; +using namespace wi::scene; + +namespace wi +{ + static Shader vertexShader; + static Shader pixelShader; + static InputLayout inputLayout; + static BlendState blendStates[BLENDMODE_COUNT]; + static RasterizerState rasterizerState; + static RasterizerState wireFrameRS; + static DepthStencilState depthStencilState; + static PipelineState PSO[BLENDMODE_COUNT]; + static PipelineState PSO_wire; + + void TrailRenderer::Cut() + { + if (points.empty()) + return; + if (cuts.empty() || cuts.back() != points.size()) + { + cuts.push_back((uint32_t)points.size()); + } + } + + void TrailRenderer::Draw(const CameraComponent& camera, CommandList cmd) const + { + if (points.size() < 2) + return; + + GraphicsDevice* device = GetDevice(); + + device->EventBegin("TrailRenderer", cmd); + + if (wi::renderer::IsWireRender()) + { + device->BindPipelineState(&PSO_wire, cmd); + } + else + { + device->BindPipelineState(&PSO[blendMode], cmd); + } + + TrailRendererCB sb = {}; + sb.g_xTrailTransform = camera.VP; + sb.g_xTrailColor = color; + sb.g_xTrailTexMulAdd = texMulAdd; + sb.g_xTrailTexMulAdd2 = texMulAdd2; + sb.g_xTrailDepthSoften = 1.0f / (width * 10); + sb.g_xTrailTextureIndex1 = device->GetDescriptorIndex(texture.IsValid() ? &texture : wi::texturehelper::getWhite(), SubresourceType::SRV); + sb.g_xTrailTextureIndex2 = device->GetDescriptorIndex(texture2.IsValid() ? &texture : wi::texturehelper::getWhite(), SubresourceType::SRV); + sb.g_xTrailLinearDepthTextureIndex = camera.texture_lineardepth_index; + sb.g_xTrailCameraFar = camera.zFarP; + device->BindDynamicConstantBuffer(sb, CBSLOT_TRAILRENDERER, cmd); + + struct Vertex + { + XMFLOAT3 position; + uint16_t uvx; + uint16_t uvy; + XMHALF4 color; + }; + + uint32_t num_cuts = uint32_t(cuts.size()); + if (num_cuts == 0) + { + num_cuts += 1; // there were no cuts + } + if (!cuts.empty() && cuts.back() != (uint32_t)points.size()) + { + num_cuts += 1; // when last segment was not indicated with cut + } + const uint32_t num_segments = uint32_t(points.size()) - num_cuts; + + const uint32_t subdivision = std::max(1u, this->subdivision); + const uint32_t vertexCountAlloc = (num_segments * subdivision + num_cuts) * 2; + + const uint32_t indexCountAlloc = num_segments * subdivision * 6; + + auto mem = device->AllocateGPU(sizeof(Vertex) * vertexCountAlloc + sizeof(uint32_t) * indexCountAlloc, cmd); + Vertex* vertices = (Vertex*)mem.data; + uint32_t* indices = (uint32_t*)(vertices + vertexCountAlloc); + + const float resolution_rcp = 1.0f / subdivision; + const XMVECTOR CAM = camera.GetEye(); + + uint32_t next_cut = 0; + + uint32_t vertexCount = 0; + uint32_t indexCount = 0; + + int i = 0; + while (next_cut <= cuts.size()) + { + int startcut = i; + int count = next_cut < cuts.size() ? cuts[next_cut] : (uint32_t)points.size(); + float subdiv_count_within_cut = float((count - 1 - startcut) * subdivision); + float subdiv_within_cut = 0; + + for (; i < count; ++i) + { + XMVECTOR P0 = XMLoadFloat3(&points[std::max(startcut, std::min(i - 1, count - 1))].position); + XMVECTOR P1 = XMLoadFloat3(&points[std::max(startcut, std::min(i, count - 1))].position); + XMVECTOR P2 = XMLoadFloat3(&points[std::max(startcut, std::min(i + 1, count - 1))].position); + XMVECTOR P3 = XMLoadFloat3(&points[std::max(startcut, std::min(i + 2, count - 1))].position); + + float width_current = points[i].width; + float width_next = points[std::min(i + 1, count - 1)].width; + + XMFLOAT4 color_current = points[i].color; + XMFLOAT4 color_next = points[std::min(i + 1, count - 1)].color; + + if (i == startcut) + { + // when P0 == P1, centripetal catmull doesn't work, so we have to do a dummy control point + P0 += P1 - P2; + } + if (i >= count - 2) + { + // when P2 == P3, centripetal catmull doesn't work, so we have to do a dummy control point + P3 += P2 - P1; + } + + bool cap = i == (count - 1); + uint32_t segment_resolution = cap ? 1 : subdivision; + + for (uint32_t j = 0; j < segment_resolution; ++j) + { + float t = float(j) / float(segment_resolution); + + XMVECTOR P = cap ? XMVectorLerp(P1, P2, t) : wi::math::CatmullRomCentripetal(P0, P1, P2, P3, t); + XMVECTOR P_prev = cap ? XMVectorLerp(P0, P1, t - resolution_rcp) : wi::math::CatmullRomCentripetal(P0, P1, P2, P3, t - resolution_rcp); + XMVECTOR P_next = cap ? XMVectorLerp(P1, P2, t + resolution_rcp) : wi::math::CatmullRomCentripetal(P0, P1, P2, P3, t + resolution_rcp); + float width_interpolated = wi::math::Lerp(width_current, width_next, t); + XMFLOAT4 color_interpolated = wi::math::Lerp(color_current, color_next, t); + + XMVECTOR T = XMVector3Normalize(P_next - P_prev); + XMVECTOR B = XMVector3Normalize(XMVector3Cross(T, P - CAM)); + B *= width_interpolated * width; + + if (!cap) + { + indices[indexCount++] = vertexCount; + indices[indexCount++] = vertexCount + 1; + indices[indexCount++] = vertexCount + 2; + indices[indexCount++] = vertexCount + 2; + indices[indexCount++] = vertexCount + 1; + indices[indexCount++] = vertexCount + 3; + } + + const float cut_percent = subdiv_within_cut / subdiv_count_within_cut; + subdiv_within_cut += 1; + + Vertex vert = {}; + vert.uvx = uint16_t(cut_percent * 65535); + vert.color.x = XMConvertFloatToHalf(color_interpolated.x); + vert.color.y = XMConvertFloatToHalf(color_interpolated.y); + vert.color.z = XMConvertFloatToHalf(color_interpolated.z); + vert.color.w = XMConvertFloatToHalf(color_interpolated.w); + + vert.uvy = 0; + XMStoreFloat3(&vert.position, XMVectorSetW(P - B, 1)); + std::memcpy(vertices + vertexCount, &vert, sizeof(vert)); + vertexCount++; + + vert.uvy = 65535; + XMStoreFloat3(&vert.position, XMVectorSetW(P + B, 1)); + std::memcpy(vertices + vertexCount, &vert, sizeof(vert)); + vertexCount++; + } + } + next_cut++; + } + assert(vertexCount == vertexCountAlloc); + assert(indexCount == indexCountAlloc); + + const GPUBuffer* vbs[] = { + &mem.buffer, + }; + const uint32_t strides[] = { + sizeof(Vertex), + }; + const uint64_t offsets[] = { + mem.offset, + }; + device->BindVertexBuffers(vbs, 0, arraysize(vbs), strides, offsets, cmd); + + device->BindIndexBuffer(&mem.buffer, IndexBufferFormat::UINT32, mem.offset + sizeof(Vertex) * vertexCountAlloc, cmd); + + device->DrawIndexed(indexCount, 0, 0, cmd); + + device->EventEnd(cmd); + } + + namespace TrailRenderer_Internal + { + void LoadShaders() + { + wi::renderer::LoadShader(ShaderStage::VS, vertexShader, "trailVS.cso"); + wi::renderer::LoadShader(ShaderStage::PS, pixelShader, "trailPS.cso"); + + inputLayout.elements = { + { "POSITION", 0, Format::R32G32B32_FLOAT, 0, InputLayout::APPEND_ALIGNED_ELEMENT, InputClassification::PER_VERTEX_DATA }, + { "TEXCOORD", 0, Format::R16G16_UNORM, 0, InputLayout::APPEND_ALIGNED_ELEMENT, InputClassification::PER_VERTEX_DATA }, + { "COLOR", 0, Format::R16G16B16A16_FLOAT, 0, InputLayout::APPEND_ALIGNED_ELEMENT, InputClassification::PER_VERTEX_DATA }, + }; + + GraphicsDevice* device = wi::graphics::GetDevice(); + + for (int i = 0; i < BLENDMODE_COUNT; ++i) + { + PipelineStateDesc desc; + desc.pt = PrimitiveTopology::TRIANGLELIST; + desc.vs = &vertexShader; + desc.ps = &pixelShader; + desc.il = &inputLayout; + desc.bs = &blendStates[i]; + desc.rs = &rasterizerState; + desc.dss = &depthStencilState; + device->CreatePipelineState(&desc, &PSO[i]); + } + + { + PipelineStateDesc desc; + desc.pt = PrimitiveTopology::TRIANGLELIST; + desc.vs = &vertexShader; + desc.ps = &pixelShader; + desc.il = &inputLayout; + desc.bs = &blendStates[BLENDMODE_ALPHA]; + desc.rs = &wireFrameRS; + desc.dss = &depthStencilState; + + device->CreatePipelineState(&desc, &PSO_wire); + } + } + } + void TrailRenderer::Initialize() + { + wi::Timer timer; + + RasterizerState rs; + rs.fill_mode = FillMode::SOLID; + rs.cull_mode = CullMode::NONE; + rs.front_counter_clockwise = true; + rs.depth_bias = 0; + rs.depth_bias_clamp = 0; + rs.slope_scaled_depth_bias = 0; + rs.depth_clip_enable = false; + rs.multisample_enable = false; + rs.antialiased_line_enable = false; + rasterizerState = rs; + + + rs.fill_mode = FillMode::WIREFRAME; + rs.cull_mode = CullMode::NONE; + rs.front_counter_clockwise = true; + rs.depth_bias = 0; + rs.depth_bias_clamp = 0; + rs.slope_scaled_depth_bias = 0; + rs.depth_clip_enable = false; + rs.multisample_enable = false; + rs.antialiased_line_enable = false; + wireFrameRS = rs; + + + DepthStencilState dsd; + dsd.depth_enable = true; + dsd.depth_write_mask = DepthWriteMask::ZERO; + dsd.depth_func = ComparisonFunc::GREATER_EQUAL; + dsd.stencil_enable = false; + depthStencilState = dsd; + + + BlendState bd; + bd.render_target[0].blend_enable = true; + bd.render_target[0].src_blend = Blend::SRC_ALPHA; + bd.render_target[0].dest_blend = Blend::INV_SRC_ALPHA; + bd.render_target[0].blend_op = BlendOp::ADD; + bd.render_target[0].src_blend_alpha = Blend::ONE; + bd.render_target[0].dest_blend_alpha = Blend::INV_SRC_ALPHA; + bd.render_target[0].blend_op_alpha = BlendOp::ADD; + bd.render_target[0].render_target_write_mask = ColorWrite::ENABLE_ALL; + bd.independent_blend_enable = false; + blendStates[BLENDMODE_ALPHA] = bd; + + bd.render_target[0].blend_enable = true; + bd.render_target[0].src_blend = Blend::SRC_ALPHA; + bd.render_target[0].dest_blend = Blend::ONE; + bd.render_target[0].blend_op = BlendOp::ADD; + bd.render_target[0].src_blend_alpha = Blend::ZERO; + bd.render_target[0].dest_blend_alpha = Blend::ONE; + bd.render_target[0].blend_op_alpha = BlendOp::ADD; + bd.render_target[0].render_target_write_mask = ColorWrite::ENABLE_ALL; + bd.independent_blend_enable = false; + blendStates[BLENDMODE_ADDITIVE] = bd; + + bd.render_target[0].blend_enable = true; + bd.render_target[0].src_blend = Blend::ONE; + bd.render_target[0].dest_blend = Blend::INV_SRC_ALPHA; + bd.render_target[0].blend_op = BlendOp::ADD; + bd.render_target[0].src_blend_alpha = Blend::ONE; + bd.render_target[0].dest_blend_alpha = Blend::ONE; + bd.render_target[0].blend_op_alpha = BlendOp::ADD; + bd.render_target[0].render_target_write_mask = ColorWrite::ENABLE_ALL; + bd.independent_blend_enable = false; + blendStates[BLENDMODE_PREMULTIPLIED] = bd; + + bd.render_target[0].src_blend = Blend::DEST_COLOR; + bd.render_target[0].dest_blend = Blend::ZERO; + bd.render_target[0].blend_op = BlendOp::ADD; + bd.render_target[0].src_blend_alpha = Blend::DEST_ALPHA; + bd.render_target[0].dest_blend_alpha = Blend::ZERO; + bd.render_target[0].blend_op_alpha = BlendOp::ADD; + bd.render_target[0].blend_enable = true; + bd.render_target[0].render_target_write_mask = ColorWrite::ENABLE_ALL; + bd.alpha_to_coverage_enable = false; + bd.independent_blend_enable = false; + blendStates[BLENDMODE_MULTIPLY] = bd; + + bd.render_target[0].blend_enable = false; + blendStates[BLENDMODE_OPAQUE] = bd; + + + static wi::eventhandler::Handle handle = wi::eventhandler::Subscribe(wi::eventhandler::EVENT_RELOAD_SHADERS, [](uint64_t userdata) { TrailRenderer_Internal::LoadShaders(); }); + TrailRenderer_Internal::LoadShaders(); + + wi::backlog::post("wi::TrailRenderer Initialized (" + std::to_string((int)std::round(timer.elapsed())) + " ms)"); + } +} diff --git a/WickedEngine/wiTrailRenderer.h b/WickedEngine/wiTrailRenderer.h new file mode 100644 index 00000000000..00518c96a63 --- /dev/null +++ b/WickedEngine/wiTrailRenderer.h @@ -0,0 +1,35 @@ +#pragma once +#include "CommonInclude.h" +#include "wiVector.h" +#include "wiGraphicsDevice.h" +#include "wiEnums.h" +#include "wiScene_Decl.h" + +namespace wi +{ + struct TrailRenderer + { + struct TrailPoint + { + XMFLOAT3 position = XMFLOAT3(0, 0, 0); + float width = 1; + XMFLOAT4 color = XMFLOAT4(1, 1, 1, 1); + }; + wi::vector points; + wi::vector cuts; + XMFLOAT4 color = XMFLOAT4(1, 1, 1, 1); + wi::enums::BLENDMODE blendMode = wi::enums::BLENDMODE_ALPHA; + uint32_t subdivision = 100; + float width = 1; + wi::graphics::Texture texture; + wi::graphics::Texture texture2; + XMFLOAT4 texMulAdd = XMFLOAT4(1, 1, 0, 0); + XMFLOAT4 texMulAdd2 = XMFLOAT4(1, 1, 0, 0); + + void Cut(); + + void Draw(const wi::scene::CameraComponent& camera, wi::graphics::CommandList cmd) const; + + static void Initialize(); + }; +} diff --git a/WickedEngine/wiTrailRenderer_BindLua.cpp b/WickedEngine/wiTrailRenderer_BindLua.cpp new file mode 100644 index 00000000000..cabbf144c2e --- /dev/null +++ b/WickedEngine/wiTrailRenderer_BindLua.cpp @@ -0,0 +1,311 @@ +#include "wiTrailRenderer_BindLua.h" +#include "wiMath_BindLua.h" +#include "wiTexture_BindLua.h" + +namespace wi::lua +{ + Luna::FunctionType TrailRenderer_BindLua::methods[] = { + lunamethod(TrailRenderer_BindLua, AddPoint), + lunamethod(TrailRenderer_BindLua, Cut), + lunamethod(TrailRenderer_BindLua, Clear), + lunamethod(TrailRenderer_BindLua, GetPointCount), + lunamethod(TrailRenderer_BindLua, GetPoint), + lunamethod(TrailRenderer_BindLua, SetPoint), + lunamethod(TrailRenderer_BindLua, SetBlendMode), + lunamethod(TrailRenderer_BindLua, GetBlendMode), + lunamethod(TrailRenderer_BindLua, SetSubdivision), + lunamethod(TrailRenderer_BindLua, GetSubdivision), + lunamethod(TrailRenderer_BindLua, SetWidth), + lunamethod(TrailRenderer_BindLua, GetWidth), + lunamethod(TrailRenderer_BindLua, SetColor), + lunamethod(TrailRenderer_BindLua, GetColor), + lunamethod(TrailRenderer_BindLua, SetTexture), + lunamethod(TrailRenderer_BindLua, GetTexture), + lunamethod(TrailRenderer_BindLua, SetTexture2), + lunamethod(TrailRenderer_BindLua, GetTexture2), + lunamethod(TrailRenderer_BindLua, SetTexMulAdd), + lunamethod(TrailRenderer_BindLua, GetTexMulAdd), + lunamethod(TrailRenderer_BindLua, SetTexMulAdd2), + lunamethod(TrailRenderer_BindLua, GetTexMulAdd2), + { NULL, NULL } + }; + Luna::PropertyType TrailRenderer_BindLua::properties[] = { + { NULL, NULL } + }; + + int TrailRenderer_BindLua::AddPoint(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "TrailRenderer::AddPoint(Vector pos, opt float width = 1, opt Vector color = Vector(1,1,1,1)) not enough arguments!"); + return 0; + } + Vector_BindLua* pos = Luna::lightcheck(L, 1); + if (pos == nullptr) + { + wi::lua::SError(L, "TrailRenderer::AddPoint(Vector pos, opt float width = 1, opt Vector color = Vector(1,1,1,1)) first argument is not a Vector!"); + return 0; + } + TrailRenderer::TrailPoint point; + point.position = pos->GetFloat3(); + + if (argc > 1) + { + point.width = wi::lua::SGetFloat(L, 2); + if (argc > 2) + { + Vector_BindLua* col = Luna::lightcheck(L, 3); + if (col == nullptr) + { + wi::lua::SError(L, "TrailRenderer::AddPoint(Vector pos, opt float width = 1, opt Vector color = Vector(1,1,1,1)) third argument is not a Vector!"); + } + else + { + point.color = col->data; + } + } + } + + trail.points.push_back(point); + return 0; + } + int TrailRenderer_BindLua::Cut(lua_State* L) + { + trail.Cut(); + return 0; + } + int TrailRenderer_BindLua::Clear(lua_State* L) + { + trail.points.clear(); + trail.cuts.clear(); + return 0; + } + int TrailRenderer_BindLua::GetPointCount(lua_State* L) + { + wi::lua::SSetInt(L, int(trail.points.size())); + return 1; + } + int TrailRenderer_BindLua::GetPoint(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + int index = wi::lua::SGetInt(L, 1); + if (index >= trail.points.size()) + { + wi::lua::SError(L, "TrailRenderer::GetPoint(int index): index out of range!"); + return 0; + } + auto& point = trail.points[index]; + Luna::push(L, point.position); + wi::lua::SSetFloat(L, point.width); + Luna::push(L, point.color); + return 3; + } + int TrailRenderer_BindLua::SetPoint(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 2) + { + wi::lua::SError(L, "TrailRenderer::SetPoint(int index, Vector pos, opt float width = 1, opt Vector color = Vector(1,1,1,1)): not enough arguments!"); + return 0; + } + Vector_BindLua* pos = Luna::lightcheck(L, 2); + if (pos == nullptr) + { + wi::lua::SError(L, "TrailRenderer::SetPoint(int index, Vector pos, opt float width = 1, opt Vector color = Vector(1,1,1,1)): second argument is not a Vector!"); + return 0; + } + int index = wi::lua::SGetInt(L, 1); + if (index >= trail.points.size()) + { + wi::lua::SError(L, "TrailRenderer::SetPoint(int index, Vector pos, opt float width = 1, opt Vector color = Vector(1,1,1,1)): index out of range!"); + return 0; + } + auto& point = trail.points[index]; + point.position = pos->GetFloat3(); + if (argc > 2) + { + point.width = wi::lua::SGetFloat(L, 3); + if (argc > 3) + { + Vector_BindLua* col = Luna::lightcheck(L, 4); + if (col == nullptr) + { + wi::lua::SError(L, "TrailRenderer::SetPoint(int index, Vector pos, opt float width = 1, opt Vector color = Vector(1,1,1,1)): fourth argument is not a Vector!"); + } + else + { + point.color = col->data; + } + } + } + return 0; + } + int TrailRenderer_BindLua::SetBlendMode(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "TrailRenderer::SetBlendMode(int blendmode): not enough arguments!"); + return 0; + } + trail.blendMode = (wi::enums::BLENDMODE)wi::lua::SGetInt(L, 1); + return 0; + } + int TrailRenderer_BindLua::GetBlendMode(lua_State* L) + { + wi::lua::SSetInt(L, (int)trail.blendMode); + return 1; + } + int TrailRenderer_BindLua::SetSubdivision(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "TrailRenderer::SetSubdivision(int subdiv): not enough arguments!"); + return 0; + } + trail.subdivision = (uint32_t)wi::lua::SGetInt(L, 1); + return 0; + } + int TrailRenderer_BindLua::GetSubdivision(lua_State* L) + { + wi::lua::SSetInt(L, (int)trail.subdivision); + return 1; + } + int TrailRenderer_BindLua::SetWidth(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "TrailRenderer::SetWidth(float width): not enough arguments!"); + return 0; + } + trail.width = wi::lua::SGetFloat(L, 1); + return 0; + } + int TrailRenderer_BindLua::GetWidth(lua_State* L) + { + wi::lua::SSetFloat(L, trail.width); + return 1; + } + int TrailRenderer_BindLua::SetColor(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "TrailRenderer::SetColor(Vector color): not enough arguments!"); + return 0; + } + Vector_BindLua* vec = Luna::lightcheck(L, 1); + if (vec == nullptr) + { + wi::lua::SError(L, "TrailRenderer::SetColor(Vector color): first argument is not a Vector!"); + return 0; + } + trail.color = vec->data; + return 0; + } + int TrailRenderer_BindLua::GetColor(lua_State* L) + { + Luna::push(L, trail.color); + return 1; + } + int TrailRenderer_BindLua::SetTexture(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "TrailRenderer::SetTexture(Texture tex): not enough arguments!"); + return 0; + } + Texture_BindLua* tex = Luna::lightcheck(L, 1); + if (tex == nullptr) + { + wi::lua::SError(L, "TrailRenderer::SetTexture(Texture tex): first argument is not a Texture!"); + return 0; + } + trail.texture = tex->resource.GetTexture(); + return 0; + } + int TrailRenderer_BindLua::GetTexture(lua_State* L) + { + wi::Resource res; + res.SetTexture(trail.texture); + Luna::push(L, res); + return 1; + } + int TrailRenderer_BindLua::SetTexture2(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "TrailRenderer::SetTexture2(Texture tex): not enough arguments!"); + return 0; + } + Texture_BindLua* tex = Luna::lightcheck(L, 1); + if (tex == nullptr) + { + wi::lua::SError(L, "TrailRenderer::SetTexture2(Texture tex): first argument is not a Texture!"); + return 0; + } + trail.texture2 = tex->resource.GetTexture(); + return 0; + } + int TrailRenderer_BindLua::GetTexture2(lua_State* L) + { + wi::Resource res; + res.SetTexture(trail.texture2); + Luna::push(L, res); + return 1; + } + int TrailRenderer_BindLua::SetTexMulAdd(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "TrailRenderer::SetTexMulAdd(Vector): not enough arguments!"); + return 0; + } + Vector_BindLua* vec = Luna::lightcheck(L, 1); + if (vec == nullptr) + { + wi::lua::SError(L, "TrailRenderer::SetTexMulAdd(Vector): first argument is not a Vector!"); + return 0; + } + trail.texMulAdd = vec->data; + return 0; + } + int TrailRenderer_BindLua::GetTexMulAdd(lua_State* L) + { + Luna::push(L, trail.texMulAdd); + return 1; + } + int TrailRenderer_BindLua::SetTexMulAdd2(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "TrailRenderer::SetTexMulAdd2(Vector): not enough arguments!"); + return 0; + } + Vector_BindLua* vec = Luna::lightcheck(L, 1); + if (vec == nullptr) + { + wi::lua::SError(L, "TrailRenderer::SetTexMulAdd2(Vector): first argument is not a Vector!"); + return 0; + } + trail.texMulAdd2 = vec->data; + return 0; + } + int TrailRenderer_BindLua::GetTexMulAdd2(lua_State* L) + { + Luna::push(L, trail.texMulAdd2); + return 1; + } + + void TrailRenderer_BindLua::Bind() + { + Luna::Register(wi::lua::GetLuaState()); + } +} diff --git a/WickedEngine/wiTrailRenderer_BindLua.h b/WickedEngine/wiTrailRenderer_BindLua.h new file mode 100644 index 00000000000..fe20323b57c --- /dev/null +++ b/WickedEngine/wiTrailRenderer_BindLua.h @@ -0,0 +1,48 @@ +#pragma once +#include "CommonInclude.h" +#include "wiLua.h" +#include "wiLuna.h" +#include "wiTrailRenderer.h" + +namespace wi::lua +{ + class TrailRenderer_BindLua + { + public: + wi::TrailRenderer trail; + + inline static constexpr char className[] = "TrailRenderer"; + static Luna::FunctionType methods[]; + static Luna::PropertyType properties[]; + + TrailRenderer_BindLua() = default; + TrailRenderer_BindLua(lua_State* L) {} + TrailRenderer_BindLua(wi::TrailRenderer& ref) : trail(ref) {} + TrailRenderer_BindLua(wi::TrailRenderer* ref) : trail(*ref) {} + + int AddPoint(lua_State* L); + int Cut(lua_State* L); + int Clear(lua_State* L); + int GetPointCount(lua_State* L); + int GetPoint(lua_State* L); + int SetPoint(lua_State* L); + int SetBlendMode(lua_State* L); + int GetBlendMode(lua_State* L); + int SetSubdivision(lua_State* L); + int GetSubdivision(lua_State* L); + int SetWidth(lua_State* L); + int GetWidth(lua_State* L); + int SetColor(lua_State* L); + int GetColor(lua_State* L); + int SetTexture(lua_State* L); + int GetTexture(lua_State* L); + int SetTexture2(lua_State* L); + int GetTexture2(lua_State* L); + int SetTexMulAdd(lua_State* L); + int GetTexMulAdd(lua_State* L); + int SetTexMulAdd2(lua_State* L); + int GetTexMulAdd2(lua_State* L); + + static void Bind(); + }; +} diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 95ed2231ff1..150d0a92cae 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wi::version // minor features, major updates, breaking compatibility changes const int minor = 71; // minor bug fixes, alterations, refactors, updates - const int revision = 381; + const int revision = 432; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision); @@ -50,72 +50,7 @@ All contributors: https://github.com/turanszkij/WickedEngine/graphs/contributors Patreon supporters --------------------------- -Nemerle -James Webb -Quifeng Jin -TheGameCreators -Joseph Goldin -Yuri -Sergey K -Yukawa Kanta -Dragon Josh -John -LurkingNinja -Bernardo Del Castillo -Invictus -Scott Hunt -Yazan Altaki -Tuan NV -Robert MacGregor -cybernescence -Alexander Dahlin -blueapples -Delhills -NI NI -Sherief -ktopoet -Justin Macklin -Cédric Fabre -TogetherTeam -Bartosz Boczula -Arne Koenig -Ivan Trajchev -nathants -Fahd Ahmed -Gabriel Jadderson -SAS_Controller -Dominik Madarász -Segfault -Mike amanfo -Dennis Brakhane -rookie -Peter Moore -therealjtgill -Nicolas Embleton -Desuuc -radino1977 -Anthony Curtis -manni heck -Matthias Hölzl -Phyffer -Lucas Pinheiro -Tapkaara -gpman -Anthony Python -Gnowos -Klaus -slaughternaut -Paul Brain -Connor Greaves -Alexandr -Lee Bamber -MCAlarm MC2 -Titoutan -Willow -Aldo -lokimx -K. Osterman -Nomad +Nemerle, James Webb, Quifeng Jin, TheGameCreators, Joseph Goldin, Yuri, Sergey K, Yukawa Kanta, Dragon Josh, John, LurkingNinja, Bernardo Del Castillo, Invictus, Scott Hunt, Yazan Altaki, Tuan NV, Robert MacGregor, cybernescence, Alexander Dahlin, blueapples, Delhills, NI NI, Sherief, ktopoet, Justin Macklin, Cédric Fabre, TogetherTeam, Bartosz Boczula, Arne Koenig, Ivan Trajchev, nathants, Fahd Ahmed, Gabriel Jadderson, SAS_Controller, Dominik Madarász, Segfault, Mike amanfo, Dennis Brakhane, rookie, Peter Moore, therealjtgill, Nicolas Embleton, Desuuc, radino1977, Anthony Curtis, manni heck, Matthias Hölzl, Phyffer, Lucas Pinheiro, Tapkaara, gpman, Anthony Python, Gnowos, Klaus, slaughternaut, Paul Brain, Connor Greaves, Alexandr, Lee Bamber, MCAlarm MC2, Titoutan, Willow, Aldo, lokimx, K. Osterman, Nomad, ykl, Alex Krokos, Timmy, Avaflow )"; return credits; diff --git a/WickedEngine/wiVoxelGrid.cpp b/WickedEngine/wiVoxelGrid.cpp new file mode 100644 index 00000000000..5b4fd233dd3 --- /dev/null +++ b/WickedEngine/wiVoxelGrid.cpp @@ -0,0 +1,782 @@ +#include "wiVoxelGrid.h" +#include "shaders/ShaderInterop.h" +#include "wiEventHandler.h" +#include "wiRenderer.h" + +using namespace wi::graphics; +using namespace wi::primitive; + +namespace wi +{ + void VoxelGrid::init(uint32_t dimX, uint32_t dimY, uint32_t dimZ) + { + resolution.x = std::max(4u, dimX); + resolution.y = std::max(4u, dimY); + resolution.z = std::max(4u, dimZ); + resolution_div4.x = (resolution.x + 3u) / 4u; + resolution_div4.y = (resolution.y + 3u) / 4u; + resolution_div4.z = (resolution.z + 3u) / 4u; + resolution_rcp.x = 1.0f / resolution.x; + resolution_rcp.y = 1.0f / resolution.y; + resolution_rcp.z = 1.0f / resolution.z; + voxels.clear(); + voxels.resize(resolution_div4.x * resolution_div4.y * resolution_div4.z); + } + void VoxelGrid::cleardata() + { + std::fill(voxels.begin(), voxels.end(), 0ull); + } + + // 3D array index to flattened 1D array index + inline uint flatten3D(uint3 coord, uint3 dim) + { + return (coord.z * dim.x * dim.y) + (coord.y * dim.x) + coord.x; + } + // flattened array index to 3D array index + inline uint3 unflatten3D(uint idx, uint3 dim) + { + const uint z = idx / (dim.x * dim.y); + idx -= (z * dim.x * dim.y); + const uint y = idx / dim.x; + const uint x = idx % dim.x; + return uint3(x, y, z); + } + + void VoxelGrid::inject_triangle(XMVECTOR A, XMVECTOR B, XMVECTOR C, bool subtract) + { + const XMVECTOR CENTER = XMLoadFloat3(¢er); + const XMVECTOR RESOLUTION = XMLoadUInt3(&resolution); + const XMVECTOR RESOLUTION_RCP = XMLoadFloat3(&resolution_rcp); + const XMVECTOR VOXELSIZE_RCP = XMLoadFloat3(&voxelSize_rcp); + + // world -> uvw space: + A = world_to_uvw(A, CENTER, RESOLUTION_RCP, VOXELSIZE_RCP); + B = world_to_uvw(B, CENTER, RESOLUTION_RCP, VOXELSIZE_RCP); + C = world_to_uvw(C, CENTER, RESOLUTION_RCP, VOXELSIZE_RCP); + + // pixel space: + A *= RESOLUTION; + B *= RESOLUTION; + C *= RESOLUTION; + + // Degenerate triangle check: + XMVECTOR Normal = XMVector3Cross(XMVectorSubtract(B, A), XMVectorSubtract(C, A)); + if (XMVector3Equal(Normal, XMVectorZero())) + return; + + XMVECTOR MIN = XMVectorMin(A, XMVectorMin(B, C)); + XMVECTOR MAX = XMVectorMax(A, XMVectorMax(B, C)); + + MIN = XMVectorFloor(MIN); + MAX = XMVectorCeiling(MAX + XMVectorSet(0.0001f, 0.0001f, 0.0001f, 0)); + + MIN = XMVectorMax(MIN, XMVectorZero()); + MAX = XMVectorMin(MAX, RESOLUTION); + + XMUINT3 mini, maxi; + XMStoreUInt3(&mini, MIN); + XMStoreUInt3(&maxi, MAX); + + volatile long long* data = (volatile long long*)voxels.data(); + for (uint32_t x = mini.x; x < maxi.x; ++x) + { + for (uint32_t y = mini.y; y < maxi.y; ++y) + { + for (uint32_t z = mini.z; z < maxi.z; ++z) + { + const DirectX::BoundingBox voxel_aabb(XMFLOAT3(x + 0.5f, y + 0.5f, z + 0.5f), XMFLOAT3(0.5f, 0.5f, 0.5f)); + if (voxel_aabb.Intersects(A, B, C)) + { + const uint3 macro_coord = uint3(x / 4u, y / 4u, z / 4u); + const uint3 sub_coord = uint3(x % 4u, y % 4u, z % 4u); + const uint32_t idx = flatten3D(macro_coord, resolution_div4); + const uint32_t bit = flatten3D(sub_coord, uint3(4, 4, 4)); + const uint64_t mask = 1ull << bit; + if (subtract) + { + AtomicAnd(data + idx, ~mask); + } + else + { + AtomicOr(data + idx, mask); + } + } + } + } + } + } + void VoxelGrid::inject_aabb(const wi::primitive::AABB& aabb, bool subtract) + { + const XMVECTOR CENTER = XMLoadFloat3(¢er); + const XMVECTOR RESOLUTION = XMLoadUInt3(&resolution); + const XMVECTOR RESOLUTION_RCP = XMLoadFloat3(&resolution_rcp); + const XMVECTOR VOXELSIZE_RCP = XMLoadFloat3(&voxelSize_rcp); + + XMVECTOR _MIN = XMLoadFloat3(&aabb._min); + XMVECTOR _MAX = XMLoadFloat3(&aabb._max); + + // world -> uvw space: + _MIN = world_to_uvw(_MIN, CENTER, RESOLUTION_RCP, VOXELSIZE_RCP); + _MAX = world_to_uvw(_MAX, CENTER, RESOLUTION_RCP, VOXELSIZE_RCP); + + // pixel space: + _MIN *= RESOLUTION; + _MAX *= RESOLUTION; + + // After changing spaces, need to minmax again: + XMVECTOR MIN = XMVectorMin(_MIN, _MAX); + XMVECTOR MAX = XMVectorMax(_MIN, _MAX); + + MIN = XMVectorFloor(MIN); + MAX = XMVectorCeiling(MAX + XMVectorSet(0.0001f, 0.0001f, 0.0001f, 0)); + + MIN = XMVectorMax(MIN, XMVectorZero()); + MAX = XMVectorMin(MAX, RESOLUTION); + + XMUINT3 mini, maxi; + XMStoreUInt3(&mini, MIN); + XMStoreUInt3(&maxi, MAX); + + wi::primitive::AABB aabb_src; + XMStoreFloat3(&aabb_src._min, MIN); + XMStoreFloat3(&aabb_src._max, MAX); + + volatile long long* data = (volatile long long*)voxels.data(); + for (uint32_t x = mini.x; x < maxi.x; ++x) + { + for (uint32_t y = mini.y; y < maxi.y; ++y) + { + for (uint32_t z = mini.z; z < maxi.z; ++z) + { + const uint3 macro_coord = uint3(x / 4u, y / 4u, z / 4u); + const uint3 sub_coord = uint3(x % 4u, y % 4u, z % 4u); + const uint32_t idx = flatten3D(macro_coord, resolution_div4); + const uint32_t bit = flatten3D(sub_coord, uint3(4, 4, 4)); + const uint64_t mask = 1ull << bit; + if (subtract) + { + AtomicAnd(data + idx, ~mask); + } + else + { + AtomicOr(data + idx, mask); + } + } + } + } + } + void VoxelGrid::inject_sphere(const wi::primitive::Sphere& sphere, bool subtract) + { + const XMVECTOR CENTER = XMLoadFloat3(¢er); + const XMVECTOR RESOLUTION = XMLoadUInt3(&resolution); + const XMVECTOR RESOLUTION_RCP = XMLoadFloat3(&resolution_rcp); + const XMVECTOR VOXELSIZE_RCP = XMLoadFloat3(&voxelSize_rcp); + + AABB aabb; + aabb.createFromHalfWidth(sphere.center, XMFLOAT3(sphere.radius, sphere.radius, sphere.radius)); + + XMVECTOR _MIN = XMLoadFloat3(&aabb._min); + XMVECTOR _MAX = XMLoadFloat3(&aabb._max); + + // world -> uvw space: + _MIN = world_to_uvw(_MIN, CENTER, RESOLUTION_RCP, VOXELSIZE_RCP); + _MAX = world_to_uvw(_MAX, CENTER, RESOLUTION_RCP, VOXELSIZE_RCP); + + // pixel space: + _MIN *= RESOLUTION; + _MAX *= RESOLUTION; + + // After changing spaces, need to minmax again: + XMVECTOR MIN = XMVectorMin(_MIN, _MAX); + XMVECTOR MAX = XMVectorMax(_MIN, _MAX); + + MIN = XMVectorFloor(MIN); + MAX = XMVectorCeiling(MAX + XMVectorSet(0.0001f, 0.0001f, 0.0001f, 0)); + + MIN = XMVectorMax(MIN, XMVectorZero()); + MAX = XMVectorMin(MAX, RESOLUTION); + + XMUINT3 mini, maxi; + XMStoreUInt3(&mini, MIN); + XMStoreUInt3(&maxi, MAX); + + volatile long long* data = (volatile long long*)voxels.data(); + for (uint32_t x = mini.x; x < maxi.x; ++x) + { + for (uint32_t y = mini.y; y < maxi.y; ++y) + { + for (uint32_t z = mini.z; z < maxi.z; ++z) + { + wi::primitive::AABB voxel_aabb; + XMUINT3 voxel_center_coord = XMUINT3(x, y, z); + XMFLOAT3 voxel_center_world = coord_to_world(voxel_center_coord); + voxel_aabb.createFromHalfWidth(voxel_center_world, voxelSize); + if (voxel_aabb.intersects(sphere)) + { + const uint3 macro_coord = uint3(x / 4u, y / 4u, z / 4u); + const uint3 sub_coord = uint3(x % 4u, y % 4u, z % 4u); + const uint32_t idx = flatten3D(macro_coord, resolution_div4); + const uint32_t bit = flatten3D(sub_coord, uint3(4, 4, 4)); + const uint64_t mask = 1ull << bit; + if (subtract) + { + AtomicAnd(data + idx, ~mask); + } + else + { + AtomicOr(data + idx, mask); + } + } + } + } + } + } + void VoxelGrid::inject_capsule(const wi::primitive::Capsule& capsule, bool subtract) + { + const XMVECTOR CENTER = XMLoadFloat3(¢er); + const XMVECTOR RESOLUTION = XMLoadUInt3(&resolution); + const XMVECTOR RESOLUTION_RCP = XMLoadFloat3(&resolution_rcp); + const XMVECTOR VOXELSIZE_RCP = XMLoadFloat3(&voxelSize_rcp); + + AABB aabb = capsule.getAABB(); + + XMVECTOR _MIN = XMLoadFloat3(&aabb._min); + XMVECTOR _MAX = XMLoadFloat3(&aabb._max); + + // world -> uvw space: + _MIN = world_to_uvw(_MIN, CENTER, RESOLUTION_RCP, VOXELSIZE_RCP); + _MAX = world_to_uvw(_MAX, CENTER, RESOLUTION_RCP, VOXELSIZE_RCP); + + // pixel space: + _MIN *= RESOLUTION; + _MAX *= RESOLUTION; + + // After changing spaces, need to minmax again: + XMVECTOR MIN = XMVectorMin(_MIN, _MAX); + XMVECTOR MAX = XMVectorMax(_MIN, _MAX); + + MIN = XMVectorFloor(MIN); + MAX = XMVectorCeiling(MAX + XMVectorSet(0.0001f, 0.0001f, 0.0001f, 0)); + + MIN = XMVectorMax(MIN, XMVectorZero()); + MAX = XMVectorMin(MAX, RESOLUTION); + + XMUINT3 mini, maxi; + XMStoreUInt3(&mini, MIN); + XMStoreUInt3(&maxi, MAX); + + volatile long long* data = (volatile long long*)voxels.data(); + for (uint32_t x = mini.x; x < maxi.x; ++x) + { + for (uint32_t y = mini.y; y < maxi.y; ++y) + { + for (uint32_t z = mini.z; z < maxi.z; ++z) + { + wi::primitive::AABB voxel_aabb; + XMUINT3 voxel_center_coord = XMUINT3(x, y, z); + XMFLOAT3 voxel_center_world = coord_to_world(voxel_center_coord); + voxel_aabb.createFromHalfWidth(voxel_center_world, voxelSize); + // This capsule-box test can fail if capsule doesn't contain any of the corners or center, + // but it intersects with the cube. But for now this simple method is used. + bool intersects = capsule.intersects(voxel_aabb.getCenter()); + if (!intersects) + { + for (int c = 0; c < 8; ++c) + { + if (capsule.intersects(voxel_aabb.corner(c))) + { + intersects = true; + break; + } + } + } + if (intersects) + { + const uint3 macro_coord = uint3(x / 4u, y / 4u, z / 4u); + const uint3 sub_coord = uint3(x % 4u, y % 4u, z % 4u); + const uint32_t idx = flatten3D(macro_coord, resolution_div4); + const uint32_t bit = flatten3D(sub_coord, uint3(4, 4, 4)); + const uint64_t mask = 1ull << bit; + if (subtract) + { + AtomicAnd(data + idx, ~mask); + } + else + { + AtomicOr(data + idx, mask); + } + } + } + } + } + } + + XMUINT3 VoxelGrid::world_to_coord(const XMFLOAT3& worldpos) const + { + XMUINT3 coord; + XMStoreUInt3(&coord, world_to_uvw(XMLoadFloat3(&worldpos), XMLoadFloat3(¢er), XMLoadFloat3(&resolution_rcp), XMLoadFloat3(&voxelSize_rcp)) * XMLoadUInt3(&resolution)); + return coord; + } + XMINT3 VoxelGrid::world_to_coord_signed(const XMFLOAT3& worldpos) const + { + XMFLOAT3 coord; + XMStoreFloat3(&coord, world_to_uvw(XMLoadFloat3(&worldpos), XMLoadFloat3(¢er), XMLoadFloat3(&resolution_rcp), XMLoadFloat3(&voxelSize_rcp)) * XMLoadUInt3(&resolution)); + return XMINT3((int)coord.x, (int)coord.y, (int)coord.z); + } + XMFLOAT3 VoxelGrid::coord_to_world(const XMUINT3& coord) const + { + XMFLOAT3 worldpos; + XMStoreFloat3(&worldpos, uvw_to_world((XMLoadUInt3(&coord) + XMVectorReplicate(0.5f)) * XMLoadFloat3(&resolution_rcp), XMLoadFloat3(¢er), XMLoadUInt3(&resolution), XMLoadFloat3(&voxelSize))); + return worldpos; + } + bool VoxelGrid::check_voxel(const XMUINT3& coord) const + { + if (!is_coord_valid(coord)) + return false; // early exit when coord is not valid (outside of resolution) + const uint3 macro_coord = uint3(coord.x / 4u, coord.y / 4u, coord.z / 4u); + const uint idx = flatten3D(macro_coord, resolution_div4); + const uint64_t voxels_4x4_block = voxels[idx]; + if (voxels_4x4_block == 0) + return false; // early exit when whole block is empty + uint3 sub_coord; + sub_coord.x = coord.x % 4u; + sub_coord.y = coord.y % 4u; + sub_coord.z = coord.z % 4u; + const uint bit = flatten3D(sub_coord, uint3(4, 4, 4)); + const uint64_t mask = 1ull << bit; + return (voxels_4x4_block & mask) != 0ull; + } + bool VoxelGrid::check_voxel(const XMFLOAT3& worldpos) const + { + return check_voxel(world_to_coord(worldpos)); + } + bool VoxelGrid::is_coord_valid(const XMUINT3& coord) const + { + return coord.x < resolution.x && coord.y < resolution.y && coord.z < resolution.z; + } + void VoxelGrid::set_voxel(const XMUINT3& coord, bool value) + { + if (!is_coord_valid(coord)) + return; // early exit when coord is not valid (outside of resolution) + const uint3 macro_coord = uint3(coord.x / 4u, coord.y / 4u, coord.z / 4u); + const uint3 sub_coord = uint3(coord.x % 4u, coord.y % 4u, coord.z % 4u); + const uint idx = flatten3D(macro_coord, resolution_div4); + const uint bit = flatten3D(sub_coord, uint3(4, 4, 4)); + const uint64_t mask = 1ull << bit; + if (value) + { + voxels[idx] |= mask; + } + else + { + voxels[idx] &= ~mask; + } + } + void VoxelGrid::set_voxel(const XMFLOAT3& worldpos, bool value) + { + set_voxel(world_to_coord(worldpos), value); + } + size_t VoxelGrid::get_memory_size() const + { + return voxels.size() * sizeof(uint64_t); + } + + void VoxelGrid::set_voxelsize(float size) + { + set_voxelsize(XMFLOAT3(size, size, size)); + } + void VoxelGrid::set_voxelsize(const XMFLOAT3& size) + { + voxelSize = size; + voxelSize_rcp.x = 1.0f / voxelSize.x; + voxelSize_rcp.y = 1.0f / voxelSize.y; + voxelSize_rcp.z = 1.0f / voxelSize.z; + } + + wi::primitive::AABB VoxelGrid::get_aabb() const + { + AABB aabb; + aabb.createFromHalfWidth(center, XMFLOAT3(resolution.x * voxelSize.x, resolution.y * voxelSize.y, resolution.z * voxelSize.z)); + return aabb; + } + void VoxelGrid::from_aabb(const wi::primitive::AABB& aabb) + { + center = aabb.getCenter(); + XMFLOAT3 halfwidth = aabb.getHalfWidth(); + set_voxelsize(XMFLOAT3(halfwidth.x / resolution.x, halfwidth.y / resolution.y, halfwidth.z / resolution.z)); + } + + bool VoxelGrid::is_visible(const XMUINT3& start, const XMUINT3& goal) const + { + const int dx = int(goal.x) - int(start.x); + const int dy = int(goal.y) - int(start.y); + const int dz = int(goal.z) - int(start.z); + + const int step = std::max(std::abs(dx), std::max(std::abs(dy), std::abs(dz))); + + const float x_incr = float(dx) / step; + const float y_incr = float(dy) / step; + const float z_incr = float(dz) / step; + + float x = float(start.x); + float y = float(start.y); + float z = float(start.z); + +#ifdef DEBUG_VOXEL_OCCLUSION + debug_subject_coords.push_back(goal); +#endif // DEBUG_VOXEL_OCCLUSION + + for (int i = 0; i < step; i++) + { + XMUINT3 coord = XMUINT3(uint32_t(std::round(x)), uint32_t(std::round(y)), uint32_t(std::round(z))); + if (coord.x == goal.x && coord.y == goal.y && coord.z == goal.z) + return true; + if (check_voxel(coord)) + { +#ifdef DEBUG_VOXEL_OCCLUSION + debug_occluded_coords.push_back(coord); +#endif // DEBUG_VOXEL_OCCLUSION + return false; + } +#ifdef DEBUG_VOXEL_OCCLUSION + debug_visible_coords.push_back(coord); +#endif // DEBUG_VOXEL_OCCLUSION + x += x_incr; + y += y_incr; + z += z_incr; + } + return true; + } + bool VoxelGrid::is_visible(const XMFLOAT3& observer, const XMFLOAT3& subject) const + { + XMUINT3 start = world_to_coord(observer); + XMUINT3 goal = world_to_coord(subject); + return is_visible(start, goal); + } + bool VoxelGrid::is_visible(const XMFLOAT3& observer, const AABB& subject) const + { + XMUINT3 start = world_to_coord(observer); + + const XMVECTOR CENTER = XMLoadFloat3(¢er); + const XMVECTOR RESOLUTION = XMLoadUInt3(&resolution); + const XMVECTOR RESOLUTION_RCP = XMLoadFloat3(&resolution_rcp); + const XMVECTOR VOXELSIZE_RCP = XMLoadFloat3(&voxelSize_rcp); + + XMVECTOR _MIN = XMLoadFloat3(&subject._min); + XMVECTOR _MAX = XMLoadFloat3(&subject._max); + + // world -> uvw space: + _MIN = world_to_uvw(_MIN, CENTER, RESOLUTION_RCP, VOXELSIZE_RCP); + _MAX = world_to_uvw(_MAX, CENTER, RESOLUTION_RCP, VOXELSIZE_RCP); + + // pixel space: + _MIN *= RESOLUTION; + _MAX *= RESOLUTION; + + // After changing spaces, need to minmax again: + XMVECTOR MIN = XMVectorMin(_MIN, _MAX); + XMVECTOR MAX = XMVectorMax(_MIN, _MAX); + + MIN = XMVectorFloor(MIN); + MAX = XMVectorCeiling(MAX + XMVectorSet(0.0001f, 0.0001f, 0.0001f, 0)); + + MIN = XMVectorMax(MIN, XMVectorZero()); + MAX = XMVectorMin(MAX, RESOLUTION); + + XMUINT3 mini, maxi; + XMStoreUInt3(&mini, MIN); + XMStoreUInt3(&maxi, MAX); + + wi::primitive::AABB aabb_src; + XMStoreFloat3(&aabb_src._min, MIN); + XMStoreFloat3(&aabb_src._max, MAX); + +#ifdef DEBUG_VOXEL_OCCLUSION + // In debug mode we visualize all tests and don't return early + bool result = false; + debug_subject_coords.clear(); + debug_occluded_coords.clear(); + debug_visible_coords.clear(); + for (uint32_t x = mini.x; x < maxi.x; ++x) + { + for (uint32_t y = mini.y; y < maxi.y; ++y) + { + for (uint32_t z = mini.z; z < maxi.z; ++z) + { + XMUINT3 goal = XMUINT3(x, y, z); + if (is_visible(start, goal)) + { + result = true; + } + } + } + } + return result; +#else + for (uint32_t x = mini.x; x < maxi.x; ++x) + { + for (uint32_t y = mini.y; y < maxi.y; ++y) + { + for (uint32_t z = mini.z; z < maxi.z; ++z) + { + XMUINT3 goal = XMUINT3(x, y, z); + if (is_visible(start, goal)) + { + return true; + } + } + } + } + return false; +#endif // DEBUG_VOXEL_OCCLUSION + } + + void VoxelGrid::add(const VoxelGrid& other) + { + if (voxels.size() != other.voxels.size()) + { + assert(0); + return; + } + for (size_t i = 0; i < voxels.size(); ++i) + { + voxels[i] |= other.voxels[i]; + } + } + void VoxelGrid::subtract(const VoxelGrid& other) + { + if (voxels.size() != other.voxels.size()) + { + assert(0); + return; + } + for (size_t i = 0; i < voxels.size(); ++i) + { + voxels[i] &= ~other.voxels[i]; + } + } + + void VoxelGrid::Serialize(wi::Archive& archive, wi::ecs::EntitySerializer& seri) + { + if (archive.IsReadMode()) + { + archive >> _flags; + archive >> voxels; + archive >> resolution; + archive >> voxelSize; + archive >> center; + archive >> debug_color; + archive >> debug_color_extent; + + resolution_div4.x = (resolution.x + 3u) / 4u; + resolution_div4.y = (resolution.y + 3u) / 4u; + resolution_div4.z = (resolution.z + 3u) / 4u; + resolution_rcp.x = 1.0f / resolution.x; + resolution_rcp.y = 1.0f / resolution.y; + resolution_rcp.z = 1.0f / resolution.z; + set_voxelsize(voxelSize); + } + else + { + archive << _flags; + archive << voxels; + archive << resolution; + archive << voxelSize; + archive << center; + archive << debug_color; + archive << debug_color_extent; + } + } + + namespace VoxelGrid_internal + { + PipelineState pso; + static void LoadShaders() + { + PipelineStateDesc desc; + desc.vs = wi::renderer::GetShader(wi::enums::VSTYPE_VERTEXCOLOR); + desc.ps = wi::renderer::GetShader(wi::enums::PSTYPE_VERTEXCOLOR); + desc.il = wi::renderer::GetInputLayout(wi::enums::ILTYPE_VERTEXCOLOR); + desc.dss = wi::renderer::GetDepthStencilState(wi::enums::DSSTYPE_DEPTHREAD); + desc.rs = wi::renderer::GetRasterizerState(wi::enums::RSTYPE_FRONT); + desc.bs = wi::renderer::GetBlendState(wi::enums::BSTYPE_ADDITIVE); + desc.pt = PrimitiveTopology::TRIANGLELIST; + + GraphicsDevice* device = GetDevice(); + device->CreatePipelineState(&desc, &pso); + } + } + using namespace VoxelGrid_internal; + + void VoxelGrid::debugdraw(const XMFLOAT4X4& ViewProjection, CommandList cmd) const + { + // add box renderer for whole volume: + XMFLOAT4X4 boxmat; + XMStoreFloat4x4(&boxmat, get_aabb().getAsBoxMatrix()); + wi::renderer::DrawBox(boxmat, debug_color_extent); + + // Add a cube for every filled voxel below: + uint32_t numVoxels = 0; + for (auto& x : voxels) + { + if (x != 0) + numVoxels += (uint32_t)countbits(x); + } +#ifdef DEBUG_VOXEL_OCCLUSION + numVoxels += uint32_t(debug_subject_coords.size() + debug_visible_coords.size() + debug_occluded_coords.size()); +#endif // DEBUG_VOXEL_OCCLUSION + if (numVoxels == 0) + return; + + static bool shaders_loaded = false; + if (!shaders_loaded) + { + shaders_loaded = true; + static wi::eventhandler::Handle handle = wi::eventhandler::Subscribe(wi::eventhandler::EVENT_RELOAD_SHADERS, [](uint64_t userdata) { LoadShaders(); }); + LoadShaders(); + } + + struct Vertex + { + XMFLOAT4 position; + XMFLOAT4 color; + }; + static constexpr Vertex cubeVerts[] = { + {XMFLOAT4(-1,1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,-1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,-1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,-1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,-1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,-1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,-1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,-1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,-1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,-1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,-1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,-1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,-1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,-1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,-1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,-1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,-1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,-1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,-1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,1,-1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(1,1,1,1), XMFLOAT4(1,1,1,1)}, + {XMFLOAT4(-1,1,-1,1), XMFLOAT4(1,1,1,1)}, + }; + + GraphicsDevice* device = GetDevice(); + + auto mem = device->AllocateGPU(sizeof(cubeVerts) * numVoxels, cmd); + + const XMVECTOR CENTER = XMLoadFloat3(¢er); + const XMVECTOR RESOLUTION = XMLoadUInt3(&resolution); + const XMVECTOR RESOLUTION_RCP = XMLoadFloat3(&resolution_rcp); + const XMVECTOR VOXELSIZE = XMLoadFloat3(&voxelSize); + const XMVECTOR VOXELSIZE_RCP = XMLoadFloat3(&voxelSize_rcp); + + size_t dst_offset = 0; + for (size_t i = 0; i < voxels.size(); ++i) + { + uint64_t voxel_bits = voxels[i]; + if (voxel_bits == 0) + continue; + const uint3 coord = unflatten3D(uint(i), resolution_div4); + while (voxel_bits != 0) + { + unsigned long bit_index = firstbitlow(voxel_bits); + voxel_bits ^= 1ull << bit_index; // remove current bit + const uint3 sub_coord = unflatten3D(bit_index, uint3(4, 4, 4)); + XMVECTOR uvw = XMVectorSet(coord.x * 4 + sub_coord.x + 0.5f, coord.y * 4 + sub_coord.y + 0.5f, coord.z * 4 + sub_coord.z + 0.5f, 1) * RESOLUTION_RCP; + XMVECTOR P = uvw_to_world(uvw, CENTER, RESOLUTION, VOXELSIZE); + Vertex verts[arraysize(cubeVerts)]; + std::memcpy(verts, cubeVerts, sizeof(cubeVerts)); + for (auto& v : verts) + { + XMVECTOR C = XMLoadFloat4(&v.position); + C *= VOXELSIZE; + C += P; + C = XMVectorSetW(C, 1); + XMStoreFloat4(&v.position, C); + v.color = debug_color; + } + std::memcpy((uint8_t*)mem.data + dst_offset, verts, sizeof(verts)); + dst_offset += sizeof(verts); + } + } + +#ifdef DEBUG_VOXEL_OCCLUSION + auto dbg_voxel = [&](const XMUINT3& coord, const XMFLOAT4& color) { + XMFLOAT3 pos = coord_to_world(coord); + XMVECTOR P = XMLoadFloat3(&pos); + Vertex verts[arraysize(cubeVerts)]; + std::memcpy(verts, cubeVerts, sizeof(cubeVerts)); + for (auto& v : verts) + { + XMVECTOR C = XMLoadFloat4(&v.position); + C *= VOXELSIZE; + C += P; + C = XMVectorSetW(C, 1); + XMStoreFloat4(&v.position, C); + v.color = color; + } + std::memcpy((uint8_t*)mem.data + dst_offset, verts, sizeof(verts)); + dst_offset += sizeof(verts); + }; + for (auto& coord : debug_subject_coords) + { + dbg_voxel(coord, XMFLOAT4(1, 1, 1, 0.25f)); + } + debug_subject_coords.clear(); + for (auto& coord : debug_visible_coords) + { + dbg_voxel(coord, XMFLOAT4(1, 1, 0, 0.125f)); + } + debug_visible_coords.clear(); + for (auto& coord : debug_occluded_coords) + { + dbg_voxel(coord, XMFLOAT4(1, 0, 0, 0.5f)); + } + debug_occluded_coords.clear(); +#endif // DEBUG_VOXEL_OCCLUSION + + device->EventBegin("VoxelGrid::debugdraw", cmd); + device->BindPipelineState(&pso, cmd); + + const GPUBuffer* vbs[] = { + &mem.buffer, + }; + const uint32_t strides[] = { + sizeof(Vertex), + }; + const uint64_t offsets[] = { + mem.offset, + }; + device->BindVertexBuffers(vbs, 0, arraysize(vbs), strides, offsets, cmd); + + MiscCB sb; + sb.g_xTransform = ViewProjection; + sb.g_xColor = XMFLOAT4(1, 1, 1, 1); + device->BindDynamicConstantBuffer(sb, CBSLOT_RENDERER_MISC, cmd); + + device->Draw(arraysize(cubeVerts) * numVoxels, 0, cmd); + + device->EventEnd(cmd); + } + +} diff --git a/WickedEngine/wiVoxelGrid.h b/WickedEngine/wiVoxelGrid.h new file mode 100644 index 00000000000..0773e2e2332 --- /dev/null +++ b/WickedEngine/wiVoxelGrid.h @@ -0,0 +1,86 @@ +#pragma once +#include "CommonInclude.h" +#include "wiVector.h" +#include "wiMath.h" +#include "wiPrimitive.h" +#include "wiGraphicsDevice.h" +#include "wiArchive.h" +#include "wiECS.h" + +namespace wi +{ + struct VoxelGrid + { + enum FLAGS + { + EMPTY = 0, + }; + uint32_t _flags = EMPTY; + + XMUINT3 resolution = XMUINT3(0, 0, 0); + XMUINT3 resolution_div4 = XMUINT3(0, 0, 0); + XMFLOAT3 resolution_rcp = XMFLOAT3(0, 0, 0); + wi::vector voxels; // 1 array element stores 4 * 4 * 4 = 64 voxels + + XMFLOAT3 center = XMFLOAT3(0, 0, 0); + XMFLOAT3 voxelSize = XMFLOAT3(0.25f, 0.25f, 0.25f); + XMFLOAT3 voxelSize_rcp = XMFLOAT3(1.0f / 0.25f, 1.0f / 0.25f, 1.0f / 0.25f); + + XMFLOAT4 debug_color = XMFLOAT4(0.4f, 1, 0.2f, 0.1f); // color of voxels in debug + XMFLOAT4 debug_color_extent = XMFLOAT4(1, 1, 0.2f, 1); // color of extent box in debug + + void init(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + void cleardata(); + void inject_triangle(XMVECTOR A, XMVECTOR B, XMVECTOR C, bool subtract = false); + void inject_aabb(const wi::primitive::AABB& aabb, bool subtract = false); + void inject_sphere(const wi::primitive::Sphere& sphere, bool subtract = false); + void inject_capsule(const wi::primitive::Capsule& capsule, bool subtract = false); + XMUINT3 world_to_coord(const XMFLOAT3& worldpos) const; + XMINT3 world_to_coord_signed(const XMFLOAT3& worldpos) const; + XMFLOAT3 coord_to_world(const XMUINT3& coord) const; + bool check_voxel(const XMUINT3& coord) const; + bool check_voxel(const XMFLOAT3& worldpos) const; + bool is_coord_valid(const XMUINT3& coord) const; + void set_voxel(const XMUINT3& coord, bool value); + void set_voxel(const XMFLOAT3& worldpos, bool value); + size_t get_memory_size() const; + void set_voxelsize(float size); + void set_voxelsize(const XMFLOAT3& size); + wi::primitive::AABB get_aabb() const; + void from_aabb(const wi::primitive::AABB& aabb); + bool is_visible(const XMUINT3& observer, const XMUINT3& subject) const; + bool is_visible(const XMFLOAT3& observer, const XMFLOAT3& subject) const; + bool is_visible(const XMFLOAT3& observer, const wi::primitive::AABB& subject) const; + void add(const VoxelGrid& other); + void subtract(const VoxelGrid& other); + void debugdraw(const XMFLOAT4X4& ViewProjection, wi::graphics::CommandList cmd) const; + + inline bool IsValid() const { return !voxels.empty(); } + + void Serialize(wi::Archive& archive, wi::ecs::EntitySerializer& seri); + + inline static XMVECTOR XM_CALLCONV world_to_uvw(XMVECTOR P, XMVECTOR center, XMVECTOR resolution_rcp, XMVECTOR voxelSize_rcp) + { + XMVECTOR diff = (P - center) * resolution_rcp * voxelSize_rcp; + XMVECTOR uvw = diff * XMVectorSet(0.5f, -0.5f, 0.5f, 1) + XMVectorReplicate(0.5f); + return uvw; + } + inline static XMVECTOR XM_CALLCONV uvw_to_world(XMVECTOR uvw, XMVECTOR center, XMVECTOR resolution, XMVECTOR voxelSize) + { + XMVECTOR P = uvw * 2 - XMVectorReplicate(1); + P *= XMVectorSet(1, -1, 1, 1); + P *= voxelSize; + P *= resolution; + P += center; + return P; + } + +//#define DEBUG_VOXEL_OCCLUSION +#ifdef DEBUG_VOXEL_OCCLUSION + mutable wi::vector debug_subject_coords; + mutable wi::vector debug_visible_coords; + mutable wi::vector debug_occluded_coords; +#endif // DEBUG_VOXEL_OCCLUSION + }; + +} diff --git a/WickedEngine/wiVoxelGrid_BindLua.cpp b/WickedEngine/wiVoxelGrid_BindLua.cpp new file mode 100644 index 00000000000..b6477ad0650 --- /dev/null +++ b/WickedEngine/wiVoxelGrid_BindLua.cpp @@ -0,0 +1,446 @@ +#include "wiVoxelGrid_BindLua.h" +#include "wiMath_BindLua.h" +#include "wiPrimitive_BindLua.h" + +namespace wi::lua +{ + Luna::FunctionType VoxelGrid_BindLua::methods[] = { + lunamethod(VoxelGrid_BindLua, Init), + lunamethod(VoxelGrid_BindLua, ClearData), + lunamethod(VoxelGrid_BindLua, FromAABB), + lunamethod(VoxelGrid_BindLua, InjectTriangle), + lunamethod(VoxelGrid_BindLua, InjectAABB), + lunamethod(VoxelGrid_BindLua, InjectSphere), + lunamethod(VoxelGrid_BindLua, InjectCapsule), + lunamethod(VoxelGrid_BindLua, WorldToCoord), + lunamethod(VoxelGrid_BindLua, CoordToWorld), + lunamethod(VoxelGrid_BindLua, CheckVoxel), + lunamethod(VoxelGrid_BindLua, SetVoxel), + lunamethod(VoxelGrid_BindLua, GetCenter), + lunamethod(VoxelGrid_BindLua, SetCenter), + lunamethod(VoxelGrid_BindLua, GetVoxelSize), + lunamethod(VoxelGrid_BindLua, SetVoxelSize), + lunamethod(VoxelGrid_BindLua, GetDebugColor), + lunamethod(VoxelGrid_BindLua, SetDebugColor), + lunamethod(VoxelGrid_BindLua, GetDebugColorExtent), + lunamethod(VoxelGrid_BindLua, SetDebugColorExtent), + lunamethod(VoxelGrid_BindLua, GetMemorySize), + lunamethod(VoxelGrid_BindLua, Add), + lunamethod(VoxelGrid_BindLua, Subtract), + lunamethod(VoxelGrid_BindLua, IsVisible), + { NULL, NULL } + }; + Luna::PropertyType VoxelGrid_BindLua::properties[] = { + { NULL, NULL } + }; + + VoxelGrid_BindLua::VoxelGrid_BindLua(lua_State* L) + { + voxelgrid = &owning; + int argc = wi::lua::SGetArgCount(L); + if (argc >= 3) + { + Init(L); + } + } + + int VoxelGrid_BindLua::Init(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 3) + { + wi::lua::SError(L, "VoxelGrid::Init(int dimX,dimY,dimZ) not enough arguments!"); + return 0; + } + uint32_t x = (uint32_t)wi::lua::SGetInt(L, 1); + uint32_t y = (uint32_t)wi::lua::SGetInt(L, 2); + uint32_t z = (uint32_t)wi::lua::SGetInt(L, 3); + voxelgrid->init(x, y, z); + return 0; + } + int VoxelGrid_BindLua::ClearData(lua_State* L) + { + voxelgrid->cleardata(); + return 0; + } + int VoxelGrid_BindLua::FromAABB(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "VoxelGrid::FromAABB(AABB aabb) not enough arguments!"); + return 0; + } + primitive::AABB_BindLua* aabb = Luna::lightcheck(L, 1); + if (aabb == nullptr) + { + wi::lua::SError(L, "VoxelGrid::FromAABB(AABB aabb) argument is not an AABB!"); + return 0; + } + voxelgrid->from_aabb(aabb->aabb); + return 0; + } + int VoxelGrid_BindLua::InjectTriangle(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 3) + { + wi::lua::SError(L, "VoxelGrid::InjectTriangle(Vector a,b,c, opt bool subtract = false) not enough arguments!"); + return 0; + } + Vector_BindLua* a = Luna::lightcheck(L, 1); + if (a == nullptr) + { + wi::lua::SError(L, "VoxelGrid::InjectTriangle(Vector a,b,c, opt bool subtract = false) first argument is not a Vector!"); + return 0; + } + Vector_BindLua* b = Luna::lightcheck(L, 2); + if (a == nullptr) + { + wi::lua::SError(L, "VoxelGrid::InjectTriangle(Vector a,b,c, opt bool subtract = false) second argument is not a Vector!"); + return 0; + } + Vector_BindLua* c = Luna::lightcheck(L, 3); + if (a == nullptr) + { + wi::lua::SError(L, "VoxelGrid::InjectTriangle(Vector a,b,c, opt bool subtract = false) third argument is not a Vector!"); + return 0; + } + bool subtract = false; + if (argc > 3) + { + subtract = wi::lua::SGetBool(L, 4); + } + voxelgrid->inject_triangle(XMLoadFloat4(&a->data), XMLoadFloat4(&b->data), XMLoadFloat4(&c->data), subtract); + return 0; + } + int VoxelGrid_BindLua::InjectAABB(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "VoxelGrid::InjectAABB(AABB aabb, opt bool subtract = false) not enough arguments!"); + return 0; + } + primitive::AABB_BindLua* aabb = Luna::lightcheck(L, 1); + if (aabb == nullptr) + { + wi::lua::SError(L, "VoxelGrid::InjectAABB(AABB aabb, opt bool subtract = false) first argument is not a Vector!"); + return 0; + } + bool subtract = false; + if (argc > 1) + { + subtract = wi::lua::SGetBool(L, 2); + } + voxelgrid->inject_aabb(aabb->aabb, subtract); + return 0; + } + int VoxelGrid_BindLua::InjectSphere(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "VoxelGrid::InjectSphere(Sphere sphere, opt bool subtract = false) not enough arguments!"); + return 0; + } + primitive::Sphere_BindLua* sphere = Luna::lightcheck(L, 1); + if (sphere == nullptr) + { + wi::lua::SError(L, "VoxelGrid::InjectSphere(Sphere sphere, opt bool subtract = false) first argument is not a Vector!"); + return 0; + } + bool subtract = false; + if (argc > 1) + { + subtract = wi::lua::SGetBool(L, 2); + } + voxelgrid->inject_sphere(sphere->sphere, subtract); + return 0; + } + int VoxelGrid_BindLua::InjectCapsule(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "VoxelGrid::InjectCapsule(Capsule capsule, opt bool subtract = false) not enough arguments!"); + return 0; + } + primitive::Capsule_BindLua* capsule = Luna::lightcheck(L, 1); + if (capsule == nullptr) + { + wi::lua::SError(L, "VoxelGrid::InjectCapsule(Capsule capsule, opt bool subtract = false) first argument is not a Vector!"); + return 0; + } + bool subtract = false; + if (argc > 1) + { + subtract = wi::lua::SGetBool(L, 2); + } + voxelgrid->inject_capsule(capsule->capsule, subtract); + return 0; + } + int VoxelGrid_BindLua::WorldToCoord(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "VoxelGrid::WorldToCoord(Vector pos) not enough arguments!"); + return 0; + } + Vector_BindLua* pos = Luna::lightcheck(L, 1); + if (pos == nullptr) + { + wi::lua::SError(L, "VoxelGrid::WorldToCoord(Vector pos) first argument is not a Vector!"); + return 0; + } + XMUINT3 coord = voxelgrid->world_to_coord(pos->GetFloat3()); + wi::lua::SSetInt(L, int(coord.x)); + wi::lua::SSetInt(L, int(coord.y)); + wi::lua::SSetInt(L, int(coord.z)); + return 3; + } + int VoxelGrid_BindLua::CoordToWorld(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 3) + { + wi::lua::SError(L, "VoxelGrid::CoordToWorld(int x,y,z) not enough arguments!"); + return 0; + } + int x = wi::lua::SGetInt(L, 1); + int y = wi::lua::SGetInt(L, 2); + int z = wi::lua::SGetInt(L, 3); + Luna::push(L, voxelgrid->coord_to_world(XMUINT3(uint32_t(x), uint32_t(y), uint32_t(z)))); + return 1; + } + int VoxelGrid_BindLua::CheckVoxel(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "VoxelGrid::CheckVoxel(Vector pos) not enough arguments!"); + wi::lua::SError(L, "VoxelGrid::CheckVoxel(int x,y,z) not enough arguments!"); + return 0; + } + Vector_BindLua* pos = Luna::lightcheck(L, 1); + if (pos == nullptr) + { + if (argc < 3) + { + wi::lua::SError(L, "VoxelGrid::CheckVoxel(int x,y,z) not enough arguments!"); + return 0; + } + int x = wi::lua::SGetInt(L, 1); + int y = wi::lua::SGetInt(L, 2); + int z = wi::lua::SGetInt(L, 3); + wi::lua::SSetBool(L, voxelgrid->check_voxel(XMUINT3(uint32_t(x), uint32_t(y), uint32_t(z)))); + return 1; + } + wi::lua::SSetBool(L, voxelgrid->check_voxel(pos->GetFloat3())); + return 1; + } + int VoxelGrid_BindLua::SetVoxel(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 2) + { + wi::lua::SError(L, "VoxelGrid::SetVoxel(Vector pos, bool value) not enough arguments!"); + wi::lua::SError(L, "VoxelGrid::SetVoxel(int x,y,z, bool value) not enough arguments!"); + return 0; + } + Vector_BindLua* pos = Luna::lightcheck(L, 1); + if (pos == nullptr) + { + if (argc < 4) + { + wi::lua::SError(L, "VoxelGrid::SetVoxel(int x,y,z, bool value) not enough arguments!"); + return 0; + } + int x = wi::lua::SGetInt(L, 1); + int y = wi::lua::SGetInt(L, 2); + int z = wi::lua::SGetInt(L, 3); + int value = wi::lua::SGetBool(L, 4); + voxelgrid->set_voxel(XMUINT3(uint32_t(x), uint32_t(y), uint32_t(z)), value); + return 0; + } + int value = wi::lua::SGetBool(L, 2); + voxelgrid->set_voxel(pos->GetFloat3(), value); + return 0; + } + int VoxelGrid_BindLua::GetCenter(lua_State* L) + { + Luna::push(L, voxelgrid->center); + return 1; + } + int VoxelGrid_BindLua::SetCenter(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "VoxelGrid::SetCenter(Vector pos) not enough arguments!"); + return 0; + } + Vector_BindLua* pos = Luna::lightcheck(L, 1); + if (pos == nullptr) + { + wi::lua::SError(L, "VoxelGrid::SetCenter(Vector pos) first argument is not a Vector!"); + return 0; + } + voxelgrid->center = pos->GetFloat3(); + return 0; + } + int VoxelGrid_BindLua::GetVoxelSize(lua_State* L) + { + Luna::push(L, voxelgrid->voxelSize); + return 1; + } + int VoxelGrid_BindLua::SetVoxelSize(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "VoxelGrid::SetVoxelSize(Vector voxelsize) not enough arguments!"); + wi::lua::SError(L, "VoxelGrid::SetVoxelSize(float voxelsize) not enough arguments!"); + return 0; + } + Vector_BindLua* size = Luna::lightcheck(L, 1); + if (size == nullptr) + { + voxelgrid->set_voxelsize(wi::lua::SGetFloat(L, 1)); + return 0; + } + voxelgrid->set_voxelsize(size->GetFloat3()); + return 0; + } + int VoxelGrid_BindLua::GetDebugColor(lua_State* L) + { + Luna::push(L, voxelgrid->debug_color); + return 1; + } + int VoxelGrid_BindLua::SetDebugColor(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "VoxelGrid::SetDebugColor(Vector color) not enough arguments!"); + return 0; + } + Vector_BindLua* color = Luna::lightcheck(L, 1); + if (color == nullptr) + { + wi::lua::SError(L, "VoxelGrid::SetDebugColor(Vector color) first argument is not a Vector!"); + return 0; + } + voxelgrid->debug_color = color->data; + return 0; + } + int VoxelGrid_BindLua::GetDebugColorExtent(lua_State* L) + { + Luna::push(L, voxelgrid->debug_color); + return 1; + } + int VoxelGrid_BindLua::SetDebugColorExtent(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "VoxelGrid::SetDebugColorExtent(Vector color) not enough arguments!"); + return 0; + } + Vector_BindLua* color = Luna::lightcheck(L, 1); + if (color == nullptr) + { + wi::lua::SError(L, "VoxelGrid::SetDebugColorExtent(Vector color) first argument is not a Vector!"); + return 0; + } + voxelgrid->debug_color_extent = color->data; + return 0; + } + int VoxelGrid_BindLua::GetMemorySize(lua_State* L) + { + wi::lua::SSetLongLong(L, (long long)voxelgrid->get_memory_size()); + return 1; + } + int VoxelGrid_BindLua::Add(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "Add(VoxelGrid other) not enough arguments!"); + return 0; + } + VoxelGrid_BindLua* other = Luna::lightcheck(L, 1); + if (other == nullptr) + { + wi::lua::SError(L, "Add(VoxelGrid other) first argument is not a VoxelGrid!"); + return 0; + } + voxelgrid->add(*other->voxelgrid); + return 0; + } + int VoxelGrid_BindLua::Subtract(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 1) + { + wi::lua::SError(L, "Subtract(VoxelGrid other) not enough arguments!"); + return 0; + } + VoxelGrid_BindLua* other = Luna::lightcheck(L, 1); + if (other == nullptr) + { + wi::lua::SError(L, "Subtract(VoxelGrid other) first argument is not a VoxelGrid!"); + return 0; + } + voxelgrid->subtract(*other->voxelgrid); + return 0; + } + int VoxelGrid_BindLua::IsVisible(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc < 2) + { + wi::lua::SError(L, "VoxelGrid::IsVisible(Vector observer, Vector subject) not enough arguments!"); + wi::lua::SError(L, "VoxelGrid::IsVisible(Vector observer, AABB subject) not enough arguments!"); + return 0; + } + Vector_BindLua* observer = Luna::lightcheck(L, 1); + if (observer == nullptr) + { + if (argc < 6) + { + wi::lua::SError(L, "VoxelGrid::IsVisible(int observer_x,observer_y,observer_z, subject_x,subject_y,subject_z) not enough arguments!"); + return 0; + } + int observer_x = wi::lua::SGetInt(L, 1); + int observer_y = wi::lua::SGetInt(L, 2); + int observer_z = wi::lua::SGetInt(L, 3); + int subject_x = wi::lua::SGetInt(L, 4); + int subject_y = wi::lua::SGetInt(L, 5); + int subject_z = wi::lua::SGetInt(L, 6); + wi::lua::SSetBool(L, voxelgrid->is_visible(XMUINT3(uint32_t(observer_x), uint32_t(observer_y), uint32_t(observer_z)), XMUINT3(uint32_t(subject_x), uint32_t(subject_y), uint32_t(subject_z)))); + return 1; + } + Vector_BindLua* subject_vec = Luna::lightcheck(L, 2); + if (subject_vec == nullptr) + { + primitive::AABB_BindLua* aabb = Luna::lightcheck(L, 2); + if (aabb == nullptr) + { + wi::lua::SError(L, "VoxelGrid::IsVisible(Vector observer, Vector subject) second argument is not a Vector!"); + wi::lua::SError(L, "VoxelGrid::IsVisible(Vector observer, AABB subject) second argument is not an AABB!"); + return 0; + } + wi::lua::SSetBool(L, voxelgrid->is_visible(observer->GetFloat3(), aabb->aabb)); + return 1; + } + wi::lua::SSetBool(L, voxelgrid->is_visible(observer->GetFloat3(), subject_vec->GetFloat3())); + return 1; + } + + void VoxelGrid_BindLua::Bind() + { + Luna::Register(wi::lua::GetLuaState()); + } +} diff --git a/WickedEngine/wiVoxelGrid_BindLua.h b/WickedEngine/wiVoxelGrid_BindLua.h new file mode 100644 index 00000000000..186eb2f7b63 --- /dev/null +++ b/WickedEngine/wiVoxelGrid_BindLua.h @@ -0,0 +1,51 @@ +#pragma once +#include "CommonInclude.h" +#include "wiLua.h" +#include "wiLuna.h" +#include "wiVoxelGrid.h" + +namespace wi::lua +{ + class VoxelGrid_BindLua + { + private: + wi::VoxelGrid owning; + public: + wi::VoxelGrid* voxelgrid = nullptr; + + inline static constexpr char className[] = "VoxelGrid"; + static Luna::FunctionType methods[]; + static Luna::PropertyType properties[]; + + VoxelGrid_BindLua() = default; + VoxelGrid_BindLua(lua_State* L); + VoxelGrid_BindLua(wi::VoxelGrid& ref) : voxelgrid(&ref) {} + VoxelGrid_BindLua(wi::VoxelGrid* ref) : voxelgrid(ref) {} + + int Init(lua_State* L); + int ClearData(lua_State* L); + int FromAABB(lua_State* L); + int InjectTriangle(lua_State* L); + int InjectAABB(lua_State* L); + int InjectSphere(lua_State* L); + int InjectCapsule(lua_State* L); + int WorldToCoord(lua_State* L); + int CoordToWorld(lua_State* L); + int CheckVoxel(lua_State* L); + int SetVoxel(lua_State* L); + int GetCenter(lua_State* L); + int SetCenter(lua_State* L); + int GetVoxelSize(lua_State* L); + int SetVoxelSize(lua_State* L); + int GetDebugColor(lua_State* L); + int SetDebugColor(lua_State* L); + int GetDebugColorExtent(lua_State* L); + int SetDebugColorExtent(lua_State* L); + int GetMemorySize(lua_State* L); + int Add(lua_State* L); + int Subtract(lua_State* L); + int IsVisible(lua_State* L); + + static void Bind(); + }; +} diff --git a/features.txt b/features.txt index a6d98b0e222..bc98f5e6e9d 100644 --- a/features.txt +++ b/features.txt @@ -87,6 +87,8 @@ Expressions Humanoid rig Animation retargeting Video decoding: H264 +3D path finding +Screen Space Global Illumination (SSGI) GLTF 2.0 - KHR extensions supported: KHR_materials_unlit