Added intel fragment shader ordering.

This commit is contained in:
Branimir Karadžić 2014-07-29 21:29:38 -07:00
parent a8abead615
commit 1d0a9841d7
3 changed files with 78 additions and 1 deletions

View File

@ -274,5 +274,6 @@
#define BGFX_CAPS_FRAGMENT_DEPTH UINT64_C(0x0000000000000040)
#define BGFX_CAPS_BLEND_INDEPENDENT UINT64_C(0x0000000000000080)
#define BGFX_CAPS_COMPUTE UINT64_C(0x0000000000000100)
#define BGFX_CAPS_FRAGMENT_ORDERING UINT64_C(0x0000000000000200)
#endif // BGFX_DEFINES_H_HEADER_GUARD

View File

@ -360,6 +360,51 @@ namespace bgfx
}
}
static BX_NO_INLINE bool getIntelExtensions(ID3D11Device* _device)
{
uint8_t temp[28];
D3D11_BUFFER_DESC desc;
desc.ByteWidth = sizeof(temp);
desc.Usage = D3D11_USAGE_STAGING;
desc.BindFlags = 0;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
desc.MiscFlags = 0;
desc.StructureByteStride = 0;
D3D11_SUBRESOURCE_DATA initData;
initData.pSysMem = &temp;
initData.SysMemPitch = sizeof(temp);
initData.SysMemSlicePitch = 0;
bx::StaticMemoryBlockWriter writer(&temp, sizeof(temp) );
bx::write(&writer, "INTCEXTNCAPSFUNC", 16);
bx::write(&writer, UINT32_C(0x00010000) );
bx::write(&writer, UINT32_C(0) );
bx::write(&writer, UINT32_C(0) );
ID3D11Buffer* buffer;
HRESULT hr = _device->CreateBuffer(&desc, &initData, &buffer);
if (SUCCEEDED(hr) )
{
buffer->Release();
bx::MemoryReader reader(&temp, sizeof(temp) );
bx::skip(&reader, 16);
uint32_t version;
bx::read(&reader, version);
uint32_t driverVersion;
bx::read(&reader, driverVersion);
return version <= driverVersion;
}
return false;
};
struct RendererContextD3D11 : public RendererContextI
{
RendererContextD3D11()
@ -561,6 +606,7 @@ namespace bgfx
| BGFX_CAPS_FRAGMENT_DEPTH
| BGFX_CAPS_BLEND_INDEPENDENT
| BGFX_CAPS_COMPUTE
| (getIntelExtensions(m_device) ? BGFX_CAPS_FRAGMENT_ORDERING : 0)
);
g_caps.maxTextureSize = D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION;
g_caps.maxFBAttachments = bx::uint32_min(D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS);

View File

@ -1122,11 +1122,15 @@ namespace bgfx
? BGFX_CAPS_FRAGMENT_DEPTH
: 0
;
g_caps.supported |= s_extension[Extension::ARB_draw_buffers_blend].m_supported
? BGFX_CAPS_BLEND_INDEPENDENT
: 0
;
g_caps.supported |= s_extension[Extension::INTEL_fragment_shader_ordering].m_supported
? BGFX_CAPS_FRAGMENT_ORDERING
: 0
;
g_caps.maxTextureSize = glGet(GL_MAX_TEXTURE_SIZE);
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
@ -3332,6 +3336,8 @@ namespace bgfx
bool usesTextureLod = !!bx::findIdentifierMatch(code, s_EXT_shader_texture_lod);
bool usesFragmentOrdering = !!bx::findIdentifierMatch(code, "beginFragmentShaderOrdering");
if (usesDerivatives)
{
writeString(&writer, "#extension GL_OES_standard_derivatives : enable\n");
@ -3407,6 +3413,18 @@ namespace bgfx
}
}
if (usesFragmentOrdering)
{
if (s_extension[Extension::INTEL_fragment_shader_ordering].m_supported)
{
writeString(&writer, "#extension GL_INTEL_fragment_shader_ordering : enable\n");
}
else
{
writeString(&writer, "#define beginFragmentShaderOrdering()\n");
}
}
writeString(&writer, "precision mediump float;\n");
bx::write(&writer, code, codeLen);
@ -3517,6 +3535,18 @@ namespace bgfx
BGFX_FATAL(0 != fragData, Fatal::InvalidShader, "Unable to find and patch gl_FragData!");
}
if (!!bx::findIdentifierMatch(code, "beginFragmentShaderOrdering") )
{
if (s_extension[Extension::INTEL_fragment_shader_ordering].m_supported)
{
writeString(&writer, "#extension GL_INTEL_fragment_shader_ordering : enable\n");
}
else
{
writeString(&writer, "#define beginFragmentShaderOrdering()\n");
}
}
if (0 != fragData)
{
writeStringf(&writer, "out vec4 bgfx_FragData[%d];\n", fragData);