functions->GetSamplePosition = gen6_get_sample_position;
}
-static void
+void
brw_initialize_context_constants(struct brw_context *brw)
{
struct gl_context *ctx = &brw->ctx;
int max_samples;
const int *msaa_modes = intel_supported_msaa_modes(brw->intelScreen);
const int clamp_max_samples =
- driQueryOptioni(&brw->optionCache, "clamp_max_samples");
+ brw->optionCache.info != NULL ?
+ driQueryOptioni(&brw->optionCache, "clamp_max_samples") : -1;
if (clamp_max_samples < 0) {
max_samples = msaa_modes[0];
struct brw_context *intel_context_create(struct intel_screen *screen);
void intel_context_destroy(struct brw_context *brw);
+void
+brw_initialize_context_constants(struct brw_context *brw);
+
#ifdef __cplusplus
}
#endif
void brwInitFragProgFuncs( struct dd_function_table *functions )
{
- assert(functions->ProgramStringNotify == _tnl_program_string);
+ /* assert(functions->ProgramStringNotify == _tnl_program_string); */
functions->NewProgram = brwNewProgram;
functions->DeleteProgram = brwDeleteProgram;
ctx->Extensions.EXT_shader_integer_mix = ctx->Const.GLSLVersion >= 130;
ctx->Extensions.EXT_timer_query = true;
- if (brw->gen == 5 || can_write_oacontrol(brw)) {
- ctx->Extensions.AMD_performance_monitor = true;
- ctx->Extensions.INTEL_performance_query = true;
+ if (brw->bufmgr) {
+ if (brw->gen == 5 || can_write_oacontrol(brw)) {
+ ctx->Extensions.AMD_performance_monitor = true;
+ ctx->Extensions.INTEL_performance_query = true;
+ }
}
}
uint64_t dummy;
ctx->Extensions.ARB_blend_func_extended =
+ brw->optionCache.info == NULL ||
!driQueryOptionb(&brw->optionCache, "disable_blend_func_extended");
ctx->Extensions.ARB_conditional_render_inverted = true;
ctx->Extensions.ARB_draw_buffers_blend = true;
ctx->Extensions.OES_depth_texture_cube_map = true;
/* Test if the kernel has the ioctl. */
- if (drm_intel_reg_read(brw->bufmgr, TIMESTAMP, &dummy) == 0)
+ if (brw->bufmgr && drm_intel_reg_read(brw->bufmgr, TIMESTAMP, &dummy) == 0)
ctx->Extensions.ARB_timer_query = true;
/* Only enable this in core profile because other parts of Mesa behave
ctx->Extensions.ARB_texture_compression_bptc = true;
ctx->Extensions.ARB_texture_view = true;
- if (can_do_pipelined_register_writes(brw)) {
+ if (brw->bufmgr &&
+ can_do_pipelined_register_writes(brw)) {
ctx->Extensions.ARB_draw_indirect = true;
ctx->Extensions.ARB_transform_feedback2 = true;
ctx->Extensions.ARB_transform_feedback3 = true;
if (ctx->API != API_OPENGL_CORE)
ctx->Extensions.ARB_color_buffer_float = true;
- if (ctx->Mesa_DXTn || driQueryOptionb(&brw->optionCache, "force_s3tc_enable"))
+ if (ctx->Mesa_DXTn ||
+ (brw->optionCache.info != NULL &&
+ driQueryOptionb(&brw->optionCache, "force_s3tc_enable")))
ctx->Extensions.EXT_texture_compression_s3tc = true;
ctx->Extensions.ANGLE_texture_compression_dxt = true;
#include <mesa/main/shaderobj.h>
#include <mesa/main/fbobject.h>
+#include <mesa/main/context.h>
#include <mesa/program/program.h>
#include <glsl/program.h>
struct anv_compiler {
struct intel_screen *screen;
struct brw_context *brw;
+ struct gl_pipeline_object pipeline;
};
-
extern "C" {
struct anv_compiler *
-anv_compiler_create(int fd)
+anv_compiler_create(struct anv_device *device)
{
+ const struct brw_device_info *devinfo = &device->info;
struct anv_compiler *compiler;
+ struct gl_context *ctx;
- compiler = (struct anv_compiler *) malloc(sizeof *compiler);
+ compiler = rzalloc(NULL, struct anv_compiler);
if (compiler == NULL)
return NULL;
- compiler->screen = intel_screen_create(fd);
- if (compiler->screen == NULL) {
- free(compiler);
- return NULL;
- }
+ compiler->screen = rzalloc(compiler, struct intel_screen);
+ if (compiler->screen == NULL)
+ goto fail;
- compiler->brw = intel_context_create(compiler->screen);
- if (compiler->brw == NULL) {
- free(compiler);
- return NULL;
- }
+ compiler->brw = rzalloc(compiler, struct brw_context);
+ if (compiler->brw == NULL)
+ goto fail;
+
+ compiler->brw->optionCache.info = NULL;
+ compiler->brw->bufmgr = NULL;
+ compiler->brw->gen = devinfo->gen;
+ compiler->brw->is_g4x = devinfo->is_g4x;
+ compiler->brw->is_baytrail = devinfo->is_baytrail;
+ compiler->brw->is_haswell = devinfo->is_haswell;
+ compiler->brw->is_cherryview = devinfo->is_cherryview;
+ compiler->brw->intelScreen = compiler->screen;
+ compiler->screen->devinfo = &device->info;
+
+ brw_process_intel_debug_variable(compiler->brw);
+
+ if (device->info.gen >= 8 && !(INTEL_DEBUG & DEBUG_VEC4VS))
+ compiler->brw->scalar_vs = true;
+
+ ctx = &compiler->brw->ctx;
+ _mesa_init_shader_object_functions(&ctx->Driver);
+
+ _mesa_init_constants(&ctx->Const, API_OPENGL_CORE);
+
+ brw_initialize_context_constants(compiler->brw);
+
+ intelInitExtensions(ctx);
+
+ /* Set dd::NewShader */
+ brwInitFragProgFuncs(&ctx->Driver);
+
+ compiler->screen->compiler = brw_compiler_create(compiler, &device->info);
+ ctx->_Shader = &compiler->pipeline;
compiler->brw->precompile = false;
return compiler;
+
+ fail:
+ ralloc_free(compiler);
+ return NULL;
}
void
anv_compiler_destroy(struct anv_compiler *compiler)
{
- intel_context_destroy(compiler->brw);
- intel_screen_destroy(compiler->screen);
- free(compiler);
+ ralloc_free(compiler);
}
/* From gen7_urb.c */
anv_state_pool_init(&device->surface_state_pool,
&device->surface_state_block_pool);
- device->compiler = anv_compiler_create(device->fd);
- device->aub_writer = NULL;
-
device->info = *physicalDevice->info;
+ device->compiler = anv_compiler_create(device);
+ device->aub_writer = NULL;
+
pthread_mutex_init(&device->mutex, NULL);
anv_device_init_meta(device);
const struct anv_pipeline_create_info *extra,
VkPipeline *pPipeline);
-struct anv_compiler *anv_compiler_create(int fd);
+struct anv_compiler *anv_compiler_create(struct anv_device *device);
void anv_compiler_destroy(struct anv_compiler *compiler);
int anv_compiler_run(struct anv_compiler *compiler, struct anv_pipeline *pipeline);
void anv_compiler_free(struct anv_pipeline *pipeline);