Пример #1
0
void GSDeviceOGL::CreateTextureFX()
{
    m_vs_cb = new GSUniformBufferOGL(g_vs_cb_index, sizeof(VSConstantBuffer));
    m_ps_cb = new GSUniformBufferOGL(g_ps_cb_index, sizeof(PSConstantBuffer));

    // warning 1 sampler by image unit. So you cannot reuse m_ps_ss...
    m_palette_ss = CreateSampler(false, false, false);
    gl_BindSampler(1, m_palette_ss);

    GSInputLayoutOGL vert_format[] =
    {
        {0 , 2 , GL_FLOAT          , GL_FALSE , sizeof(GSVertex) , (const GLvoid*)(0) }  ,
        {1 , 4 , GL_UNSIGNED_BYTE  , GL_TRUE  , sizeof(GSVertex) , (const GLvoid*)(8) }  ,
        {2 , 1 , GL_FLOAT          , GL_FALSE , sizeof(GSVertex) , (const GLvoid*)(12) } ,
        {3 , 2 , GL_UNSIGNED_SHORT , GL_FALSE , sizeof(GSVertex) , (const GLvoid*)(16) } ,
        {4 , 1 , GL_UNSIGNED_INT   , GL_FALSE , sizeof(GSVertex) , (const GLvoid*)(20) } ,
        {5 , 2 , GL_UNSIGNED_SHORT , GL_FALSE , sizeof(GSVertex) , (const GLvoid*)(24) } ,
        {6 , 4 , GL_UNSIGNED_BYTE  , GL_TRUE  , sizeof(GSVertex) , (const GLvoid*)(28) } ,
    };
    m_vb = new GSVertexBufferStateOGL(sizeof(GSVertex), vert_format, countof(vert_format));

    // Pre compile all Geometry & Vertex Shader
    // It might cost a seconds at startup but it would reduce benchmark pollution
    m_gs = CompileGS();

    for (uint32 key = 0; key < VSSelector::size(); key++)
        m_vs[key] = CompileVS(VSSelector(key));

    for (uint32 key = 0; key < OMDepthStencilSelector::size(); key++)
        m_om_dss[key] = CreateDepthStencil(OMDepthStencilSelector(key));

    // Help to debug FS in apitrace
    m_apitrace = CompilePS(PSSelector());

    // VS gl_position.z => [-1,-1]
    // FS depth => [0, 1]
    // because of -1 we loose lot of precision for small GS value
    // This extension allow FS depth to range from -1 to 1. So
    // gl_position.z could range from [0, 1]
    if (GLLoader::found_GL_NV_depth_buffer_float) {
        gl_DepthRangedNV(-1.0f, 1.0f);
    }
}
Пример #2
0
void GSDeviceOGL::CreateTextureFX()
{
	m_vs_cb = new GSUniformBufferOGL(g_vs_cb_index, sizeof(VSConstantBuffer));
	m_ps_cb = new GSUniformBufferOGL(g_ps_cb_index, sizeof(PSConstantBuffer));

	// warning 1 sampler by image unit. So you cannot reuse m_ps_ss...
	m_palette_ss = CreateSampler(false, false, false);
	gl_BindSampler(1, m_palette_ss);

	GSInputLayoutOGL vert_format[] =
	{
		{0 , 2 , GL_FLOAT          , GL_FALSE , sizeof(GSVertex) , (const GLvoid*)(0) }  ,
		{1 , 4 , GL_UNSIGNED_BYTE  , GL_TRUE  , sizeof(GSVertex) , (const GLvoid*)(8) }  ,
		{2 , 1 , GL_FLOAT          , GL_FALSE , sizeof(GSVertex) , (const GLvoid*)(12) } ,
		{3 , 2 , GL_UNSIGNED_SHORT , GL_FALSE , sizeof(GSVertex) , (const GLvoid*)(16) } ,
		{4 , 1 , GL_UNSIGNED_INT   , GL_FALSE , sizeof(GSVertex) , (const GLvoid*)(20) } ,
		{5 , 2 , GL_UNSIGNED_SHORT , GL_FALSE , sizeof(GSVertex) , (const GLvoid*)(24) } ,
		{6 , 4 , GL_UNSIGNED_BYTE  , GL_TRUE  , sizeof(GSVertex) , (const GLvoid*)(28) } ,
	};
	m_vb = new GSVertexBufferStateOGL(sizeof(GSVertex), vert_format, countof(vert_format));

	// Pre compile all Geometry & Vertex Shader
	// It might cost a seconds at startup but it would reduce benchmark pollution
	m_gs = CompileGS();

	for (uint32 key = 0; key < VSSelector::size(); key++)
		m_vs[key] = CompileVS(VSSelector(key));

	for (uint32 key = 0; key < OMDepthStencilSelector::size(); key++)
		m_om_dss[key] = CreateDepthStencil(OMDepthStencilSelector(key));

	// Help to debug FS in apitrace
	m_apitrace = CompilePS(PSSelector());

	if (!!theApp.GetConfig("GL_NV_Depth", 0)) {
		gl_DepthRangedNV(-1.0f, 1.0f);
	}
}