#include <msp/gl/extensions/arb_vertex_attrib_binding.h>
#include <msp/gl/extensions/arb_vertex_buffer_object.h>
#include <msp/gl/extensions/arb_vertex_shader.h>
+#include <msp/gl/extensions/ext_gpu_shader4.h>
#include <msp/gl/extensions/khr_debug.h>
#include "buffer.h"
#include "deviceinfo.h"
if(!vertex_format.empty())
throw invalid_operation("VertexSetup::set_format");
+ require_format(vfmt);
+
vertex_format = vfmt;
}
if(!vertex_format.empty())
throw invalid_operation("VertexSetup::set_format");
+ require_format(vfmt);
+ require_format(ifmt);
+
vertex_format = vfmt;
inst_format = ifmt;
}
return true;
}
+void VertexSetup::require_format(const VertexFormat &fmt)
+{
+ bool has_int = false;
+ for(const UInt16 *a=fmt.begin(); a!=fmt.end(); ++a)
+ has_int = has_int | is_integer_attribute(*a);
+
+ if(has_int)
+ static Require _req(EXT_gpu_shader4);
+}
+
void VertexSetup::update() const
{
static bool direct = ARB_direct_state_access && ARB_vertex_attrib_binding;
for(const UInt16 *a=fmt.begin(); a!=fmt.end(); ++a)
{
unsigned sem = get_attribute_semantic(*a);
+ bool integer = is_integer_attribute(*a);
GLenum type = get_gl_type(get_attribute_source_type(*a));
unsigned cc = get_attribute_component_count(*a);
if(direct)
{
- glVertexArrayAttribFormat(id, sem, cc, type, true, offset);
+ if(integer)
+ glVertexArrayAttribIFormat(id, sem, cc, type, offset);
+ else
+ glVertexArrayAttribFormat(id, sem, cc, type, true, offset);
glVertexArrayAttribBinding(id, sem, binding);
glEnableVertexArrayAttrib(id, sem);
}
else
{
- glVertexAttribPointer(sem, cc, type, true, stride, reinterpret_cast<void *>(offset));
+ if(integer)
+ glVertexAttribIPointer(sem, cc, type, stride, reinterpret_cast<void *>(offset));
+ else
+ glVertexAttribPointer(sem, cc, type, true, stride, reinterpret_cast<void *>(offset));
if(ARB_instanced_arrays)
glVertexAttribDivisor(sem, divisor);
glEnableVertexAttribArray(sem);