glsl: Implement SampleId and SetSampleMask
plus some minor refactoring of implementations
This commit is contained in:
parent
d1a68f7997
commit
e7c8f8911f
3 changed files with 35 additions and 30 deletions
|
@ -256,6 +256,12 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile
|
||||||
if (runtime_info.force_early_z) {
|
if (runtime_info.force_early_z) {
|
||||||
header += "layout(early_fragment_tests)in;";
|
header += "layout(early_fragment_tests)in;";
|
||||||
}
|
}
|
||||||
|
if (info.uses_sample_id) {
|
||||||
|
header += "in int gl_SampleID;";
|
||||||
|
}
|
||||||
|
if (info.stores_sample_mask) {
|
||||||
|
header += "out int gl_SampleMask[];";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Stage::Compute:
|
case Stage::Compute:
|
||||||
stage_name = "cs";
|
stage_name = "cs";
|
||||||
|
|
|
@ -239,7 +239,6 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr,
|
||||||
ctx.AddF32("{}=itof(gl_FrontFacing?-1:0);", inst);
|
ctx.AddF32("{}=itof(gl_FrontFacing?-1:0);", inst);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fmt::print("Get attribute {}", attr);
|
|
||||||
throw NotImplementedException("Get attribute {}", attr);
|
throw NotImplementedException("Get attribute {}", attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -397,10 +396,39 @@ void EmitSetFragColor(EmitContext& ctx, u32 index, u32 component, std::string_vi
|
||||||
ctx.Add("frag_color{}.{}={};", index, swizzle, value);
|
ctx.Add("frag_color{}.{}={};", index, swizzle, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EmitSetSampleMask(EmitContext& ctx, std::string_view value) {
|
||||||
|
ctx.Add("gl_SampleMask[0]=int({})", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmitSetFragDepth(EmitContext& ctx, std::string_view value) {
|
||||||
|
ctx.Add("gl_FragDepth={};", value);
|
||||||
|
}
|
||||||
|
|
||||||
void EmitLocalInvocationId(EmitContext& ctx, IR::Inst& inst) {
|
void EmitLocalInvocationId(EmitContext& ctx, IR::Inst& inst) {
|
||||||
ctx.AddU32x3("{}=gl_LocalInvocationID;", inst);
|
ctx.AddU32x3("{}=gl_LocalInvocationID;", inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EmitWorkgroupId(EmitContext& ctx, IR::Inst& inst) {
|
||||||
|
ctx.AddU32x3("{}=gl_WorkGroupID;", inst);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmitInvocationId(EmitContext& ctx, IR::Inst& inst) {
|
||||||
|
ctx.AddU32("{}=uint(gl_InvocationID);", inst);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmitSampleId(EmitContext& ctx, IR::Inst& inst) {
|
||||||
|
ctx.AddU32("{}=uint(gl_SampleID);", inst);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmitIsHelperInvocation(EmitContext& ctx, IR::Inst& inst) {
|
||||||
|
ctx.AddU1("{}=gl_HelperInvocation;", inst);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmitYDirection(EmitContext& ctx, IR::Inst& inst) {
|
||||||
|
ctx.uses_y_direction = true;
|
||||||
|
ctx.AddF32("{}=gl_FrontMaterial.ambient.a;", inst);
|
||||||
|
}
|
||||||
|
|
||||||
void EmitLoadLocal(EmitContext& ctx, IR::Inst& inst, std::string_view word_offset) {
|
void EmitLoadLocal(EmitContext& ctx, IR::Inst& inst, std::string_view word_offset) {
|
||||||
ctx.AddU32("{}=lmem[{}];", inst, word_offset);
|
ctx.AddU32("{}=lmem[{}];", inst, word_offset);
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,14 +124,6 @@ void EmitGetIndirectBranchVariable(EmitContext& ctx) {
|
||||||
NotImplemented();
|
NotImplemented();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitSetSampleMask(EmitContext& ctx, std::string_view value) {
|
|
||||||
NotImplemented();
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmitSetFragDepth(EmitContext& ctx, std::string_view value) {
|
|
||||||
ctx.Add("gl_FragDepth={};", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmitGetZFlag(EmitContext& ctx) {
|
void EmitGetZFlag(EmitContext& ctx) {
|
||||||
NotImplemented();
|
NotImplemented();
|
||||||
}
|
}
|
||||||
|
@ -164,27 +156,6 @@ void EmitSetOFlag(EmitContext& ctx) {
|
||||||
NotImplemented();
|
NotImplemented();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitWorkgroupId(EmitContext& ctx, IR::Inst& inst) {
|
|
||||||
ctx.AddU32x3("{}=gl_WorkGroupID;", inst);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmitInvocationId(EmitContext& ctx, IR::Inst& inst) {
|
|
||||||
ctx.AddU32("{}=uint(gl_InvocationID);", inst);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmitSampleId(EmitContext& ctx, IR::Inst& inst) {
|
|
||||||
NotImplemented();
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmitIsHelperInvocation(EmitContext& ctx, IR::Inst& inst) {
|
|
||||||
ctx.AddU1("{}=gl_HelperInvocation;", inst);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmitYDirection(EmitContext& ctx, IR::Inst& inst) {
|
|
||||||
ctx.uses_y_direction = true;
|
|
||||||
ctx.AddF32("{}=gl_FrontMaterial.ambient.a;", inst);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmitUndefU1(EmitContext& ctx, IR::Inst& inst) {
|
void EmitUndefU1(EmitContext& ctx, IR::Inst& inst) {
|
||||||
ctx.AddU1("{}=false;", inst);
|
ctx.AddU1("{}=false;", inst);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue