Compute Shader can work on Mac with Metal , but doesn`t work on Windows with DX11, Why #2552
Unanswered
zhengyi7592
asked this question in
Q&A
Replies: 1 comment 1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I write a simple demo with CS shader to simlutae hair effect. The demo gets the right result on Mac with Metal, but it doesn't get the right result on Windows, I don't know why...
I think there may has sth wrong at BUFFER_RW (cross platform)...
BTW, I check out the latest master branch.
Thank you!
Part of CS codes:
#include "header.sh"
#include "cs_Node.sh"
#include "cs_DistanceJoint.sh"
BUFFER_RW(_Positions, Node, 0);
BUFFER_RO(_DistanceJoints, DistanceJoint, 1);
uniform vec4 _DT;
uniform vec4 _GroupOffset;
vec3 DistanceJointSolveImpl(vec3 position1, vec3 position2, float distance)
{
vec3 relPosition = position1 - position2;
float actualDistance = length(relPosition);
float penetration = (distance - actualDistance) / actualDistance;
return relPositionpenetration0.5;
}
NUM_THREADS(1024, 1, 1)
void main()
{
ivec2 id = ivec2(gl_GlobalInvocationID.xy);
uint idx = _GroupOffset.x + id.x;
if (idx < _GroupOffset.x + _GroupOffset.y) {
vec3 joint = _DistanceJoints[idx].joint;
vec4 position1 = _Positions[(uint)joint.x].curr;
vec4 position2 = _Positions[(uint)joint.y].curr;
vec3 correction = DistanceJointSolveImpl(position1.xyz, position2.xyz, joint.z)*_DT.x;
position1 += vec4(correction, 0.0);
position2 -= vec4(correction, 0.0);
_Positions[(uint)joint.x].curr = position1;
_Positions[(uint)joint.y].curr = position2;
}
}
All reactions